34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
41 $langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
43 $action =
GETPOST(
'action',
'alpha');
44 $confirm =
GETPOST(
'confirm',
'alpha');
46 $facid =
GETPOST(
'facid',
'int');
47 $accountid =
GETPOST(
'accountid',
'int');
48 $paymentnum =
GETPOST(
'num_paiement',
'alpha');
49 $socid =
GETPOST(
'socid',
'int');
51 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
56 $amountsresttopay = array();
59 $multicurrency_amounts = array();
60 $multicurrency_amountsresttopay = array();
63 if ($user->socid > 0) {
64 $socid = $user->socid;
71 $ret = $object->fetch($facid);
75 $hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
77 $formquestion = array();
79 $usercanissuepayment = !empty($user->rights->facture->paiement);
83 $result =
restrictedArea($user,
'facture', $object->id,
'',
'',
'fk_soc', $fieldid, $isdraft);
90 $parameters = array(
'socid'=>$socid);
91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96 if (empty($reshook)) {
97 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
103 $multicurrency_totalpayment = 0;
104 $atleastonepaymentnotnull = 0;
105 $formquestion = array();
109 $tmpinvoice =
new Facture($db);
110 foreach ($_POST as $key => $value) {
111 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
112 $cursorfacid = substr($key, 7);
114 $totalpayment = $totalpayment + $amounts[$cursorfacid];
115 if (!empty($amounts[$cursorfacid])) {
116 $atleastonepaymentnotnull++;
118 $result = $tmpinvoice->fetch($cursorfacid);
122 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
123 if ($amounts[$cursorfacid]) {
125 if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) {
127 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
130 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
131 $langs->load(
"errors");
137 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
138 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
139 $cursorfacid = substr($key, 21);
141 $multicurrency_totalpayment += floatval($multicurrency_amounts[$cursorfacid]);
142 if (!empty($multicurrency_amounts[$cursorfacid])) {
143 $atleastonepaymentnotnull++;
145 $result = $tmpinvoice->fetch($cursorfacid);
149 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
150 if ($multicurrency_amounts[$cursorfacid]) {
152 if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
154 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
157 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
158 $langs->load(
"errors");
164 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key,
'int'));
169 if (!
GETPOST(
'paiementcode')) {
170 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
176 if (
GETPOST(
'accountid') <= 0) {
177 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
182 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
183 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
187 if (empty($datepaye)) {
188 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
193 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
194 $langs->load(
"errors");
195 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
203 if ($action ==
'add_paiement') {
213 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
220 $thirdparty =
new Societe($db);
222 $thirdparty->fetch($socid);
225 $multicurrency_code = array();
228 foreach ($amounts as $key => $value) {
229 $tmpinvoice =
new Facture($db);
230 $tmpinvoice->fetch($key);
233 $amounts[$key] = - abs($newvalue);
235 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
238 foreach ($multicurrency_amounts as $key => $value) {
239 $tmpinvoice =
new Facture($db);
240 $tmpinvoice->fetch($key);
243 $multicurrency_amounts[$key] = - abs($newvalue);
245 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
250 if (
GETPOST(
'accountid',
'int') <= 0) {
251 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
258 $paiement->datepaye = $datepaye;
259 $paiement->amounts = $amounts;
260 $paiement->multicurrency_amounts = $multicurrency_amounts;
261 $paiement->multicurrency_code = $multicurrency_code;
263 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
264 $paiement->note_private =
GETPOST(
'comment',
'alpha');
265 $paiement->fk_account =
GETPOST(
'accountid',
'int');
271 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
272 if ($paiement_id < 0) {
279 $label =
'(CustomerInvoicePayment)';
281 $label =
'(CustomerInvoicePaymentBack)';
283 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOST(
'accountid',
'int'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
295 foreach ($paiement->amounts as $key => $amount) {
297 if (is_numeric($amount) && $amount <> 0) {
298 if ($invoiceid != 0) {
305 if ($invoiceid > 0) {
306 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
308 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
310 header(
'Location: '.$loc);
330 if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
332 $result = $facture->fetch($facid);
335 $facture->fetch_thirdparty();
339 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
342 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
347 if ($action ==
'add_paiement') {
350 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
351 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
352 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
357 if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) {
358 if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) {
359 $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
361 $paymentnum = $facture->ref_ext;
365 if (!empty($conf->use_javascript_ajax)) {
366 print
"\n".
'<script type="text/javascript">';
367 print
'$(document).ready(function () {
370 $("#selectpaiementcode").change(function() {
374 function setPaiementCode()
376 var code = $("#selectpaiementcode option:selected").val();
377 console.log("setPaiementCode code="+code);
379 if (code == \'CHQ\' || code == \'VIR\')
383 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
385 if ($(\'#fieldchqemetteur\').val() == \'\')
388 $(\'#fieldchqemetteur\').val(emetteur);
393 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
394 $(\'#fieldchqemetteur\').val(\'\');
398 function _elemToJson(selector)
401 $.map(selector.serializeArray(), function(n,i)
403 subJson[n["name"]] = n["value"];
408 function callForResult(imgId)
411 var form = $("#payment_form");
413 json["invoice_type"] = $("#invoice_type").val();
414 json["amountPayment"] = $("#amountpayment").attr("value");
415 json["amounts"] = _elemToJson(form.find("input.amount"));
416 json["remains"] = _elemToJson(form.find("input.remain"));
419 json["imgClicked"] = imgId;
422 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
424 json = $.parseJSON(data);
428 for (var key in json)
430 if (key == "result") {
431 if (json["makeRed"]) {
432 $("#"+key).addClass("error");
434 $("#"+key).removeClass("error");
436 json[key]=json["label"]+" "+json[key];
437 $("#"+key).text(json[key]);
438 } else {console.log(key);
439 form.find("input[name*=\""+key+"\"]").each(function() {
440 $(this).attr("value", json[key]);
446 $("#payment_form").find("input.amount").change(function() {
449 $("#payment_form").find("input.amount").keyup(function() {
457 print
' $(document).ready(function () {';
458 print
' $(".AutoFillAmout").on(\'click touchstart\', function(){
459 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
463 print
' </script>'.
"\n";
466 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
467 print
'<input type="hidden" name="token" value="'.newToken().
'">';
468 print
'<input type="hidden" name="action" value="add_paiement">';
469 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
470 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
471 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
472 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
476 print
'<table class="border centpercent">';
479 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
482 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
484 $datepayment = ($datepayment ==
'' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'') : $datepayment);
485 print
$form->selectDate($datepayment,
'',
'',
'', 0,
"add_paiement", 1, 1, 0,
'',
'', $facture->date);
489 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
490 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
497 if ($facture->type != 2) {
498 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
500 if ($facture->type == 2) {
501 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
506 print
$form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
509 print
'<td> </td>';
514 print
'<tr><td>'.$langs->trans(
'Numero');
515 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
517 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
520 print
'<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
521 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
523 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
526 print
'<tr><td>'.$langs->trans(
'Bank');
527 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
529 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
532 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
533 print
'<td class="tdtop">';
534 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
546 $sql =
'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,';
547 $sql .=
' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
548 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture as f';
549 $sql .=
' WHERE f.entity IN ('.getEntity(
'facture').
')';
550 $sql .=
' AND (f.fk_soc = '.((int) $facture->socid);
552 if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
553 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->parent).
')';
556 if (!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)) {
557 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->id).
')';
559 $sql .=
') AND f.paye = 0';
560 $sql .=
' AND f.fk_statut = 1';
562 $sql .=
' AND type IN (0,1,3,5)';
564 $sql .=
' AND type = 2';
567 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
569 $resql = $db->query($sql);
571 $num = $db->num_rows(
$resql);
573 $arraytitle = $langs->trans(
'Invoice');
574 if ($facture->type == 2) {
575 $arraytitle = $langs->trans(
"CreditNotes");
577 $alreadypayedlabel = $langs->trans(
'Received');
578 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
579 if ($facture->type == 2) {
580 $alreadypayedlabel = $langs->trans(
"PaidBack");
581 $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack");
583 $remaindertopay = $langs->trans(
'RemainderToTake');
584 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
585 if ($facture->type == 2) {
586 $remaindertopay = $langs->trans(
"RemainderToPayBack");
587 $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack");
594 print
'<div class="div-table-responsive-no-min">';
595 print
'<table class="noborder centpercent">';
597 print
'<tr class="liste_titre">';
598 print
'<td>'.$arraytitle.
'</td>';
599 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
600 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
602 print
'<td>'.$langs->trans(
'Currency').
'</td>';
603 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
604 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
605 print
'<td class="right">'.$multicurrencyremaindertopay.
'</td>';
606 print
'<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
608 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
609 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
610 print
'<td class="right">'.$remaindertopay.
'</td>';
611 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
613 $parameters = array();
614 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
616 print
'<td align="right"> </td>';
621 $totalrecucreditnote = 0;
622 $totalrecudeposits = 0;
625 $objp = $db->fetch_object(
$resql);
633 $soc->fetch($objp->socid);
636 $invoice->fetch($objp->facid);
637 $paiement = $invoice->getSommePaiement();
638 $creditnotes = $invoice->getSumCreditNotesUsed();
639 $deposits = $invoice->getSumDepositsUsed();
640 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
641 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
645 $multicurrency_payment = $invoice->getSommePaiement(1);
646 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
647 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
648 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
649 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
653 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
655 print
'<td class="nowraponall">';
656 print $invoice->getNomUrl(1,
'');
657 if ($objp->socid != $facture->thirdparty->id) {
658 print
' - '.$soc->getNomUrl(1).
' ';
663 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
666 if ($objp->dlr > 0) {
667 print
'<td class="nowraponall center">';
670 if ($invoice->hasDelay()) {
676 print
'<td align="center"></td>';
681 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
686 print
'<td class="right">';
687 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
688 print
price($sign * $objp->multicurrency_total_ttc);
693 print
'<td class="right">';
694 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
695 print
price($sign * $multicurrency_payment);
696 if ($multicurrency_creditnotes) {
697 print
'+'.price($multicurrency_creditnotes);
699 if ($multicurrency_deposits) {
700 print
'+'.price($multicurrency_deposits);
706 print
'<td class="right">';
707 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
708 print
price($sign * $multicurrency_remaintopay);
712 print
'<td class="right nowraponall">';
715 $namef =
'multicurrency_amount_'.$objp->facid;
716 $nameRemain =
'multicurrency_remain_'.$objp->facid;
718 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
719 if ($action !=
'add_paiement') {
720 if (!empty($conf->use_javascript_ajax)) {
721 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $multicurrency_remaintopay).
"'");
723 print
'<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
724 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
726 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
727 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
734 print
'<td class="right"><span class="amount">'.price($sign * $objp->total_ttc).
'</span></td>';
737 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
739 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
742 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
744 print
'</span></td>';
747 print
'<td class="right">';
748 print
price($sign * $remaintopay);
749 if (!empty($conf->prelevement->enabled)) {
750 $numdirectdebitopen = 0;
751 $totaldirectdebit = 0;
752 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
753 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
754 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
755 $sql .=
" AND pfd.traite = 0";
756 $sql .=
" AND pfd.ext_payment_id IS NULL";
758 $result_sql = $db->query($sql);
760 $obj = $db->fetch_object($result_sql);
761 $numdirectdebitopen = $obj->nb;
762 $totaldirectdebit = $obj->amount;
766 if ($numdirectdebitopen) {
767 $langs->load(
"withdrawals");
768 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1, $conf->currency)),
'',
'classfortooltip');
775 print
'<td class="right nowraponall">';
778 $namef =
'amount_'.$objp->facid;
779 $nameRemain =
'remain_'.$objp->facid;
781 if ($action !=
'add_paiement') {
782 if (!empty($conf->use_javascript_ajax)) {
783 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $remaintopay).
"'");
786 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
788 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
793 $parameters = array();
794 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
797 print
'<td align="center" width="16">';
799 if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
800 || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) {
801 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
807 $total_ttc += $objp->total_ttc;
808 $totalrecu += $paiement;
809 $totalrecucreditnote += $creditnotes;
810 $totalrecudeposits += $deposits;
816 print
'<tr class="liste_total">';
817 print
'<td colspan="3" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
823 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
825 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
826 print
'<td class="right"><b>'.price($sign * $totalrecu);
827 if ($totalrecucreditnote) {
828 print
'+'.price($totalrecucreditnote);
830 if ($totalrecudeposits) {
831 print
'+'.price($totalrecudeposits);
834 print
'<td class="right"><b>'.price($sign *
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
835 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
836 print
'<td align="center"> </td>';
850 if ($action !=
'add_paiement') {
851 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
853 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
855 $buttontitle = $langs->trans(
'ToMakePayment');
857 $buttontitle = $langs->trans(
'ToMakePaymentBack');
860 print
'<br><div class="center">';
861 print
'<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
867 print
'<br><input type="submit" class="button" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
872 if ($action ==
'add_paiement') {
873 $preselectedchoice = $addwarning ?
'no' :
'yes';
876 if (!empty($totalpayment)) {
877 $text = $langs->trans(
'ConfirmCustomerPayment', $totalpayment, $langs->trans(
"Currency".$conf->currency));
879 if (!empty($multicurrency_totalpayment)) {
880 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans(
"paymentInInvoiceCurrency"));
882 if (
GETPOST(
'closepaidinvoices')) {
883 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
884 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
886 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
891 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
892 if (empty($reshook)) {
894 } elseif ($reshook > 0) {
909 if (!
GETPOST(
'action',
'aZ09')) {
910 if (empty($page) || $page == -1) {
913 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
914 $offset = $limit * $page;
920 $sortfield =
'p.datep';
923 $sql =
'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
924 $sql .=
', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
925 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
926 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
927 $sql .=
' WHERE p.fk_facture = f.rowid';
928 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
930 $sql .=
' AND f.fk_soc = '.((int) $socid);
933 $sql .= $db->order($sortfield, $sortorder);
934 $sql .= $db->plimit($limit + 1, $offset);
935 $resql = $db->query($sql);
938 $num = $db->num_rows(
$resql);
941 print_barre_liste($langs->trans(
'Payments'), $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', $num);
942 print
'<table class="noborder centpercent">';
943 print
'<tr class="liste_titre">';
947 print_liste_field_titre(
'Amount', $_SERVER[
"PHP_SELF"],
'p.amount',
'',
'',
'', $sortfield, $sortorder,
'right ');
951 while ($i < min($num, $limit)) {
952 $objp = $db->fetch_object(
$resql);
954 print
'<tr class="oddeven">';
955 print
'<td><a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$objp->facid.
'">'.$objp->ref.
"</a></td>\n";
956 print
'<td>'.dol_print_date($db->jdate($objp->dp)).
"</td>\n";
957 print
'<td>'.$objp->paiement_type.
' '.$objp->num_payment.
"</td>\n";
958 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
959 print
'<td> </td>';
962 $parameters = array();
963 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $objp, $action);
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$formconfirm
if ($action == 'delbookkeepingyear') {
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.