dolibarr 25.0.0-alpha
paiement.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
6 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
7 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
9 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2017 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
13 * Copyright (C) 2021 Charlene Benke <charlene@patas-monkey.com>
14 * Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
15 * Copyright (C) 2023 Sylvain Legrand <technique@infras.fr>
16 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
38// Load Dolibarr environment
39require '../../main.inc.php';
40
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';
55
56// Load translation files required by the page
57$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
58
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');
65
66$facid = GETPOSTINT('facid');
67$socid = GETPOSTINT('socid');
68$accountid = GETPOSTINT('accountid');
69$day = GETPOSTINT('day');
70$month = GETPOSTINT('month');
71$year = GETPOSTINT('year');
72
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'); // alpha because we must be able to search on "< x"
77$search_company = GETPOST('search_company', 'alpha');
78$search_payment_num = GETPOST('search_payment_num', 'alpha');
79
80$displayAllInvoices = getDolGlobalInt('MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
81if (GETPOSTISSET('display-all-invoices')) {
82 $displayAllInvoices = GETPOSTINT('display-all-invoices');
83}
84
85$limit = GETPOSTINT('limit') ? GETPOST('limit') : $conf->liste_limit;
86$sortfield = GETPOST('sortfield', 'aZ09comma');
87$sortorder = GETPOST('sortorder', 'aZ09comma');
88$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
89if (empty($page) || $page == -1) {
90 $page = 0;
91} // If $page is not defined, or '' or -1
92$offset = $limit * $page;
93$pageprev = $page - 1;
94$pagenext = $page + 1;
95if (!$sortorder) {
96 $sortorder = "DESC";
97}
98if (!$sortfield) {
99 $sortfield = "p.rowid";
100}
101
102$amounts = array();
103$amountsresttopay = array();
104$addwarning = 0;
105
106$multicurrency_amounts = array();
107$multicurrency_amountsresttopay = array();
108
109// Security check
110if ($user->socid > 0) {
111 $socid = $user->socid;
112}
113
114$object = new PaiementFourn($db);
115
116// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
117$hookmanager->initHooks(array('paymentsupplierlist'));
118$extrafields = new ExtraFields($db);
119
120// fetch optionals attributes and labels
121$extrafields->fetch_name_optionals_label($object->table_element);
122
123$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
124
125$arrayfields = array();
126
127$permissiontoadd = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"));
128
129// Check the user is allowed on the supplier invoice this payment page is opened for. Same check as
130// compta/paiement.php does for customer invoices, and as fourn/facture/card.php does for this object.
131// Without it, the page displays and lets a payment be posted on any supplier invoice of any third
132// party, since FactureFournisseur::fetch() does not filter on the entity nor on the assigned customers.
133$invoicetocheck = new FactureFournisseur($db);
134if ($facid > 0 && $invoicetocheck->fetch($facid) > 0) {
135 restrictedArea($user, 'fournisseur', $invoicetocheck->id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', (($invoicetocheck->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0));
136}
137
138
139/*
140 * Actions
141 */
142$error = 0;
143
144if ($cancel) {
145 if (!empty($backtopageforcancel)) {
146 header("Location: ".$backtopageforcancel);
147 exit;
148 } elseif (!empty($backtopage)) {
149 header("Location: ".$backtopage);
150 exit;
151 }
152 header("Location: ".DOL_URL_ROOT.'/fourn/facture/list.php');
153 exit;
154}
155
156if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
157 $search_ref = "";
158 $search_account = "";
159 $search_amount = "";
160 $search_paymenttype = "";
161 $search_payment_num = "";
162 $search_company = "";
163 $day = '';
164 $year = '';
165 $month = '';
166 $search_array_options = array();
167}
168
169$parameters = array('socid' => $socid);
170$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
171if ($reshook < 0) {
172 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
173}
174
175$formquestion = array();
176if (empty($reshook)) {
177 if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $permissiontoadd) {
178 $datepaye = GETPOSTDATE('re', '12:00:00');
179 $paiement_id = 0;
180 $totalpayment = 0;
181 $atleastonepaymentnotnull = 0;
182 $multicurrency_totalpayment = 0;
183
184 // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
185 $tmpinvoice = new FactureFournisseur($db);
186 $i = 0;
187 // Can be into POST or GET (GET when the payment is confirmed from the ajax dialog box)
188 foreach (array_merge($_GET, $_POST) as $key => $value) {
189 if (substr($key, 0, 7) == 'amount_') {
190 $cursorfacid = (int) substr($key, 7);
191 $amounts[$cursorfacid] = price2num(GETPOST($key));
192 if (!empty($amounts[$cursorfacid])) {
193 $atleastonepaymentnotnull++;
194 if (is_numeric($amounts[$cursorfacid])) {
195 $totalpayment += (float) $amounts[$cursorfacid];
196 } else {
197 setEventMessages($langs->transnoentities("InputValueIsNotAnNumber", GETPOST($key)), null, 'warnings');
198 }
199 }
200 $result = $tmpinvoice->fetch($cursorfacid);
201 if ($result <= 0) {
202 dol_print_error($db);
203 }
204 // The id comes from the name of a POST field, so it can name an invoice other than $facid
205 restrictedArea($user, 'fournisseur', $tmpinvoice->id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', (($tmpinvoice->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0));
206 $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
207 if ($amounts[$cursorfacid]) {
208 // Check amount
209 if ((abs((float) $amounts[$cursorfacid]) > abs((float) $amountsresttopay[$cursorfacid]))) {
210 $addwarning = 1;
211 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
212 }
213 // Check date
214 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
215 $langs->load("errors");
216 //$error++;
217 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
218 }
219 }
220
221 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
222 } elseif (substr($key, 0, 21) == 'multicurrency_amount_') {
223 $cursorfacid = (int) substr($key, 21);
224 $multicurrency_amounts[$cursorfacid] = (GETPOST($key) ? price2num(GETPOST($key)) : 0);
225 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
226 if (!empty($multicurrency_amounts[$cursorfacid])) {
227 $atleastonepaymentnotnull++;
228 }
229 $result = $tmpinvoice->fetch($cursorfacid);
230 if ($result <= 0) {
231 dol_print_error($db);
232 }
233 // The id comes from the name of a POST field, so it can name an invoice other than $facid
234 restrictedArea($user, 'fournisseur', $tmpinvoice->id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', (($tmpinvoice->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0));
235 $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
236 if ($multicurrency_amounts[$cursorfacid]) {
237 // Check amount
238 if ((abs((float) $multicurrency_amounts[$cursorfacid]) > abs((float) $multicurrency_amountsresttopay[$cursorfacid]))) {
239 $addwarning = 1;
240 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
241 }
242 // Check date
243 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
244 $langs->load("errors");
245 //$error++;
246 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
247 }
248 }
249
250 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOSTFLOAT($key));
251 }
252 }
253
254 // Check parameters
255 if (GETPOST('paiementid') <= 0) {
256 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
257 $error++;
258 }
259
260 if (isModEnabled("bank")) {
261 // If bank module is on, account is required to enter a payment
262 if (GETPOST('accountid') <= 0) {
263 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
264 $error++;
265 }
266 }
267
268 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
269 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
270 $error++;
271 }
272
273 if (empty($datepaye)) {
274 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
275 $error++;
276 }
277
278 // Check if payments in both currency
279 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
280 setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
281 $error++;
282 }
283 }
284
285 /*
286 * Action add_paiement
287 */
288 if ($action == 'add_paiement') { // Test on permission not required
289 if ($error) {
290 $action = 'create';
291 }
292 // All the next of this action is displayed at the page's bottom.
293 }
294
295
296 /*
297 * Action confirm_paiement
298 */
299 if ($action == 'confirm_paiement' && $confirm == 'yes' && $permissiontoadd) {
300 $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
301
302 $multicurrency_code = array();
303 $multicurrency_tx = array();
304
305 // Clean parameters amount if payment is for a credit note
306 foreach ($amounts as $key => $value) { // How payment is dispatched
307 $tmpinvoice = new FactureFournisseur($db);
308 $tmpinvoice->fetch($key);
309 if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
310 $newvalue = price2num($value, 'MT');
311 $amounts[$key] = - abs((float) $newvalue);
312 }
313 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
314 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
315 }
316
317 foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
318 $tmpinvoice = new FactureFournisseur($db);
319 $tmpinvoice->fetch($key);
320 if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
321 $newvalue = price2num($value, 'MT');
322 $multicurrency_amounts[$key] = - abs((float) $newvalue);
323 }
324 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
325 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
326 }
327
328 if (!$error) {
329 $db->begin();
330
331 $thirdparty = new Societe($db);
332 if ($socid > 0) {
333 $thirdparty->fetch($socid);
334 }
335
336 // Creation of payment line
337 $paiement = new PaiementFourn($db);
338 $paiement->datepaye = $datepaye;
339
340 $correctedAmounts = [];
341 foreach ($amounts as $key => $value) {
342 $correctedAmounts[$key] = (float) $value;
343 }
344
345 $paiement->amounts = $correctedAmounts; // Array of amounts
346 $paiement->multicurrency_amounts = $multicurrency_amounts;
347 $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
348 $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching
349 $paiement->paiementid = GETPOSTINT('paiementid');
350 $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml');
351 $paiement->note_private = GETPOST('comment', 'alpha');
352 $paiement->fk_account = GETPOSTINT('accountid');
353
354 // Create payment and update this->multicurrency_amounts if this->amounts filled or
355 // this->amounts if this->multicurrency_amounts filled.
356 // This also set ->amount and ->multicurrency_amount
357 $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
358 if ($paiement_id < 0) {
359 setEventMessages($paiement->error, $paiement->errors, 'errors');
360 $error++;
361 }
362
363 if (!$error) {
364 $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, GETPOST('chqemetteur'), GETPOST('chqbank'));
365 if ($result < 0) {
366 setEventMessages($paiement->error, $paiement->errors, 'errors');
367 $error++;
368 }
369 }
370
371 if (!$error) {
372 $db->commit();
373
374 // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
375 $invoiceid = 0;
376 foreach ($paiement->amounts as $key => $amount) {
377 $facid = $key;
378 if (is_numeric($amount) && $amount != 0) {
379 if ($invoiceid != 0) {
380 $invoiceid = -1; // There is more than one invoice paid by this payment
381 } else {
382 $invoiceid = $facid;
383 }
384 }
385 }
386 if ($invoiceid > 0) {
387 $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid;
388 } else {
389 $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id;
390 }
391 header('Location: '.$loc);
392 exit;
393 } else {
394 $db->rollback();
395 }
396 }
397 }
398}
399
400
401/*
402 * View
403 */
404
405$form = new Form($db);
406$formother = new FormOther($db);
407
408$supplierstatic = new Societe($db);
409$invoicesupplierstatic = new FactureFournisseur($db);
410
411llxHeader('', $langs->trans('ListPayment'), '', '', 0, 0, '', '', '', 'mod-fourn-facture page-paiement');
412
413// Does the confirm use the dialog box mode (must match the conditions into the formconfirm() method)
414$useajaxconfirm = (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) ? 1 : 0;
415
416if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
417 $object = new FactureFournisseur($db);
418 $result = $object->fetch($facid);
419
420 $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
421 $dateinvoice = ($datefacture == '' ? (getDolGlobalString('MAIN_AUTOFILL_DATE') ? '' : -1) : $datefacture);
422
423 $sql = 'SELECT s.nom as name, s.rowid as socid,';
424 $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
425 if (!$user->hasRight("societe", "client", "voir") && !$socid) {
426 $sql .= ", sc.fk_soc, sc.fk_user ";
427 }
428 $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
429 if (!$user->hasRight("societe", "client", "voir") && !$socid) {
430 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
431 }
432 $sql .= ' WHERE f.fk_soc = s.rowid';
433 $sql .= ' AND f.rowid = '.((int) $facid);
434 if (!$user->hasRight("societe", "client", "voir") && !$socid) {
435 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
436 }
437 $resql = $db->query($sql);
438 if ($resql) {
439 $totalnboflines = $num = $db->num_rows($resql);
440 if ($num) {
441 $obj = $db->fetch_object($resql);
442 $total = $obj->total;
443
444 print load_fiche_titre($langs->trans('DoPayment'));
445
446 // Add realtime total information
447 if (!empty($conf->use_javascript_ajax)) {
448 print "\n".'<script type="text/javascript">';
449 print '$(document).ready(function () {
450
451 function _elemToJson(selector)
452 {
453 var subJson = {};
454 $.map(selector.serializeArray(), function(n,i)
455 {
456 subJson[n["name"]] = n["value"];
457 });
458
459 return subJson;
460 }
461 function callForResult(imgId)
462 {
463 console.log("callForResult Calculate total of payment");
464 var json = {};
465 var form = $("#payment_form");
466
467 json["invoice_type"] = $("#invoice_type").val();
468 json["amountPayment"] = $("#amountpayment").attr("value");
469 json["amounts"] = _elemToJson(form.find("input.amount"));
470 json["remains"] = _elemToJson(form.find("input.remain"));
471 json["token"] = "'.currentToken().'";
472 if (imgId != null) {
473 json["imgClicked"] = imgId;
474 }
475
476 $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
477 {
478 json = $.parseJSON(data);
479
480 form.data(json);
481
482 for (var key in json)
483 {
484 if (key == "result") {
485 if (json["makeRed"]) {
486 $("#"+key).addClass("error");
487 } else {
488 $("#"+key).removeClass("error");
489 }
490 json[key]=json["label"]+" "+json[key];
491 $("#"+key).text(json[key]);
492 } else {console.log(key);
493 form.find("input[name*=\""+key+"\"]").each(function() {
494 $(this).attr("value", json[key]);
495 });
496 }
497 }
498 });
499 }
500 callForResult();
501 $("#payment_form").find("input.amount").change(function() {
502 callForResult();
503 });
504 $("#payment_form").find("input.amount").keyup(function() {
505 callForResult();
506 });
507 ';
508
509 print ' });'."\n";
510
511 //Add js for AutoFill
512 print ' $(document).ready(function () {';
513 print ' $(".AutoFillAmount").on(\'click touchstart\', function(e){
514 e.preventDefault();
515 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
516 });';
517 print ' });'."\n";
518
519 print ' </script>'."\n";
520 }
521
522 print '<form id="payment_form" name="addpaiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
523 print '<input type="hidden" name="token" value="'.newToken().'">';
524 print '<input type="hidden" name="action" value="add_paiement">';
525 print '<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.'">';
526 print '<input type="hidden" name="facid" value="'.$facid.'">';
527 print '<input type="hidden" name="ref_supplier" value="'.$obj->ref_supplier.'">';
528 print '<input type="hidden" name="socid" value="'.$obj->socid.'">';
529 print '<input type="hidden" name="type" id="invoice_type" value="'.$object->type.'">';
530 print '<input type="hidden" name="societe" value="'.$obj->name.'">';
531 print '<input type="hidden" name="page_y" value="">';
532
533 print dol_get_fiche_head([]);
534
535 print '<table class="border centpercent">';
536
537 print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans('Company').'</td><td>';
538 $supplierstatic->id = $obj->socid;
539 $supplierstatic->name = $obj->name;
540 print $supplierstatic->getNomUrl(1, 'supplier');
541 print '</td></tr>';
542
543 print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
544 // $object is default vendor invoice
545 $adddateof = array(array('adddateof' => $object->date));
546 $adddateof[] = array('adddateof' => $object->date_echeance, 'labeladddateof' => $langs->transnoentities('DateDue'));
547 print $form->selectDate($dateinvoice, '', 0, 0, 0, "addpaiement", 1, 1, 0, '', '', $adddateof);
548 print '</td></tr>';
549 print '<tr><td class="fieldrequired">'.$langs->trans('PaymentMode').'</td><td>';
550 print img_picto('', 'bank', 'class="pictofixedwidth"');
551 $form->select_types_paiements(!GETPOST('paiementid') ? $obj->fk_mode_reglement : GETPOST('paiementid'), 'paiementid');
552 print '</td>';
553 if (isModEnabled("bank")) {
554 print '<tr><td class="fieldrequired">'.$langs->trans('Account').'</td><td>';
555 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
556 print $form->select_comptes(empty($accountid) ? $obj->fk_account : $accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1);
557 print '</td></tr>';
558 } else {
559 print '<tr><td>&nbsp;</td></tr>';
560 }
561 print '<tr><td>'.$langs->trans('Numero');
562 print ' <em class="opacitymedium small">('.$langs->trans("ChequeOrTransferNumber").')</em>';
563 print '</td><td><input name="num_paiement" type="text" value="'.(!GETPOST('num_paiement') ? '' : GETPOST('num_paiement')).'"></td></tr>';
564 print '<tr><td>'.$langs->trans('Comments').'</td>';
565 print '<td class="tdtop">';
566 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(!GETPOST('comment') ? '' : GETPOST('comment')).'</textarea></td></tr>';
567 print '</table>';
568 print dol_get_fiche_end();
569
570 $parameters = array(
571 'facid' => $facid,
572 'ref' => $obj->ref
573 );
574 $reshook = $hookmanager->executeHooks('paymentsupplierinvoices', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
575 $error = $hookmanager->error;
576 $errors = $hookmanager->errors;
577 if (empty($reshook)) {
578 /*
579 * All unpaid supplier invoices
580 */
581 $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,';
582 $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
583 $sql .= ' f.datef as df, f.date_lim_reglement as dlr,';
584 $sql .= ' SUM(pf.amount) as am, SUM(pf.multicurrency_amount) as multicurrency_am';
585 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
586 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
587 $sql .= ' WHERE f.entity = '.((int) $conf->entity);
588 $sql .= ' AND (f.fk_soc = '.((int) $object->socid);
589 $aux = $object->fetch_thirdparty();
590 // Can pay invoices of all child of parent company
591 if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($object->thirdparty->parent)) {
592 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $object->thirdparty->parent).')';
593 }
594 // Can pay invoices of all child of myself
595 if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
596 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $object->thirdparty->id).')';
597 }
598 $sql .= ') AND f.paye = 0';
599 $sql .= ' AND f.fk_statut = 1'; // Status=0 => unvalidated, Status=2 => canceled
600
601 if (!$displayAllInvoices) {
603 $sql .= ' AND f.type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
604 } else {
605 $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes
606 }
607 }
608
609 // Group by because we have a total
610 $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,';
611 $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
612 $sql .= ' f.datef, f.date_lim_reglement';
613 // Sort invoices by date and serial number: the older one comes first
614 $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
615
616 $resql = $db->query($sql);
617 if ($resql) {
618 $num = $db->num_rows($resql);
619 if ($num > 0) {
620 $i = 0;
621
622 if (!empty($conf->use_javascript_ajax)) {
623 //Add js for AutoFill
624 print "\n".'<script type="text/javascript">';
625 print ' $(document).ready(function () {';
626 print ' $(".AutoFillAmount").on(\'click touchstart\', function(e){
627 e.preventDefault();
628 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
629 });';
630 print ' });'."\n";
631 print ' </script>'."\n";
632 }
633
634 $moreHtmlRight = '';
635 if ($action == 'create') {
636 $urlToggleDisplayMod = $_SERVER["PHP_SELF"].'?facid='.((int) $facid).'&action='.urlencode($action).'&accountid='.((int) $accountid).'&display-all-invoices=' . (intval(!$displayAllInvoices));
637
638 if (empty($displayAllInvoices)) {
639 $btnTitle = $langs->trans('DisplayOtherInvoicesToo');
641 $btnTitle = $langs->trans('DisplayCreditNotesToo');
642 }
643 } else {
644 $btnTitle = $langs->trans('HideOtherInvoices');
646 $btnTitle = $langs->trans('HideCreditNotes');
647 }
648 }
649
650 // Show a +/- sign to toggle the visibility of credit notes with the credit note picto (grey when not active, colored when active)
651 $btnCssGray = empty($displayAllInvoices) ? ' opacitymediumbycolor' : '';
652 $moreHtmlRight .= '<a class="btnTitle" title="'.dolPrintHTMLForAttribute($btnTitle).'" href="'.dol_escape_htmltag($urlToggleDisplayMod).'">';
653 $moreHtmlRight .= '<span class="fa '.(empty($displayAllInvoices) ? 'fa-plus' : 'fa-minus').' btnTitle-icon inline-blockimp valignmiddle'.$btnCssGray.'" style="font-size:1.6em"></span>';
654 $moreHtmlRight .= img_picto('', empty($displayAllInvoices) ? 'supplier_invoicea_nocolor' : 'supplier_invoicea', 'style="font-size:1.6em"', 0, 0, 1, '', 'inline-blockimp valignmiddle marginleftonlyshort'.$btnCssGray);
655 $moreHtmlRight .= '</a>';
656 }
657
658 print_barre_liste($langs->trans('Invoices'), 0, $_SERVER["PHP_SELF"], '', '', '', '', $num, $totalnboflines, 'bill', 0, $moreHtmlRight, '', 0, 0, 0, 1);
659
660
661 print '<div class="div-table-responsive-no-min">';
662 print '<table id="fourn-invoices-paiments-list" data-display-all-invoices="' . (int) $displayAllInvoices . '" class="tagtable liste" >'."\n";
663 print '<thead>';
664 print '<tr class="liste_titre">';
665 print '<th>'.$langs->trans('Invoice').'</th>';
666 //print '<th>'.$langs->trans('RefSupplier').'</th>';
667 if ($displayAllInvoices) {
668 print '<th class="center">' . $langs->trans('Type') . '</th>';
669 }
670 print '<th class="center">'.$langs->trans('Date').'</th>';
671 print '<th class="center">'.$langs->trans('DateDue').'</th>';
672 if (isModEnabled("multicurrency")) {
673 $langs->load("multicurrency");
674 $labeltoshow = $langs->trans("MulticurrencyOriginalCurrency");
675 print '<th>'.$langs->trans('Currency').'</th>';
676 print '<th class="right">'.$langs->trans('AmountTTC').' <span class="opacitymedium small nowraponall">('.$labeltoshow.')</span></th>';
677 print '<th class="right">'.$langs->trans('AlreadyPaid').' <span class="opacitymedium small nowraponall">('.$labeltoshow.')</span></th>';
678 print '<th class="right">'.$langs->trans('RemainderToPay').' <span class="opacitymedium small nowraponall">('.$labeltoshow.')</span></th>';
679 print '<th class="center">'.$langs->trans('PaymentAmount').' <span class="opacitymedium small nowraponall">('.$labeltoshow.')</span></th>';
680 }
681 print '<th class="right">'.$langs->trans('AmountTTC').'</th>';
682 print '<th class="right">'.$langs->trans('AlreadyPaid').'</th>';
683 print '<th class="right">'.$langs->trans('RemainderToPay').'</th>';
684 print '<th class="center">'.$langs->trans('PaymentAmount').'</th>';
685 print '</tr>';
686 print '</thead>';
687
688 print '<tbody>';
689 $total = 0;
690 $total_ttc = 0;
691 $totalrecu = 0;
692 $totalrecucreditnote = 0; // PHP Warning: Undefined variable $totalrecucreditnote
693 $totalrecudeposits = 0; // PHP Warning: Undefined variable $totalrecudeposits
694 while ($i < $num) {
695 $objp = $db->fetch_object($resql);
696
697 $sign = 1;
698 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE && !$displayAllInvoices) {
699 $sign = -1;
700 }
701
702 $invoice = new FactureFournisseur($db);
703 $invoice->fetch($objp->facid);
704
705 $invoicesupplierstatic->ref = $objp->ref;
706 $invoicesupplierstatic->id = $objp->facid;
707
708 $paiement = $invoice->getSommePaiement();
709 $creditnotes = $invoice->getSumCreditNotesUsed();
710 $deposits = $invoice->getSumDepositsUsed();
711 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
712 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
713
714 // Multicurrency Price
715 $multicurrency_payment = 0;
716 $multicurrency_creditnotes = 0;
717 $multicurrency_deposits = 0;
718 $multicurrency_remaintopay = 0;
719 if (isModEnabled("multicurrency")) {
720 $multicurrency_payment = $invoice->getSommePaiement(1);
721 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
722 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
723 $multicurrency_alreadypayed = (float) price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
724 $multicurrency_remaintopay = (float) price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
725 }
726
727 print '<tr data-row-type="'.$objp->type.'" class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
728
729 // Ref
730 print '<td data-col="object-name" class="nowraponall">';
731 print '<div class="inline-block lineheightsmall">';
732 print '<span data-field="ref">';
733 print $invoicesupplierstatic->getNomUrl(1);
734 print '</span> ';
735 print '<br class="paiement-line-break-for-ref">';
736 print '<span class="spantitle" data-field="ref-supplier" title="'.$langs->trans("RefSupplier").'">';
737 print showValueWithClipboardCPButton($objp->ref_supplier);
738 print '</span>';
739 print '</div>';
740 print '</td>';
741
742 // Ref supplier
743 //print '<td data-col="ref-supplier" >'.$objp->ref_supplier.'</td>';
744
745 // type
746 if ($displayAllInvoices) {
747 $typearray = [
748 FactureFournisseur::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
749 FactureFournisseur::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
750 FactureFournisseur::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
751 FactureFournisseur::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
752 ];
753 // Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
754 print '<td class="center nowraponall">' . $typearray[$objp->type] . '</td>';
755 }
756
757 // Date
758 if ($objp->df > 0) {
759 print '<td data-col="datef" data-col-value="'.$db->jdate($objp->df).'" class="center nowraponall">';
760 print dol_print_date($db->jdate($objp->df), 'day').'</td>';
761 } else {
762 print '<td data-col="datef" data-col-value="" class="center"><b>!!!</b></td>';
763 }
764
765 // Date Max Payment
766 if ($objp->dlr > 0) {
767 print '<td data-col="dater" data-col-value="'.$db->jdate($objp->dlr).'" class="center nowraponall">';
768 print dol_print_date($db->jdate($objp->dlr), 'day');
769
770 if ($invoice->hasDelay()) {
771 print img_warning($langs->trans('Late'));
772 }
773
774 print '</td>';
775 } else {
776 print '<td data-col="dater" data-col-value="" class="center"><b>--</b></td>';
777 }
778
779 // Multicurrency
780 if (isModEnabled("multicurrency")) {
781 // Currency
782 print '<td data-col="multicurrency-code" class="center">'.$objp->multicurrency_code."</td>\n";
783
784 print '<td data-col="multicurrency-total-ttc" class="right">';
785 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
786 print '<span class="amount">'.price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code).'</span>';
787 }
788 print '</td>';
789
790 print '<td data-col="multicurrency-payment" class="right">';
791 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
792 print '<span class="amount">'.price($sign * $multicurrency_payment, 0, $langs, 0, -1, -1, $objp->multicurrency_code);
793 if ($multicurrency_creditnotes) {
794 print '+'.price($multicurrency_creditnotes, 0, $langs, 0, -1, -1, $objp->multicurrency_code);
795 }
796 if ($multicurrency_deposits) {
797 print '+'.price($multicurrency_deposits, 0, $langs, 0, -1, -1, $objp->multicurrency_code);
798 }
799 print '</span>';
800 }
801 print '</td>';
802
803 print '<td data-col="remain-to-pay" class="right">';
804 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
805 print '<span class="amount">'.price($sign * (float) $multicurrency_remaintopay, 0, $langs, 0, -1, -1, $objp->multicurrency_code).'</span>';
806 }
807 print '</td>';
808
809 print '<td data-col="remain-to-pay-multicurrency-amount" class="right">';
810 // Add remind multicurrency amount
811 $namef = 'multicurrency_amount_'.$objp->facid;
812 $nameRemain = 'multicurrency_remain_'.$objp->facid;
813
814 $min = $max = '';
815 if ($displayAllInvoices) {
816 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
817 $max = ' max="0" ';
818 } else {
819 $min = ' min="0" ';
820 }
821 }
822
823 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
824 if ($action != 'add_paiement' || $useajaxconfirm) {
825 if (!empty($conf->use_javascript_ajax)) {
826 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $multicurrency_remaintopay).'">';
827 print img_picto("Auto fill", 'rightarrow.png');
828 print '</button>';
829 }
830 print '<input type=hidden class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
831 print '<input '.$min.' '.$max.' type="text" class="multicurrency_amount right width100" name="'.$namef.'" placeholder="'.dol_escape_htmltag($langs->getCurrencySymbol($objp->multicurrency_code)).'" value="'.GETPOST($namef).'">';
832 } else {
833 print '<input type="text" class="width100" name="'.$namef.'_disabled" placeholder="'.dol_escape_htmltag($langs->getCurrencySymbol($objp->multicurrency_code)).'" value="'.GETPOST($namef).'" disabled>';
834 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
835 }
836 }
837 print "</td>";
838 }
839
840 print '<td class="right"><span class="amount">'.price($sign * $objp->total_ttc).'</span></td>';
841
842 print '<td class="right"><span class="amount">'.price($sign * $objp->am);
843 if ($creditnotes) {
844 print '+'.price($creditnotes);
845 }
846 if ($deposits) {
847 print '+'.price($deposits);
848 }
849 print '</span></td>';
850
851 print '<td class="right">';
852 print '<span class="amount">'.price($sign * (float) $remaintopay).'</span>';
853 if (isModEnabled('paymentbybanktransfer')) {
854 $numdirectdebitopen = 0;
855 $totaldirectdebit = 0;
856 $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
857 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
858 $sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid);
859 $sql .= " AND pfd.traite = 0";
860 $sql .= " AND pfd.ext_payment_id IS NULL";
861
862 $result_sql = $db->query($sql);
863 if ($result_sql) {
864 $obj = $db->fetch_object($result_sql);
865 $numdirectdebitopen = $obj->nb;
866 $totaldirectdebit = $obj->amount;
867 } else {
868 dol_print_error($db);
869 }
870 if ($numdirectdebitopen) {
871 $langs->load("withdrawals");
872 print img_warning($langs->trans("WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
873 }
874 }
875 print '</td>';
876
877 // Amount
878 print '<td class="center nowraponall">';
879
880 $namef = 'amount_'.$objp->facid;
881 $nameRemain = 'remain_'.$objp->facid;
882
883 $min = $max = '';
884 if ($displayAllInvoices) {
885 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
886 $max = ' max="0" ';
887 } else {
888 $min = ' min="0" ';
889 }
890 }
891
892 if ($action != 'add_paiement' || $useajaxconfirm) {
893 if (!empty($conf->use_javascript_ajax)) {
894 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $remaintopay).'">';
895 print img_picto("Auto fill", 'rightarrow.png');
896 print '</button>';
897 }
898 print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
899 print '<input '.$max.' '.$min.' type="text" class="amount right width100" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is required to be used by javascript callForResult();
900 } else {
901 print '<input type="text" class="width100" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
902 print '<input type="hidden" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is required to be used by javascript callForResult();
903 }
904 print "</td>";
905
906 print "</tr>\n";
907 $total += $objp->total_ht;
908 $total_ttc += $objp->total_ttc;
909 $totalrecu += $objp->am;
910 $totalrecucreditnote += $creditnotes;
911 $totalrecudeposits += $deposits;
912 $i++;
913 }
914 //print '</tbody>';
915
916 if ($i > 1) {
917 //print '<tfoot>';
918
919 // Print total
920 print '<tr class="liste_total">';
921 $colspan = 3;
922
923 // type
924 if ($displayAllInvoices) {
925 $colspan++;
926 }
927
928 print '<td colspan="'.$colspan.'" class="left" scope="row">'.$langs->trans('TotalTTC').':</td>';
929 if (isModEnabled("multicurrency")) {
930 print '<td>&nbsp;</td>';
931 print '<td>&nbsp;</td>';
932 print '<td>&nbsp;</td>';
933 print '<td>&nbsp;</td>';
934 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
935 }
936 print '<td class="right"><b>'.price($total_ttc).'</b></td>';
937 print '<td class="right"><b>'.price($totalrecu);
938 if ($totalrecucreditnote) {
939 print '+'.price($totalrecucreditnote);
940 }
941 if ($totalrecudeposits) {
942 print '+'.price($totalrecudeposits);
943 }
944 print '</b></td>';
945 print '<td class="right"><b>'.price((float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
946 print '<td class="center" id="result" style="font-weight: bold;"></td>'; // Autofilled
947 print "</tr>\n";
948 //print '</tfoot>';
949 }
950 print '</tbody>';
951
952 print "</table>\n";
953
954 print "</div>";
955 }
956 $db->free($resql);
957 } else {
958 dol_print_error($db);
959 }
960 }
961
962 // Fields of the payment form, so the ajax confirm dialog can propagate them to the confirm action
963 if ($action == 'add_paiement') {
964 $i = count($formquestion);
965
966 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'paiementid', 'value' => GETPOSTINT('paiementid'));
967 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'accountid', 'value' => $accountid);
968 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'reday', 'value' => GETPOSTINT('reday'));
969 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'remonth', 'value' => GETPOSTINT('remonth'));
970 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'reyear', 'value' => GETPOSTINT('reyear'));
971 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'num_paiement', 'value' => GETPOST('num_paiement', 'alphanohtml'));
972 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'comment', 'value' => GETPOST('comment', 'restricthtml'));
973 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'closepaidinvoices', 'value' => GETPOST('closepaidinvoices'));
974 }
975
976 // Save + Cancel Buttons
977 // When the confirm is a dialog box, the save button is kept so user can close the dialog,
978 // change data and submit the payment form again
979 if ($action != 'add_paiement' || $useajaxconfirm) {
980 // Keep the checkbox state entered by the user when the page is rendered again after a submit
981 $closepaidinvoiceschecked = (($action == 'add_paiement' && !GETPOST('closepaidinvoices')) ? '' : ' checked');
982
983 print '<br><div class="center">';
984 print '<input type="checkbox"'.$closepaidinvoiceschecked.' id="closepaidinvoices" name="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$langs->trans("ClosePaidInvoicesAutomatically").'</label><br>';
985 print '<input type="submit" class="button reposition" value="'.$langs->trans('ToMakePayment').'">';
986 print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
987 print '</div>';
988 }
989
990 // Form to confirm payment
991 if ($action == 'add_paiement') {
992 $preselectedchoice = $addwarning ? 'no' : 'yes';
993
994 print '<br>';
995 $text = '';
996 if (!empty($totalpayment)) {
997 $text = $langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->transnoentitiesnoconv("Currency".$conf->currency));
998 }
999 if (!empty($multicurrency_totalpayment)) {
1000 $text .= '<br>'.$langs->trans('ConfirmSupplierPayment', price($multicurrency_totalpayment), $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
1001 }
1002 if (GETPOST('closepaidinvoices')) {
1003 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
1004 if (empty($useajaxconfirm)) {
1005 // In dialog mode, the value is read from the checkbox by the dialog box itself.
1006 // In inline mode, we must carry it into the confirm form.
1007 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
1008 }
1009 }
1010 print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id.'&socid='.$object->socid.'&type='.$object->type, $langs->trans('PayedSuppliersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice, $useajaxconfirm);
1011 }
1012
1013 print '</form>';
1014 }
1015 } else {
1016 dol_print_error($db);
1017 }
1018}
1019
1020// End of page
1021llxFooter();
1022$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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.
Definition wrapper.php:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage standard extra fields.
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 generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
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...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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.
Definition html.lib.php:542
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
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)
Definition html.lib.php:183
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
Definition receipt.php:492
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.