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';
56$langs->loadLangs(array(
'companies',
'bills',
'banks',
'compta'));
58$action =
GETPOST(
'action',
'alpha');
59$confirm =
GETPOST(
'confirm',
'alpha');
60$optioncss =
GETPOST(
'optioncss',
'alpha');
61$cancel =
GETPOST(
'cancel',
'alpha');
62$backtopage =
GETPOST(
'backtopage',
'alpha');
63$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
72$search_ref =
GETPOST(
'search_ref',
'alpha');
73$search_account =
GETPOST(
'search_account',
'alpha');
74$search_paymenttype =
GETPOST(
'search_paymenttype');
75$search_amount =
GETPOST(
'search_amount',
'alpha');
76$search_company =
GETPOST(
'search_company',
'alpha');
77$search_payment_num =
GETPOST(
'search_payment_num',
'alpha');
80$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
81$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
83if (empty($page) || $page == -1) {
86$offset = $limit * $page;
93 $sortfield =
"p.rowid";
97$amountsresttopay = array();
100$multicurrency_amounts = array();
101$multicurrency_amountsresttopay = array();
104if ($user->socid > 0) {
105 $socid = $user->socid;
111$hookmanager->initHooks(array(
'paymentsupplierlist'));
115$extrafields->fetch_name_optionals_label(
$object->table_element);
117$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
119$arrayfields = array();
121$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
130 if (!empty($backtopageforcancel)) {
131 header(
"Location: ".$backtopageforcancel);
133 } elseif (!empty($backtopage)) {
134 header(
"Location: ".$backtopage);
137 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/list.php');
141if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
143 $search_account =
"";
145 $search_paymenttype =
"";
146 $search_payment_num =
"";
147 $search_company =
"";
151 $search_array_options = array();
154$parameters = array(
'socid' => $socid);
155$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
160if (empty($reshook)) {
161 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $permissiontoadd) {
165 $atleastonepaymentnotnull = 0;
166 $multicurrency_totalpayment = 0;
167 $formquestion = array();
171 foreach ($_POST as $key => $value) {
172 if (substr($key, 0, 7) ==
'amount_') {
173 $cursorfacid = substr($key, 7);
175 if (!empty($amounts[$cursorfacid])) {
176 $atleastonepaymentnotnull++;
177 if (is_numeric($amounts[$cursorfacid])) {
178 $totalpayment += (float) $amounts[$cursorfacid];
183 $result = $tmpinvoice->fetch($cursorfacid);
187 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
188 if ($amounts[$cursorfacid]) {
190 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
192 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
195 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
196 $langs->load(
"errors");
202 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
203 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
204 $cursorfacid = substr($key, 21);
206 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
207 if (!empty($multicurrency_amounts[$cursorfacid])) {
208 $atleastonepaymentnotnull++;
210 $result = $tmpinvoice->fetch($cursorfacid);
214 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
215 if ($multicurrency_amounts[$cursorfacid]) {
217 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
219 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
222 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
223 $langs->load(
"errors");
229 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTINT($key));
234 if (
GETPOST(
'paiementid') <= 0) {
235 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
239 if (isModEnabled(
"bank")) {
241 if (
GETPOST(
'accountid') <= 0) {
242 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
247 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
248 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
252 if (empty($datepaye)) {
253 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
258 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
259 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
267 if ($action ==
'add_paiement') {
278 if ($action ==
'confirm_paiement' && $confirm ==
'yes') {
281 $multicurrency_code = array();
282 $multicurrency_tx = array();
285 foreach ($amounts as $key => $value) {
287 $tmpinvoice->fetch($key);
290 $amounts[$key] = - abs((
float) $newvalue);
292 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
293 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
296 foreach ($multicurrency_amounts as $key => $value) {
298 $tmpinvoice->fetch($key);
301 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
303 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
304 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
314 $thirdparty =
new Societe($db);
316 $thirdparty->fetch($socid);
321 $paiement->datepaye = $datepaye;
323 $correctedAmounts = [];
324 foreach ($amounts as $key => $value) {
325 $correctedAmounts[$key] = (float) $value;
328 $paiement->amounts = $correctedAmounts;
329 $paiement->multicurrency_amounts = $multicurrency_amounts;
330 $paiement->multicurrency_code = $multicurrency_code;
331 $paiement->multicurrency_tx = $multicurrency_tx;
332 $paiement->paiementid =
GETPOSTINT(
'paiementid');
333 $paiement->num_payment =
GETPOST(
'num_paiement',
'alphanohtml');
334 $paiement->note_private =
GETPOST(
'comment',
'alpha');
335 $paiement->fk_account =
GETPOSTINT(
'accountid');
341 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
342 if ($paiement_id < 0) {
349 $result = $paiement->addPaymentToBank($user,
'payment_supplier',
'(SupplierInvoicePayment)', $accountid,
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
361 foreach ($paiement->amounts as $key => $amount) {
363 if (is_numeric($amount) && $amount != 0) {
364 if ($invoiceid != 0) {
371 if ($invoiceid > 0) {
372 $loc = DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$invoiceid;
374 $loc = DOL_URL_ROOT.
'/fourn/paiement/card.php?id='.$paiement_id;
376 header(
'Location: '.$loc);
390$form =
new Form($db);
393$supplierstatic =
new Societe($db);
396llxHeader(
'', $langs->trans(
'ListPayment'),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-paiement');
398if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
400 $result =
$object->fetch($facid);
403 $dateinvoice = ($datefacture ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datefacture);
405 $sql =
'SELECT s.nom as name, s.rowid as socid,';
406 $sql .=
' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
407 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
408 $sql .=
", sc.fk_soc, sc.fk_user ";
410 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'facture_fourn as f';
411 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
412 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
414 $sql .=
' WHERE f.fk_soc = s.rowid';
415 $sql .=
' AND f.rowid = '.((int) $facid);
416 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
417 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
419 $resql = $db->query($sql);
421 $num = $db->num_rows($resql);
423 $obj = $db->fetch_object($resql);
424 $total = $obj->total;
429 if (!empty(
$conf->use_javascript_ajax)) {
430 print
"\n".
'<script type="text/javascript">';
431 print
'$(document).ready(function () {
433 function _elemToJson(selector)
436 $.map(selector.serializeArray(), function(n,i)
438 subJson[n["name"]] = n["value"];
443 function callForResult(imgId)
445 console.log("callForResult Calculate total of payment");
447 var form = $("#payment_form");
449 json["invoice_type"] = $("#invoice_type").val();
450 json["amountPayment"] = $("#amountpayment").attr("value");
451 json["amounts"] = _elemToJson(form.find("input.amount"));
452 json["remains"] = _elemToJson(form.find("input.remain"));
453 json["token"] = "'.currentToken().
'";
455 json["imgClicked"] = imgId;
458 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
460 json = $.parseJSON(data);
464 for (var key in json)
466 if (key == "result") {
467 if (json["makeRed"]) {
468 $("#"+key).addClass("error");
470 $("#"+key).removeClass("error");
472 json[key]=json["label"]+" "+json[key];
473 $("#"+key).text(json[key]);
474 } else {console.log(key);
475 form.find("input[name*=\""+key+"\"]").each(function() {
476 $(this).attr("value", json[key]);
483 $("#payment_form").find("input.amount").change(function() {
486 $("#payment_form").find("input.amount").keyup(function() {
494 print
' $(document).ready(function () {';
495 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
496 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
500 print
' </script>'.
"\n";
503 print
'<form id="payment_form" name="addpaiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
504 print
'<input type="hidden" name="token" value="'.newToken().
'">';
505 print
'<input type="hidden" name="action" value="add_paiement">';
506 print
'<input type="hidden" name="facid" value="'.$facid.
'">';
507 print
'<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.
'">';
508 print
'<input type="hidden" name="socid" value="'.$obj->socid.
'">';
509 print
'<input type="hidden" name="type" id="invoice_type" value="'.$object->type.
'">';
510 print
'<input type="hidden" name="societe" value="'.$obj->name.
'">';
514 print
'<table class="border centpercent">';
516 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
'Company').
'</td><td>';
517 $supplierstatic->id = $obj->socid;
518 $supplierstatic->name = $obj->name;
519 print $supplierstatic->getNomUrl(1,
'supplier');
522 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
524 $adddateof = array(array(
'adddateof' =>
$object->date));
525 $adddateof[] = array(
'adddateof' =>
$object->date_echeance,
'labeladddateof' => $langs->transnoentities(
'DateDue'));
526 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"addpaiement", 1, 1, 0,
'',
'', $adddateof);
528 print
'<tr><td class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</td><td>';
529 $form->select_types_paiements(!
GETPOST(
'paiementid') ? $obj->fk_mode_reglement :
GETPOST(
'paiementid'),
'paiementid');
531 if (isModEnabled(
"bank")) {
532 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Account').
'</td><td>';
533 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
534 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
537 print
'<tr><td> </td></tr>';
539 print
'<tr><td>'.$langs->trans(
'Numero').
'</td><td><input name="num_paiement" type="text" value="'.(!
GETPOST(
'num_paiement') ?
'' :
GETPOST(
'num_paiement')).
'"></td></tr>';
540 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
541 print
'<td class="tdtop">';
542 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.(!
GETPOST(
'comment') ?
'' :
GETPOST(
'comment')).
'</textarea></td></tr>';
547 $parameters = array(
'facid' => $facid,
'ref' => $ref,
'objcanvas' => $objcanvas);
548 $reshook = $hookmanager->executeHooks(
'paymentsupplierinvoices', $parameters, $object, $action);
549 $error = $hookmanager->error;
550 $errors = $hookmanager->errors;
551 if (empty($reshook)) {
555 $sql =
'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
556 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
557 $sql .=
' f.datef as df, f.date_lim_reglement as dlr,';
558 $sql .=
' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
559 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
560 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
561 $sql .=
" WHERE f.entity = ".((int)
$conf->entity);
562 $sql .=
' AND f.fk_soc = '.((int)
$object->socid);
563 $sql .=
' AND f.paye = 0';
564 $sql .=
' AND f.fk_statut = 1';
566 $sql .=
' AND f.type IN (0,1,3,5)';
568 $sql .=
' AND f.type = 2';
571 $sql .=
' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
572 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
573 $sql .=
' f.datef, f.date_lim_reglement';
575 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
577 $resql = $db->query($sql);
579 $num = $db->num_rows($resql);
584 if (!empty(
$conf->use_javascript_ajax)) {
586 print
"\n".
'<script type="text/javascript">';
587 print
' $(document).ready(function () {';
588 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
589 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
592 print
' </script>'.
"\n";
595 print
'<div class="div-table-responsive-no-min">';
596 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
598 print
'<tr class="liste_titre">';
599 print
'<td>'.$langs->trans(
'Invoice').
'</td>';
600 print
'<td>'.$langs->trans(
'RefSupplier').
'</td>';
601 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
602 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
603 if (isModEnabled(
"multicurrency")) {
604 print
'<td>'.$langs->trans(
'Currency').
'</td>';
605 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
606 print
'<td class="right">'.$langs->trans(
'MulticurrencyAlreadyPaid').
'</td>';
607 print
'<td class="right">'.$langs->trans(
'MulticurrencyRemainderToPay').
'</td>';
608 print
'<td class="center">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
610 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
611 print
'<td class="right">'.$langs->trans(
'AlreadyPaid').
'</td>';
612 print
'<td class="right">'.$langs->trans(
'RemainderToPay').
'</td>';
613 print
'<td class="center">'.$langs->trans(
'PaymentAmount').
'</td>';
619 $totalrecucreditnote = 0;
620 $totalrecudeposits = 0;
622 $objp = $db->fetch_object($resql);
630 $invoice->fetch($objp->facid);
632 $invoicesupplierstatic->ref = $objp->ref;
633 $invoicesupplierstatic->id = $objp->facid;
635 $paiement = $invoice->getSommePaiement();
636 $creditnotes = $invoice->getSumCreditNotesUsed();
637 $deposits = $invoice->getSumDepositsUsed();
638 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
639 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
642 if (isModEnabled(
"multicurrency")) {
643 $multicurrency_payment = $invoice->getSommePaiement(1);
644 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
645 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
646 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
647 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
650 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
653 print
'<td class="nowraponall">';
654 print $invoicesupplierstatic->getNomUrl(1);
658 print
'<td>'.$objp->ref_supplier.
'</td>';
662 print
'<td class="center nowraponall">';
665 print
'<td class="center"><b>!!!</b></td>';
669 if ($objp->dlr > 0) {
670 print
'<td class="center nowraponall">';
673 if ($invoice->hasDelay()) {
679 print
'<td class="center"><b>--</b></td>';
683 if (isModEnabled(
"multicurrency")) {
685 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
687 print
'<td class="right">';
688 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
689 print
price($objp->multicurrency_total_ttc);
693 print
'<td class="right">';
694 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
695 print
price($sign * $multicurrency_payment);
696 if ($multicurrency_creditnotes) {
697 print
'+'.price($multicurrency_creditnotes);
699 if ($multicurrency_deposits) {
700 print
'+'.price($multicurrency_deposits);
705 print
'<td class="right">';
706 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
707 print
price($sign * (
float) $multicurrency_remaintopay);
711 print
'<td class="right">';
713 $namef =
'multicurrency_amount_'.$objp->facid;
714 $nameRemain =
'multicurrency_remain_'.$objp->facid;
715 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
716 if ($action !=
'add_paiement') {
717 if (!empty(
$conf->use_javascript_ajax)) {
718 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $multicurrency_remaintopay).
"'");
720 print
'<input type=hidden class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
721 print
'<input type="text" size="8" class="multicurrency_amount" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
723 print
'<input type="text" size="8" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
724 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
730 print
'<td class="right">'.price($sign * $objp->total_ttc).
'</td>';
732 print
'<td class="right">'.price($sign * $objp->am);
734 print
'+'.price($creditnotes);
737 print
'+'.price($deposits);
741 print
'<td class="right">';
742 print
price($sign * (
float) $remaintopay);
743 if (isModEnabled(
'paymentbybanktransfer')) {
744 $numdirectdebitopen = 0;
745 $totaldirectdebit = 0;
746 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
747 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
748 $sql .=
" WHERE fk_facture_fourn = ".((int) $objp->facid);
749 $sql .=
" AND pfd.traite = 0";
750 $sql .=
" AND pfd.ext_payment_id IS NULL";
752 $result_sql = $db->query($sql);
754 $obj = $db->fetch_object($result_sql);
755 $numdirectdebitopen = $obj->nb;
756 $totaldirectdebit = $obj->amount;
760 if ($numdirectdebitopen) {
761 $langs->load(
"withdrawals");
762 print
img_warning($langs->trans(
"WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
768 print
'<td class="center nowraponall">';
770 $namef =
'amount_'.$objp->facid;
771 $nameRemain =
'remain_'.$objp->facid;
773 if ($action !=
'add_paiement') {
774 if (!empty(
$conf->use_javascript_ajax)) {
775 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $remaintopay).
"'");
777 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
780 print
'<input type="text" size="8" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
786 $total += $objp->total_ht;
787 $total_ttc += $objp->total_ttc;
788 $totalrecu += $objp->am;
789 $totalrecucreditnote += $creditnotes;
790 $totalrecudeposits += $deposits;
795 print
'<tr class="liste_total">';
796 print
'<td colspan="4" class="left">'.$langs->trans(
'TotalTTC').
':</td>';
797 if (isModEnabled(
"multicurrency")) {
798 print
'<td> </td>';
799 print
'<td> </td>';
800 print
'<td> </td>';
801 print
'<td> </td>';
802 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
804 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
805 print
'<td class="right"><b>'.price($sign * $totalrecu);
806 if ($totalrecucreditnote) {
807 print
'+'.price($totalrecucreditnote);
809 if ($totalrecudeposits) {
810 print
'+'.price($totalrecudeposits);
813 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
814 print
'<td class="center" id="result" style="font-weight: bold;"></td>';
828 if ($action !=
'add_paiement') {
829 print
'<br><div class="center">';
830 print
'<input type="checkbox" checked id="closepaidinvoices" name="closepaidinvoices"> <label for="closepaidinvoices">'.$langs->trans(
"ClosePaidInvoicesAutomatically").
'</label><br>';
831 print
'<input type="submit" class="button" value="'.$langs->trans(
'ToMakePayment').
'">';
832 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
837 if ($action ==
'add_paiement') {
838 $preselectedchoice = $addwarning ?
'no' :
'yes';
841 if (!empty($totalpayment)) {
842 $text = $langs->trans(
'ConfirmSupplierPayment',
price($totalpayment), $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
844 if (!empty($multicurrency_totalpayment)) {
845 $text .=
'<br>'.$langs->trans(
'ConfirmSupplierPayment',
price($multicurrency_totalpayment), $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
847 if (
GETPOST(
'closepaidinvoices')) {
848 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
849 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
851 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...