39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
48$langs->loadLangs(array(
'companies',
'bills',
'banks',
'compta'));
50$action =
GETPOST(
'action',
'alpha');
51$confirm =
GETPOST(
'confirm',
'alpha');
52$optioncss =
GETPOST(
'optioncss',
'alpha');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
64$search_ref =
GETPOST(
'search_ref',
'alpha');
65$search_account =
GETPOST(
'search_account',
'alpha');
66$search_paymenttype =
GETPOST(
'search_paymenttype');
67$search_amount =
GETPOST(
'search_amount',
'alpha');
68$search_company =
GETPOST(
'search_company',
'alpha');
69$search_payment_num =
GETPOST(
'search_payment_num',
'alpha');
72$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
75if (empty($page) || $page == -1) {
78$offset = $limit * $page;
85 $sortfield =
"p.rowid";
89$amountsresttopay = array();
92$multicurrency_amounts = array();
93$multicurrency_amountsresttopay = array();
96if ($user->socid > 0) {
97 $socid = $user->socid;
103$hookmanager->initHooks(array(
'paymentsupplierlist'));
107$extrafields->fetch_name_optionals_label(
$object->table_element);
109$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
111$arrayfields = array();
113$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
121 if (!empty($backtopageforcancel)) {
122 header(
"Location: ".$backtopageforcancel);
124 } elseif (!empty($backtopage)) {
125 header(
"Location: ".$backtopage);
128 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/list.php');
132if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
134 $search_account =
"";
136 $search_paymenttype =
"";
137 $search_payment_num =
"";
138 $search_company =
"";
142 $search_array_options = array();
145$parameters = array(
'socid' => $socid);
146$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
151if (empty($reshook)) {
152 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $permissiontoadd) {
158 $atleastonepaymentnotnull = 0;
159 $multicurrency_totalpayment = 0;
160 $formquestion = array();
164 foreach ($_POST as $key => $value) {
165 if (substr($key, 0, 7) ==
'amount_') {
166 $cursorfacid = substr($key, 7);
168 if (!empty($amounts[$cursorfacid])) {
169 $atleastonepaymentnotnull++;
170 if (is_numeric($amounts[$cursorfacid])) {
171 $totalpayment += (float) $amounts[$cursorfacid];
176 $result = $tmpinvoice->fetch($cursorfacid);
180 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
181 if ($amounts[$cursorfacid]) {
183 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
185 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
188 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
189 $langs->load(
"errors");
195 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
196 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
197 $cursorfacid = substr($key, 21);
199 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
200 if (!empty($multicurrency_amounts[$cursorfacid])) {
201 $atleastonepaymentnotnull++;
203 $result = $tmpinvoice->fetch($cursorfacid);
207 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
208 if ($multicurrency_amounts[$cursorfacid]) {
210 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
212 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
215 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
216 $langs->load(
"errors");
222 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTINT($key));
227 if (
GETPOST(
'paiementid') <= 0) {
228 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
232 if (isModEnabled(
"bank")) {
234 if (
GETPOST(
'accountid') <= 0) {
235 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
240 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
241 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
245 if (empty($datepaye)) {
246 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
251 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
252 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
260 if ($action ==
'add_paiement') {
271 if ($action ==
'confirm_paiement' && $confirm ==
'yes') {
276 $multicurrency_code = array();
277 $multicurrency_tx = array();
280 foreach ($amounts as $key => $value) {
282 $tmpinvoice->fetch($key);
285 $amounts[$key] = - abs((
float) $newvalue);
287 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
288 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
291 foreach ($multicurrency_amounts as $key => $value) {
293 $tmpinvoice->fetch($key);
296 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
298 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
299 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
309 $thirdparty =
new Societe($db);
311 $thirdparty->fetch($socid);
316 $paiement->datepaye = $datepaye;
318 $correctedAmounts = [];
319 foreach ($amounts as $key => $value) {
320 $correctedAmounts[$key] = (float) $value;
323 $paiement->amounts = $correctedAmounts;
324 $paiement->multicurrency_amounts = $multicurrency_amounts;
325 $paiement->multicurrency_code = $multicurrency_code;
326 $paiement->multicurrency_tx = $multicurrency_tx;
327 $paiement->paiementid =
GETPOSTINT(
'paiementid');
328 $paiement->num_payment =
GETPOST(
'num_paiement',
'alphanohtml');
329 $paiement->note_private =
GETPOST(
'comment',
'alpha');
330 $paiement->fk_account =
GETPOSTINT(
'accountid');
336 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
337 if ($paiement_id < 0) {
344 $result = $paiement->addPaymentToBank($user,
'payment_supplier',
'(SupplierInvoicePayment)', $accountid,
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
356 foreach ($paiement->amounts as $key => $amount) {
358 if (is_numeric($amount) && $amount != 0) {
359 if ($invoiceid != 0) {
366 if ($invoiceid > 0) {
367 $loc = DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$invoiceid;
369 $loc = DOL_URL_ROOT.
'/fourn/paiement/card.php?id='.$paiement_id;
371 header(
'Location: '.$loc);
385$form =
new Form($db);
388$supplierstatic =
new Societe($db);
391llxHeader(
'', $langs->trans(
'ListPayment'),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-paiement');
393if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
395 $result =
$object->fetch($facid);
398 $dateinvoice = ($datefacture ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datefacture);
400 $sql =
'SELECT s.nom as name, s.rowid as socid,';
401 $sql .=
' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
402 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
403 $sql .=
", sc.fk_soc, sc.fk_user ";
405 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'facture_fourn as f';
406 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
407 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
409 $sql .=
' WHERE f.fk_soc = s.rowid';
410 $sql .=
' AND f.rowid = '.((int) $facid);
411 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
412 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
414 $resql = $db->query($sql);
416 $num = $db->num_rows($resql);
418 $obj = $db->fetch_object($resql);
419 $total = $obj->total;
424 if (!empty($conf->use_javascript_ajax)) {
425 print
"\n".
'<script type="text/javascript">';
426 print
'$(document).ready(function () {
428 function _elemToJson(selector)
431 $.map(selector.serializeArray(), function(n,i)
433 subJson[n["name"]] = n["value"];
438 function callForResult(imgId)
440 console.log("callForResult Calculate total of payment");
442 var form = $("#payment_form");
444 json["invoice_type"] = $("#invoice_type").val();
445 json["amountPayment"] = $("#amountpayment").attr("value");
446 json["amounts"] = _elemToJson(form.find("input.amount"));
447 json["remains"] = _elemToJson(form.find("input.remain"));
448 json["token"] = "'.currentToken().
'";
450 json["imgClicked"] = imgId;
453 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
455 json = $.parseJSON(data);
459 for (var key in json)
461 if (key == "result") {
462 if (json["makeRed"]) {
463 $("#"+key).addClass("error");
465 $("#"+key).removeClass("error");
467 json[key]=json["label"]+" "+json[key];
468 $("#"+key).text(json[key]);
469 } else {console.log(key);
470 form.find("input[name*=\""+key+"\"]").each(function() {
471 $(this).attr("value", json[key]);
478 $("#payment_form").find("input.amount").change(function() {
481 $("#payment_form").find("input.amount").keyup(function() {
489 print
' $(document).ready(function () {';
490 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
491 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
495 print
' </script>'.
"\n";
498 print
'<form id="payment_form" name="addpaiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
499 print
'<input type="hidden" name="token" value="'.newToken().
'">';
500 print
'<input type="hidden" name="action" value="add_paiement">';
501 print
'<input type="hidden" name="facid" value="'.$facid.
'">';
502 print
'<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.
'">';
503 print
'<input type="hidden" name="socid" value="'.$obj->socid.
'">';
504 print
'<input type="hidden" name="type" id="invoice_type" value="'.$object->type.
'">';
505 print
'<input type="hidden" name="societe" value="'.$obj->name.
'">';
509 print
'<table class="border centpercent">';
511 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
'Company').
'</td><td>';
512 $supplierstatic->id = $obj->socid;
513 $supplierstatic->name = $obj->name;
514 print $supplierstatic->getNomUrl(1,
'supplier');
517 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
519 $adddateof = array(array(
'adddateof' =>
$object->date));
520 $adddateof[] = array(
'adddateof' =>
$object->date_echeance,
'labeladddateof' => $langs->transnoentities(
'DateDue'));
521 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"addpaiement", 1, 1, 0,
'',
'', $adddateof);
523 print
'<tr><td class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</td><td>';
524 $form->select_types_paiements(!
GETPOST(
'paiementid') ? $obj->fk_mode_reglement :
GETPOST(
'paiementid'),
'paiementid');
526 if (isModEnabled(
"bank")) {
527 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Account').
'</td><td>';
528 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
529 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
532 print
'<tr><td> </td></tr>';
534 print
'<tr><td>'.$langs->trans(
'Numero').
'</td><td><input name="num_paiement" type="text" value="'.(!
GETPOST(
'num_paiement') ?
'' :
GETPOST(
'num_paiement')).
'"></td></tr>';
535 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
536 print
'<td class="tdtop">';
537 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.(!
GETPOST(
'comment') ?
'' :
GETPOST(
'comment')).
'</textarea></td></tr>';
542 $parameters = array(
'facid' => $facid,
'ref' => $ref,
'objcanvas' => $objcanvas);
543 $reshook = $hookmanager->executeHooks(
'paymentsupplierinvoices', $parameters, $object, $action);
544 $error = $hookmanager->error;
545 $errors = $hookmanager->errors;
546 if (empty($reshook)) {
550 $sql =
'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
551 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
552 $sql .=
' f.datef as df, f.date_lim_reglement as dlr,';
553 $sql .=
' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
554 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
555 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
556 $sql .=
" WHERE f.entity = ".((int) $conf->entity);
557 $sql .=
' AND f.fk_soc = '.((int)
$object->socid);
558 $sql .=
' AND f.paye = 0';
559 $sql .=
' AND f.fk_statut = 1';
561 $sql .=
' AND f.type IN (0,1,3,5)';
563 $sql .=
' AND f.type = 2';
566 $sql .=
' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
567 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
568 $sql .=
' f.datef, f.date_lim_reglement';
570 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
572 $resql = $db->query($sql);
574 $num = $db->num_rows($resql);
579 if (!empty($conf->use_javascript_ajax)) {
581 print
"\n".
'<script type="text/javascript">';
582 print
' $(document).ready(function () {';
583 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
584 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
587 print
' </script>'.
"\n";
590 print
'<div class="div-table-responsive-no-min">';
591 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
593 print
'<tr class="liste_titre">';
594 print
'<td>'.$langs->trans(
'Invoice').
'</td>';
595 print
'<td>'.$langs->trans(
'RefSupplier').
'</td>';
596 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
597 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
598 if (isModEnabled(
"multicurrency")) {
599 print
'<td>'.$langs->trans(
'Currency').
'</td>';
600 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
601 print
'<td class="right">'.$langs->trans(
'MulticurrencyAlreadyPaid').
'</td>';
602 print
'<td class="right">'.$langs->trans(
'MulticurrencyRemainderToPay').
'</td>';
603 print
'<td class="center">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
605 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
606 print
'<td class="right">'.$langs->trans(
'AlreadyPaid').
'</td>';
607 print
'<td class="right">'.$langs->trans(
'RemainderToPay').
'</td>';
608 print
'<td class="center">'.$langs->trans(
'PaymentAmount').
'</td>';
614 $totalrecucreditnote = 0;
615 $totalrecudeposits = 0;
617 $objp = $db->fetch_object($resql);
625 $invoice->fetch($objp->facid);
627 $invoicesupplierstatic->ref = $objp->ref;
628 $invoicesupplierstatic->id = $objp->facid;
630 $paiement = $invoice->getSommePaiement();
631 $creditnotes = $invoice->getSumCreditNotesUsed();
632 $deposits = $invoice->getSumDepositsUsed();
633 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
634 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
637 if (isModEnabled(
"multicurrency")) {
638 $multicurrency_payment = $invoice->getSommePaiement(1);
639 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
640 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
641 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
642 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
645 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
648 print
'<td class="nowraponall">';
649 print $invoicesupplierstatic->getNomUrl(1);
653 print
'<td>'.$objp->ref_supplier.
'</td>';
657 print
'<td class="center nowraponall">';
660 print
'<td class="center"><b>!!!</b></td>';
664 if ($objp->dlr > 0) {
665 print
'<td class="center nowraponall">';
668 if ($invoice->hasDelay()) {
674 print
'<td class="center"><b>--</b></td>';
678 if (isModEnabled(
"multicurrency")) {
680 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
682 print
'<td class="right">';
683 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
684 print
price($objp->multicurrency_total_ttc);
688 print
'<td class="right">';
689 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
690 print
price($sign * $multicurrency_payment);
691 if ($multicurrency_creditnotes) {
692 print
'+'.price($multicurrency_creditnotes);
694 if ($multicurrency_deposits) {
695 print
'+'.price($multicurrency_deposits);
700 print
'<td class="right">';
701 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
702 print
price($sign * (
float) $multicurrency_remaintopay);
706 print
'<td class="right">';
708 $namef =
'multicurrency_amount_'.$objp->facid;
709 $nameRemain =
'multicurrency_remain_'.$objp->facid;
710 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
711 if ($action !=
'add_paiement') {
712 if (!empty($conf->use_javascript_ajax)) {
713 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $multicurrency_remaintopay).
"'");
715 print
'<input type=hidden class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
716 print
'<input type="text" size="8" class="multicurrency_amount" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
718 print
'<input type="text" size="8" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
719 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
725 print
'<td class="right">'.price($sign * $objp->total_ttc).
'</td>';
727 print
'<td class="right">'.price($sign * $objp->am);
729 print
'+'.price($creditnotes);
732 print
'+'.price($deposits);
736 print
'<td class="right">';
737 print
price($sign * (
float) $remaintopay);
738 if (isModEnabled(
'paymentbybanktransfer')) {
739 $numdirectdebitopen = 0;
740 $totaldirectdebit = 0;
741 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
742 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
743 $sql .=
" WHERE fk_facture_fourn = ".((int) $objp->facid);
744 $sql .=
" AND pfd.traite = 0";
745 $sql .=
" AND pfd.ext_payment_id IS NULL";
747 $result_sql = $db->query($sql);
749 $obj = $db->fetch_object($result_sql);
750 $numdirectdebitopen = $obj->nb;
751 $totaldirectdebit = $obj->amount;
755 if ($numdirectdebitopen) {
756 $langs->load(
"withdrawals");
757 print
img_warning($langs->trans(
"WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1, $conf->currency)),
'',
'classfortooltip');
763 print
'<td class="center nowraponall">';
765 $namef =
'amount_'.$objp->facid;
766 $nameRemain =
'remain_'.$objp->facid;
768 if ($action !=
'add_paiement') {
769 if (!empty($conf->use_javascript_ajax)) {
770 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $remaintopay).
"'");
772 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
775 print
'<input type="text" size="8" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
781 $total += $objp->total_ht;
782 $total_ttc += $objp->total_ttc;
783 $totalrecu += $objp->am;
784 $totalrecucreditnote += $creditnotes;
785 $totalrecudeposits += $deposits;
790 print
'<tr class="liste_total">';
791 print
'<td colspan="4" class="left">'.$langs->trans(
'TotalTTC').
':</td>';
792 if (isModEnabled(
"multicurrency")) {
793 print
'<td> </td>';
794 print
'<td> </td>';
795 print
'<td> </td>';
796 print
'<td> </td>';
797 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
799 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
800 print
'<td class="right"><b>'.price($sign * $totalrecu);
801 if ($totalrecucreditnote) {
802 print
'+'.price($totalrecucreditnote);
804 if ($totalrecudeposits) {
805 print
'+'.price($totalrecudeposits);
808 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
809 print
'<td class="center" id="result" style="font-weight: bold;"></td>';
823 if ($action !=
'add_paiement') {
824 print
'<br><div class="center">';
825 print
'<input type="checkbox" checked id="closepaidinvoices" name="closepaidinvoices"> <label for="closepaidinvoices">'.$langs->trans(
"ClosePaidInvoicesAutomatically").
'</label><br>';
826 print
'<input type="submit" class="button" value="'.$langs->trans(
'ToMakePayment').
'">';
827 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
832 if ($action ==
'add_paiement') {
833 $preselectedchoice = $addwarning ?
'no' :
'yes';
836 if (!empty($totalpayment)) {
837 $text = $langs->trans(
'ConfirmSupplierPayment',
price($totalpayment), $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
839 if (!empty($multicurrency_totalpayment)) {
840 $text .=
'<br>'.$langs->trans(
'ConfirmSupplierPayment',
price($multicurrency_totalpayment), $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
842 if (
GETPOST(
'closepaidinvoices')) {
843 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
844 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
846 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'&socid='.
$object->socid.
'&type='.
$object->type, $langs->trans(
'PayedSuppliersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 suppliers invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments for supplier 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...
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 '.
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_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...