39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
54$langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
56$action =
GETPOST(
'action',
'alpha');
57$confirm =
GETPOST(
'confirm',
'alpha');
61$paymentnum =
GETPOST(
'num_paiement',
'alpha');
64$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68$displayAllInvoices =
getDolGlobalInt(
'MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
69if (GETPOSTISSET(
'display-all-invoices')) {
70 $displayAllInvoices =
GETPOSTINT(
'display-all-invoices');
75$amountsresttopay = array();
78$multicurrency_amounts = array();
79$multicurrency_amountsresttopay = array();
82if ($user->socid > 0) {
83 $socid = $user->socid;
94$hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
96$formquestion = array();
98$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
110$parameters = array(
'socid' => $socid);
111$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
117if (empty($reshook)) {
118 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
121 $multicurrency_totalpayment = 0;
122 $atleastonepaymentnotnull = 0;
123 $formquestion = array();
127 $tmpinvoice =
new Facture($db);
128 foreach ($_POST as $key => $value) {
129 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
130 $cursorfacid = (int) substr($key, 7);
132 if (!empty($amounts[$cursorfacid])) {
133 $totalpayment += (float) $amounts[$cursorfacid];
134 $atleastonepaymentnotnull++;
136 $result = $tmpinvoice->fetch($cursorfacid);
140 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
141 if ($amounts[$cursorfacid]) {
143 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
145 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
148 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
149 $langs->load(
"errors");
155 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
156 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
157 $cursorfacid = (int) substr($key, 21);
159 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
160 if (!empty($multicurrency_amounts[$cursorfacid])) {
161 $atleastonepaymentnotnull++;
163 $result = $tmpinvoice->fetch($cursorfacid);
167 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
168 if ($multicurrency_amounts[$cursorfacid]) {
170 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
172 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
175 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
176 $langs->load(
"errors");
182 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
187 if (!
GETPOST(
'paiementcode')) {
188 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
192 if (isModEnabled(
"bank")) {
194 if (
GETPOST(
'accountid') <= 0) {
195 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
200 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
201 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
205 if (empty($datepaye)) {
206 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
211 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
212 $langs->load(
"errors");
213 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
221 if ($action ==
'add_paiement') {
231 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
236 $thirdparty =
new Societe($db);
238 $thirdparty->fetch($socid);
241 $multicurrency_code = array();
242 $multicurrency_tx = array();
245 foreach ($amounts as $key => $value) {
246 $tmpinvoice =
new Facture($db);
247 $tmpinvoice->fetch($key);
250 $amounts[$key] = - abs((
float) $newvalue);
252 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
253 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
256 foreach ($multicurrency_amounts as $key => $value) {
257 $tmpinvoice =
new Facture($db);
258 $tmpinvoice->fetch((
int) $key);
261 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
263 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
264 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
267 if (isModEnabled(
"bank")) {
270 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
277 $paiement->datepaye = $datepaye;
278 $paiement->amounts = $amounts;
279 $paiement->multicurrency_amounts = $multicurrency_amounts;
280 $paiement->multicurrency_code = $multicurrency_code;
281 $paiement->multicurrency_tx = $multicurrency_tx;
283 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
284 $paiement->note_private =
GETPOST(
'comment',
'alpha');
285 $paiement->fk_account =
GETPOSTINT(
'accountid');
292 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
293 if ($paiement_id < 0) {
305 $label =
'(CustomerInvoicePayment)';
307 $label =
'(CustomerInvoicePaymentBack)';
310 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOSTINT(
'accountid'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
322 foreach ($paiement->amounts as $key => $amount) {
324 if (is_numeric($amount) && $amount != 0) {
325 if ($invoiceid != 0) {
332 if ($invoiceid > 0) {
333 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
335 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
337 header(
'Location: '.$loc);
350$form =
new Form($db);
357$result = $facture->fetch($facid);
360 $facture->fetch_thirdparty();
364 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
367 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
372 if ($action ==
'add_paiement') {
375 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
376 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
377 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
382 if (isModEnabled(
'paypalplus') &&
getDolGlobalString(
'PAYPAL_ENABLE_TRANSACTION_MANAGEMENT') && !empty($facture->ref_ext)) {
386 $paymentnum = $facture->ref_ext;
390 if (!empty(
$conf->use_javascript_ajax)) {
391 print
"\n".
'<script type="text/javascript">';
392 print
'$(document).ready(function () {
395 $("#selectpaiementcode").change(function() {
399 function setPaiementCode()
401 var code = $("#selectpaiementcode option:selected").val();
402 console.log("setPaiementCode code="+code);
404 if (code == \'CHQ\' || code == \'VIR\')
408 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
410 if ($(\'#fieldchqemetteur\').val() == \'\')
413 $(\'#fieldchqemetteur\').val(emetteur);
418 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
419 $(\'#fieldchqemetteur\').val(\'\');
423 function _elemToJson(selector)
426 $.map(selector.serializeArray(), function(n,i)
428 subJson[n["name"]] = n["value"];
433 function callForResult(imgId)
436 var form = $("#payment_form");
438 json["invoice_type"] = $("#invoice_type").val();
439 json["amountPayment"] = $("#amountpayment").attr("value");
440 json["amounts"] = _elemToJson(form.find("input.amount"));
441 json["remains"] = _elemToJson(form.find("input.remain"));
444 json["imgClicked"] = imgId;
447 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
449 json = $.parseJSON(data);
453 for (var key in json)
455 if (key == "result") {
456 if (json["makeRed"]) {
457 $("#"+key).addClass("error");
459 $("#"+key).removeClass("error");
461 json[key]=json["label"]+" "+json[key];
462 $("#"+key).text(json[key]);
463 } else {console.log(key);
464 form.find("input[name*=\""+key+"\"]").each(function() {
465 $(this).attr("value", json[key]);
471 $("#payment_form").find("input.amount").change(function() {
474 $("#payment_form").find("input.amount").keyup(function() {
482 print
' $(document).ready(function () {';
483 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
485 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
489 print
' </script>'.
"\n";
492 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
493 print
'<input type="hidden" name="token" value="'.newToken().
'">';
494 print
'<input type="hidden" name="action" value="add_paiement">';
495 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
496 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
497 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
498 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
499 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
500 print
'<input type="hidden" name="page_y" value="">';
504 print
'<table class="border centpercent">';
507 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
510 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
512 $datepayment = ($datepayment ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datepayment);
513 $adddateof = array(array(
'adddateof'=>$facture->date));
514 $adddateof[] = array(
'adddateof'=>$facture->date_lim_reglement,
'labeladddateof'=>$langs->transnoentities(
'DateDue'));
515 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_paiement", 1, 1, 0,
'',
'', $adddateof);
519 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
520 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
526 if (isModEnabled(
"bank")) {
527 if ($facture->type != 2) {
528 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
530 if ($facture->type == 2) {
531 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
535 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
536 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', (isModEnabled(
'multicurrency') ? 1 : 0),
'widthcentpercentminusx maxwidth500', 1);
539 print
'<td> </td>';
544 print
'<tr><td>'.$langs->trans(
'Numero');
545 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
547 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
550 print
'<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
551 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
553 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
556 print
'<tr><td>'.$langs->trans(
'Bank');
557 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
559 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
562 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
563 print
'<td class="tdtop">';
564 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
568 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
569 print
'<tr><td></td>';
570 print
'<td class="tdtop right">';
571 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
584 $sql =
"SELECT f.rowid as facid, f.ref, f.total_ht, f.total_tva, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc, f.type,";
585 $sql .=
" f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr";
586 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
587 $sql .=
" WHERE f.entity IN (".getEntity(
'facture').
")";
588 $sql .=
" AND (f.fk_soc = ".((int) $facture->socid);
590 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
591 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->parent).
")";
595 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->id).
")";
597 $sql .=
") AND f.paye = 0";
598 $sql .=
" AND f.fk_statut = 1";
600 if (!$displayAllInvoices) {
602 $sql .=
" AND type IN (0,1,3,5)";
604 $sql .=
" AND type = 2";
607 if (!
getDolGlobalInt(
'FACTURE_PAYMENTS_INVOICE_REQUESTED_SORT_FIRST')) {
609 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
612 $sql .=
" ORDER BY f.rowid = ".((int) $facid).
" DESC, f.datef ASC, f.ref ASC";
615 $resql = $db->query($sql);
617 $num = $db->num_rows($resql);
618 $totalnboflines = $num = $db->num_rows($resql);
620 $arraytitle = $langs->trans(
'Invoice');
622 $arraytitle = $langs->trans(
"CreditNotes");
624 $alreadypayedlabel = $langs->trans(
'Received');
625 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
627 $alreadypayedlabel = $langs->trans(
"PaidBack");
628 $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack");
630 $remaindertopay = $langs->trans(
'RemainderToTake');
631 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
633 $remaindertopay = $langs->trans(
"RemainderToPayBack");
634 $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack");
642 if ($action==
'create') {
643 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.$facid.
'&action='.$action.
'&accountid='.$accountid.
'&display-all-invoices=' . (intval(!$displayAllInvoices));
645 if (empty($displayAllInvoices)) {
646 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
648 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
651 $btnTitle = $langs->trans(
'HideOtherInvoices');
653 $btnTitle = $langs->trans(
'HideCreditNotes');
657 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
658 $moreHtmlRight.=
dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
661 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
663 print
'<div class="div-table-responsive-no-min">';
664 print
'<table id="customer-invoices-paiments-list" class="noborder centpercent" data-display-all-invoices="' . (int) $displayAllInvoices .
'" >';
667 print
'<tr class="liste_titre">';
668 print
'<td>'.$arraytitle.
'</td>';
669 if ($displayAllInvoices) {
670 print
'<td>' . $langs->trans(
'Type') .
'</td>';
672 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
673 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
674 if (isModEnabled(
'multicurrency')) {
675 print
'<td>'.$langs->trans(
'Currency').
'</td>';
676 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
677 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
678 print
'<td class="right">'.$multicurrencyremaindertopay.
'</td>';
679 print
'<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
681 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
682 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
683 print
'<td class="right">'.$remaindertopay.
'</td>';
684 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
686 $parameters = array();
687 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
689 print
'<td align="right"> </td>';
694 $totalrecucreditnote = 0;
695 $totalrecudeposits = 0;
700 $objp = $db->fetch_object($resql);
708 $soc->fetch($objp->socid);
711 $invoice->fetch($objp->facid);
712 $paiement = $invoice->getSommePaiement();
713 $creditnotes = $invoice->getSumCreditNotesUsed();
714 $deposits = $invoice->getSumDepositsUsed();
715 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
716 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
719 $tooltiponmulticurrencyfullamount =
'';
720 $multicurrency_remaintopay =
'';
721 $multicurrency_payment = 0;
722 $multicurrency_creditnotes = 0;
723 $multicurrency_deposits = 0;
724 if (isModEnabled(
'multicurrency')) {
725 $multicurrency_payment = $invoice->getSommePaiement(1);
726 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
727 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
728 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
729 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
731 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
732 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
733 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
737 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
738 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
739 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
741 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
743 print
'<td class="nowraponall">';
744 print $invoice->getNomUrl(1,
'');
745 if ($objp->socid != $facture->thirdparty->id) {
746 print
' - '.$soc->getNomUrl(1).
' ';
751 if ($displayAllInvoices) {
759 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
763 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
766 if ($objp->dlr > 0) {
767 print
'<td class="nowraponall center">';
770 if ($invoice->hasDelay()) {
776 print
'<td align="center"></td>';
780 if (isModEnabled(
'multicurrency')) {
781 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
785 if (isModEnabled(
'multicurrency')) {
786 print
'<td class="right">';
787 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
788 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
790 print
'</span></td>';
793 print
'<td class="right">';
794 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
795 print
price($sign * $multicurrency_payment);
796 if ($multicurrency_creditnotes) {
797 print
'+'.price($multicurrency_creditnotes);
799 if ($multicurrency_deposits) {
800 print
'+'.price($multicurrency_deposits);
806 print
'<td class="right">';
807 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
808 print
price($sign * (
float) $multicurrency_remaintopay);
812 print
'<td class="right nowraponall">';
815 $namef =
'multicurrency_amount_'.$objp->facid;
816 $nameRemain =
'multicurrency_remain_'.$objp->facid;
818 if ($displayAllInvoices) {
826 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
827 if ($action !=
'add_paiement') {
828 if (!empty(
$conf->use_javascript_ajax)) {
829 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">'.
img_picto(
"Auto fill",
'rightarrow');
831 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
832 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
834 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
835 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
842 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
845 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
847 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
850 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
852 print
'</span></td>';
855 print
'<td class="right">';
856 print
price($sign * (
float) $remaintopay);
857 if (isModEnabled(
'prelevement')) {
858 $numdirectdebitopen = 0;
859 $totaldirectdebit = 0;
860 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
861 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
862 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
863 $sql .=
" AND pfd.traite = 0";
864 $sql .=
" AND pfd.ext_payment_id IS NULL";
866 $result_sql = $db->query($sql);
868 $obj = $db->fetch_object($result_sql);
869 $numdirectdebitopen = $obj->nb;
870 $totaldirectdebit = $obj->amount;
874 if ($numdirectdebitopen) {
875 $langs->load(
"withdrawals");
876 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
883 print
'<td class="right nowraponall">';
886 $namef =
'amount_'.$objp->facid;
887 $nameRemain =
'remain_'.$objp->facid;
890 if ($displayAllInvoices) {
898 if ($action !=
'add_paiement') {
899 if (!empty(
$conf->use_javascript_ajax)) {
900 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">'.
img_picto(
"Auto fill",
'rightarrow').
'</button>';
902 print
'<input '.$max.
' '.$min.
' type="text" size="8" class="amount" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
903 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
905 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
910 $parameters = array();
911 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
914 print
'<td align="center" width="16">';
916 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
917 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
918 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
924 $total_ttc += $objp->total_ttc;
925 $totalrecu += $paiement;
926 $totalrecucreditnote += $creditnotes;
927 $totalrecudeposits += $deposits;
936 if ($displayAllInvoices) {
943 print
'<tr class="liste_total">';
944 print
'<td colspan="'.$colspan.
'" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
945 if (isModEnabled(
'multicurrency')) {
950 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
952 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
953 print
'<td class="right"><b>'.price($sign * $totalrecu);
954 if ($totalrecucreditnote) {
955 print
'+'.price($totalrecucreditnote);
957 if ($totalrecudeposits) {
958 print
'+'.price($totalrecudeposits);
961 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
962 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
963 print
'<td align="center"> </td>';
978 if ($action !=
'add_paiement') {
979 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
981 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
983 $buttontitle = $langs->trans(
'ToMakePayment');
985 $buttontitle = $langs->trans(
'ToMakePaymentBack');
988 print
'<br><div class="center">';
989 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices"><label for="closepaidinvoices"> '.$checkboxlabel.
'</label>';
996 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
1001 if ($action ==
'add_paiement') {
1002 $preselectedchoice = $addwarning ?
'no' :
'yes';
1006 if (!empty($totalpayment)) {
1007 $text = $langs->trans(
'ConfirmCustomerPayment', (
string) $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
1009 if (!empty($multicurrency_totalpayment)) {
1010 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', (
string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
1012 if (
GETPOST(
'closepaidinvoices')) {
1013 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
1014 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
1016 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
1020 $parameters = array(
'formConfirm' => $formconfirm);
1021 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1022 if (empty($reshook)) {
1023 $formconfirm .= $hookmanager->resPrint;
1024 } elseif ($reshook > 0) {
1025 $formconfirm = $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_DRAFT
Draft status.
const TYPE_STANDARD
Standard invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.