38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
42require_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');
68$amountsresttopay = array();
71$multicurrency_amounts = array();
72$multicurrency_amountsresttopay = array();
75if ($user->socid > 0) {
76 $socid = $user->socid;
87$hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
89$formquestion = array();
91$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
103$parameters = array(
'socid' => $socid);
104$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110if (empty($reshook)) {
111 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
114 $multicurrency_totalpayment = 0;
115 $atleastonepaymentnotnull = 0;
116 $formquestion = array();
120 $tmpinvoice =
new Facture($db);
121 foreach ($_POST as $key => $value) {
122 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
123 $cursorfacid = substr($key, 7);
125 if (!empty($amounts[$cursorfacid])) {
126 $totalpayment += (float) $amounts[$cursorfacid];
127 $atleastonepaymentnotnull++;
129 $result = $tmpinvoice->fetch($cursorfacid);
133 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
134 if ($amounts[$cursorfacid]) {
136 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
138 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
141 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
142 $langs->load(
"errors");
148 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
149 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
150 $cursorfacid = substr($key, 21);
152 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
153 if (!empty($multicurrency_amounts[$cursorfacid])) {
154 $atleastonepaymentnotnull++;
156 $result = $tmpinvoice->fetch($cursorfacid);
160 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
161 if ($multicurrency_amounts[$cursorfacid]) {
163 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
165 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
168 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
169 $langs->load(
"errors");
175 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTINT($key));
180 if (!
GETPOST(
'paiementcode')) {
181 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
185 if (isModEnabled(
"bank")) {
187 if (
GETPOST(
'accountid') <= 0) {
188 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
193 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
194 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
198 if (empty($datepaye)) {
199 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
204 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
205 $langs->load(
"errors");
206 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
214 if ($action ==
'add_paiement') {
224 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
229 $thirdparty =
new Societe($db);
231 $thirdparty->fetch($socid);
234 $multicurrency_code = array();
235 $multicurrency_tx = array();
238 foreach ($amounts as $key => $value) {
239 $tmpinvoice =
new Facture($db);
240 $tmpinvoice->fetch($key);
243 $amounts[$key] = - abs((
float) $newvalue);
245 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
246 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
249 foreach ($multicurrency_amounts as $key => $value) {
250 $tmpinvoice =
new Facture($db);
251 $tmpinvoice->fetch($key);
254 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
256 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
257 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
260 if (isModEnabled(
"bank")) {
263 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
270 $paiement->datepaye = $datepaye;
271 $paiement->amounts = $amounts;
272 $paiement->multicurrency_amounts = $multicurrency_amounts;
273 $paiement->multicurrency_code = $multicurrency_code;
274 $paiement->multicurrency_tx = $multicurrency_tx;
276 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
277 $paiement->note_private =
GETPOST(
'comment',
'alpha');
278 $paiement->fk_account =
GETPOSTINT(
'accountid');
285 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
286 if ($paiement_id < 0) {
298 $label =
'(CustomerInvoicePayment)';
300 $label =
'(CustomerInvoicePaymentBack)';
303 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOSTINT(
'accountid'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
315 foreach ($paiement->amounts as $key => $amount) {
317 if (is_numeric($amount) && $amount != 0) {
318 if ($invoiceid != 0) {
325 if ($invoiceid > 0) {
326 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
328 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
330 header(
'Location: '.$loc);
343$form =
new Form($db);
350 $result = $facture->fetch($facid);
353 $facture->fetch_thirdparty();
357 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
360 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
365 if ($action ==
'add_paiement') {
368 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
369 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
370 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
375 if (isModEnabled(
'paypalplus') &&
getDolGlobalString(
'PAYPAL_ENABLE_TRANSACTION_MANAGEMENT') && !empty($facture->ref_ext)) {
379 $paymentnum = $facture->ref_ext;
383 if (!empty(
$conf->use_javascript_ajax)) {
384 print
"\n".
'<script type="text/javascript">';
385 print
'$(document).ready(function () {
388 $("#selectpaiementcode").change(function() {
392 function setPaiementCode()
394 var code = $("#selectpaiementcode option:selected").val();
395 console.log("setPaiementCode code="+code);
397 if (code == \'CHQ\' || code == \'VIR\')
401 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
403 if ($(\'#fieldchqemetteur\').val() == \'\')
406 $(\'#fieldchqemetteur\').val(emetteur);
411 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
412 $(\'#fieldchqemetteur\').val(\'\');
416 function _elemToJson(selector)
419 $.map(selector.serializeArray(), function(n,i)
421 subJson[n["name"]] = n["value"];
426 function callForResult(imgId)
429 var form = $("#payment_form");
431 json["invoice_type"] = $("#invoice_type").val();
432 json["amountPayment"] = $("#amountpayment").attr("value");
433 json["amounts"] = _elemToJson(form.find("input.amount"));
434 json["remains"] = _elemToJson(form.find("input.remain"));
437 json["imgClicked"] = imgId;
440 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
442 json = $.parseJSON(data);
446 for (var key in json)
448 if (key == "result") {
449 if (json["makeRed"]) {
450 $("#"+key).addClass("error");
452 $("#"+key).removeClass("error");
454 json[key]=json["label"]+" "+json[key];
455 $("#"+key).text(json[key]);
456 } else {console.log(key);
457 form.find("input[name*=\""+key+"\"]").each(function() {
458 $(this).attr("value", json[key]);
464 $("#payment_form").find("input.amount").change(function() {
467 $("#payment_form").find("input.amount").keyup(function() {
475 print
' $(document).ready(function () {';
476 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
477 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
481 print
' </script>'.
"\n";
484 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
485 print
'<input type="hidden" name="token" value="'.newToken().
'">';
486 print
'<input type="hidden" name="action" value="add_paiement">';
487 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
488 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
489 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
490 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
491 print
'<input type="hidden" name="page_y" value="">';
495 print
'<table class="border centpercent">';
498 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
501 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
503 $datepayment = ($datepayment ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datepayment);
504 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_paiement", 1, 1, 0,
'',
'', $facture->date);
508 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
509 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
515 if (isModEnabled(
"bank")) {
516 if ($facture->type != 2) {
517 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
519 if ($facture->type == 2) {
520 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
524 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
525 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', (isModEnabled(
'multicurrency') ? 1 : 0),
'widthcentpercentminusx maxwidth500', 1);
528 print
'<td> </td>';
533 print
'<tr><td>'.$langs->trans(
'Numero');
534 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
536 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
539 print
'<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
540 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
542 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
545 print
'<tr><td>'.$langs->trans(
'Bank');
546 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
548 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
551 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
552 print
'<td class="tdtop">';
553 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
557 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
558 print
'<tr><td></td>';
559 print
'<td class="tdtop right">';
560 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
573 $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,';
574 $sql .=
' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
575 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture as f';
576 $sql .=
' WHERE f.entity IN ('.getEntity(
'facture').
')';
577 $sql .=
' AND (f.fk_soc = '.((int) $facture->socid);
579 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
580 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->parent).
')';
584 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->id).
')';
586 $sql .=
') AND f.paye = 0';
587 $sql .=
' AND f.fk_statut = 1';
589 $sql .=
' AND type IN (0,1,3,5)';
591 $sql .=
' AND type = 2';
594 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
596 $resql = $db->query($sql);
598 $num = $db->num_rows($resql);
600 $arraytitle = $langs->trans(
'Invoice');
601 if ($facture->type == 2) {
602 $arraytitle = $langs->trans(
"CreditNotes");
604 $alreadypayedlabel = $langs->trans(
'Received');
605 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
606 if ($facture->type == 2) {
607 $alreadypayedlabel = $langs->trans(
"PaidBack");
608 $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack");
610 $remaindertopay = $langs->trans(
'RemainderToTake');
611 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
612 if ($facture->type == 2) {
613 $remaindertopay = $langs->trans(
"RemainderToPayBack");
614 $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack");
621 print
'<div class="div-table-responsive-no-min">';
622 print
'<table class="noborder centpercent">';
624 print
'<tr class="liste_titre">';
625 print
'<td>'.$arraytitle.
'</td>';
626 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
627 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
628 if (isModEnabled(
'multicurrency')) {
629 print
'<td>'.$langs->trans(
'Currency').
'</td>';
630 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
631 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
632 print
'<td class="right">'.$multicurrencyremaindertopay.
'</td>';
633 print
'<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
635 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
636 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
637 print
'<td class="right">'.$remaindertopay.
'</td>';
638 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
640 $parameters = array();
641 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
643 print
'<td align="right"> </td>';
648 $totalrecucreditnote = 0;
649 $totalrecudeposits = 0;
653 $objp = $db->fetch_object($resql);
661 $soc->fetch($objp->socid);
664 $invoice->fetch($objp->facid);
665 $paiement = $invoice->getSommePaiement();
666 $creditnotes = $invoice->getSumCreditNotesUsed();
667 $deposits = $invoice->getSumDepositsUsed();
668 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
669 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
672 $tooltiponmulticurrencyfullamount =
'';
673 $multicurrency_remaintopay =
'';
674 $multicurrency_payment = 0;
675 $multicurrency_creditnotes = 0;
676 $multicurrency_deposits = 0;
677 if (isModEnabled(
'multicurrency')) {
678 $multicurrency_payment = $invoice->getSommePaiement(1);
679 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
680 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
681 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
682 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
684 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
685 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
686 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
690 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
691 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
692 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
694 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
696 print
'<td class="nowraponall">';
697 print $invoice->getNomUrl(1,
'');
698 if ($objp->socid != $facture->thirdparty->id) {
699 print
' - '.$soc->getNomUrl(1).
' ';
704 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
707 if ($objp->dlr > 0) {
708 print
'<td class="nowraponall center">';
711 if ($invoice->hasDelay()) {
717 print
'<td align="center"></td>';
721 if (isModEnabled(
'multicurrency')) {
722 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
726 if (isModEnabled(
'multicurrency')) {
727 print
'<td class="right">';
728 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
729 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
731 print
'</span></td>';
734 print
'<td class="right">';
735 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
736 print
price($sign * $multicurrency_payment);
737 if ($multicurrency_creditnotes) {
738 print
'+'.price($multicurrency_creditnotes);
740 if ($multicurrency_deposits) {
741 print
'+'.price($multicurrency_deposits);
747 print
'<td class="right">';
748 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
749 print
price($sign * (
float) $multicurrency_remaintopay);
753 print
'<td class="right nowraponall">';
756 $namef =
'multicurrency_amount_'.$objp->facid;
757 $nameRemain =
'multicurrency_remain_'.$objp->facid;
759 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
760 if ($action !=
'add_paiement') {
761 if (!empty(
$conf->use_javascript_ajax)) {
762 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $multicurrency_remaintopay).
"'");
764 print
'<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.
'" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'">';
765 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
767 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
768 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
775 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
778 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
780 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
783 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
785 print
'</span></td>';
788 print
'<td class="right">';
789 print
price($sign * (
float) $remaintopay);
790 if (isModEnabled(
'prelevement')) {
791 $numdirectdebitopen = 0;
792 $totaldirectdebit = 0;
793 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
794 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
795 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
796 $sql .=
" AND pfd.traite = 0";
797 $sql .=
" AND pfd.ext_payment_id IS NULL";
799 $result_sql = $db->query($sql);
801 $obj = $db->fetch_object($result_sql);
802 $numdirectdebitopen = $obj->nb;
803 $totaldirectdebit = $obj->amount;
807 if ($numdirectdebitopen) {
808 $langs->load(
"withdrawals");
809 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
816 print
'<td class="right nowraponall">';
819 $namef =
'amount_'.$objp->facid;
820 $nameRemain =
'remain_'.$objp->facid;
822 if ($action !=
'add_paiement') {
823 if (!empty(
$conf->use_javascript_ajax)) {
824 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $remaintopay).
"'");
826 print
'<input type="text" class="maxwidth75 amount" id="'.$namef.
'" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
827 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
829 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
834 $parameters = array();
835 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
838 print
'<td align="center" width="16">';
840 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
841 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
842 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
848 $total_ttc += $objp->total_ttc;
849 $totalrecu += $paiement;
850 $totalrecucreditnote += $creditnotes;
851 $totalrecudeposits += $deposits;
857 print
'<tr class="liste_total">';
858 print
'<td colspan="3" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
859 if (isModEnabled(
'multicurrency')) {
864 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
866 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
867 print
'<td class="right"><b>'.price($sign * $totalrecu);
868 if ($totalrecucreditnote) {
869 print
'+'.price($totalrecucreditnote);
871 if ($totalrecudeposits) {
872 print
'+'.price($totalrecudeposits);
875 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
876 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
877 print
'<td align="center"> </td>';
891 if ($action !=
'add_paiement') {
892 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
894 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
896 $buttontitle = $langs->trans(
'ToMakePayment');
898 $buttontitle = $langs->trans(
'ToMakePaymentBack');
901 print
'<br><div class="center">';
902 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices"><label for="closepaidinvoices"> '.$checkboxlabel.
'</label>';
909 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
914 if ($action ==
'add_paiement') {
915 $preselectedchoice = $addwarning ?
'no' :
'yes';
919 if (!empty($totalpayment)) {
920 $text = $langs->trans(
'ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
922 if (!empty($multicurrency_totalpayment)) {
923 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
925 if (
GETPOST(
'closepaidinvoices')) {
926 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
927 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
929 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
933 $parameters = array(
'formConfirm' => $formconfirm);
934 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
935 if (empty($reshook)) {
936 $formconfirm .= $hookmanager->resPrint;
937 } elseif ($reshook > 0) {
938 $formconfirm = $hookmanager->resPrint;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.