39require
'../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
53$langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
55$action =
GETPOST(
'action',
'alpha');
56$confirm =
GETPOST(
'confirm',
'alpha');
60$paymentnum =
GETPOST(
'num_paiement',
'alpha');
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67$displayAllInvoices =
getDolGlobalInt(
'MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
69 $displayAllInvoices =
GETPOSTINT(
'display-all-invoices');
74$amountsresttopay = array();
77$multicurrency_amounts = array();
78$multicurrency_amountsresttopay = array();
81if ($user->socid > 0) {
82 $socid = $user->socid;
93$hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
95$formquestion = array();
97$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
109$parameters = array(
'socid' => $socid);
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
116if (empty($reshook)) {
117 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
120 $multicurrency_totalpayment = 0;
121 $atleastonepaymentnotnull = 0;
122 $formquestion = array();
127 foreach ($_POST as $key => $value) {
128 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
129 $cursorfacid = (int) substr($key, 7);
131 if (!empty($amounts[$cursorfacid])) {
132 $totalpayment += (float) $amounts[$cursorfacid];
133 $atleastonepaymentnotnull++;
135 $result = $tmpinvoice->fetch($cursorfacid);
142 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
143 if ($amounts[$cursorfacid]) {
145 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
147 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
150 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
151 $langs->load(
"errors");
157 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
158 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
159 $cursorfacid = (int) substr($key, 21);
161 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
162 if (!empty($multicurrency_amounts[$cursorfacid])) {
163 $atleastonepaymentnotnull++;
165 $result = $tmpinvoice->fetch($cursorfacid);
172 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
173 if ($multicurrency_amounts[$cursorfacid]) {
175 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
177 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
180 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
181 $langs->load(
"errors");
187 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
192 if (!
GETPOST(
'paiementcode')) {
193 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
199 if (
GETPOST(
'accountid') <= 0) {
200 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
205 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
206 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
210 if (empty($datepaye)) {
211 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
216 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
217 $langs->load(
"errors");
218 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
226 if ($action ==
'add_paiement') {
236 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
243 $thirdparty->fetch($socid);
246 $multicurrency_code = array();
247 $multicurrency_tx = array();
250 foreach ($amounts as $key => $value) {
252 $tmpinvoice->fetch($key);
255 $amounts[$key] = - abs((
float) $newvalue);
257 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
258 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
261 foreach ($multicurrency_amounts as $key => $value) {
263 $tmpinvoice->fetch((
int) $key);
266 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
268 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
269 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
275 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
282 $paiement->datepaye = $datepaye;
283 $paiement->amounts = $amounts;
284 $paiement->multicurrency_amounts = $multicurrency_amounts;
285 $paiement->multicurrency_code = $multicurrency_code;
286 $paiement->multicurrency_tx = $multicurrency_tx;
287 $paiement->paiementcode =
GETPOST(
'paiementcode',
'alpha');
288 $paiement->paiementid =
dol_getIdFromCode(
$db, $paiement->paiementcode,
'c_paiement',
'code',
'id', 1);
289 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
290 $paiement->note_private =
GETPOST(
'comment',
'alpha');
291 $paiement->fk_account =
GETPOSTINT(
'accountid');
298 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
299 if ($paiement_id < 0) {
311 $label =
'(CustomerInvoicePayment)';
313 $label =
'(CustomerInvoicePaymentBack)';
316 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOSTINT(
'accountid'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
328 foreach ($paiement->amounts as $key => $amount) {
330 if (is_numeric($amount) && $amount != 0) {
331 if ($invoiceid != 0) {
338 if ($invoiceid > 0) {
339 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
341 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
343 header(
'Location: '.$loc);
363$result = $facture->fetch($facid);
366 $facture->fetch_thirdparty();
370 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
373 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
378 if ($action ==
'add_paiement') {
381 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
382 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
383 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
392 $paymentnum = $facture->ref_ext;
396 if (!empty(
$conf->use_javascript_ajax)) {
397 print
"\n".
'<script type="text/javascript">';
398 print
'$(document).ready(function () {
401 $("#selectpaiementcode").change(function() {
405 function setPaiementCode()
407 var code = $("#selectpaiementcode option:selected").val();
408 console.log("setPaiementCode code="+code);
410 if (code == \'CHQ\' || code == \'VIR\')
414 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
416 if ($(\'#fieldchqemetteur\').val() == \'\')
419 $(\'#fieldchqemetteur\').val(emetteur);
424 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
425 $(\'#fieldchqemetteur\').val(\'\');
429 function _elemToJson(selector)
432 $.map(selector.serializeArray(), function(n,i)
434 subJson[n["name"]] = n["value"];
439 function callForResult(imgId, multicurrency = 0)
442 var form = $("#payment_form");
443 var keyresult = "result";
445 json["invoice_type"] = $("#invoice_type").val();
447 keyresult = "multicurrency_result";
448 json["multicurrency"] = 1;
449 json["multicurrency_amountPayment"] = $("#multicurrency_amountpayment").attr("value");
450 json["multicurrency_amounts"] = _elemToJson(form.find("input.multicurrency_amount"));
451 json["multicurrency_remains"] = _elemToJson(form.find("input.multicurrency_remain"));
453 json["amountPayment"] = $("#amountpayment").attr("value");
454 json["amounts"] = _elemToJson(form.find("input.amount"));
455 json["remains"] = _elemToJson(form.find("input.remain"));
459 json["imgClicked"] = imgId;
462 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
464 json = $.parseJSON(data);
468 for (var key in json)
470 if (key == keyresult) {
471 if (json["makeRed"]) {
472 $("#"+key).addClass("error");
474 $("#"+key).removeClass("error");
476 json[key]=json["label"]+" "+json[key];
477 $("#"+key).text(json[key]);
478 } else {console.log(key);
479 form.find("input[name*=\""+key+"\"]").each(function() {
480 $(this).attr("value", json[key]);
486 $("#payment_form").find("input.amount").change(function() {
489 $("#payment_form").find("input.amount").keyup(function() {
493 $("#payment_form").find("input.multicurrency_amount").change(function() {
494 callForResult(null, 1);
496 $("#payment_form").find("input.multicurrency_amount").keyup(function() {
497 callForResult(null, 1);
504 print
' $(document).ready(function () {';
505 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
507 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
511 print
' </script>'.
"\n";
514 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
515 print
'<input type="hidden" name="token" value="'.newToken().
'">';
516 print
'<input type="hidden" name="action" value="add_paiement">';
517 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
518 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
519 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
520 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
521 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
522 print
'<input type="hidden" name="page_y" value="">';
526 print
'<table class="border centpercent">';
529 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
532 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
534 $datepayment = ($datepayment ==
'' ? (
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datepayment);
535 $adddateof = array(array(
'adddateof'=>$facture->date));
536 $adddateof[] = array(
'adddateof'=>$facture->date_lim_reglement,
'labeladddateof'=>$langs->transnoentities(
'DateDue'));
537 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_paiement", 1, 1, 0,
'',
'', $adddateof);
541 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
542 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
549 if ($facture->type != 2) {
550 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
552 if ($facture->type == 2) {
553 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
557 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
558 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', (
isModEnabled(
'multicurrency') ? 1 : 0),
'widthcentpercentminusx maxwidth500', 1);
561 print
'<td> </td>';
566 print
'<tr><td>'.$langs->trans(
'Numero');
567 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
569 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'" spellcheck="false"></td></tr>';
572 print
'<tr><td><span class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter').
'</span>';
573 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
575 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'" spellcheck="false"></td></tr>';
578 print
'<tr><td>'.$langs->trans(
'Bank');
579 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
581 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'" spellcheck="false"></td></tr>';
584 print
'<tr><td class="tdtop">'.$langs->trans(
'Comments').
'</td>';
586 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
590 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
591 print
'<tr><td></td>';
592 print
'<td class="tdtop right">';
593 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
606 $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,";
607 $sql .=
" f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr";
608 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
609 $sql .=
" WHERE f.entity IN (".getEntity(
'facture').
")";
610 $sql .=
" AND (f.fk_soc = ".((int) $facture->socid);
612 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
613 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->parent).
")";
617 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->id).
")";
619 $sql .=
") AND f.paye = 0";
620 $sql .=
" AND f.fk_statut = 1";
622 if (!$displayAllInvoices) {
624 $sql .=
" AND type IN (0,1,3,5)";
626 $sql .=
" AND type = 2";
629 if (!
getDolGlobalInt(
'FACTURE_PAYMENTS_INVOICE_REQUESTED_SORT_FIRST')) {
631 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
634 $sql .=
" ORDER BY f.rowid = ".((int) $facid).
" DESC, f.datef ASC, f.ref ASC";
637 $resql =
$db->query($sql);
639 $num =
$db->num_rows($resql);
640 $totalnboflines = $num =
$db->num_rows($resql);
642 $arraytitle = $langs->trans(
'Invoice');
644 $arraytitle = $langs->trans(
"CreditNotes");
646 $alreadypayedlabel = $langs->trans(
'Received');
647 $multicurrencyalreadypayedlabel = $langs->trans(
'Received');
649 $alreadypayedlabel = $langs->trans(
"PaidBack");
650 $multicurrencyalreadypayedlabel = $langs->trans(
"PaidBack");
652 $remaindertopay = $langs->trans(
'RemainderToTake');
653 $multicurrencyremaindertopay = $langs->trans(
'RemainderToTake');
655 $remaindertopay = $langs->trans(
"RemainderToPayBack");
656 $multicurrencyremaindertopay = $langs->trans(
"RemainderToPayBack");
664 if ($action==
'create') {
665 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.$facid.
'&action='.$action.
'&accountid='.$accountid.
'&display-all-invoices=' . (intval(!$displayAllInvoices));
667 if (empty($displayAllInvoices)) {
668 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
670 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
673 $btnTitle = $langs->trans(
'HideOtherInvoices');
675 $btnTitle = $langs->trans(
'HideCreditNotes');
679 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
680 $moreHtmlRight.=
dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
683 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
685 print
'<div class="div-table-responsive-no-min">';
686 print
'<table id="customer-invoices-paiments-list" class="noborder centpercent" data-display-all-invoices="' . (int) $displayAllInvoices .
'" >';
689 print
'<tr class="liste_titre">';
690 print
'<td>'.$arraytitle.
'</td>';
691 if ($displayAllInvoices) {
692 print
'<td>' . $langs->trans(
'Type') .
'</td>';
694 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
695 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
697 $langs->load(
"multicurrency");
698 $labeltoshow =
'<span class="small nowraponall">'.$langs->trans(
"MulticurrencyOriginalCurrency").
'</span>';
699 print
'<td>'.$langs->trans(
'Currency').
'</th>';
700 print
'<td class="right">'.$langs->trans(
'AmountTTC').
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
701 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
702 print
'<td class="right">'.$multicurrencyremaindertopay.
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
703 print
'<td class="center">'.$langs->trans(
'PaymentAmount').
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
705 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
706 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
707 print
'<td class="right">'.$remaindertopay.
'</td>';
708 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
710 $parameters = array();
711 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
713 print
'<td align="right"> </td>';
718 $totalrecucreditnote = 0;
719 $totalrecudeposits = 0;
720 $multicurrency_total_ttc = 0;
721 $multicurrency_totalrecu = 0;
722 $multicurrency_totalrecucreditnote = 0;
723 $multicurrency_totalrecudeposits = 0;
724 $showtotalmulticurrency =
true;
729 $objp =
$db->fetch_object($resql);
737 $soc->fetch($objp->socid);
740 $invoice->fetch($objp->facid);
741 $paiement = $invoice->getSommePaiement();
742 $creditnotes = $invoice->getSumCreditNotesUsed();
743 $deposits = $invoice->getSumDepositsUsed();
744 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
745 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
748 $tooltiponmulticurrencyfullamount =
'';
749 $multicurrency_remaintopay =
'';
750 $multicurrency_payment = 0;
751 $multicurrency_creditnotes = 0;
752 $multicurrency_deposits = 0;
754 $multicurrency_payment = $invoice->getSommePaiement(1);
755 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
756 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
757 $multicurrency_alreadypayed = (float)
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
758 $multicurrency_remaintopay = (float)
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
760 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
761 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
762 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
766 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
767 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
768 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
770 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
772 print
'<td class="nowraponall">';
773 print $invoice->getNomUrl(1,
'');
774 if ($objp->socid != $facture->thirdparty->id) {
775 print
' - '.$soc->getNomUrl(1).
' ';
780 if ($displayAllInvoices) {
788 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
792 print
'<td class="center">'.dol_print_date(
$db->jdate($objp->df),
'day').
"</td>\n";
795 if ($objp->dlr > 0) {
796 print
'<td class="nowraponall center">';
799 if ($invoice->hasDelay()) {
805 print
'<td align="center"></td>';
810 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
815 print
'<td class="right">';
816 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
817 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
819 print
'</span></td>';
822 print
'<td class="right">';
823 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
824 print
price($sign * $multicurrency_payment);
825 if ($multicurrency_creditnotes) {
826 print
'+'.price($multicurrency_creditnotes);
828 if ($multicurrency_deposits) {
829 print
'+'.price($multicurrency_deposits);
835 print
'<td class="right">';
836 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
837 print
price($sign * (
float) $multicurrency_remaintopay);
841 print
'<td class="right nowraponall">';
844 $namef =
'multicurrency_amount_'.$objp->facid;
845 $nameRemain =
'multicurrency_remain_'.$objp->facid;
847 if ($displayAllInvoices) {
855 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
856 if ($action !=
'add_paiement') {
857 if (!empty(
$conf->use_javascript_ajax)) {
858 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">';
859 print
img_picto(
"Auto fill",
'rightarrow.png');
862 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount maxwidth100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
863 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
865 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
866 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
873 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
876 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
878 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
881 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
883 print
'</span></td>';
886 print
'<td class="right">';
887 print
price($sign * (
float) $remaintopay);
889 $numdirectdebitopen = 0;
890 $totaldirectdebit = 0;
891 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
892 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
893 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
894 $sql .=
" AND pfd.traite = 0";
895 $sql .=
" AND pfd.ext_payment_id IS NULL";
897 $result_sql =
$db->query($sql);
899 $obj =
$db->fetch_object($result_sql);
900 $numdirectdebitopen = $obj->nb;
901 $totaldirectdebit = $obj->amount;
905 if ($numdirectdebitopen) {
906 $langs->load(
"withdrawals");
907 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
914 print
'<td class="right nowraponall">';
917 $namef =
'amount_'.$objp->facid;
918 $nameRemain =
'remain_'.$objp->facid;
921 if ($displayAllInvoices) {
929 if ($action !=
'add_paiement') {
930 if (!empty(
$conf->use_javascript_ajax)) {
931 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">';
932 print
img_picto(
"Auto fill",
'rightarrow.png');
935 print
'<input '.$max.
' '.$min.
' type="text" class="amount maxwidth100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
936 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
938 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
943 $parameters = array();
944 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
947 print
'<td align="center" width="16">';
949 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
950 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
951 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
957 $total_ttc += $objp->total_ttc;
958 $totalrecu += $paiement;
959 $totalrecucreditnote += $creditnotes;
960 $totalrecudeposits += $deposits;
963 if (empty($objp->multicurrency_code) || $objp->multicurrency_code ==
getDolCurrency()) {
964 $showtotalmulticurrency =
false;
966 $multicurrency_total_ttc += $objp->multicurrency_total_ttc;
967 $multicurrency_totalrecu += $multicurrency_payment;
968 $multicurrency_totalrecucreditnote += $multicurrency_creditnotes;
969 $multicurrency_totalrecudeposits += $multicurrency_deposits;
979 if ($displayAllInvoices) {
985 print
'<tr class="liste_total">';
986 print
'<td colspan="'.$colspan.
'" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
989 if ($showtotalmulticurrency) {
990 print
'<td class="right"><b>'.price($sign * $multicurrency_total_ttc).
'</b></td>';
991 print
'<td class="right"><b>'.price($sign * $multicurrency_totalrecu);
992 if ($multicurrency_totalrecucreditnote) {
993 print
'+'.price($multicurrency_totalrecucreditnote);
995 if ($multicurrency_totalrecudeposits) {
996 print
'+'.price($multicurrency_totalrecudeposits);
999 print
'<td class="right"><b>'.price($sign * (
float)
price2num($multicurrency_total_ttc - $multicurrency_totalrecu - $multicurrency_totalrecucreditnote - $multicurrency_totalrecudeposits,
'MT')).
'</b></td>';
1000 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
1008 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
1009 print
'<td class="right"><b>'.price($sign * $totalrecu);
1010 if ($totalrecucreditnote) {
1011 print
'+'.price($totalrecucreditnote);
1013 if ($totalrecudeposits) {
1014 print
'+'.price($totalrecudeposits);
1017 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
1018 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
1019 print
'<td align="center"> </td>';
1036 if ($action !=
'add_paiement') {
1037 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
1039 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
1041 $buttontitle = $langs->trans(
'ToMakePayment');
1043 $buttontitle = $langs->trans(
'ToMakePaymentBack');
1046 print
'<br><div class="center">';
1047 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$checkboxlabel.
'</label>';
1048 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
1053 if ($action ==
'add_paiement') {
1054 $preselectedchoice = $addwarning ?
'no' :
'yes';
1058 if (!empty($totalpayment)) {
1059 $text = $langs->trans(
'ConfirmCustomerPayment', (
string) $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
1061 if (!empty($multicurrency_totalpayment)) {
1062 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', (
string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
1064 if (
GETPOST(
'closepaidinvoices')) {
1065 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
1066 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
1068 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
1072 $parameters = array(
'formConfirm' => $formconfirm);
1073 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1074 if (empty($reshook)) {
1075 $formconfirm .= $hookmanager->resPrint;
1076 } elseif ($reshook > 0) {
1077 $formconfirm = $hookmanager->resPrint;
if(! $sortfield) if(! $sortorder) $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.
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
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.