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);
68if (GETPOSTISSET(
'display-all-invoices')) {
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);
139 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
140 if ($amounts[$cursorfacid]) {
142 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
144 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
147 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
148 $langs->load(
"errors");
154 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
155 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
156 $cursorfacid = (int) substr($key, 21);
158 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
159 if (!empty($multicurrency_amounts[$cursorfacid])) {
160 $atleastonepaymentnotnull++;
162 $result = $tmpinvoice->fetch($cursorfacid);
166 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
167 if ($multicurrency_amounts[$cursorfacid]) {
169 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
171 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
174 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
175 $langs->load(
"errors");
181 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
186 if (!
GETPOST(
'paiementcode')) {
187 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
193 if (
GETPOST(
'accountid') <= 0) {
194 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
199 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
200 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
204 if (empty($datepaye)) {
205 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
210 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
211 $langs->load(
"errors");
212 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
220 if ($action ==
'add_paiement') {
230 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
237 $thirdparty->fetch($socid);
240 $multicurrency_code = array();
241 $multicurrency_tx = array();
244 foreach ($amounts as $key => $value) {
246 $tmpinvoice->fetch($key);
249 $amounts[$key] = - abs((
float) $newvalue);
251 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
252 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
255 foreach ($multicurrency_amounts as $key => $value) {
257 $tmpinvoice->fetch((
int) $key);
260 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
262 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
263 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
269 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
276 $paiement->datepaye = $datepaye;
277 $paiement->amounts = $amounts;
278 $paiement->multicurrency_amounts = $multicurrency_amounts;
279 $paiement->multicurrency_code = $multicurrency_code;
280 $paiement->multicurrency_tx = $multicurrency_tx;
281 $paiement->paiementcode =
GETPOST(
'paiementcode',
'alpha');
282 $paiement->paiementid =
dol_getIdFromCode(
$db, $paiement->paiementcode,
'c_paiement',
'code',
'id', 1);
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);
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);
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, multicurrency = 0)
436 var form = $("#payment_form");
437 var keyresult = "result";
439 json["invoice_type"] = $("#invoice_type").val();
441 keyresult = "multicurrency_result";
442 json["multicurrency"] = 1;
443 json["multicurrency_amountPayment"] = $("#multicurrency_amountpayment").attr("value");
444 json["multicurrency_amounts"] = _elemToJson(form.find("input.multicurrency_amount"));
445 json["multicurrency_remains"] = _elemToJson(form.find("input.multicurrency_remain"));
447 json["amountPayment"] = $("#amountpayment").attr("value");
448 json["amounts"] = _elemToJson(form.find("input.amount"));
449 json["remains"] = _elemToJson(form.find("input.remain"));
451 json["token"] = "'.currentToken().
'";
453 json["imgClicked"] = imgId;
456 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
458 json = $.parseJSON(data);
462 for (var key in json)
464 if (key == keyresult) {
465 if (json["makeRed"]) {
466 $("#"+key).addClass("error");
468 $("#"+key).removeClass("error");
470 json[key]=json["label"]+" "+json[key];
471 $("#"+key).text(json[key]);
472 } else {console.log(key);
473 form.find("input[name*=\""+key+"\"]").each(function() {
474 $(this).attr("value", json[key]);
480 $("#payment_form").find("input.amount").change(function() {
483 $("#payment_form").find("input.amount").keyup(function() {
487 $("#payment_form").find("input.multicurrency_amount").change(function() {
488 callForResult(null, 1);
490 $("#payment_form").find("input.multicurrency_amount").keyup(function() {
491 callForResult(null, 1);
498 print
' $(document).ready(function () {';
499 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
501 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
505 print
' </script>'.
"\n";
508 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
509 print
'<input type="hidden" name="token" value="'.newToken().
'">';
510 print
'<input type="hidden" name="action" value="add_paiement">';
511 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
512 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
513 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
514 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
515 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
516 print
'<input type="hidden" name="page_y" value="">';
520 print
'<table class="border centpercent">';
523 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
526 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
528 $datepayment = ($datepayment ==
'' ? (
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datepayment);
529 $adddateof = array(array(
'adddateof'=>$facture->date));
530 $adddateof[] = array(
'adddateof'=>$facture->date_lim_reglement,
'labeladddateof'=>$langs->transnoentities(
'DateDue'));
531 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_paiement", 1, 1, 0,
'',
'', $adddateof);
535 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
536 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
543 if ($facture->type != 2) {
544 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
546 if ($facture->type == 2) {
547 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
551 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
552 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', (
isModEnabled(
'multicurrency') ? 1 : 0),
'widthcentpercentminusx maxwidth500', 1);
555 print
'<td> </td>';
560 print
'<tr><td>'.$langs->trans(
'Numero');
561 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
563 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'" spellcheck="false"></td></tr>';
566 print
'<tr><td><span class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter').
'</span>';
567 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
569 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'" spellcheck="false"></td></tr>';
572 print
'<tr><td>'.$langs->trans(
'Bank');
573 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
575 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'" spellcheck="false"></td></tr>';
578 print
'<tr><td class="tdtop">'.$langs->trans(
'Comments').
'</td>';
580 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
584 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
585 print
'<tr><td></td>';
586 print
'<td class="tdtop right">';
587 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
600 $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,";
601 $sql .=
" f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr";
602 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
603 $sql .=
" WHERE f.entity IN (".getEntity(
'facture').
")";
604 $sql .=
" AND (f.fk_soc = ".((int) $facture->socid);
606 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
607 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->parent).
")";
611 $sql .=
" OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe WHERE parent = ".((int) $facture->thirdparty->id).
")";
613 $sql .=
") AND f.paye = 0";
614 $sql .=
" AND f.fk_statut = 1";
616 if (!$displayAllInvoices) {
618 $sql .=
" AND type IN (0,1,3,5)";
620 $sql .=
" AND type = 2";
623 if (!
getDolGlobalInt(
'FACTURE_PAYMENTS_INVOICE_REQUESTED_SORT_FIRST')) {
625 $sql .=
" ORDER BY f.datef ASC, f.ref ASC";
628 $sql .=
" ORDER BY f.rowid = ".((int) $facid).
" DESC, f.datef ASC, f.ref ASC";
631 $resql =
$db->query($sql);
633 $num =
$db->num_rows($resql);
634 $totalnboflines = $num =
$db->num_rows($resql);
636 $arraytitle = $langs->trans(
'Invoice');
638 $arraytitle = $langs->trans(
"CreditNotes");
640 $alreadypayedlabel = $langs->trans(
'Received');
641 $multicurrencyalreadypayedlabel = $langs->trans(
'Received');
643 $alreadypayedlabel = $langs->trans(
"PaidBack");
644 $multicurrencyalreadypayedlabel = $langs->trans(
"PaidBack");
646 $remaindertopay = $langs->trans(
'RemainderToTake');
647 $multicurrencyremaindertopay = $langs->trans(
'RemainderToTake');
649 $remaindertopay = $langs->trans(
"RemainderToPayBack");
650 $multicurrencyremaindertopay = $langs->trans(
"RemainderToPayBack");
658 if ($action==
'create') {
659 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.$facid.
'&action='.$action.
'&accountid='.$accountid.
'&display-all-invoices=' . (intval(!$displayAllInvoices));
661 if (empty($displayAllInvoices)) {
662 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
664 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
667 $btnTitle = $langs->trans(
'HideOtherInvoices');
669 $btnTitle = $langs->trans(
'HideCreditNotes');
673 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
674 $moreHtmlRight.= dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
677 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
679 print
'<div class="div-table-responsive-no-min">';
680 print
'<table id="customer-invoices-paiments-list" class="noborder centpercent" data-display-all-invoices="' . (int) $displayAllInvoices .
'" >';
683 print
'<tr class="liste_titre">';
684 print
'<td>'.$arraytitle.
'</td>';
685 if ($displayAllInvoices) {
686 print
'<td>' . $langs->trans(
'Type') .
'</td>';
688 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
689 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
691 $langs->load(
"multicurrency");
692 $labeltoshow =
'<span class="small nowraponall">'.$langs->trans(
"MulticurrencyOriginalCurrency").
'</span>';
693 print
'<td>'.$langs->trans(
'Currency').
'</th>';
694 print
'<td class="right">'.$langs->trans(
'AmountTTC').
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
695 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
696 print
'<td class="right">'.$multicurrencyremaindertopay.
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
697 print
'<td class="center">'.$langs->trans(
'PaymentAmount').
' <span class="opacitymedium">('.$labeltoshow.
')</span></td>';
699 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
700 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
701 print
'<td class="right">'.$remaindertopay.
'</td>';
702 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
704 $parameters = array();
705 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
707 print
'<td align="right"> </td>';
712 $totalrecucreditnote = 0;
713 $totalrecudeposits = 0;
714 $multicurrency_total_ttc = 0;
715 $multicurrency_totalrecu = 0;
716 $multicurrency_totalrecucreditnote = 0;
717 $multicurrency_totalrecudeposits = 0;
718 $showtotalmulticurrency =
true;
723 $objp =
$db->fetch_object($resql);
731 $soc->fetch($objp->socid);
734 $invoice->fetch($objp->facid);
735 $paiement = $invoice->getSommePaiement();
736 $creditnotes = $invoice->getSumCreditNotesUsed();
737 $deposits = $invoice->getSumDepositsUsed();
738 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
739 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
742 $tooltiponmulticurrencyfullamount =
'';
743 $multicurrency_remaintopay =
'';
744 $multicurrency_payment = 0;
745 $multicurrency_creditnotes = 0;
746 $multicurrency_deposits = 0;
748 $multicurrency_payment = $invoice->getSommePaiement(1);
749 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
750 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
751 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
752 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
754 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
755 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
756 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
760 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
761 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
762 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
764 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
766 print
'<td class="nowraponall">';
767 print $invoice->getNomUrl(1,
'');
768 if ($objp->socid != $facture->thirdparty->id) {
769 print
' - '.$soc->getNomUrl(1).
' ';
774 if ($displayAllInvoices) {
782 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
786 print
'<td class="center">'.dol_print_date(
$db->jdate($objp->df),
'day').
"</td>\n";
789 if ($objp->dlr > 0) {
790 print
'<td class="nowraponall center">';
793 if ($invoice->hasDelay()) {
799 print
'<td align="center"></td>';
804 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
809 print
'<td class="right">';
810 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
811 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
813 print
'</span></td>';
816 print
'<td class="right">';
817 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
818 print
price($sign * $multicurrency_payment);
819 if ($multicurrency_creditnotes) {
820 print
'+'.price($multicurrency_creditnotes);
822 if ($multicurrency_deposits) {
823 print
'+'.price($multicurrency_deposits);
829 print
'<td class="right">';
830 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
831 print
price($sign * (
float) $multicurrency_remaintopay);
835 print
'<td class="right nowraponall">';
838 $namef =
'multicurrency_amount_'.$objp->facid;
839 $nameRemain =
'multicurrency_remain_'.$objp->facid;
841 if ($displayAllInvoices) {
849 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
850 if ($action !=
'add_paiement') {
851 if (!empty(
$conf->use_javascript_ajax)) {
852 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">';
853 print
img_picto(
"Auto fill",
'rightarrow.png');
856 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount maxwidth100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
857 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
859 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
860 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
867 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
870 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
872 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
875 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
877 print
'</span></td>';
880 print
'<td class="right">';
881 print
price($sign * (
float) $remaintopay);
883 $numdirectdebitopen = 0;
884 $totaldirectdebit = 0;
885 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
886 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
887 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
888 $sql .=
" AND pfd.traite = 0";
889 $sql .=
" AND pfd.ext_payment_id IS NULL";
891 $result_sql =
$db->query($sql);
893 $obj =
$db->fetch_object($result_sql);
894 $numdirectdebitopen = $obj->nb;
895 $totaldirectdebit = $obj->amount;
899 if ($numdirectdebitopen) {
900 $langs->load(
"withdrawals");
901 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
908 print
'<td class="right nowraponall">';
911 $namef =
'amount_'.$objp->facid;
912 $nameRemain =
'remain_'.$objp->facid;
915 if ($displayAllInvoices) {
923 if ($action !=
'add_paiement') {
924 if (!empty(
$conf->use_javascript_ajax)) {
925 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">';
926 print
img_picto(
"Auto fill",
'rightarrow.png');
929 print
'<input '.$max.
' '.$min.
' type="text" class="amount maxwidth100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
930 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
932 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
937 $parameters = array();
938 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
941 print
'<td align="center" width="16">';
943 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
944 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
945 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
951 $total_ttc += $objp->total_ttc;
952 $totalrecu += $paiement;
953 $totalrecucreditnote += $creditnotes;
954 $totalrecudeposits += $deposits;
957 if (empty($objp->multicurrency_code) || $objp->multicurrency_code ==
getDolCurrency()) {
958 $showtotalmulticurrency =
false;
960 $multicurrency_total_ttc += $objp->multicurrency_total_ttc;
961 $multicurrency_totalrecu += $multicurrency_payment;
962 $multicurrency_totalrecucreditnote += $multicurrency_creditnotes;
963 $multicurrency_totalrecudeposits += $multicurrency_deposits;
973 if ($displayAllInvoices) {
979 print
'<tr class="liste_total">';
980 print
'<td colspan="'.$colspan.
'" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
983 if ($showtotalmulticurrency) {
984 print
'<td class="right"><b>'.price($sign * $multicurrency_total_ttc).
'</b></td>';
985 print
'<td class="right"><b>'.price($sign * $multicurrency_totalrecu);
986 if ($multicurrency_totalrecucreditnote) {
987 print
'+'.price($multicurrency_totalrecucreditnote);
989 if ($multicurrency_totalrecudeposits) {
990 print
'+'.price($multicurrency_totalrecudeposits);
993 print
'<td class="right"><b>'.price($sign * (
float)
price2num($multicurrency_total_ttc - $multicurrency_totalrecu - $multicurrency_totalrecucreditnote - $multicurrency_totalrecudeposits,
'MT')).
'</b></td>';
994 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
1002 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
1003 print
'<td class="right"><b>'.price($sign * $totalrecu);
1004 if ($totalrecucreditnote) {
1005 print
'+'.price($totalrecucreditnote);
1007 if ($totalrecudeposits) {
1008 print
'+'.price($totalrecudeposits);
1011 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
1012 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
1013 print
'<td align="center"> </td>';
1030 if ($action !=
'add_paiement') {
1031 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
1033 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
1035 $buttontitle = $langs->trans(
'ToMakePayment');
1037 $buttontitle = $langs->trans(
'ToMakePaymentBack');
1040 print
'<br><div class="center">';
1041 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$checkboxlabel.
'</label>';
1042 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
1047 if ($action ==
'add_paiement') {
1048 $preselectedchoice = $addwarning ?
'no' :
'yes';
1052 if (!empty($totalpayment)) {
1053 $text = $langs->trans(
'ConfirmCustomerPayment', (
string) $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
1055 if (!empty($multicurrency_totalpayment)) {
1056 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', (
string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
1058 if (
GETPOST(
'closepaidinvoices')) {
1059 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
1060 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
1062 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
1066 $parameters = array(
'formConfirm' => $formconfirm);
1067 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1068 if (empty($reshook)) {
1069 $formconfirm .= $hookmanager->resPrint;
1070 } elseif ($reshook > 0) {
1071 $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.
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 '.
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.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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.