33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
40 $langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
42 $action =
GETPOST(
'action',
'alpha');
43 $confirm =
GETPOST(
'confirm',
'alpha');
45 $facid =
GETPOST(
'facid',
'int');
46 $accountid =
GETPOST(
'accountid',
'int');
47 $paymentnum =
GETPOST(
'num_paiement',
'alpha');
48 $socid =
GETPOST(
'socid',
'int');
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'alpha');
55 $amountsresttopay = array();
58 $multicurrency_amounts = array();
59 $multicurrency_amountsresttopay = array();
64 $socid = $user->socid;
72 $ret = $object->fetch($facid);
76 $hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
78 $formquestion = array();
85 $parameters = array(
'socid'=>$socid);
86 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
87 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
91 if ($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes'))
98 $multicurrency_totalpayment = 0;
99 $atleastonepaymentnotnull = 0;
100 $formquestion = array();
104 $tmpinvoice =
new Facture($db);
105 foreach ($_POST as $key => $value)
107 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'')
109 $cursorfacid = substr($key, 7);
111 $totalpayment = $totalpayment + $amounts[$cursorfacid];
112 if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
113 $result = $tmpinvoice->fetch($cursorfacid);
115 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
116 if ($amounts[$cursorfacid])
119 if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
122 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
125 if ($datepaye && ($datepaye < $tmpinvoice->date))
127 $langs->load(
"errors");
133 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' => $_POST[$key]);
134 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_')
136 $cursorfacid = substr($key, 21);
138 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
139 if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
140 $result = $tmpinvoice->fetch($cursorfacid);
142 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
143 if ($multicurrency_amounts[$cursorfacid])
146 if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid])))
149 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
152 if ($datepaye && ($datepaye < $tmpinvoice->date))
154 $langs->load(
"errors");
160 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key,
'int'));
167 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')), null,
'errors');
171 if (!empty($conf->banque->enabled))
176 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')), null,
'errors');
181 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull))
183 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')), null,
'errors');
187 if (empty($datepaye))
189 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')), null,
'errors');
194 if ($totalpayment > 0 && $multicurrency_totalpayment > 0)
196 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'), null,
'errors');
204 if ($action ==
'add_paiement')
216 if ($action ==
'confirm_paiement' && $confirm ==
'yes')
224 $thirdparty =
new Societe($db);
225 if ($socid > 0) $thirdparty->fetch($socid);
228 foreach ($amounts as $key => $value)
230 $tmpinvoice =
new Facture($db);
231 $tmpinvoice->fetch($key);
235 $amounts[$key] = - abs($newvalue);
239 foreach ($multicurrency_amounts as $key => $value)
241 $tmpinvoice =
new Facture($db);
242 $tmpinvoice->fetch($key);
246 $multicurrency_amounts[$key] = - abs($newvalue);
250 if (!empty($conf->banque->enabled))
253 if (
GETPOST(
'accountid',
'int') <= 0)
255 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')), null,
'errors');
262 $paiement->datepaye = $datepaye;
263 $paiement->amounts = $amounts;
264 $paiement->multicurrency_amounts = $multicurrency_amounts;
266 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
267 $paiement->note_private =
GETPOST(
'comment',
'alpha');
273 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
274 if ($paiement_id < 0)
283 $label =
'(CustomerInvoicePayment)';
285 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOST(
'accountid'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
299 foreach ($paiement->amounts as $key => $amount)
302 if (is_numeric($amount) && $amount <> 0)
304 if ($invoiceid != 0) $invoiceid = -1;
305 else $invoiceid = $facid;
308 if ($invoiceid > 0) $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
309 else $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
310 header(
'Location: '.$loc);
323 $form =
new Form($db);
330 if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement')
333 $result = $facture->fetch($facid);
337 $facture->fetch_thirdparty();
345 if ($action ==
'add_paiement')
349 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
350 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
351 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
356 if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext))
358 if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
359 $paymentnum = $facture->ref_ext;
363 if (!empty($conf->use_javascript_ajax))
365 print "\n".
'<script type="text/javascript" language="javascript">';
366 print '$(document).ready(function () {
369 $("#selectpaiementcode").change(function() {
373 function setPaiementCode()
375 var code = $("#selectpaiementcode option:selected").val();
377 if (code == \'CHQ\' || code == \'VIR\')
381 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
383 if ($(\'#fieldchqemetteur\').val() == \'\')
386 $(\'#fieldchqemetteur\').val(emetteur);
391 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
392 $(\'#fieldchqemetteur\').val(\'\');
396 function _elemToJson(selector)
399 $.map(selector.serializeArray(), function(n,i)
401 subJson[n["name"]] = n["value"];
406 function callForResult(imgId)
409 var form = $("#payment_form");
411 json["invoice_type"] = $("#invoice_type").val();
412 json["amountPayment"] = $("#amountpayment").attr("value");
413 json["amounts"] = _elemToJson(form.find("input.amount"));
414 json["remains"] = _elemToJson(form.find("input.remain"));
417 json["imgClicked"] = imgId;
420 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
422 json = $.parseJSON(data);
426 for (var key in json)
428 if (key == "result") {
429 if (json["makeRed"]) {
430 $("#"+key).addClass("error");
432 $("#"+key).removeClass("error");
434 json[key]=json["label"]+" "+json[key];
435 $("#"+key).text(json[key]);
436 } else {console.log(key);
437 form.find("input[name*=\""+key+"\"]").each(function() {
438 $(this).attr("value", json[key]);
444 $("#payment_form").find("input.amount").change(function() {
447 $("#payment_form").find("input.amount").keyup(function() {
455 print ' $(document).ready(function () {';
456 print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
457 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
461 print ' </script>'.
"\n";
464 print '<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
465 print '<input type="hidden" name="token" value="'.newToken().
'">';
466 print '<input type="hidden" name="action" value="add_paiement">';
467 print '<input type="hidden" name="facid" value="'.$facture->id.
'">';
468 print '<input type="hidden" name="socid" value="'.$facture->socid.
'">';
469 print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
470 print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
474 print '<table class="border centpercent">';
477 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
480 print '<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
481 $datepayment =
dol_mktime(12, 0, 0, $_POST[
'remonth'], $_POST[
'reday'], $_POST[
'reyear']);
482 $datepayment = ($datepayment ==
'' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'') : $datepayment);
483 print $form->selectDate($datepayment,
'',
'',
'', 0,
"add_paiement", 1, 1, 0,
'',
'', $facture->date);
487 print '<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
488 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
494 if (!empty($conf->banque->enabled))
496 if ($facture->type != 2)
print '<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
497 if ($facture->type == 2)
print '<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
499 $form->select_comptes($accountid,
'accountid', 0,
'', 2);
502 print '<td> </td>';
507 print '<tr><td>'.$langs->trans(
'Numero');
508 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
510 print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
513 print '<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
514 print ' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
516 print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
519 print '<tr><td>'.$langs->trans(
'Bank');
520 print ' <em>('.$langs->trans(
"ChequeBank").
')</em>';
522 print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
525 print '<tr><td>'.$langs->trans(
'Comments').
'</td>';
526 print '<td class="tdtop">';
527 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea></td></tr>';
538 $sql =
'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,';
539 $sql .=
' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
540 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture as f';
541 $sql .=
' WHERE f.entity IN ('.getEntity(
'facture').
')';
542 $sql .=
' AND (f.fk_soc = '.$facture->socid;
544 if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
545 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.$facture->thirdparty->parent.
')';
548 if (!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)) {
549 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.$facture->thirdparty->id.
')';
551 $sql .=
') AND f.paye = 0';
552 $sql .=
' AND f.fk_statut = 1';
555 $sql .=
' AND type IN (0,1,3,5)';
557 $sql .=
' AND type = 2';
560 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
562 $resql = $db->query($sql);
565 $num = $db->num_rows(
$resql);
568 $arraytitle = $langs->trans(
'Invoice');
569 if ($facture->type == 2) $arraytitle = $langs->trans(
"CreditNotes");
570 $alreadypayedlabel = $langs->trans(
'Received');
571 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
572 if ($facture->type == 2) { $alreadypayedlabel = $langs->trans(
"PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack"); }
573 $remaindertopay = $langs->trans(
'RemainderToTake');
574 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
575 if ($facture->type == 2) { $remaindertopay = $langs->trans(
"RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack"); }
581 print '<div class="div-table-responsive-no-min">';
582 print '<table class="noborder centpercent">';
584 print '<tr class="liste_titre">';
585 print '<td>'.$arraytitle.
'</td>';
586 print '<td class="center">'.$langs->trans(
'Date').
'</td>';
587 print '<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
588 if (!empty($conf->multicurrency->enabled)) {
589 print '<td>'.$langs->trans(
'Currency').
'</td>';
590 print '<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
591 print '<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
592 print '<td class="right">'.$multicurrencyremaindertopay.
'</td>';
593 print '<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
595 print '<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
596 print '<td class="right">'.$alreadypayedlabel.
'</td>';
597 print '<td class="right">'.$remaindertopay.
'</td>';
598 print '<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
600 $parameters = array();
601 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
603 print '<td align="right"> </td>';
608 $totalrecucreditnote = 0;
609 $totalrecudeposits = 0;
613 $objp = $db->fetch_object(
$resql);
619 $soc->fetch($objp->socid);
622 $invoice->fetch($objp->facid);
623 $paiement = $invoice->getSommePaiement();
624 $creditnotes = $invoice->getSumCreditNotesUsed();
625 $deposits = $invoice->getSumDepositsUsed();
626 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
627 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
630 if (!empty($conf->multicurrency->enabled)) {
631 $multicurrency_payment = $invoice->getSommePaiement(1);
632 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
633 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
634 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
635 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
639 print '<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
641 print '<td class="nowraponall">';
642 print $invoice->getNomUrl(1,
'');
643 if ($objp->socid != $facture->thirdparty->id)
print ' - '.$soc->getNomUrl(1).
' ';
647 print '<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
652 print '<td class="nowraponall center">';
655 if ($invoice->hasDelay())
662 print '<td align="center"></td>';
666 if (!empty($conf->multicurrency->enabled))
print '<td class="center">'.$objp->multicurrency_code.
"</td>\n";
669 if (!empty($conf->multicurrency->enabled))
671 print '<td class="right">';
672 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
print price($sign * $objp->multicurrency_total_ttc);
676 print '<td class="right">';
677 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
680 if ($multicurrency_creditnotes)
print '+'.price($multicurrency_creditnotes);
681 if ($multicurrency_deposits)
print '+'.price($multicurrency_deposits);
686 print '<td class="right">';
687 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
print price($sign * $multicurrency_remaintopay);
690 print '<td class="right nowraponall">';
693 $namef =
'multicurrency_amount_'.$objp->facid;
694 $nameRemain =
'multicurrency_remain_'.$objp->facid;
696 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
698 if ($action !=
'add_paiement')
700 if (!empty($conf->use_javascript_ajax))
701 print img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $multicurrency_remaintopay).
"'");
702 print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.
'" value="'.$_POST[$namef].
'">';
703 print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
705 print '<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.$_POST[$namef].
'" disabled>';
706 print '<input type="hidden" name="'.$namef.
'" value="'.$_POST[$namef].
'">';
713 print '<td class="right">'.price($sign * $objp->total_ttc).
'</td>';
716 print '<td class="right">'.price($sign * $paiement);
717 if ($creditnotes)
print '<span class="opacitymedium">+'.price($creditnotes).
'</span>';
718 if ($deposits)
print '<span class="opacitymedium">+'.price($deposits).
'</span>';
722 print '<td class="right">'.price($sign * $remaintopay).
'</td>';
726 print '<td class="right nowraponall">';
729 $namef =
'amount_'.$objp->facid;
730 $nameRemain =
'remain_'.$objp->facid;
732 if ($action !=
'add_paiement')
734 if (!empty($conf->use_javascript_ajax))
735 print img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $remaintopay).
"'");
737 print '<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
744 $parameters = array();
745 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
748 print '<td align="center" width="16">';
750 if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
751 || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id])))
753 print ' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
759 $total += $objp->total;
760 $total_ttc += $objp->total_ttc;
761 $totalrecu += $paiement;
762 $totalrecucreditnote += $creditnotes;
763 $totalrecudeposits += $deposits;
770 print '<tr class="liste_total">';
771 print '<td colspan="3" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
772 if (!empty($conf->multicurrency->enabled)) {
777 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
779 print '<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
780 print '<td class="right"><b>'.price($sign * $totalrecu);
781 if ($totalrecucreditnote)
print '+'.price($totalrecucreditnote);
782 if ($totalrecudeposits)
print '+'.price($totalrecudeposits);
784 print '<td class="right"><b>'.price($sign *
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
785 print '<td class="right" id="result" style="font-weight: bold;"></td>';
786 print '<td align="center"> </td>';
799 if ($action !=
'add_paiement')
801 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
803 $buttontitle = $langs->trans(
'ToMakePayment');
806 print '<br><div class="center">';
807 print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
813 print '<br><input type="submit" class="button" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
818 if ($action ==
'add_paiement')
820 $preselectedchoice = $addwarning ?
'no' :
'yes';
823 if (!empty($totalpayment)) $text = $langs->trans(
'ConfirmCustomerPayment', $totalpayment, $langs->trans(
"Currency".$conf->currency));
824 if (!empty($multicurrency_totalpayment))
826 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans(
"paymentInInvoiceCurrency"));
828 if (
GETPOST(
'closepaidinvoices'))
830 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
831 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
833 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
844 if (!
GETPOST(
'action',
'aZ09'))
846 if (empty($page) || $page == -1) $page = 0;
847 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
848 $offset = $limit * $page;
850 if (!$sortorder) $sortorder =
'DESC';
851 if (!$sortfield) $sortfield =
'p.datep';
853 $sql =
'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
854 $sql .=
', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
855 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
856 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
857 $sql .=
' WHERE p.fk_facture = f.rowid';
858 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
861 $sql .=
' AND f.fk_soc = '.$socid;
864 $sql .=
' ORDER BY '.$sortfield.
' '.$sortorder;
865 $sql .= $db->plimit($limit + 1, $offset);
866 $resql = $db->query($sql);
870 $num = $db->num_rows(
$resql);
874 print '<table class="noborder centpercent">';
875 print
'<tr class="liste_titre">';
879 print_liste_field_titre(
'Amount', $_SERVER[
"PHP_SELF"],
'p.amount',
'',
'',
'', $sortfield, $sortorder,
'right ');
883 while ($i < min($num, $limit))
885 $objp = $db->fetch_object(
$resql);
887 print
'<tr class="oddeven">';
888 print
'<td><a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$objp->facid.
'">'.$objp->ref.
"</a></td>\n";
889 print
'<td>'.dol_print_date($db->jdate($objp->dp)).
"</td>\n";
890 print
'<td>'.$objp->paiement_type.
' '.$objp->num_payment.
"</td>\n";
891 print
'<td class="right">'.price($objp->amount).
'</td>';
892 print
'<td> </td>';
895 $parameters = array();
896 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $objp, $action);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
const TYPE_CREDIT_NOTE
Credit note invoice.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage payments of customer invoices.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...