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();
126 $tmpinvoice =
new Facture($db);
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) {
235 $thirdparty =
new Societe($db);
237 $thirdparty->fetch($socid);
240 $multicurrency_code = array();
241 $multicurrency_tx = array();
244 foreach ($amounts as $key => $value) {
245 $tmpinvoice =
new Facture($db);
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) {
256 $tmpinvoice =
new Facture($db);
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);
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);
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);
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.
'" spellcheck="false"></td></tr>';
550 print
'<tr><td><span class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter').
'</span>';
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').
'" spellcheck="false"></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').
'" spellcheck="false"></td></tr>';
562 print
'<tr><td class="tdtop">'.$langs->trans(
'Comments').
'</td>';
564 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.
'">'.
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(
'Received');
627 $alreadypayedlabel = $langs->trans(
"PaidBack");
628 $multicurrencyalreadypayedlabel = $langs->trans(
"PaidBack");
630 $remaindertopay = $langs->trans(
'RemainderToTake');
631 $multicurrencyremaindertopay = $langs->trans(
'RemainderToTake');
633 $remaindertopay = $langs->trans(
"RemainderToPayBack");
634 $multicurrencyremaindertopay = $langs->trans(
"RemainderToPayBack");
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>';
675 $langs->load(
"multicurrency");
676 $labeltoshow =
'<span class="small nowraponall">'.$langs->trans(
"MulticurrencyOriginalCurrency").
'</span>';
677 print
'<th>'.$langs->trans(
'Currency').
'</th>';
678 print
'<th class="right">'.$langs->trans(
'AmountTTC').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
679 print
'<th class="right">'.$multicurrencyalreadypayedlabel.
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
680 print
'<th class="right">'.$multicurrencyremaindertopay.
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
681 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
683 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
684 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
685 print
'<td class="right">'.$remaindertopay.
'</td>';
686 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
688 $parameters = array();
689 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
691 print
'<td align="right"> </td>';
696 $totalrecucreditnote = 0;
697 $totalrecudeposits = 0;
698 $multicurrency_total_ttc = 0;
699 $multicurrency_totalrecu = 0;
700 $multicurrency_totalrecucreditnote = 0;
701 $multicurrency_totalrecudeposits = 0;
702 $showtotalmulticurrency =
true;
707 $objp = $db->fetch_object($resql);
715 $soc->fetch($objp->socid);
718 $invoice->fetch($objp->facid);
719 $paiement = $invoice->getSommePaiement();
720 $creditnotes = $invoice->getSumCreditNotesUsed();
721 $deposits = $invoice->getSumDepositsUsed();
722 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
723 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
726 $tooltiponmulticurrencyfullamount =
'';
727 $multicurrency_remaintopay =
'';
728 $multicurrency_payment = 0;
729 $multicurrency_creditnotes = 0;
730 $multicurrency_deposits = 0;
732 $multicurrency_payment = $invoice->getSommePaiement(1);
733 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
734 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
735 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
736 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
738 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
739 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
740 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
744 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
745 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
746 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
748 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
750 print
'<td class="nowraponall">';
751 print $invoice->getNomUrl(1,
'');
752 if ($objp->socid != $facture->thirdparty->id) {
753 print
' - '.$soc->getNomUrl(1).
' ';
758 if ($displayAllInvoices) {
766 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
770 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
773 if ($objp->dlr > 0) {
774 print
'<td class="nowraponall center">';
777 if ($invoice->hasDelay()) {
783 print
'<td align="center"></td>';
788 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
793 print
'<td class="right">';
794 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
795 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
797 print
'</span></td>';
800 print
'<td class="right">';
801 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
802 print
price($sign * $multicurrency_payment);
803 if ($multicurrency_creditnotes) {
804 print
'+'.price($multicurrency_creditnotes);
806 if ($multicurrency_deposits) {
807 print
'+'.price($multicurrency_deposits);
813 print
'<td class="right">';
814 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
815 print
price($sign * (
float) $multicurrency_remaintopay);
819 print
'<td class="right nowraponall">';
822 $namef =
'multicurrency_amount_'.$objp->facid;
823 $nameRemain =
'multicurrency_remain_'.$objp->facid;
825 if ($displayAllInvoices) {
833 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
834 if ($action !=
'add_paiement') {
835 if (!empty($conf->use_javascript_ajax)) {
836 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">';
837 print
img_picto(
"Auto fill",
'rightarrow.png');
840 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount maxwidth100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
841 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
843 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
844 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
851 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
854 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
856 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
859 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
861 print
'</span></td>';
864 print
'<td class="right">';
865 print
price($sign * (
float) $remaintopay);
867 $numdirectdebitopen = 0;
868 $totaldirectdebit = 0;
869 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
870 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
871 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
872 $sql .=
" AND pfd.traite = 0";
873 $sql .=
" AND pfd.ext_payment_id IS NULL";
875 $result_sql = $db->query($sql);
877 $obj = $db->fetch_object($result_sql);
878 $numdirectdebitopen = $obj->nb;
879 $totaldirectdebit = $obj->amount;
883 if ($numdirectdebitopen) {
884 $langs->load(
"withdrawals");
885 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1, $conf->currency)),
'',
'classfortooltip');
892 print
'<td class="right nowraponall">';
895 $namef =
'amount_'.$objp->facid;
896 $nameRemain =
'remain_'.$objp->facid;
899 if ($displayAllInvoices) {
907 if ($action !=
'add_paiement') {
908 if (!empty($conf->use_javascript_ajax)) {
909 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">';
910 print
img_picto(
"Auto fill",
'rightarrow.png');
913 print
'<input '.$max.
' '.$min.
' type="text" class="amount maxwidth100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
914 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
916 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
921 $parameters = array();
922 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
925 print
'<td align="center" width="16">';
927 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
928 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
929 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
935 $total_ttc += $objp->total_ttc;
936 $totalrecu += $paiement;
937 $totalrecucreditnote += $creditnotes;
938 $totalrecudeposits += $deposits;
941 if (empty($objp->multicurrency_code) || $objp->multicurrency_code ==
getDolCurrency()) {
942 $showtotalmulticurrency =
false;
944 $multicurrency_total_ttc += $objp->multicurrency_total_ttc;
945 $multicurrency_totalrecu += $multicurrency_payment;
946 $multicurrency_totalrecucreditnote += $multicurrency_creditnotes;
947 $multicurrency_totalrecudeposits += $multicurrency_deposits;
957 if ($displayAllInvoices) {
963 print
'<tr class="liste_total">';
964 print
'<td colspan="'.$colspan.
'" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
967 if ($showtotalmulticurrency) {
968 print
'<td class="right"><b>'.price($sign * $multicurrency_total_ttc).
'</b></td>';
969 print
'<td class="right"><b>'.price($sign * $multicurrency_totalrecu);
970 if ($multicurrency_totalrecucreditnote) {
971 print
'+'.price($multicurrency_totalrecucreditnote);
973 if ($multicurrency_totalrecudeposits) {
974 print
'+'.price($multicurrency_totalrecudeposits);
977 print
'<td class="right"><b>'.price($sign * (
float)
price2num($multicurrency_total_ttc - $multicurrency_totalrecu - $multicurrency_totalrecucreditnote - $multicurrency_totalrecudeposits,
'MT')).
'</b></td>';
978 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
986 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
987 print
'<td class="right"><b>'.price($sign * $totalrecu);
988 if ($totalrecucreditnote) {
989 print
'+'.price($totalrecucreditnote);
991 if ($totalrecudeposits) {
992 print
'+'.price($totalrecudeposits);
995 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
996 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
997 print
'<td align="center"> </td>';
1014 if ($action !=
'add_paiement') {
1015 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
1017 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
1019 $buttontitle = $langs->trans(
'ToMakePayment');
1021 $buttontitle = $langs->trans(
'ToMakePaymentBack');
1024 print
'<br><div class="center">';
1025 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$checkboxlabel.
'</label>';
1026 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
1031 if ($action ==
'add_paiement') {
1032 $preselectedchoice = $addwarning ?
'no' :
'yes';
1036 if (!empty($totalpayment)) {
1037 $text = $langs->trans(
'ConfirmCustomerPayment', (
string) $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
1039 if (!empty($multicurrency_totalpayment)) {
1040 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', (
string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
1042 if (
GETPOST(
'closepaidinvoices')) {
1043 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
1044 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
1046 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
1050 $parameters = array(
'formConfirm' => $formconfirm);
1051 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1052 if (empty($reshook)) {
1053 $formconfirm .= $hookmanager->resPrint;
1054 } elseif ($reshook > 0) {
1055 $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 '.
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.
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...
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left 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 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.