39require
'../../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
57$langs->loadLangs(array(
'companies',
'bills',
'banks',
'compta'));
59$action =
GETPOST(
'action',
'alpha');
60$confirm =
GETPOST(
'confirm',
'alpha');
61$optioncss =
GETPOST(
'optioncss',
'alpha');
62$cancel =
GETPOST(
'cancel',
'alpha');
63$backtopage =
GETPOST(
'backtopage',
'alpha');
64$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
73$search_ref =
GETPOST(
'search_ref',
'alpha');
74$search_account =
GETPOST(
'search_account',
'alpha');
75$search_paymenttype =
GETPOST(
'search_paymenttype');
76$search_amount =
GETPOST(
'search_amount',
'alpha');
77$search_company =
GETPOST(
'search_company',
'alpha');
78$search_payment_num =
GETPOST(
'search_payment_num',
'alpha');
80$displayAllInvoices =
getDolGlobalInt(
'MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
81if (GETPOSTISSET(
'display-all-invoices')) {
82 $displayAllInvoices =
GETPOSTINT(
'display-all-invoices');
86$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
87$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
89if (empty($page) || $page == -1) {
92$offset = $limit * $page;
99 $sortfield =
"p.rowid";
103$amountsresttopay = array();
106$multicurrency_amounts = array();
107$multicurrency_amountsresttopay = array();
110if ($user->socid > 0) {
111 $socid = $user->socid;
117$hookmanager->initHooks(array(
'paymentsupplierlist'));
121$extrafields->fetch_name_optionals_label(
$object->table_element);
123$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
125$arrayfields = array();
127$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
136 if (!empty($backtopageforcancel)) {
137 header(
"Location: ".$backtopageforcancel);
139 } elseif (!empty($backtopage)) {
140 header(
"Location: ".$backtopage);
143 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/list.php');
147if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
149 $search_account =
"";
151 $search_paymenttype =
"";
152 $search_payment_num =
"";
153 $search_company =
"";
157 $search_array_options = array();
160$parameters = array(
'socid' => $socid);
161$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
166$formquestion = array();
167if (empty($reshook)) {
168 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $permissiontoadd) {
172 $atleastonepaymentnotnull = 0;
173 $multicurrency_totalpayment = 0;
178 foreach ($_POST as $key => $value) {
179 if (substr($key, 0, 7) ==
'amount_') {
180 $cursorfacid = (int) substr($key, 7);
182 if (!empty($amounts[$cursorfacid])) {
183 $atleastonepaymentnotnull++;
184 if (is_numeric($amounts[$cursorfacid])) {
185 $totalpayment += (float) $amounts[$cursorfacid];
190 $result = $tmpinvoice->fetch($cursorfacid);
194 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
195 if ($amounts[$cursorfacid]) {
197 if ((abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
199 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
202 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
203 $langs->load(
"errors");
209 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
210 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
211 $cursorfacid = (int) substr($key, 21);
213 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
214 if (!empty($multicurrency_amounts[$cursorfacid])) {
215 $atleastonepaymentnotnull++;
217 $result = $tmpinvoice->fetch($cursorfacid);
221 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
222 if ($multicurrency_amounts[$cursorfacid]) {
224 if ((abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
226 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
229 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
230 $langs->load(
"errors");
236 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTFLOAT($key));
241 if (
GETPOST(
'paiementid') <= 0) {
242 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
248 if (
GETPOST(
'accountid') <= 0) {
249 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
254 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
255 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
259 if (empty($datepaye)) {
260 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
265 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
266 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
274 if ($action ==
'add_paiement') {
285 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $permissiontoadd) {
288 $multicurrency_code = array();
289 $multicurrency_tx = array();
292 foreach ($amounts as $key => $value) {
294 $tmpinvoice->fetch($key);
297 $amounts[$key] = - abs((
float) $newvalue);
299 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
300 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
303 foreach ($multicurrency_amounts as $key => $value) {
305 $tmpinvoice->fetch($key);
308 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
310 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
311 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
319 $thirdparty->fetch($socid);
324 $paiement->datepaye = $datepaye;
326 $correctedAmounts = [];
327 foreach ($amounts as $key => $value) {
328 $correctedAmounts[$key] = (float) $value;
331 $paiement->amounts = $correctedAmounts;
332 $paiement->multicurrency_amounts = $multicurrency_amounts;
333 $paiement->multicurrency_code = $multicurrency_code;
334 $paiement->multicurrency_tx = $multicurrency_tx;
335 $paiement->paiementid =
GETPOSTINT(
'paiementid');
336 $paiement->num_payment =
GETPOST(
'num_paiement',
'alphanohtml');
337 $paiement->note_private =
GETPOST(
'comment',
'alpha');
338 $paiement->fk_account =
GETPOSTINT(
'accountid');
343 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
344 if ($paiement_id < 0) {
350 $result = $paiement->addPaymentToBank($user,
'payment_supplier',
'(SupplierInvoicePayment)', $accountid,
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
362 foreach ($paiement->amounts as $key => $amount) {
364 if (is_numeric($amount) && $amount != 0) {
365 if ($invoiceid != 0) {
372 if ($invoiceid > 0) {
373 $loc = DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$invoiceid;
375 $loc = DOL_URL_ROOT.
'/fourn/paiement/card.php?id='.$paiement_id;
377 header(
'Location: '.$loc);
397llxHeader(
'', $langs->trans(
'ListPayment'),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-paiement');
399if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
401 $result =
$object->fetch($facid);
404 $dateinvoice = ($datefacture ==
'' ? (
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datefacture);
406 $sql =
'SELECT s.nom as name, s.rowid as socid,';
407 $sql .=
' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
408 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
409 $sql .=
", sc.fk_soc, sc.fk_user ";
411 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'facture_fourn as f';
412 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
413 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
415 $sql .=
' WHERE f.fk_soc = s.rowid';
416 $sql .=
' AND f.rowid = '.((int) $facid);
417 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
418 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
420 $resql =
$db->query($sql);
422 $totalnboflines = $num =
$db->num_rows($resql);
424 $obj =
$db->fetch_object($resql);
425 $total = $obj->total;
430 if (!empty(
$conf->use_javascript_ajax)) {
431 print
"\n".
'<script type="text/javascript">';
432 print
'$(document).ready(function () {
434 function _elemToJson(selector)
437 $.map(selector.serializeArray(), function(n,i)
439 subJson[n["name"]] = n["value"];
444 function callForResult(imgId)
446 console.log("callForResult Calculate total of payment");
448 var form = $("#payment_form");
450 json["invoice_type"] = $("#invoice_type").val();
451 json["amountPayment"] = $("#amountpayment").attr("value");
452 json["amounts"] = _elemToJson(form.find("input.amount"));
453 json["remains"] = _elemToJson(form.find("input.remain"));
454 json["token"] = "'.currentToken().
'";
456 json["imgClicked"] = imgId;
459 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
461 json = $.parseJSON(data);
465 for (var key in json)
467 if (key == "result") {
468 if (json["makeRed"]) {
469 $("#"+key).addClass("error");
471 $("#"+key).removeClass("error");
473 json[key]=json["label"]+" "+json[key];
474 $("#"+key).text(json[key]);
475 } else {console.log(key);
476 form.find("input[name*=\""+key+"\"]").each(function() {
477 $(this).attr("value", json[key]);
484 $("#payment_form").find("input.amount").change(function() {
487 $("#payment_form").find("input.amount").keyup(function() {
495 print
' $(document).ready(function () {';
496 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
498 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
502 print
' </script>'.
"\n";
505 print
'<form id="payment_form" name="addpaiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
506 print
'<input type="hidden" name="token" value="'.newToken().
'">';
507 print
'<input type="hidden" name="action" value="add_paiement">';
508 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
509 print
'<input type="hidden" name="facid" value="'.$facid.
'">';
510 print
'<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.
'">';
511 print
'<input type="hidden" name="socid" value="'.$obj->socid.
'">';
512 print
'<input type="hidden" name="type" id="invoice_type" value="'.$object->type.
'">';
513 print
'<input type="hidden" name="societe" value="'.$obj->name.
'">';
517 print
'<table class="border centpercent">';
519 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
'Company').
'</td><td>';
520 $supplierstatic->id = $obj->socid;
521 $supplierstatic->name = $obj->name;
522 print $supplierstatic->getNomUrl(1,
'supplier');
525 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
527 $adddateof = array(array(
'adddateof' =>
$object->date));
528 $adddateof[] = array(
'adddateof' =>
$object->date_echeance,
'labeladddateof' => $langs->transnoentities(
'DateDue'));
529 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"addpaiement", 1, 1, 0,
'',
'', $adddateof);
531 print
'<tr><td class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</td><td>';
532 $form->select_types_paiements(!
GETPOST(
'paiementid') ? $obj->fk_mode_reglement :
GETPOST(
'paiementid'),
'paiementid');
535 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Account').
'</td><td>';
536 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
537 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
540 print
'<tr><td> </td></tr>';
542 print
'<tr><td>'.$langs->trans(
'Numero').
'</td><td><input name="num_paiement" type="text" value="'.(!
GETPOST(
'num_paiement') ?
'' :
GETPOST(
'num_paiement')).
'"></td></tr>';
543 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
544 print
'<td class="tdtop">';
545 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.(!
GETPOST(
'comment') ?
'' :
GETPOST(
'comment')).
'</textarea></td></tr>';
553 $reshook = $hookmanager->executeHooks(
'paymentsupplierinvoices', $parameters, $object, $action);
554 $error = $hookmanager->error;
555 $errors = $hookmanager->errors;
556 if (empty($reshook)) {
560 $sql =
'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
561 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
562 $sql .=
' f.datef as df, f.date_lim_reglement as dlr,';
563 $sql .=
' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
564 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
565 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
566 $sql .=
' WHERE f.entity = '.((int)
$conf->entity);
567 $sql .=
' AND (f.fk_soc = '.((int)
$object->socid);
568 $aux =
$object->fetch_thirdparty();
571 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->parent).
')';
575 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->id).
')';
577 $sql .=
') AND f.paye = 0';
578 $sql .=
' AND f.fk_statut = 1';
580 if (!$displayAllInvoices) {
582 $sql .=
' AND f.type IN (0,1,3,5)';
584 $sql .=
' AND f.type = 2';
589 $sql .=
' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
590 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
591 $sql .=
' f.datef, f.date_lim_reglement';
593 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
595 $resql =
$db->query($sql);
597 $num =
$db->num_rows($resql);
602 if (!empty(
$conf->use_javascript_ajax)) {
604 print
"\n".
'<script type="text/javascript">';
605 print
' $(document).ready(function () {';
606 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
608 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
611 print
' </script>'.
"\n";
615 if ($action ==
'create') {
616 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.((int) $facid).
'&action='.urlencode($action).
'&accountid='.((int) $accountid).
'&display-all-invoices=' . (intval(!$displayAllInvoices));
618 if (empty($displayAllInvoices)) {
619 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
621 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
624 $btnTitle = $langs->trans(
'HideOtherInvoices');
626 $btnTitle = $langs->trans(
'HideCreditNotes');
630 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
631 $moreHtmlRight.= dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
634 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
637 print
'<div class="div-table-responsive-no-min">';
638 print
'<table id="fourn-invoices-paiments-list" data-display-all-invoices="' . (int) $displayAllInvoices .
'" class="tagtable liste" >'.
"\n";
640 print
'<tr class="liste_titre">';
641 print
'<th>'.$langs->trans(
'Invoice').
'</th>';
643 if ($displayAllInvoices) {
644 print
'<th class="center">' . $langs->trans(
'Type') .
'</th>';
646 print
'<th class="center">'.$langs->trans(
'Date').
'</th>';
647 print
'<th class="center">'.$langs->trans(
'DateMaxPayment').
'</th>';
649 $langs->load(
"multicurrency");
650 $labeltoshow =
'<span class="small nowraponall">'.$langs->trans(
"MulticurrencyOriginalCurrency").
'</span>';
651 print
'<th>'.$langs->trans(
'Currency').
'</th>';
652 print
'<th class="right">'.$langs->trans(
'AmountTTC').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
653 print
'<th class="right">'.$langs->trans(
'AlreadyPaid').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
654 print
'<th class="right">'.$langs->trans(
'RemainderToPay').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
655 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
' <span class="opacitymedium">('.$labeltoshow.
')</span></th>';
657 print
'<th class="right">'.$langs->trans(
'AmountTTC').
'</th>';
658 print
'<th class="right">'.$langs->trans(
'AlreadyPaid').
'</th>';
659 print
'<th class="right">'.$langs->trans(
'RemainderToPay').
'</th>';
660 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
'</th>';
668 $totalrecucreditnote = 0;
669 $totalrecudeposits = 0;
671 $objp =
$db->fetch_object($resql);
679 $invoice->fetch($objp->facid);
681 $invoicesupplierstatic->ref = $objp->ref;
682 $invoicesupplierstatic->id = $objp->facid;
684 $paiement = $invoice->getSommePaiement();
685 $creditnotes = $invoice->getSumCreditNotesUsed();
686 $deposits = $invoice->getSumDepositsUsed();
687 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
688 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
691 $multicurrency_payment = 0;
692 $multicurrency_creditnotes = 0;
693 $multicurrency_deposits = 0;
694 $multicurrency_remaintopay = 0;
696 $multicurrency_payment = $invoice->getSommePaiement(1);
697 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
698 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
699 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
700 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
703 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
706 print
'<td data-col="object-name" class="nowraponall">';
707 print
'<div class="inline-block lineheightsmall">';
708 print $invoicesupplierstatic->getNomUrl(1);
709 print
'<br><span class="opacitymedium small" title="'.$langs->trans(
"RefSupplier").
'">';
719 if ($displayAllInvoices) {
727 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
732 print
'<td data-col="datef" data-col-value="'.$db->jdate($objp->df).
'" class="center nowraponall">';
735 print
'<td data-col="datef" data-col-value="" class="center"><b>!!!</b></td>';
739 if ($objp->dlr > 0) {
740 print
'<td data-col="dater" data-col-value="'.$db->jdate($objp->dlr).
'" class="center nowraponall">';
743 if ($invoice->hasDelay()) {
749 print
'<td data-col="dater" data-col-value="" class="center"><b>--</b></td>';
755 print
'<td data-col="multicurrency-code" class="center">'.$objp->multicurrency_code.
"</td>\n";
757 print
'<td data-col="multicurrency-total-ttc" class="right">';
758 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
759 print
price($objp->multicurrency_total_ttc);
763 print
'<td data-col="multicurrency-payment" class="right">';
764 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
765 print
price($sign * $multicurrency_payment);
766 if ($multicurrency_creditnotes) {
767 print
'+'.price($multicurrency_creditnotes);
769 if ($multicurrency_deposits) {
770 print
'+'.price($multicurrency_deposits);
775 print
'<td data-col="remain-to-pay" class="right">';
776 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
777 print
price($sign * (
float) $multicurrency_remaintopay);
781 print
'<td data-col="remain-to-pay-multicurrency-amount" class="right">';
783 $namef =
'multicurrency_amount_'.$objp->facid;
784 $nameRemain =
'multicurrency_remain_'.$objp->facid;
787 if ($displayAllInvoices) {
795 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
796 if ($action !=
'add_paiement') {
797 if (!empty(
$conf->use_javascript_ajax)) {
798 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">';
799 print
img_picto(
"Auto fill",
'rightarrow.png');
802 print
'<input type=hidden class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
803 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount width100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
805 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
806 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
812 print
'<td class="right">'.price($sign * $objp->total_ttc).
'</td>';
814 print
'<td class="right">'.price($sign * $objp->am);
816 print
'+'.price($creditnotes);
819 print
'+'.price($deposits);
823 print
'<td class="right">';
824 print
price($sign * (
float) $remaintopay);
826 $numdirectdebitopen = 0;
827 $totaldirectdebit = 0;
828 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
829 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
830 $sql .=
" WHERE fk_facture_fourn = ".((int) $objp->facid);
831 $sql .=
" AND pfd.traite = 0";
832 $sql .=
" AND pfd.ext_payment_id IS NULL";
834 $result_sql =
$db->query($sql);
836 $obj =
$db->fetch_object($result_sql);
837 $numdirectdebitopen = $obj->nb;
838 $totaldirectdebit = $obj->amount;
842 if ($numdirectdebitopen) {
843 $langs->load(
"withdrawals");
844 print
img_warning($langs->trans(
"WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
850 print
'<td class="center nowraponall">';
852 $namef =
'amount_'.$objp->facid;
853 $nameRemain =
'remain_'.$objp->facid;
856 if ($displayAllInvoices) {
864 if ($action !=
'add_paiement') {
865 if (!empty(
$conf->use_javascript_ajax)) {
866 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">';
867 print
img_picto(
"Auto fill",
'rightarrow.png');
870 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
871 print
'<input '.$max.
' '.$min.
' type="text" class="amount width100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
873 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
879 $total += $objp->total_ht;
880 $total_ttc += $objp->total_ttc;
881 $totalrecu += $objp->am;
882 $totalrecucreditnote += $creditnotes;
883 $totalrecudeposits += $deposits;
892 print
'<tr class="liste_total">';
896 if ($displayAllInvoices) {
900 print
'<td colspan="'.$colspan.
'" class="left" scope="row">'.$langs->trans(
'TotalTTC').
':</td>';
902 print
'<td> </td>';
903 print
'<td> </td>';
904 print
'<td> </td>';
905 print
'<td> </td>';
906 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
908 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
909 print
'<td class="right"><b>'.price($totalrecu);
910 if ($totalrecucreditnote) {
911 print
'+'.price($totalrecucreditnote);
913 if ($totalrecudeposits) {
914 print
'+'.price($totalrecudeposits);
917 print
'<td class="right"><b>'.price((
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
918 print
'<td class="center" id="result" style="font-weight: bold;"></td>';
935 if ($action !=
'add_paiement') {
936 print
'<br><div class="center">';
937 print
'<input type="checkbox" checked id="closepaidinvoices" name="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$langs->trans(
"ClosePaidInvoicesAutomatically").
'</label><br>';
938 print
'<input type="submit" class="button" value="'.$langs->trans(
'ToMakePayment').
'">';
939 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
944 if ($action ==
'add_paiement') {
945 $preselectedchoice = $addwarning ?
'no' :
'yes';
949 if (!empty($totalpayment)) {
950 $text = $langs->trans(
'ConfirmSupplierPayment',
price($totalpayment), $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
952 if (!empty($multicurrency_totalpayment)) {
953 $text .=
'<br>'.$langs->trans(
'ConfirmSupplierPayment',
price($multicurrency_totalpayment), $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
955 if (
GETPOST(
'closepaidinvoices')) {
956 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
957 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
959 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'&socid='.
$object->socid.
'&type='.
$object->type, $langs->trans(
'PayedSuppliersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage 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...
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.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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 '.
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.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date