Plugins  LAST
 All Data Structures Files Functions Variables Pages
modop_display.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /* $Revision$ */
20 
21 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
22 
23 /*!\file
24  * \brief display the form for the operation
25  */
26 require_once('class_modop_operation.php');
27 require_once NOALYSS_INCLUDE.'/lib/class_icard.php';
28 require_once NOALYSS_INCLUDE.'/lib/class_ipopup.php';
29 require_once NOALYSS_INCLUDE.'/class/class_acc_ledger_purchase.php';
30 require_once NOALYSS_INCLUDE.'/class/class_acc_ledger_sold.php';
31 require_once NOALYSS_INCLUDE.'/class/class_periode.php';
32 echo js_include('acc_ledger.js');
33 //----------------------------------------------------------------------
34 // create compute button
35 $cn=Dossier::connect();
36 
37 /* we can't modify from a closed periode */
38 /* get periode */
39 $sql="select jr_tech_per from jrn where jr_id=$1";
40 $periode=$cn->get_value($sql,array(trim($_GET['jr_id'])));
41 if ( $cn->count() == 0 )
42 {
43  alert(_('Opération non trouvée'));
44  exit();
45 }
46 
47 $oPeriode=new Periode($cn);
49 
50 if ($oPeriode->is_closed() == 1)
51 {
52  alert(_('On ne peut pas modifier dans une période fermée'));
53  exit();
54 }
55 
56 /* check if periode is closed */
57 // retrieve jrn
58 $op=new Modop_Operation($cn,$_GET['jr_id']);
59 try
60 {
61  $op->format(); /* load format the data into an array with by the class_acc_ledger... */
62 }
63 catch (Exception $e)
64 {
65  alert(j($e->getMessage()));
66  exit;
67 }
68 /* ---------------------------------------------------------------------- */
69 // Purchase
70 /* ---------------------------------------------------------------------- */
71 if ($op->ledger_type=='ACH')
72 {
73  try
74  {
75  $jrn=new Acc_Ledger_Purchase($cn,$op->array['p_jrn']);
76  echo '<FORM enctype="multipart/form-data" METHOD="POST" class="print">';
77  $op->suspend_receipt();
78  echo HtmlInput::hidden('ac',$_REQUEST['ac']);
79  echo $jrn->input($op->array);
80  echo HtmlInput::extension().dossier::hidden();
81  echo HtmlInput::hidden('bon_comm',$op->array['bon_comm']);
82  echo HtmlInput::hidden('other_info',$op->array['other_info']);
83  echo HtmlInput::hidden('action','confirm');
84  echo HtmlInput::submit('save','Sauve');
85  echo HtmlInput::hidden('e_mp',0);
86  echo HtmlInput::hidden('ext_jr_id',$op->jr_id);
87  echo HtmlInput::hidden('ext_jr_internal',$op->jr_internal);
88  echo HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"');
89  echo '</form>';
90 
91  }
92  catch (Exception $exc)
93  {
94  alert( $exc->getMessage());
95  }
96 
97 
98 
99 }
100 /* ---------------------------------------------------------------------- */
101 // SOLD
102 /* ---------------------------------------------------------------------- */
103 if ($op->ledger_type=='VEN')
104 {
105 
106  try
107  {
108  $jrn=new Acc_Ledger_Sold($cn,$op->array['p_jrn']);
109  $op->suspend_receipt();
110 
111  echo '<FORM enctype="multipart/form-data" METHOD="POST" class="print">';
112  echo $jrn->input($op->array);
113  echo HtmlInput::hidden('ac',$_REQUEST['ac']);
114  echo HtmlInput::extension().dossier::hidden();
115  echo HtmlInput::hidden('action','confirm');
116  echo HtmlInput::submit('save','Sauve');
117  echo HtmlInput::hidden('e_mp',0);
118  echo HtmlInput::hidden('ext_jr_id',$op->jr_id);
119  echo HtmlInput::hidden('ext_jr_internal',$op->jr_internal);
120  echo HtmlInput::hidden('bon_comm',$op->array['bon_comm']);
121  echo HtmlInput::hidden('other_info',$op->array['other_info']);
122  echo HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"');
123  echo HtmlInput::button('actualiser',_('Actualiser'), ' onClick="compute_all_ledger();"');
124  echo '</form>';
125  }
126  catch (Exception $exc)
127  {
128  alert( $exc->getMessage() ) ;
129  }
130 
131 
132 }
133 /* ---------------------------------------------------------------------- */
134 // MISC OP
135 /* ---------------------------------------------------------------------- */
136 if ($op->ledger_type=='ODS')
137 {
138 
139  $jrn=new Acc_Ledger($cn,$op->array['p_jrn']);
140  $op->suspend_receipt();
141 
142  echo '<FORM enctype="multipart/form-data" METHOD="POST" class="print">';
143  echo $jrn->input($op->array);
144  echo HtmlInput::hidden('ac',$_REQUEST['ac']);
145  echo HtmlInput::extension().dossier::hidden();
146  echo HtmlInput::hidden('action','confirm');
147  echo HtmlInput::submit('save','Sauve');
148  echo HtmlInput::hidden('ext_jr_id',$op->jr_id);
149  echo HtmlInput::hidden('ext_jr_internal',$op->jr_internal);
150  echo HtmlInput::button('add',_('Ajout d\'une ligne'),'onClick="quick_writing_add_row()"');
151  echo '</form>';
152  echo '<div class="info">'.
153  _('Débit').' = <span id="totalDeb"></span>'.
154  _('Crédit').' = <span id="totalCred"></span>'.
155  _('Difference').' = <span id="totalDiff"></span></div> ';
156  echo "<script>checkTotalDirect();</script>";
157  echo '</div>';
158 
159 
160 }
161 /* ---------------------------------------------------------------------- */
162 // FIN
163 /* ---------------------------------------------------------------------- */
164 if ($op->ledger_type=='FIN')
165 {
166  require_once NOALYSS_INCLUDE.'/class/class_acc_ledger_fin.php';
167  $f_legend='Banque';
168  $jrn=new Acc_Ledger_Fin($cn,$op->array['p_jrn']);
169 
170  $f_add_button=new IButton('add_card');
171  $f_add_button->label=_('Créer une nouvelle fiche');
172  $f_add_button->set_attribute('ipopup','ipop_newcard');
173  $f_add_button->set_attribute('filter',$jrn->get_all_fiche_def ());
174  $f_add_button->javascript=" select_card_type(this);";
175  $str_add_button=$f_add_button->input();
176  echo '<FORM enctype="multipart/form-data" METHOD="post" class="print">';
177  echo HtmlInput::hidden('ac',$_REQUEST['ac']);
178  $Date=new IDate("e_date",$op->array['e_date']);
179  $f_date=$Date->input();
180  $label=HtmlInput::infobulle(3);
181 
182  // Ledger (p_jrn)
183  //--
184  $add_js="";
185 
186  $wLedger=$jrn->select_ledger('FIN',2);
187  $wLedger->javascript=$add_js;
188 
189  if ($wLedger == null) exit ('Pas de journal disponible');
190 
191  $label=" Journal ".HtmlInput::infobulle(2) ;
192  $f_jrn=$label.$wLedger->input();
193 
194  //retrieve bank name
195  $e_bank_account=$op->array['e_bank'];
196  $e_bank_account_label="";
197 
198  // retrieve e_bank_account_label
199  if ( $e_bank_account != "" )
200  {
201  $fBank=new fiche($cn);
202  $fBank->get_by_qcode($e_bank_account);
203  $e_bank_account_label=$fBank->strAttribut(ATTR_DEF_NAME).' '.
204  ' Adresse : '.$fBank->strAttribut(ATTR_DEF_ADRESS).' '.
205  $fBank->strAttribut(ATTR_DEF_CP).' '.
206  $fBank->strAttribut(ATTR_DEF_CITY).' ';
207 
208  }
209  $f_bank=$e_bank_account.$e_bank_account_label;
210 
211  $ibank=new ICard();
212  $ibank->readonly=false;
213  $ibank->label="Banque ".HtmlInput::infobulle(0);
214  $ibank->name="e_bank_account";
215  $ibank->value=$e_bank_account;
216  $ibank->extra='deb'; // credits
217  $ibank->typecard='deb';
218  $ibank->set_dblclick("fill_ipopcard(this);");
219  $ibank->set_attribute('ipopup','ipopcard');
220 
221  // name of the field to update with the name of the card
222  $ibank->set_attribute('label','e_bank_account_label');
223  // Add the callback function to filter the card on the jrn
224  $ibank->set_callback('filter_card');
225  $ibank->set_function('fill_fin_data');
226  $ibank->javascript=sprintf(' onchange="fill_fin_data_onchange(this);" ');
227 
228  $f_legend_detail='Opérations financières';
229 
230  // Extrait
231  $default_pj='';
232  $wPJ=new IText('e_pj');
233  $wPJ->readonly=false;
234  $wPJ->size=10;
235  $wPJ->value=$op->array['e_pj'];
236  $f_extrait=$wPJ->input();
237  $label=HtmlInput::infobulle(7);
238 
239  //--------------------------------------------------
240  // financial operation
241  //-------------------------------------------------
242 
243  $array=array();
244  // Parse each " tiers"
245  $tiers=$op->array['e_other'];
246  $tiers_label="";
247  $tiers_amount=$op->array['e_amount'];
248 
249  $tiers_comment=$op->array['e_comm'];
250  $fTiers=new fiche($cn);
251  $fTiers->get_by_qcode($tiers);
252 
253  $tiers_label=$fTiers->strAttribut(ATTR_DEF_NAME);
254  $W1=new ICard();
255  $W1->label="";
256  $W1->name="e_other";
257  $W1->value=$tiers;
258  $W1->extra='cred'; // credits
259  $W1->typecard='cred';
260  $W1->set_dblclick("fill_ipopcard(this);");
261  $W1->set_attribute('ipopup','ipopcard');
262 
263  // name of the field to update with the name of the card
264  $W1->set_attribute('label','e_other_label');
265  // name of the field to update with the name of the card
266  $W1->set_attribute('typecard','filter');
267  // Add the callback function to filter the card on the jrn
268  $W1->set_callback('filter_card');
269  $W1->set_function('fill_data');
270  $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
271  $W1->name);
272  $array[0]['qcode']=$W1->input();
273  $array[0]['search']=$W1->search();
274 
275  // label
276  $other=new ISpan("e_other_label", $tiers_label);
277  $array[0]['span']=$other->input();
278  // Comment
279  $wComment=new IText("e_other_comment",$tiers_comment);
280 
281  $wComment->size=35;
282  $wComment->setReadOnly(false);
283  $array[0]['comment']=$wComment->input();
284  // amount
285  $wAmount=new INum("e_other_amount",$tiers_amount);
286 
287  $wAmount->size=7;
288  $wAmount->setReadOnly(false);
289  $array[0]['amount']=$wAmount->input();
290  // show compute
291  require_once('template_ledger_fin.php');
292 
293  echo HtmlInput::extension().dossier::hidden().HtmlInput::hidden('jrn_type','FIN');
294  echo HtmlInput::submit('save',_('Sauve'),'onclick=\'return confirm(&quot;Vous confirmez &quot;)\'');
295  echo HtmlInput::hidden('ext_jr_id',$op->jr_id).HtmlInput::hidden('action','save');
296 
297  echo '</form>';
298 
299 }
if($cn->count()==0) $oPeriode
$periode
$sql
$f_add_button
if(isset($_POST['remove'])) $array
$_REQUEST['sb']
Definition: am_print.php:39
if($oPeriode->is_closed()==1) $op