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 foreach ($_POST as $key => $value) {
188 if (substr($key, 0, 7) == 'amount_') {
189 $cursorfacid = (int) substr($key, 7);
190 $amounts[$cursorfacid] = price2num(GETPOST($key));
191 if (!empty($amounts[$cursorfacid])) {
192 $atleastonepaymentnotnull++;
193 if (is_numeric($amounts[$cursorfacid])) {
194 $totalpayment += (float) $amounts[$cursorfacid];
195 } else {
196 setEventMessages($langs->transnoentities("InputValueIsNotAnNumber", GETPOST($key)), null, 'warnings');
197 }
198 }
199 $result = $tmpinvoice->fetch($cursorfacid);
200 if ($result <= 0) {
201 dol_print_error($db);
202 }
203 // The id comes from the name of a POST field, so it can name an invoice other than $facid
204 restrictedArea($user, 'fournisseur', $tmpinvoice->id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', (($tmpinvoice->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0));
205 $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
206 if ($amounts[$cursorfacid]) {
207 // Check amount
208 if ((abs((float) $amounts[$cursorfacid]) > abs((float) $amountsresttopay[$cursorfacid]))) {
209 $addwarning = 1;
210 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
211 }
212 // Check date
213 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
214 $langs->load("errors");
215 //$error++;
216 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
217 }
218 }
219
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);
223 $multicurrency_amounts[$cursorfacid] = (GETPOST($key) ? price2num(GETPOST($key)) : 0);
224 $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
225 if (!empty($multicurrency_amounts[$cursorfacid])) {
226 $atleastonepaymentnotnull++;
227 }
228 $result = $tmpinvoice->fetch($cursorfacid);
229 if ($result <= 0) {
230 dol_print_error($db);
231 }
232 // The id comes from the name of a POST field, so it can name an invoice other than $facid
233 restrictedArea($user, 'fournisseur', $tmpinvoice->id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', (($tmpinvoice->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0));
234 $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
235 if ($multicurrency_amounts[$cursorfacid]) {
236 // Check amount
237 if ((abs((float) $multicurrency_amounts[$cursorfacid]) > abs((float) $multicurrency_amountsresttopay[$cursorfacid]))) {
238 $addwarning = 1;
239 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
240 }
241 // Check date
242 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
243 $langs->load("errors");
244 //$error++;
245 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
246 }
247 }
248
249 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOSTFLOAT($key));
250 }
251 }
252
253 // Check parameters
254 if (GETPOST('paiementid') <= 0) {
255 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
256 $error++;
257 }
258
259 if (isModEnabled("bank")) {
260 // If bank module is on, account is required to enter a payment
261 if (GETPOST('accountid') <= 0) {
262 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
263 $error++;
264 }
265 }
266
267 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
268 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
269 $error++;
270 }
271
272 if (empty($datepaye)) {
273 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
274 $error++;
275 }
276
277 // Check if payments in both currency
278 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
279 setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
280 $error++;
281 }
282 }
283
284 /*
285 * Action add_paiement
286 */
287 if ($action == 'add_paiement') { // Test on permission not required
288 if ($error) {
289 $action = 'create';
290 }
291 // All the next of this action is displayed at the page's bottom.
292 }
293
294
295 /*
296 * Action confirm_paiement
297 */
298 if ($action == 'confirm_paiement' && $confirm == 'yes' && $permissiontoadd) {
299 $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
300
301 $multicurrency_code = array();
302 $multicurrency_tx = array();
303
304 // Clean parameters amount if payment is for a credit note
305 foreach ($amounts as $key => $value) { // How payment is dispatched
306 $tmpinvoice = new FactureFournisseur($db);
307 $tmpinvoice->fetch($key);
308 if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
309 $newvalue = price2num($value, 'MT');
310 $amounts[$key] = - abs((float) $newvalue);
311 }
312 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
313 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
314 }
315
316 foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
317 $tmpinvoice = new FactureFournisseur($db);
318 $tmpinvoice->fetch($key);
319 if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
320 $newvalue = price2num($value, 'MT');
321 $multicurrency_amounts[$key] = - abs((float) $newvalue);
322 }
323 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
324 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
325 }
326
327 if (!$error) {
328 $db->begin();
329
330 $thirdparty = new Societe($db);
331 if ($socid > 0) {
332 $thirdparty->fetch($socid);
333 }
334
335 // Creation of payment line
336 $paiement = new PaiementFourn($db);
337 $paiement->datepaye = $datepaye;
338
339 $correctedAmounts = [];
340 foreach ($amounts as $key => $value) {
341 $correctedAmounts[$key] = (float) $value;
342 }
343
344 $paiement->amounts = $correctedAmounts; // Array of amounts
345 $paiement->multicurrency_amounts = $multicurrency_amounts;
346 $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
347 $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching
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');
352
353 // Create payment and update this->multicurrency_amounts if this->amounts filled or
354 // this->amounts if this->multicurrency_amounts filled.
355 // This also set ->amount and ->multicurrency_amount
356 $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
357 if ($paiement_id < 0) {
358 setEventMessages($paiement->error, $paiement->errors, 'errors');
359 $error++;
360 }
361
362 if (!$error) {
363 $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, GETPOST('chqemetteur'), GETPOST('chqbank'));
364 if ($result < 0) {
365 setEventMessages($paiement->error, $paiement->errors, 'errors');
366 $error++;
367 }
368 }
369
370 if (!$error) {
371 $db->commit();
372
373 // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
374 $invoiceid = 0;
375 foreach ($paiement->amounts as $key => $amount) {
376 $facid = $key;
377 if (is_numeric($amount) && $amount != 0) {
378 if ($invoiceid != 0) {
379 $invoiceid = -1; // There is more than one invoice paid by this payment
380 } else {
381 $invoiceid = $facid;
382 }
383 }
384 }
385 if ($invoiceid > 0) {
386 $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid;
387 } else {
388 $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id;
389 }
390 header('Location: '.$loc);
391 exit;
392 } else {
393 $db->rollback();
394 }
395 }
396 }
397}
398
399
400/*
401 * View
402 */
403
404$form = new Form($db);
405$formother = new FormOther($db);
406
407$supplierstatic = new Societe($db);
408$invoicesupplierstatic = new FactureFournisseur($db);
409
410llxHeader('', $langs->trans('ListPayment'), '', '', 0, 0, '', '', '', 'mod-fourn-facture page-paiement');
411
412if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
413 $object = new FactureFournisseur($db);
414 $result = $object->fetch($facid);
415
416 $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
417 $dateinvoice = ($datefacture == '' ? (getDolGlobalString('MAIN_AUTOFILL_DATE') ? '' : -1) : $datefacture);
418
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 ";
423 }
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";
427 }
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);
432 }
433 $resql = $db->query($sql);
434 if ($resql) {
435 $totalnboflines = $num = $db->num_rows($resql);
436 if ($num) {
437 $obj = $db->fetch_object($resql);
438 $total = $obj->total;
439
440 print load_fiche_titre($langs->trans('DoPayment'));
441
442 // Add realtime total information
443 if (!empty($conf->use_javascript_ajax)) {
444 print "\n".'<script type="text/javascript">';
445 print '$(document).ready(function () {
446
447 function _elemToJson(selector)
448 {
449 var subJson = {};
450 $.map(selector.serializeArray(), function(n,i)
451 {
452 subJson[n["name"]] = n["value"];
453 });
454
455 return subJson;
456 }
457 function callForResult(imgId)
458 {
459 console.log("callForResult Calculate total of payment");
460 var json = {};
461 var form = $("#payment_form");
462
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().'";
468 if (imgId != null) {
469 json["imgClicked"] = imgId;
470 }
471
472 $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
473 {
474 json = $.parseJSON(data);
475
476 form.data(json);
477
478 for (var key in json)
479 {
480 if (key == "result") {
481 if (json["makeRed"]) {
482 $("#"+key).addClass("error");
483 } else {
484 $("#"+key).removeClass("error");
485 }
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]);
491 });
492 }
493 }
494 });
495 }
496 callForResult();
497 $("#payment_form").find("input.amount").change(function() {
498 callForResult();
499 });
500 $("#payment_form").find("input.amount").keyup(function() {
501 callForResult();
502 });
503 ';
504
505 print ' });'."\n";
506
507 //Add js for AutoFill
508 print ' $(document).ready(function () {';
509 print ' $(".AutoFillAmount").on(\'click touchstart\', function(e){
510 e.preventDefault();
511 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
512 });';
513 print ' });'."\n";
514
515 print ' </script>'."\n";
516 }
517
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.'">';
527
528 print dol_get_fiche_head([]);
529
530 print '<table class="border centpercent">';
531
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');
536 print '</td></tr>';
537
538 print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
539 // $object is default vendor invoice
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);
543 print '</td></tr>';
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');
546 print '</td>';
547 if (isModEnabled("bank")) {
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);
551 print '</td></tr>';
552 } else {
553 print '<tr><td>&nbsp;</td></tr>';
554 }
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>';
561 print '</table>';
562 print dol_get_fiche_end();
563
564 $parameters = array(
565 'facid' => $facid,
566 'ref' => $obj->ref
567 );
568 $reshook = $hookmanager->executeHooks('paymentsupplierinvoices', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
569 $error = $hookmanager->error;
570 $errors = $hookmanager->errors;
571 if (empty($reshook)) {
572 /*
573 * All unpaid supplier invoices
574 */
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();
584 // Can pay invoices of all child of parent company
585 if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($object->thirdparty->parent)) {
586 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $object->thirdparty->parent).')';
587 }
588 // Can pay invoices of all child of myself
589 if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
590 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $object->thirdparty->id).')';
591 }
592 $sql .= ') AND f.paye = 0';
593 $sql .= ' AND f.fk_statut = 1'; // Status=0 => unvalidated, Status=2 => canceled
594
595 if (!$displayAllInvoices) {
597 $sql .= ' AND f.type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
598 } else {
599 $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes
600 }
601 }
602
603 // Group by because we have a total
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';
607 // Sort invoices by date and serial number: the older one comes first
608 $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
609
610 $resql = $db->query($sql);
611 if ($resql) {
612 $num = $db->num_rows($resql);
613 if ($num > 0) {
614 $i = 0;
615 print '<br>';
616
617 if (!empty($conf->use_javascript_ajax)) {
618 //Add js for AutoFill
619 print "\n".'<script type="text/javascript">';
620 print ' $(document).ready(function () {';
621 print ' $(".AutoFillAmount").on(\'click touchstart\', function(e){
622 e.preventDefault();
623 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value"));
624 });';
625 print ' });'."\n";
626 print ' </script>'."\n";
627 }
628
629 $moreHtmlRight = '';
630 if ($action == 'create') {
631 $urlToggleDisplayMod = $_SERVER["PHP_SELF"].'?facid='.((int) $facid).'&action='.urlencode($action).'&accountid='.((int) $accountid).'&display-all-invoices=' . (intval(!$displayAllInvoices));
632
633 if (empty($displayAllInvoices)) {
634 $btnTitle = $langs->trans('DisplayOtherInvoicesToo');
636 $btnTitle = $langs->trans('DisplayCreditNotesToo');
637 }
638 } else {
639 $btnTitle = $langs->trans('HideOtherInvoices');
641 $btnTitle = $langs->trans('HideCreditNotes');
642 }
643 }
644
645 $btnIcon = empty($displayAllInvoices) ? 'fa fa-eye' : 'fa fa-eye-slash';
646 $moreHtmlRight.= dolGetButtonTitle($btnTitle, '', $btnIcon, $urlToggleDisplayMod);
647 }
648
649 print_barre_liste($langs->trans('Invoices'), 0, $_SERVER["PHP_SELF"], '', '', '', '', $num, $totalnboflines, 'bill', 0, $moreHtmlRight, '', 0, 0, 0, 1);
650
651
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";
654 print '<thead>';
655 print '<tr class="liste_titre">';
656 print '<th>'.$langs->trans('Invoice').'</th>';
657 //print '<th>'.$langs->trans('RefSupplier').'</th>';
658 if ($displayAllInvoices) {
659 print '<th class="center">' . $langs->trans('Type') . '</th>';
660 }
661 print '<th class="center">'.$langs->trans('Date').'</th>';
662 print '<th class="center">'.$langs->trans('DateDue').'</th>';
663 if (isModEnabled("multicurrency")) {
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>';
671 }
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>';
676 print '</tr>';
677 print '</thead>';
678
679 print '<tbody>';
680 $total = 0;
681 $total_ttc = 0;
682 $totalrecu = 0;
683 $totalrecucreditnote = 0; // PHP Warning: Undefined variable $totalrecucreditnote
684 $totalrecudeposits = 0; // PHP Warning: Undefined variable $totalrecudeposits
685 while ($i < $num) {
686 $objp = $db->fetch_object($resql);
687
688 $sign = 1;
689 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE && !$displayAllInvoices) {
690 $sign = -1;
691 }
692
693 $invoice = new FactureFournisseur($db);
694 $invoice->fetch($objp->facid);
695
696 $invoicesupplierstatic->ref = $objp->ref;
697 $invoicesupplierstatic->id = $objp->facid;
698
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');
704
705 // Multicurrency Price
706 $multicurrency_payment = 0;
707 $multicurrency_creditnotes = 0;
708 $multicurrency_deposits = 0;
709 $multicurrency_remaintopay = 0;
710 if (isModEnabled("multicurrency")) {
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');
716 }
717
718 print '<tr data-row-type="'.$objp->type.'" class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
719
720 // Ref
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);
725 print '</span> ';
726 print '<br class="paiement-line-break-for-ref">';
727 print '<span class="spantitle" data-field="ref-supplier" title="'.$langs->trans("RefSupplier").'">';
728 print showValueWithClipboardCPButton($objp->ref_supplier);
729 print '</span>';
730 print '</div>';
731 print '</td>';
732
733 // Ref supplier
734 //print '<td data-col="ref-supplier" >'.$objp->ref_supplier.'</td>';
735
736 // type
737 if ($displayAllInvoices) {
738 $typearray = [
739 FactureFournisseur::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
740 FactureFournisseur::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
741 FactureFournisseur::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
742 FactureFournisseur::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
743 ];
744 // Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
745 print '<td class="center nowraponall">' . $typearray[$objp->type] . '</td>';
746 }
747
748 // Date
749 if ($objp->df > 0) {
750 print '<td data-col="datef" data-col-value="'.$db->jdate($objp->df).'" class="center nowraponall">';
751 print dol_print_date($db->jdate($objp->df), 'day').'</td>';
752 } else {
753 print '<td data-col="datef" data-col-value="" class="center"><b>!!!</b></td>';
754 }
755
756 // Date Max Payment
757 if ($objp->dlr > 0) {
758 print '<td data-col="dater" data-col-value="'.$db->jdate($objp->dlr).'" class="center nowraponall">';
759 print dol_print_date($db->jdate($objp->dlr), 'day');
760
761 if ($invoice->hasDelay()) {
762 print img_warning($langs->trans('Late'));
763 }
764
765 print '</td>';
766 } else {
767 print '<td data-col="dater" data-col-value="" class="center"><b>--</b></td>';
768 }
769
770 // Multicurrency
771 if (isModEnabled("multicurrency")) {
772 // Currency
773 print '<td data-col="multicurrency-code" class="center">'.$objp->multicurrency_code."</td>\n";
774
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);
778 }
779 print '</td>';
780
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);
786 }
787 if ($multicurrency_deposits) {
788 print '+'.price($multicurrency_deposits);
789 }
790 }
791 print '</td>';
792
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);
796 }
797 print '</td>';
798
799 print '<td data-col="remain-to-pay-multicurrency-amount" class="right">';
800 // Add remind multicurrency amount
801 $namef = 'multicurrency_amount_'.$objp->facid;
802 $nameRemain = 'multicurrency_remain_'.$objp->facid;
803
804 $min = $max = '';
805 if ($displayAllInvoices) {
806 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
807 $max = ' max="0" ';
808 } else {
809 $min = ' min="0" ';
810 }
811 }
812
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');
818 print '</button>';
819 }
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).'">';
822 } else {
823 print '<input type="text" class="width100" name="'.$namef.'_disabled" value="'.GETPOST($namef).'" disabled>';
824 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
825 }
826 }
827 print "</td>";
828 }
829
830 print '<td class="right"><span class="amount">'.price($sign * $objp->total_ttc).'</span></td>';
831
832 print '<td class="right"><span class="amount">'.price($sign * $objp->am);
833 if ($creditnotes) {
834 print '+'.price($creditnotes);
835 }
836 if ($deposits) {
837 print '+'.price($deposits);
838 }
839 print '</span></td>';
840
841 print '<td class="right">';
842 print '<span class="amount">'.price($sign * (float) $remaintopay).'</span>';
843 if (isModEnabled('paymentbybanktransfer')) {
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";
851
852 $result_sql = $db->query($sql);
853 if ($result_sql) {
854 $obj = $db->fetch_object($result_sql);
855 $numdirectdebitopen = $obj->nb;
856 $totaldirectdebit = $obj->amount;
857 } else {
858 dol_print_error($db);
859 }
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');
863 }
864 }
865 print '</td>';
866
867 // Amount
868 print '<td class="center nowraponall">';
869
870 $namef = 'amount_'.$objp->facid;
871 $nameRemain = 'remain_'.$objp->facid;
872
873 $min = $max = '';
874 if ($displayAllInvoices) {
875 if ($objp->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
876 $max = ' max="0" ';
877 } else {
878 $min = ' min="0" ';
879 }
880 }
881
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');
886 print '</button>';
887 }
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)).'">'; // class is required to be used by javascript callForResult();
890 } else {
891 print '<input type="text" class="width100" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
892 print '<input type="hidden" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is required to be used by javascript callForResult();
893 }
894 print "</td>";
895
896 print "</tr>\n";
897 $total += $objp->total_ht;
898 $total_ttc += $objp->total_ttc;
899 $totalrecu += $objp->am;
900 $totalrecucreditnote += $creditnotes;
901 $totalrecudeposits += $deposits;
902 $i++;
903 }
904 //print '</tbody>';
905
906 if ($i > 1) {
907 //print '<tfoot>';
908
909 // Print total
910 print '<tr class="liste_total">';
911 $colspan = 3;
912
913 // type
914 if ($displayAllInvoices) {
915 $colspan++;
916 }
917
918 print '<td colspan="'.$colspan.'" class="left" scope="row">'.$langs->trans('TotalTTC').':</td>';
919 if (isModEnabled("multicurrency")) {
920 print '<td>&nbsp;</td>';
921 print '<td>&nbsp;</td>';
922 print '<td>&nbsp;</td>';
923 print '<td>&nbsp;</td>';
924 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
925 }
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);
930 }
931 if ($totalrecudeposits) {
932 print '+'.price($totalrecudeposits);
933 }
934 print '</b></td>';
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>'; // Autofilled
937 print "</tr>\n";
938 //print '</tfoot>';
939 }
940 print '</tbody>';
941
942 print "</table>\n";
943
944 print "</div>";
945 }
946 $db->free($resql);
947 } else {
948 dol_print_error($db);
949 }
950 }
951
952 // Save + Cancel Buttons
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 ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
958 print '</div>';
959 }
960
961 // Form to confirm payment
962 if ($action == 'add_paiement') {
963 $preselectedchoice = $addwarning ? 'no' : 'yes';
964
965 print '<br>';
966 $text = '';
967 if (!empty($totalpayment)) {
968 $text = $langs->trans('ConfirmSupplierPayment', price($totalpayment), $langs->transnoentitiesnoconv("Currency".$conf->currency));
969 }
970 if (!empty($multicurrency_totalpayment)) {
971 $text .= '<br>'.$langs->trans('ConfirmSupplierPayment', price($multicurrency_totalpayment), $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
972 }
973 if (GETPOST('closepaidinvoices')) {
974 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
975 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
976 }
977 print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id.'&socid='.$object->socid.'&type='.$object->type, $langs->trans('PayedSuppliersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
978 }
979
980 print '</form>';
981 }
982 } else {
983 dol_print_error($db);
984 }
985}
986
987// End of page
988llxFooter();
989$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
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...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
Definition html.lib.php:540
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.
Definition html.lib.php:738
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:181
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.