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');
79$displayAllInvoices =
getDolGlobalInt(
'MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
80if (GETPOSTISSET(
'display-all-invoices')) {
81 $displayAllInvoices =
GETPOSTINT(
'display-all-invoices');
85$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
88if (empty($page) || $page == -1) {
91$offset = $limit * $page;
98 $sortfield =
"p.rowid";
102$amountsresttopay = array();
105$multicurrency_amounts = array();
106$multicurrency_amountsresttopay = array();
109if ($user->socid > 0) {
110 $socid = $user->socid;
116$hookmanager->initHooks(array(
'paymentsupplierlist'));
120$extrafields->fetch_name_optionals_label(
$object->table_element);
122$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
124$arrayfields = array();
126$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
135 if (!empty($backtopageforcancel)) {
136 header(
"Location: ".$backtopageforcancel);
138 } elseif (!empty($backtopage)) {
139 header(
"Location: ".$backtopage);
142 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/list.php');
146if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
148 $search_account =
"";
150 $search_paymenttype =
"";
151 $search_payment_num =
"";
152 $search_company =
"";
156 $search_array_options = array();
159$parameters = array(
'socid' => $socid);
160$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
165$formquestion = array();
166if (empty($reshook)) {
167 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $permissiontoadd) {
171 $atleastonepaymentnotnull = 0;
172 $multicurrency_totalpayment = 0;
177 foreach ($_POST as $key => $value) {
178 if (substr($key, 0, 7) ==
'amount_') {
179 $cursorfacid = (int) substr($key, 7);
181 if (!empty($amounts[$cursorfacid])) {
182 $atleastonepaymentnotnull++;
183 if (is_numeric($amounts[$cursorfacid])) {
184 $totalpayment += (float) $amounts[$cursorfacid];
189 $result = $tmpinvoice->fetch($cursorfacid);
193 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
194 if ($amounts[$cursorfacid]) {
196 if ((abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
198 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
201 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
202 $langs->load(
"errors");
208 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
209 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
210 $cursorfacid = (int) substr($key, 21);
212 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
213 if (!empty($multicurrency_amounts[$cursorfacid])) {
214 $atleastonepaymentnotnull++;
216 $result = $tmpinvoice->fetch($cursorfacid);
220 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
221 if ($multicurrency_amounts[$cursorfacid]) {
223 if ((abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
225 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
228 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
229 $langs->load(
"errors");
235 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTFLOAT($key));
240 if (
GETPOST(
'paiementid') <= 0) {
241 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
245 if (isModEnabled(
"bank")) {
247 if (
GETPOST(
'accountid') <= 0) {
248 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
253 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
254 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
258 if (empty($datepaye)) {
259 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
264 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
265 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
273 if ($action ==
'add_paiement') {
284 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $permissiontoadd) {
287 $multicurrency_code = array();
288 $multicurrency_tx = array();
291 foreach ($amounts as $key => $value) {
293 $tmpinvoice->fetch($key);
296 $amounts[$key] = - abs((
float) $newvalue);
298 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
299 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
302 foreach ($multicurrency_amounts as $key => $value) {
304 $tmpinvoice->fetch($key);
307 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
309 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
310 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
316 $thirdparty =
new Societe($db);
318 $thirdparty->fetch($socid);
323 $paiement->datepaye = $datepaye;
325 $correctedAmounts = [];
326 foreach ($amounts as $key => $value) {
327 $correctedAmounts[$key] = (float) $value;
330 $paiement->amounts = $correctedAmounts;
331 $paiement->multicurrency_amounts = $multicurrency_amounts;
332 $paiement->multicurrency_code = $multicurrency_code;
333 $paiement->multicurrency_tx = $multicurrency_tx;
334 $paiement->paiementid =
GETPOSTINT(
'paiementid');
335 $paiement->num_payment =
GETPOST(
'num_paiement',
'alphanohtml');
336 $paiement->note_private =
GETPOST(
'comment',
'alpha');
337 $paiement->fk_account =
GETPOSTINT(
'accountid');
342 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
343 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 $totalnboflines = $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(e){
497 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
501 print
' </script>'.
"\n";
504 print
'<form id="payment_form" name="addpaiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
505 print
'<input type="hidden" name="token" value="'.newToken().
'">';
506 print
'<input type="hidden" name="action" value="add_paiement">';
507 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
508 print
'<input type="hidden" name="facid" value="'.$facid.
'">';
509 print
'<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.
'">';
510 print
'<input type="hidden" name="socid" value="'.$obj->socid.
'">';
511 print
'<input type="hidden" name="type" id="invoice_type" value="'.$object->type.
'">';
512 print
'<input type="hidden" name="societe" value="'.$obj->name.
'">';
516 print
'<table class="border centpercent">';
518 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
'Company').
'</td><td>';
519 $supplierstatic->id = $obj->socid;
520 $supplierstatic->name = $obj->name;
521 print $supplierstatic->getNomUrl(1,
'supplier');
524 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
526 $adddateof = array(array(
'adddateof' =>
$object->date));
527 $adddateof[] = array(
'adddateof' =>
$object->date_echeance,
'labeladddateof' => $langs->transnoentities(
'DateDue'));
528 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"addpaiement", 1, 1, 0,
'',
'', $adddateof);
530 print
'<tr><td class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</td><td>';
531 $form->select_types_paiements(!
GETPOST(
'paiementid') ? $obj->fk_mode_reglement :
GETPOST(
'paiementid'),
'paiementid');
533 if (isModEnabled(
"bank")) {
534 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Account').
'</td><td>';
535 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
536 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
539 print
'<tr><td> </td></tr>';
541 print
'<tr><td>'.$langs->trans(
'Numero').
'</td><td><input name="num_paiement" type="text" value="'.(!
GETPOST(
'num_paiement') ?
'' :
GETPOST(
'num_paiement')).
'"></td></tr>';
542 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
543 print
'<td class="tdtop">';
544 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.(!
GETPOST(
'comment') ?
'' :
GETPOST(
'comment')).
'</textarea></td></tr>';
552 $reshook = $hookmanager->executeHooks(
'paymentsupplierinvoices', $parameters, $object, $action);
553 $error = $hookmanager->error;
554 $errors = $hookmanager->errors;
555 if (empty($reshook)) {
559 $sql =
'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
560 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
561 $sql .=
' f.datef as df, f.date_lim_reglement as dlr,';
562 $sql .=
' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
563 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
564 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
565 $sql .=
' WHERE f.entity = '.((int)
$conf->entity);
566 $sql .=
' AND (f.fk_soc = '.((int)
$object->socid);
567 $aux =
$object->fetch_thirdparty();
570 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->parent).
')';
574 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->id).
')';
576 $sql .=
') AND f.paye = 0';
577 $sql .=
' AND f.fk_statut = 1';
579 if (!$displayAllInvoices) {
581 $sql .=
' AND f.type IN (0,1,3,5)';
583 $sql .=
' AND f.type = 2';
588 $sql .=
' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
589 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
590 $sql .=
' f.datef, f.date_lim_reglement';
592 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
594 $resql = $db->query($sql);
596 $num = $db->num_rows($resql);
601 if (!empty(
$conf->use_javascript_ajax)) {
603 print
"\n".
'<script type="text/javascript">';
604 print
' $(document).ready(function () {';
605 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
607 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
610 print
' </script>'.
"\n";
614 if ($action ==
'create') {
615 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.((int) $facid).
'&action='.urlencode($action).
'&accountid='.((int) $accountid).
'&display-all-invoices=' . (intval(!$displayAllInvoices));
617 if (empty($displayAllInvoices)) {
618 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
620 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
623 $btnTitle = $langs->trans(
'HideOtherInvoices');
625 $btnTitle = $langs->trans(
'HideCreditNotes');
629 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
630 $moreHtmlRight.=
dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
633 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
636 print
'<div class="div-table-responsive-no-min">';
637 print
'<table id="fourn-invoices-paiments-list" data-display-all-invoices="' . (int) $displayAllInvoices .
'" class="tagtable liste" >'.
"\n";
639 print
'<tr class="liste_titre">';
640 print
'<th>'.$langs->trans(
'Invoice').
'</th>';
641 print
'<th>'.$langs->trans(
'RefSupplier').
'</th>';
642 if ($displayAllInvoices) {
643 print
'<th class="center">' . $langs->trans(
'Type') .
'</th>';
645 print
'<th class="center">'.$langs->trans(
'Date').
'</th>';
646 print
'<th class="center">'.$langs->trans(
'DateMaxPayment').
'</th>';
647 if (isModEnabled(
"multicurrency")) {
648 print
'<th>'.$langs->trans(
'Currency').
'</th>';
649 print
'<th class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</th>';
650 print
'<th class="right">'.$langs->trans(
'MulticurrencyAlreadyPaid').
'</th>';
651 print
'<th class="right">'.$langs->trans(
'MulticurrencyRemainderToPay').
'</th>';
652 print
'<th class="center">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</th>';
654 print
'<th class="right">'.$langs->trans(
'AmountTTC').
'</th>';
655 print
'<th class="right">'.$langs->trans(
'AlreadyPaid').
'</th>';
656 print
'<th class="right">'.$langs->trans(
'RemainderToPay').
'</th>';
657 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
'</th>';
664 $totalrecucreditnote = 0;
665 $totalrecudeposits = 0;
667 $objp = $db->fetch_object($resql);
675 $invoice->fetch($objp->facid);
677 $invoicesupplierstatic->ref = $objp->ref;
678 $invoicesupplierstatic->id = $objp->facid;
680 $paiement = $invoice->getSommePaiement();
681 $creditnotes = $invoice->getSumCreditNotesUsed();
682 $deposits = $invoice->getSumDepositsUsed();
683 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
684 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
687 $multicurrency_payment = 0;
688 $multicurrency_creditnotes = 0;
689 $multicurrency_deposits = 0;
690 $multicurrency_remaintopay = 0;
691 if (isModEnabled(
"multicurrency")) {
692 $multicurrency_payment = $invoice->getSommePaiement(1);
693 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
694 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
695 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
696 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
699 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
702 print
'<td data-col="object-name" class="nowraponall">';
703 print $invoicesupplierstatic->getNomUrl(1);
707 print
'<td data-col="ref-supplier" >'.$objp->ref_supplier.
'</td>';
710 if ($displayAllInvoices) {
718 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
723 print
'<td data-col="datef" data-col-value="'.$db->jdate($objp->df).
'" class="center nowraponall">';
726 print
'<td data-col="datef" data-col-value="" class="center"><b>!!!</b></td>';
730 if ($objp->dlr > 0) {
731 print
'<td data-col="dater" data-col-value="'.$db->jdate($objp->dlr).
'" class="center nowraponall">';
734 if ($invoice->hasDelay()) {
740 print
'<td data-col="dater" data-col-value="" class="center"><b>--</b></td>';
744 if (isModEnabled(
"multicurrency")) {
746 print
'<td data-col="multicurrency-code" class="center">'.$objp->multicurrency_code.
"</td>\n";
748 print
'<td data-col="multicurrency-total-ttc" class="right">';
749 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
750 print
price($objp->multicurrency_total_ttc);
754 print
'<td data-col="multicurrency-payment" class="right">';
755 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
756 print
price($sign * $multicurrency_payment);
757 if ($multicurrency_creditnotes) {
758 print
'+'.price($multicurrency_creditnotes);
760 if ($multicurrency_deposits) {
761 print
'+'.price($multicurrency_deposits);
766 print
'<td data-col="remain-to-pay" class="right">';
767 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
768 print
price($sign * (
float) $multicurrency_remaintopay);
772 print
'<td data-col="remain-to-pay-multicurrency-amount" class="right">';
774 $namef =
'multicurrency_amount_'.$objp->facid;
775 $nameRemain =
'multicurrency_remain_'.$objp->facid;
778 if ($displayAllInvoices) {
786 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
787 if ($action !=
'add_paiement') {
788 if (!empty(
$conf->use_javascript_ajax)) {
789 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">'.
img_picto(
"Auto fill",
'rightarrow');
791 print
'<input type=hidden class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
792 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount width100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
794 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
795 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
801 print
'<td class="right">'.price($sign * $objp->total_ttc).
'</td>';
803 print
'<td class="right">'.price($sign * $objp->am);
805 print
'+'.price($creditnotes);
808 print
'+'.price($deposits);
812 print
'<td class="right">';
813 print
price($sign * (
float) $remaintopay);
814 if (isModEnabled(
'paymentbybanktransfer')) {
815 $numdirectdebitopen = 0;
816 $totaldirectdebit = 0;
817 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
818 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
819 $sql .=
" WHERE fk_facture_fourn = ".((int) $objp->facid);
820 $sql .=
" AND pfd.traite = 0";
821 $sql .=
" AND pfd.ext_payment_id IS NULL";
823 $result_sql = $db->query($sql);
825 $obj = $db->fetch_object($result_sql);
826 $numdirectdebitopen = $obj->nb;
827 $totaldirectdebit = $obj->amount;
831 if ($numdirectdebitopen) {
832 $langs->load(
"withdrawals");
833 print
img_warning($langs->trans(
"WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
839 print
'<td class="center nowraponall">';
841 $namef =
'amount_'.$objp->facid;
842 $nameRemain =
'remain_'.$objp->facid;
845 if ($displayAllInvoices) {
853 if ($action !=
'add_paiement') {
854 if (!empty(
$conf->use_javascript_ajax)) {
855 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">'.
img_picto(
"Auto fill",
'rightarrow').
'</button>';
857 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
858 print
'<input '.$max.
' '.$min.
' type="text" class="amount width100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
860 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
866 $total += $objp->total_ht;
867 $total_ttc += $objp->total_ttc;
868 $totalrecu += $objp->am;
869 $totalrecucreditnote += $creditnotes;
870 $totalrecudeposits += $deposits;
878 print
'<tr class="liste_total">';
882 if ($displayAllInvoices) {
886 print
'<td colspan="'.$colspan.
'" class="left">'.$langs->trans(
'TotalTTC').
':</td>';
887 if (isModEnabled(
"multicurrency")) {
888 print
'<td> </td>';
889 print
'<td> </td>';
890 print
'<td> </td>';
891 print
'<td> </td>';
892 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
894 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
895 print
'<td class="right"><b>'.price($totalrecu);
896 if ($totalrecucreditnote) {
897 print
'+'.price($totalrecucreditnote);
899 if ($totalrecudeposits) {
900 print
'+'.price($totalrecudeposits);
903 print
'<td class="right"><b>'.price((
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
904 print
'<td class="center" id="result" style="font-weight: bold;"></td>';
919 if ($action !=
'add_paiement') {
920 print
'<br><div class="center">';
921 print
'<input type="checkbox" checked id="closepaidinvoices" name="closepaidinvoices"> <label for="closepaidinvoices">'.$langs->trans(
"ClosePaidInvoicesAutomatically").
'</label><br>';
922 print
'<input type="submit" class="button" value="'.$langs->trans(
'ToMakePayment').
'">';
923 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
928 if ($action ==
'add_paiement') {
929 $preselectedchoice = $addwarning ?
'no' :
'yes';
933 if (!empty($totalpayment)) {
934 $text = $langs->trans(
'ConfirmSupplierPayment',
price($totalpayment), $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
936 if (!empty($multicurrency_totalpayment)) {
937 $text .=
'<br>'.$langs->trans(
'ConfirmSupplierPayment',
price($multicurrency_totalpayment), $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
939 if (
GETPOST(
'closepaidinvoices')) {
940 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
941 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
943 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
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 suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard 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.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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.
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_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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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...