noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
acc_ledger_purchase.class.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!
23 * \file
24 * \brief class for the purchase, herits from acc_ledger
25 */
26require_once NOALYSS_INCLUDE.'/lib/user_common.php';
27require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
28
29
30/*!
31 * \class Acc_Ledger_Purchase
32 * \brief Handle the ledger of purchase,
33 *
34 *
35 */
37{
38 private $payment_operation; /*<! id of the payment , set in insert */
39
40 function __construct ($p_cn,$p_init)
41 {
42 $this->ledger_type='ACH';
43 parent::__construct($p_cn,$p_init);
44 $this->payment_operation=-1;
45 }
46 /*!
47 * \brief verify that the data are correct before inserting or confirming
48 *\param an array (usually $_POST)
49 *\return String
50 *\throw Exception if an error occurs
51 */
52 public function verify_operation($p_array)
53 {
54 global $g_parameter,$g_user;
55
56 if (is_array($p_array ) == false || empty($p_array))
57 throw new Exception ("Array empty");
58 /*
59 * Check needed value
60 */
61 check_parameter($p_array,'p_jrn,e_date,e_client');
62
63 extract ($p_array, EXTR_SKIP);
64 /* check if we can write into this ledger */
65 if ( $g_user->check_jrn($p_jrn) != 'W' )
66 throw new Exception (_('Accès interdit'),20);
67
68
69 /* check for a double reload */
70 if ( isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1',array($mt)) != 0 )
71 throw new Exception (_('Double Encodage'),5);
72
73 /* check if there is a customer */
74 if ( noalyss_strlentrim($e_client)== 0 )
75 throw new Exception(_('Vous n\'avez pas donné de fournisseur'),11);
76
77 /* check if the date is valid */
78 if ( isDate($e_date) == null )
79 {
80 throw new Exception(_('Date invalide'), 2);
81 }
82 $oPeriode=new Periode($this->db);
83 if ( $this->check_periode() == false || ! isset($p_array['period']))
84 {
85 $tperiode=$oPeriode->find_periode($e_date);
86 }
87 else
88 {
89 $tperiode=$period;
90 $oPeriode->p_id=$tperiode;
91 /* check that the datum is in the choosen periode */
92 list ($min,$max)=$oPeriode->get_date_limit($tperiode);
93 if ( cmpDate($e_date,$min) < 0 ||
94 cmpDate($e_date,$max) > 0)
95 throw new Exception(_('Date et periode ne correspondent pas'),6);
96 }
97 /* check if the periode is closed */
98 if ( $this->is_closed($tperiode)==1 )
99 {
100 throw new Exception(_('Periode fermee'),6);
101 }
102
103 /* check if we are using the strict mode */
104 if( $this->check_strict() == true)
105 {
106 /* if we use the strict mode, we get the date of the last
107 operation */
108 $last_date=$this->get_last_date();
109 if ( $last_date != null && cmpDate($e_date,$last_date) < 0 )
110 throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ')
111 .$last_date._(' vous ne pouvez pas encoder à une '.
112 ' date antérieure dans ce journal'),13);
113
114 }
115
116 /* check the account */
117 $fiche=new Fiche($this->db);
118 $fiche->get_by_qcode($e_client);
119 if ($fiche->get_f_enable() == '0')
120 throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50);
121
122 if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
123 throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8);
124
125
126
127 /* get the account and explode if necessary */
128 $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
129 // if 2 accounts, take only the credit one for supplier
130 if ( strpos($sposte,',') != 0 )
131 {
132 $array=explode(',',$sposte);
133 $poste_val=$array[1];
134 }
135 else
136 {
137 $poste_val=$sposte;
138 }
139
140 /* The account exists */
141 $poste=new Acc_Account_Ledger($this->db,$poste_val);
142 if ( $poste->load() == false )
143 {
144 throw new Exception(_('Pour la fiche ').$e_client._(' le poste comptable [').$poste->id.'] '._('n\'existe pas'),9);
145 }
146 /* Check if the card belong to the ledger */
147 $fiche=new Fiche ($this->db);
148 $fiche->get_by_qcode($e_client,'cred');
149 if ( $fiche->belong_ledger($p_jrn) !=1 )
150 throw new Exception(_('La fiche ').$e_client._('n\'est pas accessible à ce journal'),10);
151
152 $nb=0;
153 //------------------------------------------------------
154 // The "Paid By" check
155 //------------------------------------------------------
156 if ($e_mp != 0 ) {
157 $this->check_payment($e_mp,${"e_mp_qcode_".$e_mp});
158 // check for the currency , if we use a financial ledger and a card which is a bank account (with his own
159 // ledger , then the currency of the operation must be the same
160 $this->check_currency(${"e_mp_qcode_" . $e_mp},$p_currency_code);
161 }
162
163
164 //----------------------------------------
165 // foreach item
166 //----------------------------------------
167 for ($i=0;$i< $nb_item;$i++)
168 {
169 if ( noalyss_strlentrim(${'e_march'.$i})== 0) continue;
170
171 /* check if all card has a ATTR_DEF_ACCOUNT*/
172 $fiche=new Fiche($this->db);
173 $fiche->get_by_qcode(${'e_march'.$i});
174 if ($fiche->get_f_enable() == '0')
175 throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50);
176
177 /* check if amount are numeric and */
178 if ( isNumber(${'e_march'.$i.'_price'}) == 0 )
179 throw new Exception(_('La fiche ').${'e_march'.$i}._('a un montant invalide').' ['.${'e_march'.$i}.']',6);
180 if ( isNumber(${'e_quant'.$i}) == 0 )
181 throw new Exception(_('La fiche ').${'e_march'.$i}._('a une quantité invalide').' ['.${'e_quant'.$i}.']',7);
182
183 // Check if the given tva id is valid
184 if ( $g_parameter->MY_TVA_USE=='Y')
185 {
186 $tva_rate = Acc_Tva::build($this->db,${'e_march' . $i . '_tva_id'});
187 if ($tva_rate->tva_id == -1)
188 throw new Exception(_('La fiche ').${'e_march'.$i}._('a un code tva invalide').' ['.${'e_march'.$i.'_tva_id'}.']',13);
189 $tva_rate->load();
190 /*
191 * check if the accounting for VAT are valid
192 */
193 $a_poste=explode(',',$tva_rate->tva_poste);
194
195 if (
196 $this->db->get_value('select count(*) from tmp_pcmn where pcm_val=$1',array($a_poste[0])) == 0 )
197 throw new Exception(_(" La TVA ".$tva_rate->tva_label." utilise des postes comptables inexistants"));
198
199 }
200
201 if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
202 throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8);
203
204 /* get the account and explode if necessary */
205 $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
206 // if 2 accounts, take only the debit
207 if ( strpos($sposte,',') != 0 )
208 {
209 $array=explode(',',$sposte);
210 $poste_val=$array[0];
211 }
212 else
213 {
214 $poste_val=$sposte;
215 }
216
217 /* The account exists */
218 $poste=new Acc_Account_Ledger($this->db,$poste_val);
219 if ( $poste->load() == false )
220 {
221 throw new Exception(_('Pour la fiche ').${'e_march'.$i}._(' le poste comptable').' ['.$poste->id._('n\'existe pas'),9);
222 }
223 /* Check if the card belong to the ledger */
224 $fiche=new Fiche ($this->db);
225 $fiche->get_by_qcode(${'e_march'.$i});
226 if ( $fiche->belong_ledger($p_jrn,'deb') !=1 )
227 throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'est pas accessible à ce journal'),10);
228 /**
229 * we have to check also if the different accountings exist
230 "ATTR_DEF_DEP_PRIV"
231 "ATTR_DEF_DEPENSE_NON_DEDUCTIBLE"
232 "ATTR_DEF_TVA_NON_DEDUCTIBLE"
233 "ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP"
234 */
235 foreach (array(
240 {
241 if ( ! $fiche->empty_attribute($key[0]) && $fiche->empty_attribute($key[2]))
242 {
243 $a=new Acc_Parm_Code($this->db,$key[1]);
244 if ( $this->db->count_sql('select pcm_val from tmp_pcmn where pcm_val=$1',array($a->p_value))==0)
245 throw new Exception ($key[1]._("ce code n'a pas de poste comptable, créez ce poste : [".$a->p_value."]"));
246 }
247 if ( ! $fiche->empty_attribute($key[0]) && ! $fiche->empty_attribute($key[2]))
248 {
249 $nd_str=$fiche->strAttribut($key[2]);
250 if ( $nd_str != '')
251 {
252 $poste_nd=new Acc_Account_Ledger($this->db,$nd_str);
253 if ( $poste_nd->load() == false)
254 {
255 $nd_msg=sprintf(_("Pour la fiche %s, le compte contrepartie %s n'existe pas"),
256 $fiche->getName(),$poste_nd->id);
257 $nd_msg=h($nd_msg);
258 throw new Exception ($nd_msg);
259 }
260 }
261 }
262 }
263 if ( ${"e_quant".$i} != 0 && trim(${"e_quant".$i}) !="" ) {$nb++;}
264 }
265
266 if ( $nb == 0 )
267 throw new Exception(_('Il n\'y a aucune marchandise'),12);
268
269 // check payment date
270 if ( isset ($mp_date) && trim ($mp_date) != "" && isDate($mp_date) == null) {
271 throw new Exception(_('Date de paiement invalide'),13);
272
273 }
274 // check that MP is in a not closed and exists
275 if ( isset ($mp_date) && trim ($mp_date) != "" && isDate($mp_date) == $mp_date ) {
276 $periode=new Periode($this->cn);
277 $periode->find_periode($mp_date);
278 $periode->set_ledger($this->id);
279 if ( $periode->is_closed() ) {
280 throw new Exception(_("Période fermée")." $mp_date ");
281 }
282
283 }
284 // check limit date
285 if ( isset ($e_ech) && trim ($e_ech)!="" && isDate($e_ech) == null )
286 {
287 throw new Exception(_('Date échéance invalide'),14);
288
289 }
290 // Check currency_rate if valid
291 if ( isNumber($p_currency_rate) == 0 || $p_currency_rate <=0 ) {
292 throw new Exception(_('Taux devise invalide'),15);
293 }
294 $this->check_currency_setting($p_currency_code);
295 }
296 /**
297 * Compute the ND amount thanks the attribute of the concerned card. The object
298 * $p_nd_amount will changed
299 *
300 * @param Acc_Compute $p_nd_amount object with ND amount
301 * @param Fiche $p_fiche Concerned Card (purchase items)
302 * @param type $p_tva_bot 0 TVA on one side, 1 TVA on both side
303 */
304 private function compute_no_deductible(Acc_Compute $p_nd_amount, Fiche $p_fiche)
305 {
307 {
308 $p_nd_amount->amount_nd_rate = $p_fiche->strAttribut(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
309 $p_nd_amount->compute_nd();
310 }
312 {
313 $p_nd_amount->nd_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE);
314 $p_nd_amount->compute_nd_vat();
315 }
317 {
318 $p_nd_amount->nd_ded_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
319 $p_nd_amount->compute_ndded_vat();
320 }
321
322 if (!$p_fiche->empty_attribute(ATTR_DEF_DEP_PRIV))
323 {
324 $p_nd_amount->amount_perso_rate = $p_fiche->strAttribut(ATTR_DEF_DEP_PRIV);
325 $p_nd_amount->compute_perso();
326 }
327
328 }
329
330 /**
331 * @brief Insert into JRNX the No Deductible amount and into Analytic Accountancy for the ND VAT
332 * @param Acc_Compute $p_nd_amount content ND amount
333 * @param Fiche $p_fiche Card of the Service
334 * @param type $p_tva_both 0 if TVA is normal or 1 if on both side
335 * @param type $p_tot_debit total debit
336 * @param $p_acc_operation Acc_Operation for inserting into jrnx
337 * @param $p_group group for AC
338 * @param $idx row number
339 *
340 * @see Acc_Ledger_Purchase::insert
341 */
342 private function insert_no_deductible(Acc_Compute $p_nd_amount, Fiche $p_fiche, $p_tva_both,&$p_tot_debit,Acc_Operation $p_acc_operation,$p_group,$idx)
343 {
344 global $g_parameter;
345 if ($p_acc_operation->jrnx_id == 0) {
346 throw new Exception(__FILE__.__LINE__.'invalid acc_operation.j_id');
347 }
348 $source_j_id=$p_acc_operation->jrnx_id ;
349 /*
350 * Save all the no deductible
351 * ATTR_DEF_ACCOUNT_ND_TVA,ATTR_DEF_ACCOUNT_ND_TVA_ND,ATTR_DEF_ACCOUNT_ND_PERSO,ATTR_DEF_ACCOUNT_ND
352 */
353 if ($p_nd_amount->amount_nd_rate != 0)
354 {
355 $dna_default = new Acc_Parm_Code($this->db, 'DNA');
356
357 /* save op. */
358 if (!$p_fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND))
359 {
360 $dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND);
361 } else
362 {
363 $dna = $dna_default->p_value;
364 }
365 $dna = ($dna == '') ? $dna_default->p_value : $dna;
366
367 $p_acc_operation->type = 'd';
368 $p_acc_operation->amount = $p_nd_amount->amount_nd;
369 $p_acc_operation->poste = $dna;
370 $p_acc_operation->qcode = '';
371 $p_acc_operation->desc=$this->find_label($dna)." ND ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
372 if ($p_nd_amount->amount_nd > 0)
373 $p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->amount_nd );
374 $j_id = $p_acc_operation->insert_jrnx();
375 }
376 /*
377 * ATTR_DEF_ACCOUNT_ND_PERSO
378 */
379 if ($p_nd_amount->amount_perso != 0)
380 {
381 $dna_default = new Acc_Parm_Code($this->db, 'DEP_PRIV');
382
383 /* save op. */
384 $p_acc_operation->type = 'd';
386 {
387 $dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_PERSO);
388 } else
389 {
390 $dna = $dna_default->p_value;
391 }
392 $dna = ($dna == '') ? $dna_default->p_value : $dna;
393
394 $p_acc_operation->amount = $p_nd_amount->amount_perso ;
395 $p_acc_operation->poste = $dna;
396 $p_acc_operation->qcode = '';
397 $p_acc_operation->desc=$this->find_label($dna)." ND_PRIV ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
398 if ($p_nd_amount->amount_perso> 0)
399 $p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->amount_perso);
400 $j_id = $p_acc_operation->insert_jrnx();
401 }
402 if ($p_nd_amount->nd_vat != 0)
403 {
404 $dna_default = new Acc_Parm_Code($this->db, 'TVA_DNA');
405
406 /* save op. */
407 $p_acc_operation->type = 'd';
408 $p_acc_operation->qcode = '';
410 {
411 $dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA_ND);
412 } else
413 {
414 $dna = $dna_default->p_value;
415 }
416 $dna = ($dna == '') ? $dna_default->p_value : $dna;
417
418 $p_acc_operation->amount = $p_nd_amount->nd_vat;
419 $p_acc_operation->poste = $dna;
420 $p_acc_operation->desc=$this->find_label($dna)." ND_TVA ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
421 $j_id = $p_acc_operation->insert_jrnx();
422 if ( $g_parameter->MY_ANALYTIC != "nu"
423 && $g_parameter->match_analytic($p_fiche->strAttribut(ATTR_DEF_ACCOUNT))
424 )
425 {
426 $op=new Anc_Operation($this->db);
427 $op->oa_group=$p_group;
428 $op->j_id=$j_id;
429 $op->oa_date=$p_acc_operation->date;
430
431 $op->oa_debit='t';
432 $op->oa_description=sql_string('ND_TVA');
433 $op->oa_jrnx_id_source=$source_j_id;
434 $op->save_form_plan_vat_nd($_POST,$idx,$j_id,$p_nd_amount->nd_vat,$p_acc_operation->jrnx_id);
435 }
436 if ($p_nd_amount->nd_vat> 0)
437 $p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->nd_vat);
438
439 }
440 if ($p_nd_amount->nd_ded_vat != 0)
441 {
442 $dna_default = new Acc_Parm_Code($this->db, 'TVA_DED_IMPOT');
443 /* save op. */
445 {
446 $dna = $p_fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA);
447 } else
448 {
449 $dna = $dna_default->p_value;
450 }
451 $dna = ($dna == '') ? $dna_default->value : $dna;
452
453
454
455 $p_acc_operation->type = 'd';
456 $p_acc_operation->qcode = '';
457 $p_acc_operation->amount = $p_nd_amount->nd_ded_vat;
458 $p_acc_operation->poste = $dna;
459 $p_acc_operation->desc=$this->find_label($dna)." DED_TVA ".$p_fiche->strAttribut(ATTR_DEF_QUICKCODE);
460 if ($p_nd_amount->nd_ded_vat > 0)
461 $p_tot_debit = bcadd($p_tot_debit, $p_nd_amount->nd_ded_vat);
462 $j_id = $p_acc_operation->insert_jrnx();
463 if ( $g_parameter->MY_ANALYTIC != "nu"
464 && $g_parameter->match_analytic($p_fiche->strAttribut(ATTR_DEF_ACCOUNT))
465 )
466 {
467 $op=new Anc_Operation($this->db);
468 $op->oa_group=$p_group;
469 $op->j_id=$j_id;
470 $op->oa_date=$p_acc_operation->date;
471
472 $op->oa_debit='t';
473 $op->oa_description=sql_string('DED_TVA ');
474 $op->oa_jrnx_id_source=$source_j_id;
475 $op->save_form_plan_vat_nd($_POST,$idx,$j_id,$p_nd_amount->nd_ded_vat);
476 }
477 }
478 }
479
480 /*!
481 * \brief insert into the database, it calls first the verify function
482 * change the value of this->jr_id and this->jr_internal.
483 * It generates the document and save the middle of payment, if 'gen_invoice is set
484 * and e_mp
485 *\param $p_array is usually $_POST or a predefined operation
486 \code
487 Array
488 (
489
490 [e_client] =>BELGACOM
491 [nb_item] =>9
492 [p_jrn] =>3
493 [period] =>117
494 [e_comm] =>Frais de téléphone
495 [e_date] =>01.09.2009
496 [e_ech] =>
497 [jrn_type] =>ACH
498 [e_pj] =>ACH53
499 [e_pj_suggest] =>ACH53
500 [mt] =>1265318941.39
501 [e_mp] =>0
502 [e_march0] =>TEL
503 [e_march0_price] =>63.6700
504 [e_march0_tva_id] =>1
505 [e_march0_tva_amount] =>13.3700
506 [e_quant0] =>1.000
507 ...
508 [bon_comm] =>
509 [other_info] =>
510 [record] =>Enregistrement
511 [p_currency_code]=> id currency
512 [p_currency_rate]=>rate used
513 )
514 \endcode
515 *\return string
516 *\note throw an Exception
517 */
518 public function insert($p_array=null)
519 {
520 global $g_parameter,$g_user;
521 extract ($p_array, EXTR_SKIP);
522 $this->verify($p_array) ;
523 if ( !isset($p_array['jrn_note_input'])) {$p_array['jrn_note_input']='';}
524 $group=$this->db->get_next_seq("s_oa_group"); /* for analytic */
525 $seq=$this->db->get_next_seq('s_grpt');
526 $this->id=$p_jrn;
527
528 $internal=$this->compute_internal_code($seq);
529 $this->internal=$internal;
530
531 $cust=new Fiche($this->db);
532 $cust->get_by_qcode($e_client);
533 $sposte=$cust->strAttribut(ATTR_DEF_ACCOUNT);
534 // if 2 accounts, take only the credit Supplier
535 if ( strpos($sposte,',') != 0 )
536 {
537 $array=explode(',',$sposte);
538 $poste=$array[1];
539 }
540 else
541 {
542 $poste=$sposte;
543 }
544
545 $oPeriode=new Periode($this->db);
547
548 if ( $check_periode == true && isset($p_array['period']) )
549 $tperiode=$period;
550 else
551 $tperiode=$oPeriode->find_periode($e_date);
552
553
554 try
555 {
556 bcscale(4);
557 // variable : $tot_amount float : total amount of the purchase (debit)
558 $tot_amount=0;
559
560 // variable : $tot_tva float : total amount of the VAT
561 $tot_tva=0;
562
563 // variable: $tot_debit float : amount on debit side
564 $tot_debit=0;
565
566 $this->db->start();
567
568
569 // variable: $tot_tva_reversed float total VAT autoreverse, to deduce from supplier's amount
570 $tot_tva_reversed=0;
571
572 // variable : $tva array that will contain all the VAT Amount
573 $tva=array();
574
575 // variable : $tva_reverse array that contain all the VAT autoreverse AND negative
576 $tva_reverse = array();
577
578 // variable : $tva_reverse_credit array that contain all the VAT autoreverse for credit
579 $tva_reverse_credit = array();
580
581 // variable : $tot_amount_cur : total amount in currency
582 $tot_amount_cur=0;
583
584 // find the currency from v_currency_last_value
585 // variable : $currency_rate_ref Acc_Currency , currency object for this operation
586 $currency_rate_ref=new Acc_Currency($this->db, $p_currency_code);
587
588 /* Save all the items without vat and no deductible vat and expense*/
589 for ($i=0;$i< $nb_item;$i++)
590 {
591 if ( empty(${'e_march'.$i}) || empty(${'e_quant'.$i}) ) continue;
592
593 /* First we save all the items without vat */
594 $fiche=new Fiche($this->db);
595 $fiche->get_by_qcode(${"e_march".$i});
596 // variable : $tva_both integer 1 for autoreverse ,0 normal, fetch it once for this item,
597 $tva_both=0;
598 /* tva */
599 if ($g_parameter->MY_TVA_USE=='Y')
600 {
601 $idx_tva=trim(${'e_march'.$i.'_tva_id'});
602 $oTva=Acc_Tva::build($this->db,$idx_tva);
603
604 $oTva->load();
605 $tva_both=$oTva->get_parameter("both_side");
606 }
607 /* -- Create acc_operation -- */
608 $acc_operation=new Acc_Operation($this->db);
609 $acc_operation->date=$e_date;
610 $acc_operation->grpt=$seq;
611 $acc_operation->jrn=$p_jrn;
612 $acc_operation->type='d';
613 $acc_operation->periode=$tperiode;
614 $acc_operation->qcode="";
615 $amount_4=bcmul(${'e_march'.$i.'_price'},${'e_quant'.$i});
616
617 /* We have to compute all the amount thanks Acc_Compute */
618
619 $acc_amount=new Acc_Compute();
620 $acc_amount->check=false;
621 $acc_amount->set_parameter('amount',$amount_4);
622 // Set the currency rate
623 $acc_amount->set_parameter("currency_rate", $p_currency_rate);
624 $acc_amount->convert_euro();
625 $amount_euro=$acc_amount->amount;
626
627 // Compute VAT or take the given one
628 if ( $g_parameter->MY_TVA_USE=='Y')
629 {
630 $acc_amount->set_parameter('amount_vat_rate',$oTva->get_parameter('rate'));
631 if ( noalyss_strlentrim(${'e_march'.$i.'_tva_amount'}) ==0 || ${'e_march'.$i.'_tva_amount'} == 0)
632 {
633 // vat must computed and the amount is already converted to EUR
634 $acc_amount->compute_vat();
635
636 }
637 else
638 {
639 // we convert the vat in euro
640 $acc_amount->set_parameter("amount_vat", ${'e_march'.$i.'_tva_amount'});
641 $acc_amount->convert_euro_vat();
642
643 }
644 // convert amount in eur
645 $tot_tva=bcadd($tot_tva,$acc_amount->amount_vat);
646 $tot_tva=round($tot_tva,2);
647 }
648
649
650 /* compute ND */
651 // variable: $save_amount_vat total float amount of VAT before changing due to NOT DEDUCTIBLE
652 $save_amount_vat=$acc_amount->amount_vat;
653 $this->compute_no_deductible($acc_amount, $fiche);
654 $acc_amount->correct();
655 // TVA which avoid
656 if ( $tva_both == 1 ) {
657 $acc_amount->autoreverse=$save_amount_vat;
658 $tot_tva_reversed=bcadd($tot_tva_reversed,$save_amount_vat);
659 }
660
661
662
663 $tot_amount=round(bcadd($tot_amount,$acc_amount->amount),2);
664 $tot_amount=round(bcadd($tot_amount,$acc_amount->amount_nd),2);
665 $tot_amount=round(bcadd($tot_amount,$acc_amount->amount_perso),2);
666
667 /* get the account and explode if necessary */
668 $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
669 // if 2 accounts, take only the debit one for customer
670 if ( strpos($sposte,',') != 0 )
671 {
672 $array=explode(',',$sposte);
673 $poste_val=$array[0];
674 }
675 else
676 {
677 $poste_val=$sposte;
678 }
679 if ($g_parameter->MY_UPDLAB=='Y')
680 {
681 $acc_operation->desc=strip_tags(${"e_march".$i."_label"});
682 }
683 else
684 {
685 $acc_operation->desc=null;
686 }
687 $acc_operation->poste=$poste_val;
688 $acc_operation->amount=$acc_amount->amount;
689 $acc_operation->qcode=${"e_march".$i};
690 if ($acc_amount->amount>0)
691 {
692 $tot_debit=bcadd($tot_debit, $acc_amount->amount);
693 }
694 $j_id=$acc_operation->insert_jrnx();
695
696 /* insert ND */
697 $this->insert_no_deductible($acc_amount, $fiche, $tva_both, $tot_debit,$acc_operation,$group,$i);
698
699
700 /* Compute sum vat */
701 if ( $g_parameter->MY_TVA_USE=='Y')
702 {
703 $tva_item=$acc_amount->amount_vat;
704
705 if ($tva_both == 0 ){
706 $tva[$idx_tva]=(isset( $tva[$idx_tva]))? $tva[$idx_tva]:0;
707 $tva[$idx_tva]=bcadd($tva[$idx_tva], $tva_item);
708 }else {
709 // $tva_item < 0 && $tva_both == 1
710 $tva_reverse[$idx_tva]=(isset($tva_reverse[$idx_tva]))?$tva_reverse[$idx_tva]:0;
711 $tva_reverse[$idx_tva]=bcadd($tva_item,$tva_reverse[$idx_tva]);
712 $tva_reverse_credit[$idx_tva]=(isset($tva_reverse_credit[$idx_tva]))?$tva_reverse_credit[$idx_tva]:0;
713 $tva_reverse_credit[$idx_tva]=bcadd($save_amount_vat,$tva_reverse_credit[$idx_tva]);
714 }
715 }
716 /* Save the stock */
717 /* if the quantity is < 0 then the stock increase (return of
718 * material)
719 */
720 $nNeg=(${"e_quant" . $i}< 0) ? -1 : 1;
721
722 // always save quantity but in withStock we can find
723 // what card need a stock management
724 if ( $g_parameter->MY_STOCK='Y'&& isset ($repo))
725 {
726 $dir=(${'e_quant'.$i} < 0 ) ? 'c':'d';
727 Stock_Goods::insert_goods($this->db,array('j_id'=>$j_id,'goods'=>${'e_march'.$i},'quant'=>$nNeg*${'e_quant'.$i},'dir'=>$dir,'repo'=>$repo)) ;
728 }
729
730 if ( $g_parameter->MY_ANALYTIC != "nu" && $g_parameter->match_analytic($poste_val))
731 {
732 // for each item, insert into operation_analytique */
733 $op=new Anc_Operation($this->db);
734 $op->set_currency_rate($p_currency_rate);
735 $op->oa_group=$group;
736 $op->j_id=$j_id;
737 $op->oa_date=$e_date;
738 $op->oa_debit='t';
739 $op->oa_description=sql_string($e_comm);
740 $op->save_form_plan($p_array,$i,$j_id);
741 }
742 // insert into quant_purchase
743 //-----
744
745 if (empty( ${'e_march' . $i . '_price'} ) ) ${'e_march' . $i . '_price'} = 0;
746 if (empty( ${'e_march' . $i } ) ) ${'e_march' . $i } = 0;
747 if (empty( ${'e_quant' . $i } ) ) ${'e_quant' . $i } = 0;
748 $price_euro=bcdiv(${'e_march'.$i.'_price'}, $p_currency_rate);
749
750 if ( $g_parameter->MY_TVA_USE=='Y')
751 {
752
753 $r=$this->db->exec_sql("select insert_quant_purchase ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)",
754 array(
755 null /*1*/
756 ,$j_id /* 2 */
757 ,${"e_march".$i} /* 3 */
758 ,${"e_quant".$i} /* 4 */
759 ,round($amount_euro,2) /* 5 */
760 ,$acc_amount->amount_vat /* 6 */
761 ,$oTva->get_parameter('id') /* 7 */
762 ,$acc_amount->amount_nd /* 8 */
763 ,$acc_amount->nd_vat /* 9 */
764 ,$acc_amount->nd_ded_vat /* 10 */
765 ,$acc_amount->amount_perso /* 11 */
766 ,$e_client /* 12 */
767 , $acc_amount->autoreverse /*13*/
768 ,$price_euro /* 14 */
769 ));
770
771
772 }
773 else
774 {
775 $acc_amount->amount_vat=0;
776 $r=$this->db->exec_sql("select insert_quant_purchase ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)",
777 array(
778 null /*1*/
779 ,$j_id /* 2 */
780 ,${"e_march".$i} /* 3 */
781 ,${"e_quant".$i} /* 4 */
782 ,round($acc_amount->amount,2) /* 5 */
783 ,0 /* 6 */
784 ,null/* 7 */
785 ,$acc_amount->amount_nd /* 8 */
786 ,0 /* 9 */
787 ,$acc_amount->nd_ded_vat /* 10 */
788 ,$acc_amount->amount_perso /* 11 */
789 ,$e_client /* 12 */
790 , $acc_amount->autoreverse /*13*/
791 ,$price_euro /* 14 */
792 ));
793 }
794 /*
795 * Insert also in operation_currency
796 */
797 $operation_currency=new Operation_currency_SQL($this->db);
798 $operation_currency->oc_amount=$acc_amount->amount_currency;
799 $operation_currency->oc_vat_amount=($tva_both==0)?$acc_amount->amount_vat_currency:0;
800 $operation_currency->oc_price_unit=${'e_march'.$i.'_price'};
801 $operation_currency->j_id=$j_id;
802 $operation_currency->insert();
803 $tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_currency,4),4);
804 $tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_vat_currency,4),4);
805 if ( DEBUGNOALYSS > 1 ) {
806 echo __LINE__." insert into operation currency oc_amount:{$acc_amount->amount_currency} oc_vat_amount {$acc_amount->amount_vat_currency} <br>";
807 }
808 } // end loop : save all items
809
810
811 /*** save other tax ****/
812 if ( $this->has_other_tax() && isset($p_array['other_tax'])) {
813 $row=$this->db->get_row("select ac_id,ac_label,ac_accounting
814 from acc_other_tax
815 where ac_id=$1 ",
816 [$p_array['other_tax']]);
817 if ( ! empty ($row )) {
818 $other_tax_amount=bcmul($p_array['other_tax_amount'],$p_currency_rate);
819 $acc_operation=new Acc_Operation($this->db);
820 $acc_operation->date=$e_date;
821 $acc_operation->poste=$row['ac_accounting'];
822 $acc_operation->amount=$other_tax_amount;
823 $acc_operation->grpt=$seq;
824 $acc_operation->jrn=$p_jrn;
825 $acc_operation->type='d';
826 $acc_operation->periode=$tperiode;
827 $acc_operation->desc=$row['ac_label'];
828 $jrn_tax_sql=new Jrn_Tax_SQL($this->db);
829 $jrn_tax_sql->j_id=$acc_operation->insert_jrnx();
830 $jrn_tax_sql->ac_id=$row['ac_id'];
831 $jrn_tax_sql->pcm_val=$row['ac_accounting'];
832 $jrn_tax_sql->insert();
833 $operation_currency=new Operation_currency_SQL($this->db);
834 $operation_currency->oc_amount=$p_array['other_tax_amount'];
835 $operation_currency->oc_vat_amount=0;
836 $operation_currency->oc_price_unit=0;
837 $operation_currency->j_id=$jrn_tax_sql->j_id;
838 $operation_currency->insert();
839
840 $tot_debit=bcadd($tot_debit, abs($other_tax_amount));
842 }
843
844 }
845
846
847 /*** save total customer ***/
848 if ( DEBUGNOALYSS > 1 ) {
849 echo __LINE__." tot_amount $tot_amount<br>";
850 echo __LINE__." tot_tva $tot_tva<br>";
851
852 }
853 $cust_amount=round(bcadd($tot_amount,$tot_tva),2);
854 $acc_operation=new Acc_Operation($this->db);
855 $acc_operation->date=$e_date;
856 $acc_operation->poste=$poste;
857 $acc_operation->amount=bcsub($cust_amount,$tot_tva_reversed);
858 $acc_operation->grpt=$seq;
859 $acc_operation->jrn=$p_jrn;
860 $acc_operation->type='c';
861 $acc_operation->periode=$tperiode;
862 $acc_operation->qcode=${"e_client"};
863 if ($cust_amount<0)
864 {
865 $tot_debit=bcadd($tot_debit, abs($cust_amount));
866 }
867 $let_client=$acc_operation->insert_jrnx();
868
869 // --- insert also the currency amount for the customer
870 $operation_currency=new Operation_currency_SQL($this->db);
871 $operation_currency->oc_amount=$tot_amount_cur;
872 $operation_currency->oc_vat_amount=0;
873 $operation_currency->oc_price_unit=0;
874 $operation_currency->j_id=$let_client ;
875 $operation_currency->insert();
876
877 if ( $g_parameter->MY_TVA_USE=='Y')
878 {
879 /* save all vat
880 * $i contains the tva_id and value contains the vat amount
881 */
882 foreach ($tva as $i => $value)
883 {
884 $oTva=Acc_Tva::build($this->db,$i);
885 $poste_vat=$oTva->get_side('d');
886
887 $cust_amount=round(bcadd($tot_amount,$tot_tva),2);
888 $acc_operation=new Acc_Operation($this->db);
889 $acc_operation->date=$e_date;
890 $acc_operation->poste=$poste_vat;
891 $acc_operation->amount=$value;
892 $acc_operation->grpt=$seq;
893 $acc_operation->jrn=$p_jrn;
894 $acc_operation->type='d';
895 $acc_operation->periode=$tperiode;
896 if ( $value > 0 ) $tot_debit=bcadd($tot_debit,abs($value));
897 $acc_operation->insert_jrnx();
898
899 } // LOOP : foreach $tva
900 foreach ($tva_reverse as $i => $value) {
901 $oTva = Acc_Tva::build($this->db,$i);
902 $poste_vat = $oTva->get_side('d');
903 if ( $poste_vat == '#')
904 {
905 $poste_vat=$oTva->get_side('c');
906 }
907
908 $acc_operation = new Acc_Operation($this->db);
909 $acc_operation->date = $e_date;
910 $acc_operation->poste = $poste_vat;
911 $acc_operation->amount = $value;
912 $acc_operation->grpt = $seq;
913 $acc_operation->jrn = $p_jrn;
914 $acc_operation->type = 'd';
915 $acc_operation->periode = $tperiode;
916
917 $acc_operation->insert_jrnx();
918
919 // if TVA is on both side, we deduce it immediately
920 // $x temp variable is the tva_reverse_account and will be used to check $poste_vat
921 $x=$oTva->get_parameter("tva_reverse_account");
922 $poste_vat =(trim($x??"")=="")? $oTva->get_side('c'):$x;
923
924 if ( $poste_vat == '#')
925 {
926 $poste_vat=$oTva->get_side('d');
927 }
928 $acc_operation = new Acc_Operation($this->db);
929 $acc_operation->date = $e_date;
930 $acc_operation->poste = $poste_vat;
931 $acc_operation->amount = $tva_reverse_credit[$i];
932 $acc_operation->grpt = $seq;
933 $acc_operation->jrn = $p_jrn;
934 $acc_operation->type = 'c';
935 $acc_operation->periode = $tperiode;
936 $acc_operation->insert_jrnx();
937 $tot_debit = bcadd($tot_debit, $value);
938 $tot_debit = round($tot_debit, 2);
939 } //LOOP: foreach $tva_reverse
940 }
941
942 /* insert into jrn */
943 $acc_operation=new Acc_Operation($this->db);
944 $acc_operation->date=$e_date;
945 $acc_operation->echeance=$e_ech;
946 // Total DEB
947 $acc_operation->amount=$this->db->get_value("select sum(j_montant) from jrnx where j_grpt = $1 and j_debit='t'",
948 array($seq));
949 $acc_operation->desc=$e_comm;
950 $acc_operation->grpt=$seq;
951 $acc_operation->jrn=$p_jrn;
952 $acc_operation->periode=$tperiode;
953 $acc_operation->pj=$e_pj;
954 $acc_operation->mt=$mt;
955 $acc_operation->currency_id=$p_currency_code;
956 $acc_operation->currency_rate=$p_currency_rate;
957 $acc_operation->currency_rate_ref=$currency_rate_ref->get_rate();
958
959 if ( ! $this->jr_id=$acc_operation->insert_jrn() ) {
960 throw new Exception (_("Erreur de balance"),EXC_BALANCE);
961 }
962 $this->pj=$acc_operation->update_receipt();
963
964 // Set Internal code
965 $this->grpt_id=$seq;
966 $this->update_internal_code($internal);
967 /* update quant_purchase */
968 $this->db->exec_sql('update quant_purchase set qp_internal = $1 where j_id in (select j_id from jrnx where j_grpt=$2)',
969 array($internal,$seq));
970
971 /**= e_pj then do not increment sequence , if the given receipt number is equal to one computed then increment */
972 if ($e_pj == $this->pj && noalyss_strlentrim($e_pj) != 0)
973 {
974 $this->inc_seq_pj();
975 }
976
977 /* Save the attachment */
978 if ( isset ($_FILES))
979 {
980 if ( sizeof($_FILES) != 0 )
981 $this->db->save_receipt($seq);
982 }
983 $str_file="";
984 /* Generate an document and save it into the database (Note de frais only)
985 */
986 if ( isset($_POST['gen_invoice']) )
987 {
988 $ref_doc= $this->create_document($internal,$p_array);
989 $this->doc=HtmlInput::show_receipt_document($this->jr_id,h($ref_doc));
990 }
991
992 //----------------------------------------
993 // Save the payer
994 //----------------------------------------
995 if ( $e_mp != 0 )
996 {
997 /* mp */
998 $mp=new Acc_Payment($this->db,$e_mp);
999 $mp->load();
1000
1001 /* jrnx */
1002 $acseq=$this->db->get_next_seq('s_grpt');
1003 $acjrn=new Acc_Ledger($this->db,$mp->get_parameter('ledger_target'));
1004 $acinternal=$acjrn->compute_internal_code($acseq);
1005 /*
1006 * for the use of the card of the bank
1007 */
1008 if ( $acjrn->get_type()=='FIN') {
1009 $acjrn=new Acc_Ledger_Fin($this->db, $mp->get_parameter('ledger_target'));
1010 $acfiche=new Fiche($this->db,$acjrn->get_bank());
1011 $fqcode=$acfiche->strAttribut(ATTR_DEF_QUICKCODE);
1012 } else {
1013 $fqcode = ${'e_mp_qcode_' . $e_mp};
1014 $acfiche = new Fiche($this->db);
1015 $acfiche->get_by_qcode($fqcode);
1016 }
1017 /* Insert paid by */
1018 $acc_pay=new Acc_Operation($this->db);
1019 $acc_pay->date=$e_date;
1020
1021 /* get the account and explode if necessary */
1022 $sposte=$acfiche->strAttribut(ATTR_DEF_ACCOUNT);
1023 // if 2 accounts, take only the debit one for customer
1024 if ( strpos($sposte,',') != 0 )
1025 {
1026 $array=explode(',',$sposte);
1027 $poste_val=$array[1];
1028 }
1029 else
1030 {
1031 $poste_val=$sposte;
1032 }
1033 // remove the VAT autoliquidation
1034 $cust_amount=bcsub($cust_amount, $tot_tva_reversed);
1035
1036 // Convert paid amount in EUR
1037 $acompte_defcur=bcdiv($acompte, $p_currency_rate);
1038
1039 $famount=bcsub($cust_amount,$acompte_defcur);
1040
1041 $acc_pay->poste=$poste_val;
1042 $acc_pay->qcode=$fqcode;
1043 $acc_pay->amount=abs(round($famount,2));
1044 $acc_pay->desc='';
1045 $acc_pay->grpt=$acseq;
1046 $acc_pay->jrn=$mp->get_parameter('ledger_target');
1047 $acc_pay->periode=$tperiode;
1048 $acc_pay->type=($famount>=0)?'c':'d';
1049 $let_pay=$acc_pay->insert_jrnx();
1050
1051 /* Insert supplier */
1052 $acc_pay=new Acc_Operation($this->db);
1053 $acc_pay->date=empty($mp_date)?$e_date:$mp_date;
1054 $acc_pay->poste=$poste;
1055 $acc_pay->qcode=$e_client;
1056 $acc_pay->amount=abs(round($famount,2));
1057 $acc_pay->desc='';
1058 $acc_pay->grpt=$acseq;
1059 $acc_pay->jrn=$mp->get_parameter('ledger_target');
1060 $acc_pay->periode=$tperiode;
1061 $acc_pay->type=($famount>=0)?'d':'c';
1062 $let_other=$acc_pay->insert_jrnx();
1063
1064 // insert into operation_currency
1065 $operation_currency=new Operation_currency_SQL($this->db);
1066 $operation_currency->oc_amount=bcsub($tot_amount_cur,$acompte);
1067 $operation_currency->oc_vat_amount=0;
1068 $operation_currency->oc_price_unit=0;
1069 $operation_currency->j_id=$let_other;
1070 $operation_currency->insert();
1071
1072 // insert into operation_currency bank
1073 $operation_currency=new Operation_currency_SQL($this->db);
1074 $operation_currency->oc_amount=bcsub($tot_amount_cur,$acompte);
1075 $operation_currency->oc_vat_amount=0;
1076 $operation_currency->oc_price_unit=0;
1077 $operation_currency->j_id=$let_pay;
1078 $operation_currency->insert();
1079
1080 /* insert into jrn */
1081 $acc_pay->mt=$mt;
1082 $acc_pay->desc=(!isset($e_comm_paiement) || noalyss_strlentrim($e_comm_paiement) == 0) ?$e_comm:$e_comm_paiement;
1083
1084 // Add info for currency
1085 $acc_pay->currency_id=$p_currency_code;
1086 $acc_pay->currency_rate=$p_currency_rate;
1087 $acc_pay->currency_rate_ref=$currency_rate_ref->get_rate();
1088
1089
1090 // insert into the table JRN
1091 $mp_jr_id=$acc_pay->insert_jrn();
1092 $this->payment_operation=$mp_jr_id;
1093 $acjrn->grpt_id=$acseq;
1094 $acjrn->update_internal_code($acinternal);
1095 // add an automatic PJ if ODS
1096 if ($acjrn->get_type()=="ODS") {
1097 $acc_pay->pj=$acjrn->guess_pj();
1098 $acc_pay->update_receipt();
1099 }
1100 $r1=$this->get_id($internal);
1101 $r2=$this->get_id($acinternal);
1102
1103 /*
1104 * add lettering
1105 */
1106 $oletter=new Lettering($this->db);
1107 $oletter->insert_couple($let_client,$let_other);
1108
1109 /* set the flag paid */
1110 $Res=$this->db->exec_sql("update jrn set jr_rapt='paid' where jr_id=$1",array($r1));
1111
1112 /* Reconcialiation */
1113 $rec=new Acc_Reconciliation($this->db);
1114 $rec->set_jr_id($r1);
1115 $rec->insert($r2);
1116 /*
1117 * save also into quant_fin
1118 */
1119
1120 /* get ledger property */
1121 $ledger=new Acc_Ledger_Fin($this->db,$acc_pay->jrn);
1122 $prop=$ledger->get_propertie();
1123
1124 /* if ledger is FIN then insert into quant_fin */
1125 if ( $prop['jrn_def_type'] == 'FIN' )
1126 {
1127 $ledger->insert_quant_fin($acfiche->id,$mp_jr_id,$cust->id,bcmul($famount,-1),$let_other);
1128 }
1129
1130
1131 }
1132 /*----------------------------------------------
1133 * Save the note
1134 ----------------------------------------------*/
1135 if (isset($p_array['jrn_note_input']) && !empty($p_array['jrn_note_input'])) {
1136 $acc_operation_note=Acc_Operation_Note::build_jrn_id(-1);
1137 $acc_operation_note->setNote($p_array['jrn_note_input']);
1138 $acc_operation_note->setOperation_id( $this->jr_id);
1139 $acc_operation_note->save();
1140 }
1141 }//end try
1142 catch (Exception $e)
1143 {
1144 record_log($e);
1145 $this->db->rollback();
1146 throw $e;
1147 }
1148 $this->db->commit();
1149 return $internal;
1150 }
1151
1152 /*!\brief display the form for entering data for invoice
1153 *\param $p_array is null or you can put the predef operation or the $_POST
1154 \code
1155 array
1156 'sa' => string 'n' (length=1)
1157 'p_action' => string 'ach' (length=3)
1158 'gDossier' => string '28' (length=2)
1159 'e_client' => string 'ASEKURA' (length=7)
1160 'nb_item' => string '9' (length=1)
1161 'p_jrn' => string '3' (length=1)
1162 'period' => string '126' (length=3)
1163 'e_comm' => string 'descriptio' (length=10)
1164 'e_date' => string '01.05.2010' (length=10)
1165 'e_ech' => string '' (length=0)
1166 'jrn_type' => string 'ACH' (length=3)
1167 'e_pj' => string 'ACH37' (length=5)
1168 'e_pj_suggest' => string 'ACH37' (length=5)
1169 'mt' => string '1273759434.5701' (length=15)
1170 'e_mp' => string '0' (length=1)
1171 'e_march0' => string 'DOC' (length=3)
1172 'e_march0_price' => string '2000' (length=4)
1173 'e_march0_tva_id' => string '3' (length=1)
1174 'e_march0_tva_amount' => string '120' (length=3)
1175 'e_quant0' => string '1' (length=1)
1176 'gen_invoice' => string 'on' (length=2)
1177 'gen_doc' => string '7' (length=1)
1178 'bon_comm' => string '' (length=0)
1179 'other_info' => string '' (length=0)
1180 'correct' => string 'Corriger' (length=8)
1181 \endcode
1182 *\return HTML string
1183 */
1184 public function input($p_array=null,$p_readonly=0)
1185 {
1186 global $g_parameter,$g_user;
1187 // load ledger definition
1188 $this->load();
1189 $http=new HttpInput();
1190 if ( $p_array != null ) extract($p_array, EXTR_SKIP);
1191
1192 $flag_tva=$g_parameter->MY_TVA_USE;
1193
1194 /* Add button */
1195 $str_add_button_tiers = "";
1196 $add_card=FALSE;
1197 if ($g_user->check_action(FICADD) == 1) {
1198 $add_card=TRUE;
1199 $str_add_button_tiers = $this->add_card("cred", "e_client");
1200 }
1201 // The first day of the periode
1202 $oPeriode=new Periode($this->db);
1203 list ($l_date_start,$l_date_end)=$oPeriode->get_date_limit($g_user->get_periode());
1204 if ( $g_parameter->MY_DATE_SUGGEST=='Y' )
1205 $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date;
1206 else
1207 $op_date=( ! isset($e_date) ) ?'':$e_date;
1208
1209 $e_ech=(isset($e_ech))?$e_ech:"";
1210 $e_comm=(isset($e_comm))?$e_comm:"";
1211
1212 $r="";
1213 $r.=dossier::hidden();
1214 $f_legend_detail=_("Détail articles achetés");
1215
1216 // Date
1217 //--
1218 $Date=new IDate();
1219 $Date->setReadOnly(false);
1220 $Date->table=1;
1221 $Date->tabindex=1;
1222 $f_date=$Date->input("e_date",$op_date);
1223 // Payment limit
1224 //--
1225 $Echeance=new IDate();
1226 $Echeance->setReadOnly(false);
1227 $Echeance->tabindex=2;
1229 $f_echeance=$Echeance->input('e_ech',$e_ech,'Echéance'.$label);
1230 $f_periode="";
1231 if ($this->check_periode() == true)
1232 {
1233 // Periode
1234 //--
1235 $l_user_per=$g_user->get_periode();
1236 $def=(isset($periode))?$periode:$l_user_per;
1237
1238 $period=new IPeriod("period");
1239 $period->user=$g_user;
1240 $period->cn=$this->db;
1241 $period->value=$def;
1242 $period->type=OPEN;
1243 try
1244 {
1245 $l_form_per=$period->input();
1246 }
1247 catch (Exception $e)
1248 {
1249 record_log($e);
1250 if ($e->getCode() == 1 )
1251 {
1252 throw new Exception( _("Aucune période ouverte"));
1253 }
1254 }
1255
1256 $r.="<td>";
1258 $f_periode=td(_("Période comptable")." $label ").td($l_form_per);
1259 }
1260 // Ledger (p_jrn)
1261 //--
1262 /* if we suggest the next pj, then we need a javascript */
1263 $add_js="";
1264 if ( $g_parameter->MY_PJ_SUGGEST !='N')
1265 {
1266 $add_js="update_receipt();";
1267 }
1268 if ($g_parameter->MY_DATE_SUGGEST == 'Y')
1269 {
1270 $add_js.='get_last_date();';
1271 }
1272 $add_js.='update_name();';
1273 $add_js.='update_pay_method();';
1274 $add_js.='update_row("sold_item");';
1275 $add_js.='update_other_tax();';
1276 $add_js.='update_visibility_quantity();';
1277
1278 $wLedger=$this->select_ledger('ACH',2,FALSE);
1279
1280 if ($wLedger == null) throw new Exception(_('Pas de journal disponible'));
1281 $wLedger->javascript="onChange='update_predef(\"ach\",\"f\",\"".$http->request("ac")."\");$add_js'";
1282 $wLedger->table=0;
1283 $f_jrn=$wLedger->input();
1284
1285 // Comment
1286 //--
1287 $Commentaire=new IText();
1288 $Commentaire->table=0;
1289 $Commentaire->setReadOnly(false);
1290 $Commentaire->size=60;
1291 $Commentaire->tabindex=3;
1293 $f_desc=$Commentaire->input("e_comm",$e_comm);
1294
1295 // PJ
1296 //--
1297 /* suggest PJ ? */
1298 $default_pj='';
1299 if ( $g_parameter->MY_PJ_SUGGEST !='N')
1300 {
1301 $default_pj=$this->guess_pj();
1302 }
1303
1304 $pj=new IText();
1305 $pj->value=(isset($e_pj))?$e_pj:$default_pj;
1306
1307 if ( $g_parameter->MY_PJ_SUGGEST=='A' || $g_user->check_action(UPDRECEIPT)==0)
1308 {
1309 $pj->setReadOnly(true);
1310 $pj->id="e_pj";
1311 }
1312 $pj->table=0;
1313 $pj->name="e_pj";
1314 $pj->size=10;
1315 $pj->readonly=false;
1316
1317 $f_pj=$pj->input().HtmlInput::hidden('e_pj_suggest',$default_pj);
1318
1319 // Display the customer
1320 //--
1321 $fiche='cred';
1322
1323 // Save old value and set a new one
1324 //--
1325 $e_client=( isset ($e_client) )?$e_client:"";
1326 $e_client_label="&nbsp;";//str_pad("",100,".");
1327
1328
1329 // retrieve e_client_label
1330 //--
1331
1332 if ( noalyss_strlentrim($e_client) != 0)
1333 {
1334 $fClient=new Fiche($this->db);
1335 $fClient->get_by_qcode($e_client);
1336 $e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '.
1337 ' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '.
1338 $fClient->strAttribut(ATTR_DEF_CP).' '.
1339 $fClient->strAttribut(ATTR_DEF_CITY).' ';
1340
1341
1342 }
1343
1344 $W1=new ICard();
1345 $W1->label=_("Fournisseur ").Icon_Action::infobulle(0) ;
1346 $W1->name="e_client";
1347 $W1->tabindex=3;
1348 $W1->value=$e_client;
1349 $W1->table=0;
1350 $W1->set_dblclick("fill_ipopcard(this);");
1351 $W1->set_attribute('ipopup','ipopcard');
1352
1353 // name of the field to update with the name of the card
1354 $W1->set_attribute('label','e_client_label');
1355 // name of the field to update with the name of the card
1356 $W1->set_attribute('typecard','cred');
1357
1358 // Add the callback function to filter the card on the jrn
1359 $W1->set_callback('filter_card');
1360 $W1->set_function('fill_data');
1361 $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
1362 $W1->name);
1363 $f_client_qcode=$W1->input();
1364 $client_label=new ISpan();
1365 $client_label->style="vertical-align:top";
1366 $client_label->table=0;
1367 $f_client=$client_label->input("e_client_label",$e_client_label);
1368 $f_client_bt=$W1->search();
1369
1370
1371 // Record the current number of article
1372
1373 $e_comment=(isset($e_comment))?$e_comment:"";
1374 $p_article= ( isset ($nb_item))?$nb_item:$this->get_min_row();
1375 $p_article=($p_article < $this->get_min_row())?$this->get_min_row():$p_article;
1376
1377 $Hid=new IHidden();
1378 $r.=$Hid->input("nb_item",$p_article);
1379
1380 // For each article
1381 //--
1382 for ($i=0;$i< $p_article ;$i++)
1383 {
1384 // Code id, price & vat code
1385 //--
1386 $march=(isset(${"e_march$i"}))?${"e_march$i"}:"" ;
1387 $march_price=(isset(${"e_march".$i."_price"}))?${"e_march".$i."_price"}:""
1388 ;
1389 /* use vat */
1390 if ( $g_parameter->MY_TVA_USE=='Y')
1391 {
1392 $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
1393 $march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:"";
1394 }
1395
1396
1397
1398 $march_label=(isset(${"e_march".$i."_label"}))?${"e_march".$i."_label"}:"";
1399 // retrieve the tva label and name
1400 //--
1401 if ( noalyss_strlentrim($march)!=0 && noalyss_strlentrim($march_label)==0 )
1402 {
1403 $fMarch=new Fiche($this->db);
1404 $fMarch->get_by_qcode($march);
1405 $march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
1406 /* vat use */
1407 if ( ! isset($march_tva_id) && $g_parameter->MY_TVA_USE=='Y' )
1408 $march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
1409 }
1410 // Show input
1411 //--
1412 $W1=new ICard();
1413 $W1->label="";
1414 $W1->name="e_march".$i;
1415 $W1->value=$march;
1416 $W1->table=0;
1417 $W1->set_dblclick("fill_ipopcard(this);");
1418 $W1->set_attribute('ipopup','ipopcard');
1419
1420 $W1->set_attribute('typecard','deb');
1421
1422 // name of the field to update with the name of the card
1423 $W1->set_attribute('label','e_march'.$i.'_label');
1424 // name of the field with the price
1425 $W1->set_attribute('purchase','e_march'.$i.'_price'); /* autocomplete */
1426 $W1->set_attribute('price','e_march'.$i.'_price'); /* via search */
1427
1428 // name of the field with the TVA_ID
1429 $W1->set_attribute('tvaid','e_march'.$i.'_tva_id');
1430 // Add the callback function to filter the card on the jrn
1431 $W1->set_callback('filter_card');
1432 $W1->set_function('fill_data');
1433 $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
1434 $W1->name);
1435 $W1->readonly=false;
1436 $array[$i]['quick_code']=$W1->input();
1437 $array[$i]['bt']=$W1->search();
1438 $array[$i]['card_add']=($add_card==TRUE)?$this->add_card("deb", $W1->id):"";
1439
1440 $array[$i]['hidden']='';
1441 // For computing we need some hidden field for holding the value
1442 if ( $g_parameter->MY_TVA_USE=='Y')
1443 {
1444 $array[$i]['hidden'].=HtmlInput::hidden('tva_march'.$i,0);
1445 }
1446
1447 if ( $g_parameter->MY_TVA_USE=='Y')
1448 $tvac=new INum('tvac_march'.$i);
1449 else
1450 $tvac=new IHidden('tvac_march'.$i);
1451
1452 $tvac->readOnly=1;
1453 $tvac->value=0;
1454 $array[$i]['tvac']=$tvac->input();
1455
1456 $htva=new INum('htva_march'.$i);
1457 $htva->readOnly=1;
1458
1459 $htva->value=0;
1460 $array[$i]['htva']=$htva->input();
1461
1462 if ( $g_parameter->MY_UPDLAB == 'Y')
1463 {
1464 $Span=new IText("e_march".$i."_label");
1465 $Span->style='class="input_text label_item"';
1466 } else
1467 {
1468 $Span=new ISpan("e_march".$i."_label");
1469 $Span->extra='class="label_item"';
1470 }
1471 $Span->value=$march_label;
1472 $Span->setReadOnly(false);
1473 // card's name, price
1474 //--
1475 $array[$i]['denom']=$Span->input("e_march".$i."_label",$march_label);
1476 // price
1477 $Price=new INum();
1478 $Price->setReadOnly(false);
1479 $Price->size=9;
1480 $Price->javascript="onblur=\"format_number(this,4);clean_tva($i);compute_ledger($i)\"";
1481 $array[$i]['pu']=$Price->input("e_march".$i."_price",$march_price);
1482 if ( $g_parameter->MY_TVA_USE=='Y')
1483 {
1484
1485 // vat label
1486 //--
1487 $Tva=new ITva_Popup($this->db);
1488 $Tva->js="onblur=\"clean_tva($i);compute_ledger($i)\"";
1489 $Tva->in_table=true;
1490 $Tva->set_attribute('compute',$i);
1491 $Tva->set_filter("purchase");
1492 $Tva->value=$march_tva_id;
1493 $array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
1494
1495 // Tva_amount
1496
1497 // price
1498 $Tva_amount=new INum();
1499 $Tva_amount->setReadOnly(false);
1500 $Tva_amount->size=9;
1501 $Tva_amount->javascript="onblur=\"format_number(this);compute_ledger($i)\"";
1502 $array[$i]['amount_tva']=$Tva_amount->input("e_march".$i."_tva_amount",$march_tva_amount);
1503 }
1504 // quantity
1505 //--
1506 $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"
1507 ;
1508 $Quantity=new INum();
1509 $Quantity->setReadOnly(false);
1510 $Quantity->size=9;
1511 $Quantity->javascript="onchange=\"format_number(this,2);clean_tva($i);compute_ledger($i)\"";
1512 $array[$i]['quantity']=$Quantity->input("e_quant".$i,$quant);
1513
1514 }
1515 $f_type=_('Fournisseur');
1516
1517 // Currency
1518 $currency_select = $this->CurrencyInput("currency_code", "p_currency_rate" , "p_currency_euro");
1519 $currency_select->selected=$http->request('p_currency_code','string',0);
1520
1521 $currency_input=new INum("p_currency_rate");
1522 $currency_input->prec=8;
1523 $currency_input->id="p_currency_rate";
1524 $currency_input->value=$http->request('p_currency_rate','string',1);
1525 $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"';
1526
1527 $currency=new Acc_Currency($this->db,0);
1528
1529 //
1530 // Button for template operation
1531 //
1532 ob_start();
1533 echo '<div id="predef_form">';
1534 echo HtmlInput::hidden('p_jrn_predef', $this->id);
1535 $op = new Pre_operation($this->db);
1536 $op->set_p_jrn($this->id);
1537 $op->set_jrn_type("ACH");
1538 $op->set_od_direct('f');
1539 $url=http_build_query(array('p_jrn_predef'=>$this->id,'ac'=>$http->request('ac'),'gDossier'=>dossier::id()));
1540 echo $op->form_get('do.php?'.$url);
1541 echo '</div>';
1542 $str_op_template=ob_get_contents();
1543 ob_end_clean();
1544
1545 ob_start();
1546 require_once NOALYSS_TEMPLATE.'/form_ledger_detail.php';
1547 $r.=ob_get_contents();
1548 ob_end_clean();
1549
1550 // Set correctly the REQUEST param for jrn_type
1551 $r.= HtmlInput::hidden('jrn_type','ACH');
1553
1554
1555
1556 /* if we suggest the pj n# the run the script */
1557 if ( $g_parameter->MY_PJ_SUGGEST !='N')
1558 {
1559 $r.='<script> update_receipt();</script>';
1560 }
1561 // set focus on date
1562 $r.= create_script("$('".$Date->id."').focus()");
1563 $r.='<div id="additional_tax_div">';
1564 $r.=$this->input_additional_tax();
1565 $r.='</div>';
1566 return $r;
1567 }
1568
1569 /*!@brief show the summary of the operation and propose to save it
1570 *@param array contains normally $_POST. It proposes also to save
1571 * the Analytic accountancy
1572 * @param $p_summary true to confirm false, show only the result in RO
1573 *@return string
1574 */
1575 function confirm($p_array,$p_summary=false)
1576 {
1577 global $g_parameter,$g_user;
1578 extract ($p_array,EXTR_SKIP);
1579 if ( !isset($p_array['jrn_note_input'])) {$p_array['jrn_note_input']='';}
1580 // we don't need to verify if we need only a feedback
1581 if ( ! $p_summary ){$this->verify($p_array) ;}
1582
1583 $anc=null;
1584 // to show a select list for the analytic
1585 // if analytic is op (optionnel) there is a blank line
1586
1587 bcscale(4);
1588 $client=new Fiche($this->db);
1589 $client->get_by_qcode($e_client,true);
1590
1591 $client_name=h($client->getName().
1592 ' '.$client->strAttribut(ATTR_DEF_ADRESS).' '.
1593 $client->strAttribut(ATTR_DEF_CP).' '.
1594 $client->strAttribut(ATTR_DEF_CITY));
1595 $lPeriode=new Periode($this->db);
1596 if ($this->check_periode() == true)
1597 {
1598 $lPeriode->p_id=$period;
1599 }
1600 else
1601 {
1602 $lPeriode->find_periode($e_date);
1603 }
1604 $date_limit=$lPeriode->get_date_limit();
1605 $r="";
1606 $r .= '<div id="summary_op1">';
1607 $r.='<TABLE>';
1608 if ( $p_summary ) {
1609 $jr_id=$this->db->get_value('select jr_id from jrn where jr_internal=$1',array($this->internal));
1610 $r.="<tr>";
1611 $r.='<td>';
1612 $r.=_('Détail opération ');
1613 $r.='</td>';
1614 $r.='<td>';
1615 $r.=sprintf ('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>',
1616 $jr_id,dossier::id(),$this->internal);
1617 $r.='</td>';
1618 $r.="</tr>";
1619 }
1620 $r.='<tr>';
1621
1623 if ( ! $p_summary) {
1624 $r.='<td>' . _('Numéro Pièce') .$span.'</td><td>'. hb($e_pj) . '</td>';
1625 } else {
1626 if ( $g_parameter->MY_PJ_SUGGEST=="A" || $g_user->check_action(UPDRECEIPT)==0) $e_pj=$this->pj;
1627
1628 if ( strcmp($this->pj,$e_pj) != 0 )
1629 {
1630 $r.='<td>' . _('Numéro Pièce').$span .'</td><td>'. hb($this->pj) .
1631 '<span class="notice"> '._('Attention numéro pièce existante, elle a du être adaptée').'</span></td>';
1632 } else {
1633 $r.='<td>' . _('Numéro Pièce') .$span.'</td><td>'. hb($this->pj) . '</td>';
1634 }
1635 }
1636 $r.='</tr>';
1637 $r.='<td> ' . _('Date') . '</td><td> ' . hb($e_date) . '</td>';
1638 $r.='</tr>';
1639 $r.='<tr>';
1640 $r.='<td>' . _('Echeance') . '</td><td> ' . hb($e_ech) . '</td>';
1641 $r.='</tr>';
1642
1643
1644 $r.='<tr>';
1645 $r.='<td> ' . _('Période Comptable') . '</td><td> ' .hb( $date_limit['p_start'] . '-' . $date_limit['p_end']) . '</td>';
1646 $r.='</tr>';
1647 $r.='</table>';
1648 $r.='</div>';
1649 $r .= '<div id="summary_op2">';
1650 $r.='<table>';
1651 $r.='<tr>';
1652 $r.='<td> ' . _('Journal') . '</td><td> ' . hb($this->get_name()) . '</td>';
1653 $r.='</tr>';
1654 $r.='<tr>';
1655 $r.='<td> ' . _('Libellé') . '</td><td> ' . hb($e_comm) . '</td>';
1656 $r.='</tr>';
1657 $r.='<tr>';
1658
1659 $r.='<tr>';
1660 $r.='<td> ' . _('Fournisseur') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
1661 $r.='</tr>';
1662 $r.='</table>';
1663 $r.='<pre>'._('Note').' '.h($p_array['jrn_note_input']).'</pre>';
1664 $r.='</div>';
1665 $r.='<div style="position:float;clear:both">';
1666 $r.='</div>';
1667 $r.='<h2>' . _('Détail articles achetés') . '</h2>';
1668 $r.='<p class="decale">';
1669 $r.='<table class="result" >';
1670 $r.='<TR>';
1671 $r.="<th>" . _('Code') . "</th>";
1672 $r.="<th>" . _('Dénomination') . "</th>";
1673 $r.="<th style=\"text-align:right\">" . _('prix') . "</th>";
1674 $r.="<th style=\"text-align:right\">" . _('quantité') . "</th>";
1675
1676
1677 if ($g_parameter->MY_TVA_USE == 'Y') {
1678 $r.="<th style=\"text-align:right\">" . _('tva') . "</th>";
1679 $r.='<th style="text-align:right"> ' . _('Montant TVA') . '</th>';
1680 $r.='<th style="text-align:right">' . _('Montant HTVA') . '</th>';
1681 $r.='<th style="text-align:right">' . _('Montant TVAC') . '</th>';
1682 } else {
1683 $r.='<th style="text-align:right">' . _('Montant') . '</th>';
1684 }
1685
1686 /* if we use the AC */
1687 if ($g_parameter->MY_ANALYTIC!='nu')
1688 {
1689 $anc=new Anc_Plan($this->db);
1690 $a_anc=$anc->get_list();
1691 $x=count($a_anc);
1692 /* set the width of the col */
1693 $r.='<th colspan="'.$x.'">'._('Compt. Analytique').'</th>';
1694
1695 /* add hidden variables pa[] to hold the value of pa_id */
1696 $r.=Anc_Plan::hidden($a_anc);
1697 }
1698
1699 $r.='</tr>';
1700 $tot_amount=0.0;
1701 $tot_tva=0.0;
1702 //--
1703 // For each item
1704 //--
1705 for ($i = 0; $i < $nb_item;$i++)
1706 {
1707 $tot_row=0;
1708 if ( noalyss_strlentrim(${"e_march".$i}) == 0 ) continue;
1709
1710 /* retrieve information for card */
1711 $fiche=new Fiche($this->db);
1712 $fiche->get_by_qcode(${"e_march".$i});
1713 if ( $g_parameter->MY_UPDLAB=='Y')
1714 $fiche_name=h(${"e_march".$i."_label"});
1715 else
1716 $fiche_name=$fiche->strAttribut (ATTR_DEF_NAME);
1717 $amount=bcmul(${"e_march".$i."_price"},${'e_quant'.$i});
1718 if ( $g_parameter->MY_TVA_USE=='Y')
1719 {
1720 $idx_tva=${"e_march".$i."_tva_id"};
1721 $oTva=Acc_Tva::build($this->db,$idx_tva);
1722
1723 $oTva->load();
1724 $op=new Acc_Compute();
1725
1726 $op->set_parameter("amount",$amount);
1727 $op->set_parameter('amount_vat_rate',$oTva->get_parameter('rate'));
1728 $op->compute_vat();
1729 $tva_computed=$op->get_parameter('amount_vat');
1730 //----- if tva_amount is not given we compute the vat ----
1731 if ( strlen (trim (${'e_march'.$i.'_tva_amount'})) == 0)
1732 {
1733 $tva_item=$op->get_parameter('amount_vat');
1734 }
1735 else
1736 $tva_item=round(${'e_march'.$i.'_tva_amount'},2);
1737
1738 if (isset($tva[$idx_tva] ) )
1739 $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]);
1740 else
1741 $tva[$idx_tva]=$tva_item;
1742
1743
1744
1745 }
1746 $tot_amount=round(bcadd($tot_amount,$amount),2);
1747 $tot_row=round(bcadd($tot_row,$amount),2);
1748 $r.='<tr>';
1749 $r.='<td>';
1750 $r.=${"e_march".$i};
1751 $r.='</td>';
1752 $r.='<TD style="border-bottom:1px dotted grey;">';
1753 $r.=$fiche_name;
1754 $r.='</td>';
1755 $r.='<td class="num">';
1756 $r.=nbm(${"e_march".$i."_price"},4);
1757 $r.='</td>';
1758 $r.='<td class="num">';
1759 $r.=nbm(${"e_quant".$i},4);
1760 $r.='</td>';
1761 $both_side=0;
1762 if ($g_parameter->MY_TVA_USE == 'Y')
1763 {
1764 $r.='<td class="num">';
1765 $r.=$oTva->get_parameter('label');
1766 $both_side=$oTva->get_parameter("both_side");
1767 if ( $both_side == 0) {
1768 $tot_row=bcadd($tot_row,$tva_item);
1769 $tot_tva=round(bcadd($tva_item,$tot_tva),2);
1770 }
1771 $r.='</td>';
1772 /* warning if tva_computed and given are not the
1773 same */
1774 $css_void_tva=($both_side == 1)?'style="text-decoration:line-through"':'';
1775 if ( bcsub($tva_item,$tva_computed) != 0 && ! ($tva_item == 0 && $both_side == 1))
1776 {
1777
1778 $r.='<td style="background-color:red" class="num" '.$css_void_tva.'>';
1780 $r.='<a href="#" class="error" style="display:inline" title="'. _("Attention Différence entre TVA calculée et donnée").'">'
1781 .nbm($tva_item).'<a>';
1782 }
1783 else{
1784 $r.='<td class="num" '.$css_void_tva.'>';
1785 $r.=nbm($tva_item);
1786 }
1787 $r.='</td>';
1788 $r.='<td class="num"> ';
1789 $r.=nbm(round($amount,2));
1790 $r.='</td>';
1791 }
1792 $r.='<td class="num">';
1793 $r.=nbm(round($tot_row,2));
1794 $r.='</td>';
1795 // encode the pa
1796 if ( $g_parameter->MY_ANALYTIC!='nu'
1797 && $g_parameter->match_analytic($fiche->strAttribut(ATTR_DEF_ACCOUNT))==TRUE
1798 ) // use of AA
1799 {
1800 // show form
1801 $anc_op=new Anc_Operation($this->db);
1802 $null=($g_parameter->MY_ANALYTIC=='op')?1:0;
1803 $r.='<td>';
1804 $p_mode=($p_summary==false)?1:0;
1805 $p_array['pa_id']=$a_anc;
1806 /* op is the operation it contains either a sequence or a jrnx.j_id */
1807 $r.=HtmlInput::hidden('op[]=',$i);
1808 $r.=$anc_op->display_form_plan($p_array,$null,$p_mode,$i,round($amount,2));
1809 $r.='</td>';
1810 }
1811
1812
1813 $r.='</tr>';
1814
1815 }
1816 // Add the sum
1817 $decalage=($g_parameter->MY_TVA_USE == 'Y')?'<td></td><td></td><td></td><td></td>':'<td></td>';
1818 $tot = round(bcadd($tot_amount, $tot_tva), 2);
1819 $str_tot=_('Totaux');
1820 $tot_eur=round(bcdiv($tot, $p_currency_rate),2);
1821
1822 // Get currency code
1823 $default_currency=new Acc_Currency($this->db,0);
1824 $str_code=$default_currency->get_code();
1825 if ( $p_currency_code != 0 ) {
1826 $acc_currency=new Acc_Currency($this->db);
1827 $acc_currency->set_id($p_currency_code);
1828 $str_code=$acc_currency->get_code();
1829 }
1830 // Format amount
1832 $tot_tva=nbm($tot_tva);
1833 $tot_str=nbm($tot);
1834
1835 if ( $g_parameter->MY_TVA_USE == 'Y') {
1836 $r.=<<<EOF
1837<tr class="highlight">
1838 {$decalage}
1839 <td>
1840 {$str_tot} {$str_code}
1841 </td>
1842 <td class="num">
1843 {$tot_tva}
1844 </td>
1845 <td class="num">
1846 {$tot_amount}
1847 </td>
1848 <td class="num">
1849 {$tot_str} {$str_code}
1850 </td>
1851</tr>
1852EOF;
1853 if ($p_currency_code !=0) {
1854 $sql_currency=new Currency_SQL($this->cn,0);
1855 $iso_code=$sql_currency->getp("cr_code_iso");
1856 $rate=_("Taux ");
1857 $r.=<<<EOF
1858 <tr class="highlight">
1859 {$decalage}
1860 <td>
1861
1862 </td>
1863 <td class="num">
1864
1865 </td>
1866 <td class="num">
1867 {$rate} {$p_currency_rate}
1868 </td>
1869 <td class="num">
1870 {$tot_eur} {$iso_code}
1871 </td>
1872 </tr>
1873 EOF;
1874 } // if ($p_currency_code !=0
1875 }else // if $g_parameter->MY_TVA_USE=='Y'
1876 {
1877 $sql_currency=new Currency_SQL($this->cn,0);
1878 $iso_code=$sql_currency->getp("cr_code_iso");
1879 $r.=<<<EOF
1880<tr class="highlight">
1881 {$decalage}
1882 <td>
1883 {$str_tot} {$str_code}
1884 </td>
1885 <td class="num">
1886 {$tot_amount}
1887 </td>
1888 <td class="num">
1889
1890 </td>
1891 <td class="num">
1892 {$tot_str} {$str_code}
1893 </td>
1894</tr>
1895<tr class="highlight">
1896 {$decalage}
1897 <td>
1898 </td>
1899 <td>
1900 </td>
1901 <td>
1902 </td>
1903 <td class="num">
1904 {$tot_str} {$iso_code}
1905 </td>
1906</tr>
1907EOF;
1908
1909 }
1910 $r.='</table>';
1911 $r.='</p>';
1912 if ( $g_parameter->MY_ANALYTIC!='nu' && !$p_summary) // use of AA
1913 $r.='<input type="button" class="button" value="'._('Vérifiez imputation analytique').'" onClick="verify_ca(\'\');">';
1914
1915 $r.='<div id="total_div_id" >';
1916 $r.='<h2>Totaux</h2>';
1917 $other_tax_label="";
1919 if ( $this->has_other_tax() && isset($p_array['other_tax'])) {
1920 $other_tax_label=_("Autre taxe");
1921 $other_tax_amount=htmlspecialchars($p_array['other_tax_amount']);
1922 }
1923 /* use VAT */
1924 if ($g_parameter->MY_TVA_USE == 'Y') {
1925 $r.='<table>';
1926 $r.='<tr><td>Total HTVA</td>';
1927 $r.=td(hb($tot_amount ),'class="num"');
1928 foreach ($tva as $i => $value) {
1929 $oTva=Acc_Tva::build($this->db,$i);
1930 $oTva->load();
1931
1932 $r.='<tr><td> TVA ' . $oTva->get_parameter('label').'</td>';
1933 $r.=td(hb(nbm($tva[$i])),'class="num"');
1934 }
1935 $r.='<tr>'.td(_('Total TVA')).td(hb($tot_tva),'class="num"');
1936 if ( ! empty($other_tax_label) ) {
1937 $r.='<tr>'.td($other_tax_label).td(hb($other_tax_amount),'class="num"');
1938 }
1939 if ( $other_tax_amount!="") {$tot=bcadd($tot,$other_tax_amount,2);}
1940 $r.='<tr>'.td(_('Total TVAC')).td(hb($tot),'class="num"');
1941 $r.='</table>';
1942 } else {
1943 if ( ! empty($other_tax_label) ) {
1944 $r.='<tr>'.td($other_tax_label).td(hb($other_tax_amount),'class="num"');
1945 }
1946 if ( $other_tax_amount!="") {$tot=bcadd($tot,$other_tax_amount,2);}
1947 $r.='<br>Total '.hb($tot);
1948 }
1949 $r.='</div>';
1950 /* Add hidden */
1951 $r.=HtmlInput::hidden('e_client',$e_client);
1952 $r.=HtmlInput::hidden('nb_item',$nb_item);
1953 $r.=HtmlInput::hidden('p_jrn',$p_jrn);
1954 $r.=HtmlInput::hidden('jrn_note_input',h($p_array['jrn_note_input']));
1955
1956 if ( isset($period))
1957 $r.=HtmlInput::hidden('period',$period);
1958 $r.=HtmlInput::hidden('e_comm',$e_comm);
1959 $r.=HtmlInput::hidden('e_date',$e_date);
1960 $r.=HtmlInput::hidden('e_ech',$e_ech);
1961 $r.=HtmlInput::hidden('jrn_type',$jrn_type);
1962 $r.=HtmlInput::hidden('e_pj',$e_pj);
1963 $r.=HtmlInput::hidden('e_pj_suggest',$e_pj_suggest);
1964 $r.=HtmlInput::post_to_hidden(['p_currency_rate','p_currency_code']);
1965 if ( $this->has_other_tax() && isset($p_array["other_tax"])) {
1966 $r.=HtmlInput::hidden("other_tax",$p_array['other_tax']);
1967 $r.=HtmlInput::hidden("other_tax_amount",$p_array['other_tax_amount']);
1968 }
1969 $mt=microtime(true);
1970 $r.=HtmlInput::hidden('mt',$mt);
1971
1972 $e_mp=(isset($e_mp))?$e_mp:0;
1973 $r.=HtmlInput::hidden('e_mp',$e_mp);
1974 /* Paid by */
1975 /* if the paymethod is not 0 and if a quick code is given */
1976
1977
1978 for ($i=0;$i < $nb_item;$i++)
1979 {
1980 $r.=HtmlInput::hidden("e_march".$i,${"e_march".$i});
1981 if (isset (${"e_march".$i."_label"})) $r.=HtmlInput::hidden("e_march".$i."_label",${"e_march".$i."_label"});
1982 $r.=HtmlInput::hidden("e_march".$i."_price",${"e_march".$i."_price"});
1983 if ( $g_parameter->MY_TVA_USE=='Y' )
1984 {
1985 $r.=HtmlInput::hidden("e_march".$i."_tva_id",${"e_march".$i."_tva_id"});
1986 $r.=HtmlInput::hidden('e_march'.$i.'_tva_amount', ${'e_march'.$i.'_tva_amount'});
1987 }
1988 $r.=HtmlInput::hidden("e_quant".$i,${"e_quant".$i});
1989
1990 }
1991
1992 /**
1993 * Payment method
1994 */
1995 if ( $e_mp!=0 && strlen (trim (${'e_mp_qcode_'.$e_mp})) != 0 )
1996 {
1997 $r.="<p>";
1998 $r.=HtmlInput::hidden('e_mp_qcode_'.$e_mp,${'e_mp_qcode_'.$e_mp});
1999 $r.=HtmlInput::hidden('acompte',$acompte);
2000 $r.=HtmlInput::hidden('e_comm_paiement',$e_comm_paiement);
2001 $r.=HtmlInput::hidden('mp_date',$mp_date);
2002 /* needed for generating a invoice */
2003 $r.=HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp});
2004 $fname = new Fiche($this->db);
2005 $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp});
2006 $detail_payment="";
2007 // payment operation
2008 if ($this->payment_operation != 1) {
2009 $pay_internal=$this->db->get_value("select jr_internal from jrn where jr_id=$1",
2010 [$this->payment_operation]);
2011 $detail_payment=HtmlInput::detail_op($this->payment_operation,$pay_internal);
2012 }
2013 $r.='<h2>' . _("Payé par")." " . ${'e_mp_qcode_' . $e_mp} .
2014 " " . $fname->getName() .$detail_payment. '</h2> ' ;
2015 $r.='<p class="decale">' . _('Déduction acompte ') . h($acompte) . '</p>' .
2016 _('Libellé :') . h($e_comm_paiement) ;
2017 $r.='<br>';
2018 $r.='<br>';
2019
2020 $r.="</p>";
2021 }
2022 // check for upload piece
2023 /*
2024 * warning if the amount is positive and expecting a negative one
2025 */
2026 $negative=$this->display_negative_warning($tot);
2027 if ( $negative != "") {
2028 $r.=span($negative,'class="warning" ');
2029 }
2030 return $r;
2031 }
2032
2033 /*!\brief the function extra info allows to
2034 * - add a attachment
2035 * - generate an invoice
2036 * - insert extra info
2037 *\return html string
2038 */
2039 public function extra_info()
2040 {
2041 $r="";
2042 $r = '<div id="facturation_div_id" style="height:185px;height:10rem">';
2043 $r.='<p class="decale">';
2044 // check for upload piece
2045 $file=new IFile();
2046 $file->setAlertOnSize(true);
2047 $file->table=0;
2048 $r.=_("Ajoutez une pièce justificative ");
2049 $r.=$file->input("pj","");
2050
2051 if ( $this->db->count_sql("select md_id,md_name from document_modele where md_affect='ACH'") > 0 )
2052 {
2053
2054 $r.=_('ou générer un document').' <input type="checkbox" name="gen_invoice" >';
2055 // We propose to generate the fee note
2056 $doc_gen=new ISelect();
2057 $doc_gen->name="gen_doc";
2058 $doc_gen->value=$this->db->make_array(
2059 "select md_id,md_name ".
2060 " from document_modele where md_affect='ACH' order by 2");
2061 $r.=$doc_gen->input().'<br>';
2062 }
2063 $r.='<br>';
2064 $obj=new IText();
2065 $r.=_('Numero de bon de commande : ').$obj->input('bon_comm').'<br>';
2066 $r.=_('Autre information : ').$obj->input('other_info').'<br>';
2067 $r.='</p>';
2068 $r.='</div>';
2069 return $r;
2070 }
2071
2072
2073 /**
2074 * @brief update the payment
2075 * @todo to remove, obsolete
2076 * @deprecated
2077 */
2078 function show_unpaid_deprecated()
2079 {
2080 // Show list of unpaid sell
2081 // Date - date of payment - Customer - amount
2082 // Nav. bar
2083 $step=$_SESSION[SESSION_KEY.'g_pagesize'];
2084 $page=(isset($_GET['offset']))?$_GET['page']:1;
2085 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
2086
2087
2089 list($max_line,$list)=$this->list_operation($sql,null,$offset,1);
2090 $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$this->id ;
2091 list($max_line2,$list2)=$this->list_operation($sql,null,$offset,1);
2092
2093 // Get the max line
2094 $m=($max_line2>$max_line)?$max_line2:$max_line;
2095 $bar2=navigation_bar($offset,$m,$step,$page);
2096
2097 echo $bar2;
2098 echo '<h2 class="info"> '._('Echeance dépassée').' </h2>';
2099 echo $list;
2100 echo '<h2 class="info"> '._('Non Payée').' </h2>';
2101 echo $list2;
2102 echo $bar2;
2103 // Add hidden parameter
2104 $hid=new IHidden();
2105
2106 echo '<hr>';
2107
2108 if ( $m != 0 )
2109 echo HtmlInput::submit('paid',_('Mise à jour paiement'));
2110
2111
2112 }
2113 /**
2114 * Retrieve data from the view v_detail_purchase
2115 * @note $g_user connected user
2116 * @param $p_from jrn.jr_tech_per from
2117 * @param $p_end jrn.jr_tech_per to
2118 * @return handle to database result
2119 */
2120 function get_detail_purchase($p_from,$p_end,$p_filter_operation='all')
2121 {
2122 global $g_user;
2123 // Journal valide
2124 if ( $this->id == 0 ) die (__FILE__.":".__LINE__." Journal invalide");
2125 switch ( $p_filter_operation)
2126 {
2127 case 'all':
2128 $sql_filter="";
2129 break;
2130 case 'paid':
2131 $sql_filter=" and (jr_date_paid is not null or jr_rapt ='paid' ) ";
2132 break;
2133 case 'unpaid':
2134 $sql_filter=" and (jr_date_paid is null and coalesce(jr_rapt,'x') <> 'paid' ) ";
2135 break;
2136 default:
2137 throw new Exception(_("Filtre invalide",5));
2138
2139 }
2140
2141 // get the data from the view
2142 $sql = "select *
2143 from v_detail_purchase
2144 where
2145 jr_def_id = $1
2146 and jr_date >= (select p_start from parm_periode where p_id = $2)
2147 {$sql_filter}
2148 and jr_date <= (select p_end from parm_periode where p_id = $3) "
2149 .' order by jr_date,substring(jr_pj_number,\'[0-9]+$\')::numeric asc ';
2150 $ret = $this->db->exec_sql($sql, array($this->id,$p_from, $p_end));
2151 return $ret;
2152 }
2153 /**
2154 * @brief compute an array with the heading cells for the
2155 * details, used for the export in CSV
2156 * @return array
2157 */
2158 static function heading_detail_purchase()
2159 {
2160 $array['jr_id'] = _('Numéro opération');
2161 $array['jr_date'] = _('Date');
2162 $array['jr_date_paid'] = _('Date paiement');
2163 $array['jr_ech'] = _('Date échéance');
2164 $array['jr_tech_per'] = _('Période');
2165 $array['jr_comment'] = _('Libellé');
2166 $array['jr_pj_number'] = _('Pièce');
2167 $array['jr_internal'] = _('Interne');
2168 $array['jr_def_id'] = _('Code journal');
2169 $array['j_poste'] = _('Poste');
2170 $array['j_text'] = _('Commentaire');
2171 $array['j_qcode'] = _('Code Item');
2172 $array['jr_rapt'] = _('Payé');
2173 $array['item_card'] = _('N° fiche');
2174 $array['item_name'] = _('Nom fiche');
2175 $array['qp_supplier'] = _('N° fiche fournisseur');
2176 $array['tiers_name'] = _('Nom fournisseur');
2177 $array['quick_code'] = _('Code fournisseur');
2178 $array['tva_label'] = _('Nom TVA');
2179 $array['tva_comment'] = _('Commentaire TVA');
2180 $array['tva_both_side'] = _('TVA annulée');
2181 $array['vat_sided'] = _('TVA Non Payé');
2182 $array['vat_code'] = _('Code TVA');
2183 $array['vat'] = _('Montant TVA');
2184 $array['price'] = _('Total HTVA');
2185 $array['quantity'] = _('quantité');
2186 $array['price_per_unit'] = _('PU');
2187 $array['non_ded_amount'] = _('Montant ND');
2188 $array['non_ded_tva'] = _('Montant TVA ND');
2189 $array['non_ded_tva_recup'] = _('TVA récup.');
2190 $array['htva'] = _('HTVA Opération');
2191 $array['tot_vat'] = _('TVA Opération');
2192 $array['tot_tva_np'] = _('TVA NP opération');
2193 $array['other_tax'] = _("Autre taxe");
2194 $array['oc_amount'] = _('Mont. Devise');
2195 $array['oc_vat_amount'] = _('Mont. TVA Devise');
2196 $array['cr_code_iso'] = _('Devise');
2197
2198 return $array;
2199 }
2200
2201
2202}
2203
2204
2205
2206
2207
isNumber($p_int)
hb($p_string)
Definition ac_common.php:53
span($p_string, $p_extra='')
Definition ac_common.php:43
isDate($p_date)
noalyss_strlentrim($p_string)
tr($p_string, $p_extra='')
Definition ac_common.php:88
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
global $g_parameter
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$op
h( $row[ 'oa_description'])
$jr_id
$op jr_id
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo
catch(Exception $e) $tva_rate
for($i=0; $i< count($plan); $i++)( $j==0) $a_poste
$input_from cn
_("actif, passif,charge,...")
$_GET['qcode']
Manage the account from the table jrn, jrnx or tmp_pcmn.
this class aims to compute different amount
compute_nd()
Compute the no deductible part of the amount, it reduce also the vat.
display currency , convert to euro , and save them if used.
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
Handle the ledger of purchase,.
insert($p_array=null)
insert into the database, it calls first the verify function change the value of this->jr_id and this...
insert_no_deductible(Acc_Compute $p_nd_amount, Fiche $p_fiche, $p_tva_both, &$p_tot_debit, Acc_Operation $p_acc_operation, $p_group, $idx)
Insert into JRNX the No Deductible amount and into Analytic Accountancy for the ND VAT.
__construct($p_cn, $p_init)
construct
input($p_array=null, $p_readonly=0)
display the form for entering data for invoice
compute_no_deductible(Acc_Compute $p_nd_amount, Fiche $p_fiche)
Compute the ND amount thanks the attribute of the concerned card.
verify_operation($p_array)
verify that the data are correct before inserting or confirming
confirm($p_array, $p_summary=false)
show the summary of the operation and propose to save it
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.
CurrencyInput($p_currency_code, $p_currency_rate, $p_eur_amount)
Create a select from value for currency and add javascript to update $p_currency_rate and $p_eur_amou...
$nb
!< type of the ledger ACH ODS FIN VEN or GL
warn_manual_receipt($p_array)
warn if the suggested receipt and receipt are different , it means that the user tried to number hims...
inc_seq_pj()
increment the sequence for the pj
select_ledger($p_type="ALL", $p_access=3, $enable=TRUE)
Show a select list of the ledgers you can access in writing, reading or simply accessing.
get_name()
Return the name of a ledger.
display_negative_warning($p_amount)
If the amount is positive and the ledger expects a negative amount, il will return the saved warning.
compute_internal_code($p_grpt)
compute the internal code of the saved operation and set the $this->jr_internal to the computed value
input_additional_tax()
form : display additional tax available for this ledger and value, set 2 values : checkbox if tax app...
check_currency($p_qcode_payment, $p_currency_id)
When we write a record for the payment at the same time as a sale or a purchase, to have a bank saldo...
$row
!< database connextion
find_label($p_value)
Retrieve the label of an accounting.
create_document($internal, $p_array)
create the invoice and saved it as attachment to the operation,
is_closed($p_periode)
check if the current ledger is closed
has_other_tax()
returns true if the ledger has an additional tax
add_card($p_filter, $p_id_update)
Return a button to create new card, depending of the ledger.
update_internal_code($p_internal)
check_payment($e_mp, $e_mp_qcode)
check if the payment method is valid
$db
!< jrn_def.jrn_def_id
get_last_date()
get the date of the last operation
check_periode()
Check if a Dossier is using the check on the periode, if true than the user has to enter the date and...
check_strict()
Check if a Dossier is using the strict mode or not.
guess_pj()
guess what the next pj should be
get_id($p_internal)
retrieve the jr_id thanks the internal code, do not change anything to the current object
check_currency_setting($p_currency_code)
Check that the currency code does exist and the setting of the folder is correct.
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
insert_jrnx()
Insert into the table Jrn The needed data are :
Manage the table parm_code which contains the custom parameter for the module accountancy.
Handle the table payment_method.
new class for managing the reconciliation it must be used instead of the function InsertRapt,...
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
Concerns the Analytic plan (table plan_analytique)
static hidden($p_array)
return an HTML string containing hidden input type to hold the differant PA_ID
abstract of the table public.currency
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
strAttribut($p_ad_id, $p_return=1)
empty_attribute($p_attr)
check if an attribute is empty
static ledger_add_item($p_ledger)
Build a HTML string for adding multiple rows.
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Html Input for uploading file, must be in a form with enctype="multipart/form-data".
Html Input.
This class handles only the numeric input, the input will call a javascript to change comma to period...
Generate the form for the periode Data Members.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Html Input.
let you choose a TVA in a popup
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
ORM of the table public.jrn_tax.
mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and lette...
ORM abstract of the table public.operation_currency.
manage the predefined operation, link to the table op_def and op_def_detail
static insert_goods(&$p_cn, $p_array)
Insert into stock_goods from ACH and VEN.
$check_periode
$def
show a form for quick_writing
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
$other_tax_amount
Definition compute.php:88
const ATTR_DEF_ADRESS
Definition constant.php:223
const OPEN
Definition constant.php:201
const ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP
Definition constant.php:236
const ATTR_DEF_ACCOUNT_ND_TVA_ND
Definition constant.php:242
const ATTR_DEF_NAME
Definition constant.php:216
const SQL_LIST_UNPAID_INVOICE
Definition constant.php:329
const ATTR_DEF_ACCOUNT_ND
Definition constant.php:244
const ATTR_DEF_ACCOUNT_ND_TVA
Definition constant.php:241
const ATTR_DEF_CP
Definition constant.php:224
const ATTR_DEF_TVA
Definition constant.php:221
const SQL_LIST_UNPAID_INVOICE_DATE_LIMIT
Definition constant.php:333
const ATTR_DEF_ACCOUNT_ND_PERSO
Definition constant.php:243
const ATTR_DEF_DEP_PRIV
Definition constant.php:233
const ATTR_DEF_TVA_NON_DEDUCTIBLE
Definition constant.php:235
const ATTR_DEF_CITY
Definition constant.php:229
const EXC_BALANCE
Definition constant.php:349
const ATTR_DEF_DEPENSE_NON_DEDUCTIBLE
Definition constant.php:234
const ATTR_DEF_QUICKCODE
Definition constant.php:237
const ATTR_DEF_ACCOUNT
Definition constant.php:215
const FICADD
const UPDRECEIPT
$jrn_type[]
$_POST['ac']
Definition do.php:312
$oPeriode
Definition do.php:156
$SecUser db
create_script($p_string)
create the HTML for adding the script tags around of the script
$str_code
$str_file
$sql_filter
Definition preod.inc.php:43
$date_limit
check_parameter($p_array, $p_needed)
Check that all the index are in the array, used by function to check if the array contains the needed...
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)