27 require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
28 require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
39 parent::__construct($p_cn, $p_init);
40 $this->ledger_type =
'VEN';
53 throw new Exception (
"Array empty");
63 if (isset($mt) && $this->
db->count_sql(
'select jr_mt from jrn where jr_mt=$1', array($mt)) != 0)
64 throw new Exception(_(
'Double Encodage'), 5);
68 throw new Exception(_(
'Accès interdit'), 20);
71 if (strlen(trim($e_client)) == 0)
72 throw new Exception(_(
'Vous n\'avez pas donné de client'), 11);
75 if (
isDate($e_date) ==
null) {
76 throw new Exception(_(
'Date invalide'), 2);
88 throw new Exception(_(
'Date et periode ne correspondent pas'), 6);
92 $tperiode =
$per->find_periode($e_date);
97 throw new Exception(_(
'Periode fermee'), 6);
104 if ($last_date !=
null &&
cmpDate($e_date, $last_date) < 0)
105 throw new Exception(_(
'Vous utilisez le mode strict la dernière operation est date du ')
106 . $last_date . _(
' vous ne pouvez pas encoder à une date antérieure'), 13);
111 $fiche->get_by_qcode($e_client);
113 throw new Exception(_(
'La fiche ') . $e_client . _(
'n\'a pas de poste comptable'), 8);
118 if (strpos($sposte,
',') != 0) {
119 $array = explode(
',', $sposte);
122 $poste_val = $sposte;
128 if (
$poste->load() ==
false) {
129 throw new Exception(_(
'Pour la fiche ') . $e_client . _(
' le poste comptable [') .
$poste->id . _(
'] n\'existe pas'), 9);
134 $fiche->get_by_qcode($e_client,
'deb');
136 throw new Exception(_(
'La fiche ') . $e_client . _(
'n\'est pas accessible à ce journal'), 10);
143 for (
$i = 0;
$i < $nb_item;
$i++) {
144 if (! isset (${
'e_march' .
$i}) || strlen(trim(${
'e_march' .
$i})) == 0)
147 if (
isNumber(${
'e_march' .
$i .
'_price'}) == 0)
148 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un montant invalide [') . ${
'e_march' .
$i} .
']', 6);
150 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a une quantité invalide [') . ${
'e_quant' .
$i} .
']', 7);
153 $fiche->get_by_qcode(${
'e_march' .
$i});
155 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'n\'a pas de poste comptable'), 8);
159 if (
isNumber(${
'e_march' .
$i .
'_tva_id'}) == 0)
160 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un code tva invalide') .
' [' . ${
'e_march' .
$i .
'_tva_id'} .
']', 13);
162 $tva_rate->set_parameter(
'id', ${
'e_march' .
$i .
'_tva_id'});
164 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un code tva invalide') .
' [' . ${
'e_march' .
$i .
'_tva_id'} .
']', 13);
173 $this->
db->get_value(
'select count(*) from tmp_pcmn where pcm_val=$1', array(
$a_poste[1])) == 0)
174 throw new Exception(_(
" La TVA " .
$tva_rate->tva_label .
" utilise des postes comptables inexistants"));
180 if (strpos($sposte,
',') != 0) {
181 $array = explode(
',', $sposte);
184 $poste_val = $sposte;
187 if (
$poste->load() ==
false) {
188 throw new Exception(_(
'Pour la fiche ') . ${
'e_march' .
$i} . _(
' le poste comptable [') .
$poste->id . _(
'n\'existe pas'), 9);
192 $fiche->get_by_qcode(${
'e_march' .
$i});
194 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'n\'est pas accessible à ce journal'), 10);
196 if ( ${
"e_quant".$i} != 0 && trim(${
"e_quant".$i}) !=
"" ) {
$nb++;}
200 throw new Exception(_(
'Il n\'y a aucune marchandise'), 12);
217 if ( isset ($mp_date) && trim ($mp_date) !=
"" &&
isDate($mp_date) ==
null) {
218 throw new Exception(_(
'Date de paiement invalide'),13);
223 if ( isset ($e_ech) && trim ($e_ech)!=
"" &&
isDate($e_ech) ==
null )
225 throw new Exception(_(
'Date échéance invalide'),14);
229 if (
isNumber($p_currency_rate) == 0 || $p_currency_rate <=0 ) {
230 throw new Exception(_(
'Taux devise invalide'),15);
249 $group = $this->
db->get_next_seq(
"s_oa_group");
250 $seq = $this->
db->get_next_seq(
's_grpt');
253 $this->
internal = $internal;
261 $tperiode =
$oPeriode->find_periode($e_date);
264 $cust->get_by_qcode($e_client);
269 if (strpos($sposte,
',') != 0) {
270 $array = explode(
',', $sposte);
288 for (
$i = 0;
$i < $nb_item;
$i++) {
290 if ( empty(${
'e_march'.$i}) || empty(${
'e_quant'.$i}) )
continue;
294 $fiche->get_by_qcode(${
"e_march" .
$i});
295 $amount_currency = bcmul(${
'e_march' .
$i .
'_price'}, ${
'e_quant' .
$i});
298 $amount=bcdiv($amount_currency,$p_currency_rate);
302 if ( DEBUGNOALYSS > 1 ) { echo __LINE__.
" tot_amount $tot_amount<br>";}
304 $acc_operation->date = $e_date;
308 if (strpos($sposte,
',') != 0) {
309 $array = explode(
',', $sposte);
312 $poste_val = $sposte;
315 $acc_operation->poste = $poste_val;
316 $acc_operation->amount =
$amount;
317 $acc_operation->grpt =
$seq;
318 $acc_operation->jrn =
$p_jrn;
319 $acc_operation->type =
'c';
320 $acc_operation->periode = $tperiode;
323 $acc_operation->desc=strip_tags(${
"e_march".$i.
"_label"});
327 $acc_operation->desc=
null;
330 $acc_operation->qcode = ${
"e_march" .
$i};
333 $tot_debit=round(bcadd($tot_debit, abs(
$amount)),2);
336 $j_id = $acc_operation->insert_jrnx();
341 $idx_tva = ${
'e_march' .
$i .
'_tva_id'};
342 $tva_item_currency = ${
'e_march' .
$i .
'_tva_amount'};
343 $oTva->set_parameter(
"id", $idx_tva);
346 if (trim($tva_item_currency) ==
'' || ${
'e_march'.$i.
'_tva_amount'} == 0) {
350 $tva_item_currency = bcmul(
$amount,
$l->get_parameter(
'rate'));
351 $tva_item=round($tva_item_currency,2);
353 $tva_item=bcdiv($tva_item_currency,$p_currency_rate);
354 $tva_item=round($tva_item,2);
355 if (isset($tva[$idx_tva]))
357 $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]);
358 $tva[$idx_tva]=round($tva[$idx_tva],2);
362 $tva[$idx_tva]=$tva_item;
364 if ($oTva->get_parameter(
"both_side") == 0) {
365 $tot_tva = bcadd($tva_item, $tot_tva);
366 $tot_tva = round($tot_tva, 2);
369 $tva_item_currency = 0;
372 $tot_debit=round(bcadd($tot_debit, abs($n_both)),2);
381 $nNeg = (${
"e_quant" .
$i} < 0) ? -1 : 1;
387 $dir=(${
'e_quant'.$i} < 0 ) ?
'd':
'c';
395 $op->set_currency_rate($p_currency_rate);
396 $op->oa_group = $group;
398 $op->oa_date = $e_date;
403 if (empty( ${
'e_march' .
$i .
'_price'} ) ) ${
'e_march' .
$i .
'_price'} = 0;
404 if (empty( ${
'e_march' .
$i } ) ) ${
'e_march' .
$i } = 0;
405 if (empty( ${
'e_quant' .
$i } ) ) ${
'e_quant' .
$i } = 0;
407 $price_euro=bcdiv(${
'e_march'.$i.
'_price'}, $p_currency_rate);
411 $r = $this->
db->exec_sql(
"select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)", array(
null,
423 $r = $this->
db->exec_sql(
"select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) ", array(
null,
439 $operation_currency->oc_amount=$amount_currency;
440 $operation_currency->oc_vat_amount=$tva_item_currency;
441 $operation_currency->oc_price_unit=${
'e_march'.$i.
'_price'};
442 $operation_currency->j_id=
$j_id;
443 $operation_currency->insert();
444 $tot_amount_cur=round(bcadd($tot_amount_cur,$amount_currency),2);
445 $tot_amount_cur=round(bcadd($tot_amount_cur,$tva_item_currency),2);
450 $cust_amount = round($cust_amount,2);
451 if ( DEBUGNOALYSS > 1 ) {
452 echo __LINE__.
" cust_amount $cust_amount<br>";
453 echo __LINE__.
" tot_amount $tot_amount<br>";
454 echo __LINE__.
" tot_tva $tot_tva<br>";
459 $acc_operation->date = $e_date;
460 $acc_operation->poste =
$poste;
461 $acc_operation->amount = $cust_amount;
462 $acc_operation->grpt =
$seq;
463 $acc_operation->jrn =
$p_jrn;
464 $acc_operation->type =
'd';
465 $acc_operation->periode = $tperiode;
466 $acc_operation->qcode = ${
"e_client"};
469 $tot_debit=bcadd($tot_debit, $cust_amount);
470 $tot_debit=round($tot_debit, 2);
472 $let_tiers = $acc_operation->insert_jrnx();
476 $operation_currency->oc_amount=$tot_amount_cur;
477 $operation_currency->oc_vat_amount=0;
478 $operation_currency->oc_price_unit=0;
479 $operation_currency->j_id=$let_tiers ;
480 $operation_currency->insert();
488 if ( DEBUGNOALYSS > 1 ) {
493 $oTva->set_parameter(
'id',
$i);
496 $poste_vat = $oTva->get_side(
'c');
500 $acc_operation->date = $e_date;
501 $acc_operation->poste = $poste_vat;
502 $acc_operation->amount =
$value;
503 $acc_operation->grpt =
$seq;
504 $acc_operation->jrn =
$p_jrn;
505 $acc_operation->type =
'c';
506 $acc_operation->periode = $tperiode;
509 $tot_debit=bcadd($tot_debit, abs(
$value));
510 $tot_debit=round($tot_debit, 2);
512 $acc_operation->insert_jrnx();
513 if ( DEBUGNOALYSS > 1 ) {
514 echo __LINE__.
" tot_tva $tot_tva<br>";
518 if ($oTva->get_parameter(
"both_side") == 1) {
519 $poste_vat = $oTva->get_side(
'd');
522 $acc_operation->date = $e_date;
523 $acc_operation->poste = $poste_vat;
524 $acc_operation->amount =
$value;
525 $acc_operation->grpt =
$seq;
526 $acc_operation->jrn =
$p_jrn;
527 $acc_operation->type =
'd';
528 $acc_operation->periode = $tperiode;
529 $acc_operation->insert_jrnx();
530 $tot_debit = bcadd($tot_debit,
$value);
531 $tot_debit = round($tot_debit, 2);
542 if ( DEBUGNOALYSS > 1 ) { echo __LINE__.
" tot_debit ".round($tot_debit,2).
"<br>"; }
544 $acc_operation->date = $e_date;
545 $acc_operation->echeance = $e_ech;
546 $acc_operation->amount = abs(round($tot_debit, 2));
547 $acc_operation->desc = $e_comm;
548 $acc_operation->grpt =
$seq;
549 $acc_operation->jrn =
$p_jrn;
550 $acc_operation->periode = $tperiode;
551 $acc_operation->pj = $e_pj;
552 $acc_operation->mt = $mt;
553 $acc_operation->currency_id=$p_currency_code;
554 $acc_operation->currency_rate=$p_currency_rate;
555 $acc_operation->currency_rate_ref=$currency_rate_ref->get_rate();
557 if ( ! $this->
jr_id=$acc_operation->insert_jrn() ) {
558 throw new Exception (_(
"Erreur de balance"));
561 $this->pj = $acc_operation->set_pj();
565 if (strcmp($e_pj, $e_pj_suggest) == 0 && strlen(trim($e_pj)) != 0) {
569 $this->
db->exec_sql(
"update jrn set jr_internal=$1 where jr_grpt_id = $2" ,[$internal,
$seq]);
573 $this->
db->exec_sql(
'update quant_sold set qs_internal = $1
574 where j_id in (select j_id from jrnx where j_grpt=$2)'
575 , array($internal,
$seq));
578 if (isset($_FILES[
'pj'])) {
579 if (strlen(trim($_FILES[
'pj'][
'name'])) != 0)
580 $this->
db->save_receipt(
$seq);
583 if (isset(
$_POST[
'gen_invoice'])) {
595 $pay_date=($mp_date==
"")?$e_date:$mp_date;
602 $fqcode = ${
'e_mp_qcode_' . $e_mp};
603 $acfiche =
new Fiche($this->
db);
604 $acfiche->get_by_qcode($fqcode);
607 $acseq = $this->
db->get_next_seq(
's_grpt');
608 $acjrn =
new Acc_Ledger($this->
db, $mp->get_parameter(
'ledger_target'));
609 $acinternal = $acjrn->compute_internal_code($acseq);
613 $acc_pay->date = $pay_date;
617 if (strpos($sposte,
',') != 0) {
618 $array = explode(
',', $sposte);
621 $poste_val = $sposte;
624 $acompte_eur=bcdiv(
$acompte, $p_currency_rate);
626 $famount=bcsub($cust_amount,$acompte_eur);
627 $acc_pay->poste = $poste_val;
628 $acc_pay->qcode = $fqcode;
629 $acc_pay->amount = abs(round($famount, 2));
630 $acc_pay->desc =
null;
632 $acc_pay->grpt = $acseq;
633 $acc_pay->jrn = $mp->get_parameter(
'ledger_target');
634 $acc_pay->periode = $tperiode;
635 $acc_pay->type = ($famount >= 0) ?
'd' :
'c';
636 $let_pay=$acc_pay->insert_jrnx();
640 $acc_pay->date = $pay_date;
642 $acc_pay->qcode = $e_client;
643 $acc_pay->amount = abs(round($famount, 2));
644 $acc_pay->desc =
null;
645 $acc_pay->grpt = $acseq;
646 $acc_pay->jrn = $mp->get_parameter(
'ledger_target');
647 $acc_pay->periode = $tperiode;
648 $acc_pay->type = ($famount >= 0) ?
'c' :
'd';
649 $let_other = $acc_pay->insert_jrnx();
653 $operation_currency->oc_amount=bcsub($tot_amount_cur,
$acompte);
654 $operation_currency->oc_vat_amount=0;
655 $operation_currency->oc_price_unit=0;
656 $operation_currency->j_id=$let_other;
657 $operation_currency->insert();
661 $operation_currency->oc_amount=bcsub($tot_amount_cur,
$acompte);
662 $operation_currency->oc_vat_amount=0;
663 $operation_currency->oc_price_unit=0;
664 $operation_currency->j_id=$let_pay;
665 $operation_currency->insert();
668 $acc_pay->currency_id=$p_currency_code;
669 $acc_pay->currency_rate=$p_currency_rate;
670 $acc_pay->currency_rate_ref=$currency_rate_ref->get_rate();
675 $acjrn->grpt_id = $acseq;
676 $acc_pay->desc = (!isset($e_comm_paiement) || strlen(trim($e_comm_paiement)) == 0) ? $e_comm : $e_comm_paiement;
677 $mp_jr_id = $acc_pay->insert_jrn();
678 $acjrn->update_internal_code($acinternal);
680 if ($acjrn->get_type()==
"ODS") {
681 $acc_pay->pj=$acjrn->guess_pj();
684 $r1 = $this->
get_id($internal);
685 $r2 = $this->
get_id($acinternal);
691 $oletter->insert_couple($let_tiers, $let_other);
695 $Res = $this->
db->exec_sql(
"update jrn set jr_rapt='paid' where jr_id=$1", array($r1));
699 $rec->set_jr_id($r1);
712 if (
$prop[
'jrn_def_type'] ==
'FIN') {
713 $ledger->insert_quant_fin($acfiche->id, $mp_jr_id, $cust->id, bcmul($famount, 1),$let_other);
716 }
catch (Exception
$e) {
718 echo
'<span class="error">' .
719 'Erreur dans l\'enregistrement ' .
720 __FILE__ .
':' . __LINE__ .
' ' .
722 echo
$e->getTraceAsString();
724 $this->
db->rollback();
725 throw new Exception (
$e);
755 $client =
new Fiche($this->
db);
756 $client->get_by_qcode($e_client,
true);
758 $client_name = $client->getName() .
764 $lPeriode->p_id = $period;
766 $lPeriode->find_periode($e_date);
770 $r .=
'<div id="summary_op1" >';
773 $jr_id=$this->
db->get_value(
'select jr_id from jrn where jr_internal=$1',array($this->
internal));
776 $r.=_(
'Détail opération ');
779 $r.=sprintf (
'<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>',
786 $r.=
'<td>' . _(
'Numéro Pièce') .
'</td><td>'.
hb($e_pj) .
'</td>';
789 if ( strcmp($this->pj,$e_pj) != 0 )
791 $r.=
'<td>' . _(
'Numéro Pièce') .
'</td><td>'.
hb($this->pj) .
792 '<span class="notice"> '._(
'Attention numéro pièce existante, elle a du être adaptée').
'</span></td>';
794 $r.=
'<td>' . _(
'Numéro Pièce') .
'</td><td>'.
hb($this->pj) .
'</td>';
799 $r.=
'<td> ' . _(
'Date') .
'</td><td> ' .
hb($e_date) .
'</td>';
802 $r.=
'<td>' . _(
'Echeance') .
'</td><td> ' .
hb($e_ech) .
'</td>';
805 $r.=
'<td> ' . _(
'Période Comptable') .
'</td><td> ' .hb(
$date_limit[
'p_start'] .
'-' .
$date_limit[
'p_end']) .
'</td>';
809 $r .=
'<div id="summary_op2">';
812 $r.=
'<td> ' . _(
'Journal') .
'</td><td> ' .
hb($this->
get_name()) .
'</td>';
815 $r.=
'<td> ' . _(
'Libellé') .
'</td><td> ' .
hb($e_comm) .
'</td>';
819 $r.=
'<td> ' . _(
'Client') .
'</td><td> ' .
hb($e_client .
':' . $client_name) .
'</td>';
823 $r.=
'<div style="position:float;clear:both">';
826 $r.=
'<h2>' . _(
'Détail articles vendus') .
'</h2>';
827 $r.=
'<p class="decale">';
828 $r.=
'<table class="result" >';
830 $r.=
"<th>" . _(
'Code') .
"</th>";
831 $r.=
"<th>" . _(
'Dénomination') .
"</th>";
832 $r.=
"<th style=\"text-align:right\">" . _(
'prix') .
"</th>";
833 $r.=
"<th style=\"text-align:right\">" . _(
'quantité') .
"</th>";
837 $r.=
"<th style=\"text-align:right\">" . _(
'tva') .
"</th>";
838 $r.=
'<th style="text-align:right"> ' . _(
'Montant TVA') .
'</th>';
839 $r.=
'<th style="text-align:right">' . _(
'Montant HTVA') .
'</th>';
840 $r.=
'<th style="text-align:right">' . _(
'Montant TVAC') .
'</th>';
842 $r.=
'<th style="text-align:right">' . _(
'Montant') .
'</th>';
847 $a_anc =
$anc->get_list();
850 $r.=
'<th colspan="' . $x .
'">' . _(
'Compt. Analytique') .
'</th>';
858 for (
$i = 0;
$i < $nb_item;
$i++) {
859 if (strlen(trim(${
"e_march" .
$i})) == 0)
864 $fiche->get_by_qcode(${
"e_march" .
$i});
865 if ($g_parameter->MY_UPDLAB ==
'Y')
866 $fiche_name =
h(${
"e_march" .
$i .
"_label"});
871 $idx_tva = ${
"e_march" .
$i .
"_tva_id"};
873 $oTva->set_parameter(
'id', $idx_tva);
877 $amount = bcmul(${
"e_march" .
$i .
"_price"}, ${
'e_quant' .
$i});
880 $op->set_parameter(
'amount_vat_rate', $oTva->get_parameter(
'rate'));
882 $tva_computed =
$op->get_parameter(
'amount_vat');
883 $tva_item = ${
"e_march" .
$i .
"_tva_amount"};
884 if (isset($tva[$idx_tva]))
885 $tva[$idx_tva]=bcadd($tva[$idx_tva],$tva_item,2);
887 $tva[$idx_tva] = $tva_item;
888 $tot_tva = round(bcadd($tva_item, $tot_tva), 2);
894 $r.=${
"e_march" .
$i};
896 $r.=
'<TD style="border-bottom:1px dotted grey;">';
899 $r.=
'<td class="num">';
900 $r.=
nbm(${
"e_march" .
$i .
"_price"},4);
902 $r.=
'<td class="num">';
907 $r.=
'<td class="num">';
908 $r.=$oTva->get_parameter(
'label');
910 $both_side=$oTva->get_parameter(
"both_side");
913 if (bcsub($tva_item, $tva_computed) != 0 && ! ($tva_item == 0 && $both_side == 1)) {
914 $r.=
'<td style="background-color:red" class="num">';
916 $r.=
'<a href="#" class="error" style="display:inline" title="' . _(
"Attention Différence entre TVA calculée et donnée") .
'">'
917 .
nbm($tva_item) .
'<a>';
919 $r.=
'<td class="num">';
923 $r.=
'<td class="num">';
926 $tot_row = bcadd($tva_item,
$amount);
927 $r.=
td(
nbm($tot_row),
'class="num"');
929 $r.=
'<td class="num">';
940 $p_mode = ($p_summary ==
false) ? 1 : 0;
953 $decalage=(
$g_parameter->MY_TVA_USE ==
'Y')?
'<td></td><td></td><td></td><td></td>':
'<td></td>';
955 $tot_eur=round(bcdiv(
$tot, $p_currency_rate),2);
957 $str_tot=_(
'Totaux');
962 if ( $p_currency_code != 0 ) {
964 $acc_currency->set_id($p_currency_code);
969 $tot_tva=
nbm($tot_tva);
973 <
tr class=
"highlight">
989 if ($p_currency_code !=0) {
992 <
tr class=
"highlight">
1001 {$rate} {$p_currency_rate}
1012 <
tr class=
"highlight">
1027 <
tr class=
"highlight">
1035 {$rate} {$p_currency_rate}
1046 $r.=
'<input type="button" class="button" value="' . _(
'Vérifiez Imputation Analytique') .
'" onClick="verify_ca(\'\');">';
1047 $r.=(! $p_summary )?
'<div id="total_div_id" >':
'<div>';
1048 $r.=
'<h2>Totaux</h2>';
1053 $r.=
'<tr><td>Total HTVA</td>';
1056 $oTva->set_parameter(
'id',
$i);
1059 $r.=
'<tr><td> TVA ' . $oTva->get_parameter(
'label').
'</td>';
1062 $r.=
'<tr>'.td(_(
'Total TVA')).td(
hb($tot_tva),
'class="num"');
1063 $r.=
'<tr>'.td(_(
'Total TVAC')).td(
hb(
$tot),
'class="num"');
1066 $r.=
'<br>Total '.hb(
$tot);
1075 $mt = microtime(
true);
1090 $e_mp = (isset($e_mp)) ? $e_mp : 0;
1093 if ( isset(
$repo) ) {
1099 if ($e_mp != 0 && strlen(trim(${
'e_mp_qcode_' . $e_mp})) != 0) {
1107 $fname =
new Fiche($this->
db);
1108 $fname->get_by_qcode(${
'e_mp_qcode_' . $e_mp});
1109 $r.=
'<h2>' .
"Payé par " . ${
'e_mp_qcode_' . $e_mp} .
1110 " le ".${
"mp_date"}.
1111 " " . $fname->getName() .
'</h2> ' .
'<p class="decale">' . _(
'Déduction acompte ') .
h(
$acompte) .
'</p>' .
1112 _(
'Libellé :') .
h($e_comm_paiement) ;
1117 for (
$i = 0;
$i < $nb_item;
$i++) {
1119 if (isset(${
"e_march" .
$i .
"_label"}))
1132 if ( $negative !=
"") {
1133 $r.=
span($negative,
'class="warning" ');
1146 $r =
'<div id="facturation_div_id" style="height:185px;height:10rem">';
1150 $file->setAlertOnSize(
true);
1151 $r.=
'<p class="decale">';
1152 $r.=_(
"Ajoutez une pièce justificative ");
1155 if ($this->
db->count_sql(
"select md_id,md_name from document_modele where md_affect='VEN'") > 0) {
1158 $r.=_(
'ou générer une facture') .
' <input type="checkbox" name="gen_invoice" CHECKED>';
1161 $doc_gen->name =
"gen_doc";
1162 $doc_gen->value = $this->
db->make_array(
1163 "select md_id,md_name " .
1164 " from document_modele where md_affect='VEN'");
1165 $r.=$doc_gen->input() .
'<br>';
1169 $r.=_(
'Numero de bon de commande : ') .
$obj->input(
'bon_comm') .
'<br>';
1170 $r.=_(
'Autre information : ') .
$obj->input(
'other_info') .
'<br>';
1193 $str_add_button_tiers =
"";
1197 $str_add_button_tiers = $this->
add_card(
"deb",
"e_client");
1202 list ($l_date_start, $l_date_end) =
$oPeriode->get_date_limit(
$g_user->get_periode());
1204 $op_date = (!isset($e_date) ) ? $l_date_start : $e_date;
1206 $op_date = (!isset($e_date) ) ?
'' : $e_date;
1208 $e_ech = (isset($e_ech)) ? $e_ech :
"";
1209 $e_comm = (isset($e_comm)) ? $e_comm :
"";
1212 $r.=dossier::hidden();
1213 $f_legend = _(
'Client');
1215 $Echeance =
new IDate();
1216 $Echeance->setReadOnly(
false);
1218 $Echeance->tabindex = 2;
1220 $f_echeance = $Echeance->input(
'e_ech', $e_ech, _(
'Echéance') .
$label);
1221 $Date =
new IDate();
1222 $Date->setReadOnly(
false);
1224 $f_date = $Date->input(
"e_date", $op_date);
1230 $l_user_per =
$g_user->get_periode();
1233 $period =
new IPeriod(
"period");
1236 $period->value =
$def;
1237 $period->type =
OPEN;
1239 $l_form_per = $period->input();
1240 }
catch (Exception
$e) {
1241 if (
$e->getCode() == 1) {
1242 throw new Exception( _(
"Aucune période ouverte") );
1246 $f_periode =
'<td>' . _(
"Période comptable") .
"</td> <td> $label " . $l_form_per .
'</td>';
1251 $add_js =
"update_pj();";
1254 $add_js.=
'get_last_date();';
1256 $add_js.=
'update_name();';
1257 $add_js.=
'update_pay_method();';
1258 $add_js.=
'update_row("sold_item");';
1262 throw new Exception(_(
'Pas de journal disponible'));
1264 $wLedger->javascript =
"onChange='update_predef(\"ven\",\"f\",\"".$_REQUEST[
'ac'].
"\");$add_js'";
1269 $Commentaire =
new IText();
1270 $Commentaire->table = 0;
1271 $Commentaire->setReadOnly(
false);
1272 $Commentaire->size = 60;
1273 $Commentaire->tabindex = 3;
1277 $f_desc = $Commentaire->input(
"e_comm", $e_comm) ;
1291 $pj->value = (isset($e_pj)) ? $e_pj : $default_pj;
1299 $e_client = ( isset($e_client) ) ? $e_client :
"";
1300 $e_client_label =
" ";
1304 if (strlen(trim($e_client)) != 0) {
1305 $fClient =
new Fiche($this->
db);
1306 $fClient->get_by_qcode($e_client);
1307 $e_client_label = $fClient->strAttribut(
ATTR_DEF_NAME) .
' ' .
1315 $W1->name =
"e_client";
1317 $W1->value = $e_client;
1319 $W1->set_dblclick(
"fill_ipopcard(this);");
1320 $W1->set_attribute(
'ipopup',
'ipopcard');
1323 $W1->set_attribute(
'label',
'e_client_label');
1325 $W1->set_attribute(
'typecard',
'deb');
1328 $W1->set_callback(
'filter_card');
1329 $W1->set_function(
'fill_data');
1330 $W1->javascript = sprintf(
' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
1331 $f_client_qcode = $W1->input();
1332 $client_label =
new ISpan();
1333 $client_label->table = 0;
1334 $f_client = $client_label->input(
"e_client_label", $e_client_label);
1335 $f_client_bt = $W1->search();
1340 $p_article = ( isset($nb_item)) ? $nb_item : $this->
get_min_row();
1341 $r.=$Hid->input(
"nb_item", $p_article);
1345 $f_legend_detail = _(
"Détail articles vendus");
1349 for (
$i = 0;
$i < $p_article;
$i++) {
1352 $march = (isset(${
"e_march$i"})) ? ${
"e_march$i"} :
"";
1353 $march_price = (isset(${
"e_march" .
$i .
"_price"})) ? ${
"e_march" .
$i .
"_price"} :
"" ;
1354 if ($flag_tva ==
'Y') {
1355 $march_tva_id = (isset(${
"e_march$i" .
"_tva_id"})) ? ${
"e_march$i" .
"_tva_id"} :
"";
1356 $march_tva_amount = (isset(${
"e_march$i" .
"_tva_amount"})) ? ${
"e_march$i" .
"_tva_amount"} :
"";
1358 $march_label = (isset(${
"e_march" .
$i .
"_label"})) ? ${
"e_march" .
$i .
"_label"} :
"";
1362 if (strlen(trim($march)) != 0 && strlen(trim($march_label)) == 0) {
1363 $fMarch =
new Fiche($this->
db);
1364 $fMarch->get_by_qcode($march);
1366 if ($flag_tva ==
'Y') {
1367 if (!(isset(${
"e_march$i" .
"_tva_id"})))
1375 $W1->name =
"e_march" .
$i;
1376 $W1->value = $march;
1378 $W1->set_attribute(
'typecard',
'cred');
1379 $W1->set_dblclick(
"fill_ipopcard(this);");
1380 $W1->set_attribute(
'ipopup',
'ipopcard');
1383 $W1->set_attribute(
'label',
'e_march' .
$i .
'_label');
1385 $W1->set_attribute(
'price',
'e_march' .
$i .
'_price');
1387 $W1->set_attribute(
'tvaid',
'e_march' .
$i .
'_tva_id');
1389 $W1->set_callback(
'filter_card');
1390 $W1->set_function(
'fill_data');
1391 $W1->javascript = sprintf(
' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
1393 $W1->readonly =
false;
1395 $array[
$i][
'quick_code'] = $W1->input();
1397 $array[
$i][
'card_add']=($add_card==TRUE)?$this->
add_card(
"cred", $W1->id):
"";
1400 if ($flag_tva ==
'Y')
1403 $htva =
new INum(
'htva_march' .
$i);
1404 $htva->readOnly = 1;
1406 $array[
$i][
'htva'] = $htva->input();
1409 $tvac =
new INum(
'tvac_march' .
$i);
1413 $tvac->readOnly = 1;
1415 $array[
$i][
'tvac'] = $tvac->input();
1419 $Span=
new IText(
"e_march".
$i.
"_label");
1420 $Span->style=
'class="input_text label_item"';
1423 $Span=
new ISpan(
"e_march".
$i.
"_label");
1424 $Span->extra=
'class="label_item"';
1426 $Span->value = $march_label;
1427 $Span->setReadOnly(
false);
1430 $array[
$i][
'denom'] = $Span->input(
"e_march" .
$i .
"_label", $march_label);
1432 $Price =
new INum();
1433 $Price->setReadOnly(
false);
1435 $Price->javascript =
"onblur=\"format_number(this,4);clean_tva($i);compute_ledger($i)\"";
1436 $array[
$i][
'pu'] = $Price->input(
"e_march" .
$i .
"_price", $march_price);
1440 if ($flag_tva ==
'Y') {
1444 $Tva->in_table =
true;
1445 $Tva->set_attribute(
'compute',
$i);
1446 $Tva->set_filter(
"sale");
1448 $Tva->js =
'onblur="clean_tva(' .
$i .
');compute_ledger(' .
$i .
')"';
1449 $Tva->value = $march_tva_id;
1450 $array[
$i][
'tva'] = $Tva->input(
"e_march$i" .
"_tva_id");
1453 $wTva_amount =
new INum();
1454 $wTva_amount->readOnly =
false;
1455 $wTva_amount->size = 6;
1456 $wTva_amount->javascript =
"onblur='format_number(this);compute_ledger($i)'";
1457 $array[
$i][
'amount_tva'] = $wTva_amount->input(
"e_march" .
$i .
"_tva_amount", $march_tva_amount);
1461 $quant = (isset(${
"e_quant$i"})) ? ${
"e_quant$i"} :
"1"
1463 $Quantity =
new INum();
1465 $Quantity->setReadOnly(
false);
1466 $Quantity->size = 8;
1467 $Quantity->javascript =
"onchange=\"format_number(this);clean_tva($i);compute_ledger($i);\"";
1468 $array[
$i][
'quantity'] = $Quantity->input(
"e_quant" .
$i, $quant);
1470 $f_type = _(
'Client');
1473 $currency_select = $this->
CurrencyInput(
"currency_code",
"p_currency_rate" ,
"p_currency_euro");
1474 $currency_select->selected=
$http->request(
'p_currency_code',
'string',0);
1476 $currency_input=
new INum(
"p_currency_rate");
1477 $currency_input->id=
"p_currency_rate";
1478 $currency_input->prec=6;
1479 $currency_input->value=
$http->request(
'p_currency_rate',
'string',1);
1480 $currency_input->javascript=
'onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"';
1488 echo
'<div id="predef_form">';
1491 $op->set_jrn_type(
"VEN");
1492 $op->set_p_jrn($this->
id);
1493 $op->set_od_direct(
'f');
1494 $http=new \HttpInput();
1495 $url=http_build_query(array(
'p_jrn_predef'=>$this->
id,
'ac'=>
$http->request(
'ac'),
1497 echo
$op->form_get(
'do.php?'.
$url);
1499 $str_op_template=ob_get_contents();
1503 require_once NOALYSS_TEMPLATE.
'/form_ledger_detail.php';
1504 $r.=ob_get_contents();
1528 if ( $this->
id == 0 ) die (__FILE__.
":".__LINE__.
" Journal invalide");
1531 if (
$g_user->get_ledger_access($this->id) ==
'X' )
return null;
1533 switch ( $p_filter_operation)
1539 $sql_filter=
" and (jr_date_paid is not null or jr_rapt ='paid' ) ";
1542 $sql_filter=
" and (jr_date_paid is null and coalesce(jr_rapt,'x') <> 'paid' ) ";
1545 throw new Exception(_(
"Filtre invalide",5));
1553 and jr_date >= (select p_start from parm_periode where p_id = $2)
1555 and jr_date <= (select p_end from parm_periode where p_id = $3) "
1556 .
' order by jr_date,substring(jr_pj_number,\'[0-9]+$\')::numeric asc ';
1567 $array[
'jr_id'] = _(
'Numéro opération');
1568 $array[
'jr_date'] = _(
'Date');
1569 $array[
'jr_date_paid'] = _(
'Date paiement');
1570 $array[
'jr_ech'] = _(
'Date échéance');
1571 $array[
'jr_tech_per'] = _(
'Période');
1572 $array[
'jr_comment'] = _(
'Libellé');
1573 $array[
'jr_pj_number'] = _(
'Pièce');
1574 $array[
'jr_internal'] = _(
'Interne');
1575 $array[
'jr_def_id'] = _(
'Code journal');
1576 $array[
'j_poste'] = _(
'Poste');
1577 $array[
'j_text'] = _(
'Commentaire');
1578 $array[
'j_qcode'] = _(
'Code Item');
1579 $array[
'item_card'] = _(
'N° fiche');
1580 $array[
'item_name'] = _(
'Nom fiche');
1581 $array[
'qs_client'] = _(
'N° fiche fournisseur');
1582 $array[
'tiers_name'] = _(
'Nom fournisseur');
1583 $array[
'quick_code'] = _(
'Code fournisseur');
1584 $array[
'tva_label'] = _(
'Nom TVA');
1585 $array[
'tva_comment'] = _(
'Commentaire TVA');
1586 $array[
'tva_both_side'] = _(
'TVA annulée');
1587 $array[
'vat_sided'] = _(
'TVA Non Payé');
1588 $array[
'vat_code'] = _(
'Code TVA');
1589 $array[
'vat'] = _(
'Montant TVA');
1590 $array[
'price'] = _(
'Total HTVA');
1591 $array[
'quantity'] = _(
'quantité');
1592 $array[
'price_per_unit'] = _(
'PU');
1593 $array[
'htva'] = _(
'HTVA Opération');
1594 $array[
'tot_vat'] = _(
'TVA Opération');
1595 $array[
'tot_vat_np'] = _(
'TVA ND');
1596 $array[
'oc_amount'] = _(
'Mont. Devise');
1597 $array[
'oc_vat_amount'] = _(
'Mont. TVA Devise');
1598 $array[
'cr_code_iso'] = _(
'Devise');