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);
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"));
134if ($facid > 0 && $invoicetocheck->fetch($facid) > 0) {
145 if (!empty($backtopageforcancel)) {
146 header(
"Location: ".$backtopageforcancel);
148 } elseif (!empty($backtopage)) {
149 header(
"Location: ".$backtopage);
152 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/list.php');
156if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
158 $search_account =
"";
160 $search_paymenttype =
"";
161 $search_payment_num =
"";
162 $search_company =
"";
166 $search_array_options = array();
169$parameters = array(
'socid' => $socid);
170$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
172 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
175$formquestion = array();
176if (empty($reshook)) {
177 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $permissiontoadd) {
181 $atleastonepaymentnotnull = 0;
182 $multicurrency_totalpayment = 0;
187 foreach ($_POST as $key => $value) {
188 if (substr($key, 0, 7) ==
'amount_') {
189 $cursorfacid = (int) substr($key, 7);
191 if (!empty($amounts[$cursorfacid])) {
192 $atleastonepaymentnotnull++;
193 if (is_numeric($amounts[$cursorfacid])) {
194 $totalpayment += (float) $amounts[$cursorfacid];
196 setEventMessages($langs->transnoentities(
"InputValueIsNotAnNumber",
GETPOST($key)),
null,
'warnings');
199 $result = $tmpinvoice->fetch($cursorfacid);
201 dol_print_error($db);
205 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
206 if ($amounts[$cursorfacid]) {
208 if ((abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
210 $formquestion[
'text'] = img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
213 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
214 $langs->load(
"errors");
216 setEventMessages($langs->transnoentities(
"WarningPaymentDateLowerThanInvoiceDate",
dol_print_date($datepaye,
'day'),
dol_print_date($tmpinvoice->date,
'day'), $tmpinvoice->ref),
null,
'warnings');
220 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
221 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
222 $cursorfacid = (int) substr($key, 21);
224 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
225 if (!empty($multicurrency_amounts[$cursorfacid])) {
226 $atleastonepaymentnotnull++;
228 $result = $tmpinvoice->fetch($cursorfacid);
230 dol_print_error($db);
234 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
235 if ($multicurrency_amounts[$cursorfacid]) {
237 if ((abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
239 $formquestion[
'text'] = img_warning($langs->trans(
"PaymentHigherThanReminderToPaySupplier")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPaySupplier");
242 if ($datepaye && ($datepaye < $tmpinvoice->
date)) {
243 $langs->load(
"errors");
245 setEventMessages($langs->transnoentities(
"WarningPaymentDateLowerThanInvoiceDate",
dol_print_date($datepaye,
'day'),
dol_print_date($tmpinvoice->date,
'day'), $tmpinvoice->ref),
null,
'warnings');
249 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTFLOAT($key));
254 if (
GETPOST(
'paiementid') <= 0) {
255 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
261 if (
GETPOST(
'accountid') <= 0) {
262 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
267 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
268 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
272 if (empty($datepaye)) {
273 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
278 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
279 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
287 if ($action ==
'add_paiement') {
298 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $permissiontoadd) {
301 $multicurrency_code = array();
302 $multicurrency_tx = array();
305 foreach ($amounts as $key => $value) {
307 $tmpinvoice->fetch($key);
310 $amounts[$key] = - abs((
float) $newvalue);
312 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
313 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
316 foreach ($multicurrency_amounts as $key => $value) {
318 $tmpinvoice->fetch($key);
321 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
323 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
324 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
330 $thirdparty =
new Societe($db);
332 $thirdparty->fetch($socid);
337 $paiement->datepaye = $datepaye;
339 $correctedAmounts = [];
340 foreach ($amounts as $key => $value) {
341 $correctedAmounts[$key] = (float) $value;
344 $paiement->amounts = $correctedAmounts;
345 $paiement->multicurrency_amounts = $multicurrency_amounts;
346 $paiement->multicurrency_code = $multicurrency_code;
347 $paiement->multicurrency_tx = $multicurrency_tx;
348 $paiement->paiementid =
GETPOSTINT(
'paiementid');
349 $paiement->num_payment =
GETPOST(
'num_paiement',
'alphanohtml');
350 $paiement->note_private =
GETPOST(
'comment',
'alpha');
351 $paiement->fk_account =
GETPOSTINT(
'accountid');
356 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
357 if ($paiement_id < 0) {
358 setEventMessages($paiement->error, $paiement->errors,
'errors');
363 $result = $paiement->addPaymentToBank($user,
'payment_supplier',
'(SupplierInvoicePayment)', $accountid,
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
365 setEventMessages($paiement->error, $paiement->errors,
'errors');
375 foreach ($paiement->amounts as $key => $amount) {
377 if (is_numeric($amount) && $amount != 0) {
378 if ($invoiceid != 0) {
385 if ($invoiceid > 0) {
386 $loc = DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$invoiceid;
388 $loc = DOL_URL_ROOT.
'/fourn/paiement/card.php?id='.$paiement_id;
390 header(
'Location: '.$loc);
404$form =
new Form($db);
407$supplierstatic =
new Societe($db);
410llxHeader(
'', $langs->trans(
'ListPayment'),
'',
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-paiement');
412if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
414 $result =
$object->fetch($facid);
417 $dateinvoice = ($datefacture ==
'' ? (
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datefacture);
419 $sql =
'SELECT s.nom as name, s.rowid as socid,';
420 $sql .=
' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
421 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
422 $sql .=
", sc.fk_soc, sc.fk_user ";
424 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'facture_fourn as f';
425 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
426 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
428 $sql .=
' WHERE f.fk_soc = s.rowid';
429 $sql .=
' AND f.rowid = '.((int) $facid);
430 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
431 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
433 $resql = $db->query($sql);
435 $totalnboflines = $num = $db->num_rows($resql);
437 $obj = $db->fetch_object($resql);
438 $total = $obj->total;
443 if (!empty(
$conf->use_javascript_ajax)) {
444 print
"\n".
'<script type="text/javascript">';
445 print
'$(document).ready(function () {
447 function _elemToJson(selector)
450 $.map(selector.serializeArray(), function(n,i)
452 subJson[n["name"]] = n["value"];
457 function callForResult(imgId)
459 console.log("callForResult Calculate total of payment");
461 var form = $("#payment_form");
463 json["invoice_type"] = $("#invoice_type").val();
464 json["amountPayment"] = $("#amountpayment").attr("value");
465 json["amounts"] = _elemToJson(form.find("input.amount"));
466 json["remains"] = _elemToJson(form.find("input.remain"));
467 json["token"] = "'.currentToken().
'";
469 json["imgClicked"] = imgId;
472 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
474 json = $.parseJSON(data);
478 for (var key in json)
480 if (key == "result") {
481 if (json["makeRed"]) {
482 $("#"+key).addClass("error");
484 $("#"+key).removeClass("error");
486 json[key]=json["label"]+" "+json[key];
487 $("#"+key).text(json[key]);
488 } else {console.log(key);
489 form.find("input[name*=\""+key+"\"]").each(function() {
490 $(this).attr("value", json[key]);
497 $("#payment_form").find("input.amount").change(function() {
500 $("#payment_form").find("input.amount").keyup(function() {
508 print
' $(document).ready(function () {';
509 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
511 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
515 print
' </script>'.
"\n";
518 print
'<form id="payment_form" name="addpaiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
519 print
'<input type="hidden" name="token" value="'.newToken().
'">';
520 print
'<input type="hidden" name="action" value="add_paiement">';
521 print
'<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.
'">';
522 print
'<input type="hidden" name="facid" value="'.$facid.
'">';
523 print
'<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.
'">';
524 print
'<input type="hidden" name="socid" value="'.$obj->socid.
'">';
525 print
'<input type="hidden" name="type" id="invoice_type" value="'.$object->type.
'">';
526 print
'<input type="hidden" name="societe" value="'.$obj->name.
'">';
530 print
'<table class="border centpercent">';
532 print
'<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans(
'Company').
'</td><td>';
533 $supplierstatic->id = $obj->socid;
534 $supplierstatic->name = $obj->name;
535 print $supplierstatic->getNomUrl(1,
'supplier');
538 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
540 $adddateof = array(array(
'adddateof' =>
$object->date));
541 $adddateof[] = array(
'adddateof' =>
$object->date_echeance,
'labeladddateof' => $langs->transnoentities(
'DateDue'));
542 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"addpaiement", 1, 1, 0,
'',
'', $adddateof);
544 print
'<tr><td class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</td><td>';
545 $form->select_types_paiements(!
GETPOST(
'paiementid') ? $obj->fk_mode_reglement :
GETPOST(
'paiementid'),
'paiementid');
548 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Account').
'</td><td>';
549 print img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
550 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
553 print
'<tr><td> </td></tr>';
555 print
'<tr><td>'.$langs->trans(
'Numero');
556 print
' <em class="opacitymedium small">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
557 print
'</td><td><input name="num_paiement" type="text" value="'.(!
GETPOST(
'num_paiement') ?
'' :
GETPOST(
'num_paiement')).
'"></td></tr>';
558 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
559 print
'<td class="tdtop">';
560 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.(!
GETPOST(
'comment') ?
'' :
GETPOST(
'comment')).
'</textarea></td></tr>';
568 $reshook = $hookmanager->executeHooks(
'paymentsupplierinvoices', $parameters, $object, $action);
569 $error = $hookmanager->error;
570 $errors = $hookmanager->errors;
571 if (empty($reshook)) {
575 $sql =
'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
576 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
577 $sql .=
' f.datef as df, f.date_lim_reglement as dlr,';
578 $sql .=
' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
579 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
580 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
581 $sql .=
' WHERE f.entity = '.((int)
$conf->entity);
582 $sql .=
' AND (f.fk_soc = '.((int)
$object->socid);
583 $aux =
$object->fetch_thirdparty();
586 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->parent).
')';
590 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int)
$object->thirdparty->id).
')';
592 $sql .=
') AND f.paye = 0';
593 $sql .=
' AND f.fk_statut = 1';
595 if (!$displayAllInvoices) {
597 $sql .=
' AND f.type IN (0,1,3,5)';
599 $sql .=
' AND f.type = 2';
604 $sql .=
' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
605 $sql .=
' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
606 $sql .=
' f.datef, f.date_lim_reglement';
608 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
610 $resql = $db->query($sql);
612 $num = $db->num_rows($resql);
617 if (!empty(
$conf->use_javascript_ajax)) {
619 print
"\n".
'<script type="text/javascript">';
620 print
' $(document).ready(function () {';
621 print
' $(".AutoFillAmount").on(\'click touchstart\', function(e){
623 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
626 print
' </script>'.
"\n";
630 if ($action ==
'create') {
631 $urlToggleDisplayMod = $_SERVER[
"PHP_SELF"].
'?facid='.((int) $facid).
'&action='.urlencode($action).
'&accountid='.((int) $accountid).
'&display-all-invoices=' . (intval(!$displayAllInvoices));
633 if (empty($displayAllInvoices)) {
634 $btnTitle = $langs->trans(
'DisplayOtherInvoicesToo');
636 $btnTitle = $langs->trans(
'DisplayCreditNotesToo');
639 $btnTitle = $langs->trans(
'HideOtherInvoices');
641 $btnTitle = $langs->trans(
'HideCreditNotes');
645 $btnIcon = empty($displayAllInvoices) ?
'fa fa-eye' :
'fa fa-eye-slash';
646 $moreHtmlRight.=
dolGetButtonTitle($btnTitle,
'', $btnIcon, $urlToggleDisplayMod);
649 print_barre_liste($langs->trans(
'Invoices'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $num, $totalnboflines,
'bill', 0, $moreHtmlRight,
'', 0, 0, 0, 1);
652 print
'<div class="div-table-responsive-no-min">';
653 print
'<table id="fourn-invoices-paiments-list" data-display-all-invoices="' . (int) $displayAllInvoices .
'" class="tagtable liste" >'.
"\n";
655 print
'<tr class="liste_titre">';
656 print
'<th>'.$langs->trans(
'Invoice').
'</th>';
658 if ($displayAllInvoices) {
659 print
'<th class="center">' . $langs->trans(
'Type') .
'</th>';
661 print
'<th class="center">'.$langs->trans(
'Date').
'</th>';
662 print
'<th class="center">'.$langs->trans(
'DateDue').
'</th>';
664 $langs->load(
"multicurrency");
665 $labeltoshow = $langs->trans(
"MulticurrencyOriginalCurrency");
666 print
'<th>'.$langs->trans(
'Currency').
'</th>';
667 print
'<th class="right">'.$langs->trans(
'AmountTTC').
' <span class="opacitymedium small nowraponall">('.$labeltoshow.
')</span></th>';
668 print
'<th class="right">'.$langs->trans(
'AlreadyPaid').
' <span class="opacitymedium small nowraponall">('.$labeltoshow.
')</span></th>';
669 print
'<th class="right">'.$langs->trans(
'RemainderToPay').
' <span class="opacitymedium small nowraponall">('.$labeltoshow.
')</span></th>';
670 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
' <span class="opacitymedium small nowraponall">('.$labeltoshow.
')</span></th>';
672 print
'<th class="right">'.$langs->trans(
'AmountTTC').
'</th>';
673 print
'<th class="right">'.$langs->trans(
'AlreadyPaid').
'</th>';
674 print
'<th class="right">'.$langs->trans(
'RemainderToPay').
'</th>';
675 print
'<th class="center">'.$langs->trans(
'PaymentAmount').
'</th>';
683 $totalrecucreditnote = 0;
684 $totalrecudeposits = 0;
686 $objp = $db->fetch_object($resql);
694 $invoice->fetch($objp->facid);
696 $invoicesupplierstatic->ref = $objp->ref;
697 $invoicesupplierstatic->id = $objp->facid;
699 $paiement = $invoice->getSommePaiement();
700 $creditnotes = $invoice->getSumCreditNotesUsed();
701 $deposits = $invoice->getSumDepositsUsed();
702 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
703 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
706 $multicurrency_payment = 0;
707 $multicurrency_creditnotes = 0;
708 $multicurrency_deposits = 0;
709 $multicurrency_remaintopay = 0;
711 $multicurrency_payment = $invoice->getSommePaiement(1);
712 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
713 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
714 $multicurrency_alreadypayed = (float)
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
715 $multicurrency_remaintopay = (float)
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
718 print
'<tr data-row-type="'.$objp->type.
'" class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
721 print
'<td data-col="object-name" class="nowraponall">';
722 print
'<div class="inline-block lineheightsmall">';
723 print
'<span data-field="ref">';
724 print $invoicesupplierstatic->getNomUrl(1);
726 print
'<br class="paiement-line-break-for-ref">';
727 print
'<span class="spantitle" data-field="ref-supplier" title="'.$langs->trans(
"RefSupplier").
'">';
737 if ($displayAllInvoices) {
745 print
'<td class="center nowraponall">' . $typearray[$objp->type] .
'</td>';
750 print
'<td data-col="datef" data-col-value="'.$db->jdate($objp->df).
'" class="center nowraponall">';
753 print
'<td data-col="datef" data-col-value="" class="center"><b>!!!</b></td>';
757 if ($objp->dlr > 0) {
758 print
'<td data-col="dater" data-col-value="'.$db->jdate($objp->dlr).
'" class="center nowraponall">';
761 if ($invoice->hasDelay()) {
762 print img_warning($langs->trans(
'Late'));
767 print
'<td data-col="dater" data-col-value="" class="center"><b>--</b></td>';
773 print
'<td data-col="multicurrency-code" class="center">'.$objp->multicurrency_code.
"</td>\n";
775 print
'<td data-col="multicurrency-total-ttc" class="right">';
776 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
777 print
price($objp->multicurrency_total_ttc);
781 print
'<td data-col="multicurrency-payment" class="right">';
782 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
783 print
price($sign * $multicurrency_payment);
784 if ($multicurrency_creditnotes) {
785 print
'+'.price($multicurrency_creditnotes);
787 if ($multicurrency_deposits) {
788 print
'+'.price($multicurrency_deposits);
793 print
'<td data-col="remain-to-pay" class="right">';
794 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
795 print
price($sign * (
float) $multicurrency_remaintopay);
799 print
'<td data-col="remain-to-pay-multicurrency-amount" class="right">';
801 $namef =
'multicurrency_amount_'.$objp->facid;
802 $nameRemain =
'multicurrency_remain_'.$objp->facid;
805 if ($displayAllInvoices) {
813 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
814 if ($action !=
'add_paiement') {
815 if (!empty(
$conf->use_javascript_ajax)) {
816 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $multicurrency_remaintopay).
'">';
817 print img_picto(
"Auto fill",
'rightarrow.png');
820 print
'<input type=hidden class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
821 print
'<input '.$min.
' '.$max.
' type="text" class="multicurrency_amount width100" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
823 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
824 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
830 print
'<td class="right"><span class="amount">'.price($sign * $objp->total_ttc).
'</span></td>';
832 print
'<td class="right"><span class="amount">'.price($sign * $objp->am);
834 print
'+'.price($creditnotes);
837 print
'+'.price($deposits);
839 print
'</span></td>';
841 print
'<td class="right">';
842 print
'<span class="amount">'.price($sign * (
float) $remaintopay).
'</span>';
844 $numdirectdebitopen = 0;
845 $totaldirectdebit = 0;
846 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
847 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
848 $sql .=
" WHERE fk_facture_fourn = ".((int) $objp->facid);
849 $sql .=
" AND pfd.traite = 0";
850 $sql .=
" AND pfd.ext_payment_id IS NULL";
852 $result_sql = $db->query($sql);
854 $obj = $db->fetch_object($result_sql);
855 $numdirectdebitopen = $obj->nb;
856 $totaldirectdebit = $obj->amount;
858 dol_print_error($db);
860 if ($numdirectdebitopen) {
861 $langs->load(
"withdrawals");
862 print img_warning($langs->trans(
"WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
868 print
'<td class="center nowraponall">';
870 $namef =
'amount_'.$objp->facid;
871 $nameRemain =
'remain_'.$objp->facid;
874 if ($displayAllInvoices) {
882 if ($action !=
'add_paiement') {
883 if (!empty(
$conf->use_javascript_ajax)) {
884 print
'<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.
'" data-value="'.($sign * (float) $remaintopay).
'">';
885 print img_picto(
"Auto fill",
'rightarrow.png');
888 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
889 print
'<input '.$max.
' '.$min.
' type="text" class="amount width100" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
891 print
'<input type="text" class="width100" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
897 $total += $objp->total_ht;
898 $total_ttc += $objp->total_ttc;
899 $totalrecu += $objp->am;
900 $totalrecucreditnote += $creditnotes;
901 $totalrecudeposits += $deposits;
910 print
'<tr class="liste_total">';
914 if ($displayAllInvoices) {
918 print
'<td colspan="'.$colspan.
'" class="left" scope="row">'.$langs->trans(
'TotalTTC').
':</td>';
920 print
'<td> </td>';
921 print
'<td> </td>';
922 print
'<td> </td>';
923 print
'<td> </td>';
924 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
926 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
927 print
'<td class="right"><b>'.price($totalrecu);
928 if ($totalrecucreditnote) {
929 print
'+'.price($totalrecucreditnote);
931 if ($totalrecudeposits) {
932 print
'+'.price($totalrecudeposits);
935 print
'<td class="right"><b>'.price((
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
936 print
'<td class="center" id="result" style="font-weight: bold;"></td>';
948 dol_print_error($db);
953 if ($action !=
'add_paiement') {
954 print
'<br><div class="center">';
955 print
'<input type="checkbox" checked id="closepaidinvoices" name="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$langs->trans(
"ClosePaidInvoicesAutomatically").
'</label><br>';
956 print
'<input type="submit" class="button" value="'.$langs->trans(
'ToMakePayment').
'">';
957 print
' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
962 if ($action ==
'add_paiement') {
963 $preselectedchoice = $addwarning ?
'no' :
'yes';
967 if (!empty($totalpayment)) {
968 $text = $langs->trans(
'ConfirmSupplierPayment',
price($totalpayment), $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
970 if (!empty($multicurrency_totalpayment)) {
971 $text .=
'<br>'.$langs->trans(
'ConfirmSupplierPayment',
price($multicurrency_totalpayment), $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
973 if (
GETPOST(
'closepaidinvoices')) {
974 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
975 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
977 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'&socid='.
$object->socid.
'&type='.
$object->type, $langs->trans(
'PayedSuppliersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
983 dol_print_error($db);
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...
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.