dolibarr 19.0.3
paiement.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
7 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
12 * Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com>
13 * Copyright (C) 2023 Sylvain Legrand <technique@infras.fr>
14 * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
42
43// Load translation files required by the page
44$langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency'));
45
46$action = GETPOST('action', 'alpha');
47$confirm = GETPOST('confirm', 'alpha');
48
49$facid = GETPOST('facid', 'int');
50$accountid = GETPOST('accountid', 'int');
51$paymentnum = GETPOST('num_paiement', 'alpha');
52$socid = GETPOST('socid', 'int');
53
54$sortfield = GETPOST('sortfield', 'aZ09comma');
55$sortorder = GETPOST('sortorder', 'aZ09comma');
56$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57
58$amounts = array();
59$amountsresttopay = array();
60$addwarning = 0;
61
62$multicurrency_amounts = array();
63$multicurrency_amountsresttopay = array();
64
65// Security check
66if ($user->socid > 0) {
67 $socid = $user->socid;
68}
69
70$object = new Facture($db);
71
72// Load object
73if ($facid > 0) {
74 $ret = $object->fetch($facid);
75}
76
77// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
78$hookmanager->initHooks(array('paiementcard', 'globalcard'));
79
80$formquestion = array();
81
82$usercanissuepayment = $user->hasRight('facture', 'paiement');
83
84$fieldid = 'rowid';
85$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
86$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
87
88
89/*
90 * Actions
91 */
92
93$parameters = array('socid'=>$socid);
94$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
95if ($reshook < 0) {
96 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
97}
98
99if (empty($reshook)) {
100 if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) {
101 $error = 0;
102
103 $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
104 $paiement_id = 0;
105 $totalpayment = 0;
106 $multicurrency_totalpayment = 0;
107 $atleastonepaymentnotnull = 0;
108 $formquestion = array();
109 $i = 0;
110
111 // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
112 $tmpinvoice = new Facture($db);
113 foreach ($_POST as $key => $value) {
114 if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') {
115 $cursorfacid = substr($key, 7);
116 $amounts[$cursorfacid] = price2num(GETPOST($key));
117 $totalpayment = $totalpayment + $amounts[$cursorfacid];
118 if (!empty($amounts[$cursorfacid])) {
119 $atleastonepaymentnotnull++;
120 }
121 $result = $tmpinvoice->fetch($cursorfacid);
122 if ($result <= 0) {
123 dol_print_error($db);
124 }
125 $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
126 if ($amounts[$cursorfacid]) {
127 // Check amount
128 if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) {
129 $addwarning = 1;
130 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
131 }
132 // Check date
133 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
134 $langs->load("errors");
135 //$error++;
136 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
137 }
138 }
139
140 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
141 } elseif (substr($key, 0, 21) == 'multicurrency_amount_') {
142 $cursorfacid = substr($key, 21);
143 $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key));
144 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
145 if (!empty($multicurrency_amounts[$cursorfacid])) {
146 $atleastonepaymentnotnull++;
147 }
148 $result = $tmpinvoice->fetch($cursorfacid);
149 if ($result <= 0) {
150 dol_print_error($db);
151 }
152 $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
153 if ($multicurrency_amounts[$cursorfacid]) {
154 // Check amount
155 if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
156 $addwarning = 1;
157 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
158 }
159 // Check date
160 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
161 $langs->load("errors");
162 //$error++;
163 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
164 }
165 }
166
167 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
168 }
169 }
170
171 // Check parameters
172 if (!GETPOST('paiementcode')) {
173 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
174 $error++;
175 }
176
177 if (isModEnabled("banque")) {
178 // If bank module is on, account is required to enter a payment
179 if (GETPOST('accountid') <= 0) {
180 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
181 $error++;
182 }
183 }
184
185 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
186 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
187 $error++;
188 }
189
190 if (empty($datepaye)) {
191 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
192 $error++;
193 }
194
195 // Check if payments in both currency
196 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
197 $langs->load("errors");
198 setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
199 $error++;
200 }
201 }
202
203 /*
204 * Action add_paiement
205 */
206 if ($action == 'add_paiement') {
207 if ($error) {
208 $action = 'create';
209 }
210 // The next of this action is displayed at the page's bottom.
211 }
212
213 /*
214 * Action confirm_paiement
215 */
216 if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) {
217 $error = 0;
218
219 $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzuser');
220
221 $db->begin();
222
223 $thirdparty = new Societe($db);
224 if ($socid > 0) {
225 $thirdparty->fetch($socid);
226 }
227
228 $multicurrency_code = array();
229 $multicurrency_tx = array();
230
231 // Clean parameters amount if payment is for a credit note
232 foreach ($amounts as $key => $value) { // How payment is dispatched
233 $tmpinvoice = new Facture($db);
234 $tmpinvoice->fetch($key);
235 if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
236 $newvalue = price2num($value, 'MT');
237 $amounts[$key] = - abs($newvalue);
238 }
239 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
240 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
241 }
242
243 foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
244 $tmpinvoice = new Facture($db);
245 $tmpinvoice->fetch($key);
246 if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
247 $newvalue = price2num($value, 'MT');
248 $multicurrency_amounts[$key] = - abs($newvalue);
249 }
250 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
251 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
252 }
253
254 if (isModEnabled("banque")) {
255 // If the bank module is active, an account is required to input a payment
256 if (GETPOST('accountid', 'int') <= 0) {
257 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
258 $error++;
259 }
260 }
261
262 // Creation of payment line
263 $paiement = new Paiement($db);
264 $paiement->datepaye = $datepaye;
265 $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
266 $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
267 $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
268 $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching
269 $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
270 $paiement->num_payment = GETPOST('num_paiement', 'alpha');
271 $paiement->note_private = GETPOST('comment', 'alpha');
272 $paiement->fk_account = GETPOST('accountid', 'int');
273
274 if (!$error) {
275 // Create payment and update this->multicurrency_amounts if this->amounts filled or
276 // this->amounts if this->multicurrency_amounts filled.
277 // This also set ->amount and ->multicurrency_amount
278 $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents
279 if ($paiement_id < 0) {
280 setEventMessages($paiement->error, $paiement->errors, 'errors');
281 $error++;
282 }
283 }
284
285 if (!$error) {
286 $label = '(CustomerInvoicePayment)';
287 if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
288 $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
289 }
290 $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank'));
291 if ($result < 0) {
292 setEventMessages($paiement->error, $paiement->errors, 'errors');
293 $error++;
294 }
295 }
296
297 if (!$error) {
298 $db->commit();
299
300 // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
301 $invoiceid = 0;
302 foreach ($paiement->amounts as $key => $amount) {
303 $facid = $key;
304 if (is_numeric($amount) && $amount != 0) {
305 if ($invoiceid != 0) {
306 $invoiceid = -1; // There is more than one invoice payed by this payment
307 } else {
308 $invoiceid = $facid;
309 }
310 }
311 }
312 if ($invoiceid > 0) {
313 $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid;
314 } else {
315 $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
316 }
317 header('Location: '.$loc);
318 exit;
319 } else {
320 $db->rollback();
321 }
322 }
323}
324
325
326/*
327 * View
328 */
329
330$form = new Form($db);
331
332
333llxHeader('', $langs->trans("Payment"));
334
335
336
337if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
338 $facture = new Facture($db);
339 $result = $facture->fetch($facid);
340
341 if ($result >= 0) {
342 $facture->fetch_thirdparty();
343
344 $title = '';
345 if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
346 $title .= $langs->trans("EnterPaymentReceivedFromCustomer");
347 }
348 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
349 $title .= $langs->trans("EnterPaymentDueToCustomer");
350 }
351 print load_fiche_titre($title);
352
353 // Initialize data for confirmation (this is used because data can be change during confirmation)
354 if ($action == 'add_paiement') {
355 $i = 0;
356
357 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id);
358 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid);
359 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type);
360 }
361
362 // Invoice with Paypal transaction
363 // TODO add hook here
364 if (isModEnabled('paypalplus') && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) {
365 if (getDolGlobalString('PAYPAL_BANK_ACCOUNT')) {
366 $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
367 }
368 $paymentnum = $facture->ref_ext;
369 }
370
371 // Add realtime total information
372 if (!empty($conf->use_javascript_ajax)) {
373 print "\n".'<script type="text/javascript">';
374 print '$(document).ready(function () {
375 setPaiementCode();
376
377 $("#selectpaiementcode").change(function() {
378 setPaiementCode();
379 });
380
381 function setPaiementCode()
382 {
383 var code = $("#selectpaiementcode option:selected").val();
384 console.log("setPaiementCode code="+code);
385
386 if (code == \'CHQ\' || code == \'VIR\')
387 {
388 if (code == \'CHQ\')
389 {
390 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
391 }
392 if ($(\'#fieldchqemetteur\').val() == \'\')
393 {
394 var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'\' : jQuery(\'#thirdpartylabel\').val();
395 $(\'#fieldchqemetteur\').val(emetteur);
396 }
397 }
398 else
399 {
400 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
401 $(\'#fieldchqemetteur\').val(\'\');
402 }
403 }
404
405 function _elemToJson(selector)
406 {
407 var subJson = {};
408 $.map(selector.serializeArray(), function(n,i)
409 {
410 subJson[n["name"]] = n["value"];
411 });
412
413 return subJson;
414 }
415 function callForResult(imgId)
416 {
417 var json = {};
418 var form = $("#payment_form");
419
420 json["invoice_type"] = $("#invoice_type").val();
421 json["amountPayment"] = $("#amountpayment").attr("value");
422 json["amounts"] = _elemToJson(form.find("input.amount"));
423 json["remains"] = _elemToJson(form.find("input.remain"));
424 json["token"] = "'.currentToken().'";
425 if (imgId != null) {
426 json["imgClicked"] = imgId;
427 }
428
429 $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
430 {
431 json = $.parseJSON(data);
432
433 form.data(json);
434
435 for (var key in json)
436 {
437 if (key == "result") {
438 if (json["makeRed"]) {
439 $("#"+key).addClass("error");
440 } else {
441 $("#"+key).removeClass("error");
442 }
443 json[key]=json["label"]+" "+json[key];
444 $("#"+key).text(json[key]);
445 } else {console.log(key);
446 form.find("input[name*=\""+key+"\"]").each(function() {
447 $(this).attr("value", json[key]);
448 });
449 }
450 }
451 });
452 }
453 $("#payment_form").find("input.amount").change(function() {
454 callForResult();
455 });
456 $("#payment_form").find("input.amount").keyup(function() {
457 callForResult();
458 });
459 ';
460
461 print ' });'."\n";
462
463 //Add js for AutoFill
464 print ' $(document).ready(function () {';
465 print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
466 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
467 });';
468 print ' });'."\n";
469
470 print ' </script>'."\n";
471 }
472
473 print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
474 print '<input type="hidden" name="token" value="'.newToken().'">';
475 print '<input type="hidden" name="action" value="add_paiement">';
476 print '<input type="hidden" name="facid" value="'.$facture->id.'">';
477 print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
478 print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
479 print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).'">';
480 print '<input type="hidden" name="page_y" value="">';
481
482 print dol_get_fiche_head();
483
484 print '<table class="border centpercent">';
485
486 // Third party
487 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
488
489 // Date payment
490 print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
491 $datepayment = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
492 $datepayment = ($datepayment == '' ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $datepayment);
493 print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
494 print '</td></tr>';
495
496 // Payment mode
497 print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
498 $form->select_types_paiements((GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2);
499 print "</td>\n";
500 print '</tr>';
501
502 // Bank account
503 print '<tr>';
504 if (isModEnabled("banque")) {
505 if ($facture->type != 2) {
506 print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>';
507 }
508 if ($facture->type == 2) {
509 print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
510 }
511
512 print '<td>';
513 print img_picto('', 'bank_account');
514 print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1);
515 print '</td>';
516 } else {
517 print '<td>&nbsp;</td>';
518 }
519 print "</tr>\n";
520
521 // Bank check number
522 print '<tr><td>'.$langs->trans('Numero');
523 print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
524 print '</td>';
525 print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
526
527 // Check transmitter
528 print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
529 print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
530 print '</td>';
531 print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
532
533 // Bank name
534 print '<tr><td>'.$langs->trans('Bank');
535 print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
536 print '</td>';
537 print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
538
539 // Comments
540 print '<tr><td>'.$langs->trans('Comments').'</td>';
541 print '<td class="tdtop">';
542 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
543 print '</td></tr>';
544
545 // Go Source Invoice (useful when there are many invoices)
546 if ($action != 'add_paiement' && getDolGlobalString('FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
547 print '<tr><td></td>';
548 print '<td class="tdtop right">';
549 print '<a class="right" href="#amount_'.$facid.'">'.$langs->trans("GoSourceInvoice").'</a>';
550 print '</td></tr>';
551 }
552
553 print '</table>';
554
555 print dol_get_fiche_end();
556
557
558 /*
559 * List of unpaid invoices
560 */
561
562 $sql = 'SELECT f.rowid as facid, f.ref, f.total_ht, f.total_tva, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc, f.type,';
563 $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
564 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
565 $sql .= ' WHERE f.entity IN ('.getEntity('facture').')';
566 $sql .= ' AND (f.fk_soc = '.((int) $facture->socid);
567 // Can pay invoices of all child of parent company
568 if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
569 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->parent).')';
570 }
571 // Can pay invoices of all child of myself
572 if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
573 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->id).')';
574 }
575 $sql .= ') AND f.paye = 0';
576 $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
577 if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
578 $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
579 } else {
580 $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
581 }
582 // Sort invoices by date and serial number: the older one comes first
583 $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
584
585 $resql = $db->query($sql);
586 if ($resql) {
587 $num = $db->num_rows($resql);
588 if ($num > 0) {
589 $arraytitle = $langs->trans('Invoice');
590 if ($facture->type == 2) {
591 $arraytitle = $langs->trans("CreditNotes");
592 }
593 $alreadypayedlabel = $langs->trans('Received');
594 $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived');
595 if ($facture->type == 2) {
596 $alreadypayedlabel = $langs->trans("PaidBack");
597 $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack");
598 }
599 $remaindertopay = $langs->trans('RemainderToTake');
600 $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake');
601 if ($facture->type == 2) {
602 $remaindertopay = $langs->trans("RemainderToPayBack");
603 $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack");
604 }
605
606 $i = 0;
607 //print '<tr><td colspan="3">';
608 print '<br>';
609
610 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
611 print '<table class="noborder centpercent">';
612
613 print '<tr class="liste_titre">';
614 print '<td>'.$arraytitle.'</td>';
615 print '<td class="center">'.$langs->trans('Date').'</td>';
616 print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
617 if (isModEnabled('multicurrency')) {
618 print '<td>'.$langs->trans('Currency').'</td>';
619 print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
620 print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>';
621 print '<td class="right">'.$multicurrencyremaindertopay.'</td>';
622 print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
623 }
624 print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
625 print '<td class="right">'.$alreadypayedlabel.'</td>';
626 print '<td class="right">'.$remaindertopay.'</td>';
627 print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
628
629 $parameters = array();
630 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
631
632 print '<td align="right">&nbsp;</td>';
633 print "</tr>\n";
634
635 $total_ttc = 0;
636 $totalrecu = 0;
637 $totalrecucreditnote = 0;
638 $totalrecudeposits = 0;
639
640 while ($i < $num) {
641 $objp = $db->fetch_object($resql);
642
643 $sign = 1;
644 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
645 $sign = -1;
646 }
647
648 $soc = new Societe($db);
649 $soc->fetch($objp->socid);
650
651 $invoice = new Facture($db);
652 $invoice->fetch($objp->facid);
653 $paiement = $invoice->getSommePaiement();
654 $creditnotes = $invoice->getSumCreditNotesUsed();
655 $deposits = $invoice->getSumDepositsUsed();
656 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
657 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
658
659 // Multicurrency Price
660 if (isModEnabled('multicurrency')) {
661 $multicurrency_payment = $invoice->getSommePaiement(1);
662 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
663 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
664 $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
665 $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
666 // Multicurrency full amount tooltip
667 $tootltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
668 $tootltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
669 $tootltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
670 }
671
672 // Full amount tooltip
673 $tootltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
674 $tootltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
675 $tootltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
676
677 print '<tr class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
678
679 print '<td class="nowraponall">';
680 print $invoice->getNomUrl(1, '');
681 if ($objp->socid != $facture->thirdparty->id) {
682 print ' - '.$soc->getNomUrl(1).' ';
683 }
684 print "</td>\n";
685
686 // Date
687 print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
688
689 // Due date
690 if ($objp->dlr > 0) {
691 print '<td class="nowraponall center">';
692 print dol_print_date($db->jdate($objp->dlr), 'day');
693
694 if ($invoice->hasDelay()) {
695 print img_warning($langs->trans('Late'));
696 }
697
698 print '</td>';
699 } else {
700 print '<td align="center"></td>';
701 }
702
703 // Currency
704 if (isModEnabled('multicurrency')) {
705 print '<td class="center">'.$objp->multicurrency_code."</td>\n";
706 }
707
708 // Multicurrency full amount
709 if (isModEnabled('multicurrency')) {
710 print '<td class="right">';
711 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
712 print '<span class="amount classfortooltip" title="'.$tootltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc);
713 }
714 print '</span></td>';
715
716 // Multicurrency Price
717 print '<td class="right">';
718 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
719 print price($sign * $multicurrency_payment);
720 if ($multicurrency_creditnotes) {
721 print '+'.price($multicurrency_creditnotes);
722 }
723 if ($multicurrency_deposits) {
724 print '+'.price($multicurrency_deposits);
725 }
726 }
727 print '</td>';
728
729 // Multicurrency remain to pay
730 print '<td class="right">';
731 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
732 print price($sign * $multicurrency_remaintopay);
733 }
734 print '</td>';
735
736 print '<td class="right nowraponall">';
737
738 // Add remind multicurrency amount
739 $namef = 'multicurrency_amount_'.$objp->facid;
740 $nameRemain = 'multicurrency_remain_'.$objp->facid;
741
742 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
743 if ($action != 'add_paiement') {
744 if (!empty($conf->use_javascript_ajax)) {
745 print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'");
746 }
747 print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.GETPOST($namef).'">';
748 print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
749 } else {
750 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.GETPOST($namef).'" disabled>';
751 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
752 }
753 }
754 print "</td>";
755 }
756
757 // Full amount
758 print '<td class="right"><span class="amount classfortooltip" title="'.$tootltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>';
759
760 // Received + already paid
761 print '<td class="right"><span class="amount">'.price($sign * $paiement);
762 if ($creditnotes) {
763 print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
764 }
765 if ($deposits) {
766 print '<span class="opacitymedium">+'.price($deposits).'</span>';
767 }
768 print '</span></td>';
769
770 // Remain to take or to pay back
771 print '<td class="right">';
772 print price($sign * $remaintopay);
773 if (isModEnabled('prelevement')) {
774 $numdirectdebitopen = 0;
775 $totaldirectdebit = 0;
776 $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
777 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
778 $sql .= " WHERE fk_facture = ".((int) $objp->facid);
779 $sql .= " AND pfd.traite = 0";
780 $sql .= " AND pfd.ext_payment_id IS NULL";
781
782 $result_sql = $db->query($sql);
783 if ($result_sql) {
784 $obj = $db->fetch_object($result_sql);
785 $numdirectdebitopen = $obj->nb;
786 $totaldirectdebit = $obj->amount;
787 } else {
788 dol_print_error($db);
789 }
790 if ($numdirectdebitopen) {
791 $langs->load("withdrawals");
792 print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
793 }
794 }
795 print '</td>';
796 //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
797
798 // Amount
799 print '<td class="right nowraponall">';
800
801 // Add remind amount
802 $namef = 'amount_'.$objp->facid;
803 $nameRemain = 'remain_'.$objp->facid;
804
805 if ($action != 'add_paiement') {
806 if (!empty($conf->use_javascript_ajax)) {
807 print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
808 }
809 print '<input type="text" class="maxwidth75 amount" id="'.$namef.'" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
810 print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
811 } else {
812 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
813 print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
814 }
815 print "</td>";
816
817 $parameters = array();
818 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
819
820 // Warning
821 print '<td align="center" width="16">';
822 //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
823 if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
824 || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) {
825 print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
826 }
827 print '</td>';
828
829 print "</tr>\n";
830
831 $total_ttc += $objp->total_ttc;
832 $totalrecu += $paiement;
833 $totalrecucreditnote += $creditnotes;
834 $totalrecudeposits += $deposits;
835 $i++;
836 }
837
838 if ($i > 1) {
839 // Print total
840 print '<tr class="liste_total">';
841 print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>';
842 if (isModEnabled('multicurrency')) {
843 print '<td></td>';
844 print '<td></td>';
845 print '<td></td>';
846 print '<td></td>';
847 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
848 }
849 print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
850 print '<td class="right"><b>'.price($sign * $totalrecu);
851 if ($totalrecucreditnote) {
852 print '+'.price($totalrecucreditnote);
853 }
854 if ($totalrecudeposits) {
855 print '+'.price($totalrecudeposits);
856 }
857 print '</b></td>';
858 print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
859 print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
860 print '<td align="center">&nbsp;</td>';
861 print "</tr>\n";
862 }
863 print "</table>";
864 print "</div>\n";
865 }
866 $db->free($resql);
867 } else {
868 dol_print_error($db);
869 }
870
871 $formconfirm = '';
872
873 // Save button
874 if ($action != 'add_paiement') {
875 $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
876 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
877 $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
878 }
879 $buttontitle = $langs->trans('ToMakePayment');
880 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
881 $buttontitle = $langs->trans('ToMakePaymentBack');
882 }
883
884 print '<br><div class="center">';
885 print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
886 /*if (isModEnabled('prelevement')) {
887 $langs->load("withdrawals");
888 if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed");
889 }*/
890 print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
891 print '</div>';
892 }
893
894 // Form to confirm payment
895 if ($action == 'add_paiement') {
896 $preselectedchoice = $addwarning ? 'no' : 'yes';
897
898 print '<br>';
899 if (!empty($totalpayment)) {
900 $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency));
901 }
902 if (!empty($multicurrency_totalpayment)) {
903 $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
904 }
905 if (GETPOST('closepaidinvoices')) {
906 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
907 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
908 }
909 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
910 }
911
912 // Call Hook formConfirm
913 $parameters = array('formConfirm' => $formconfirm);
914 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
915 if (empty($reshook)) {
916 $formconfirm .= $hookmanager->resPrint;
917 } elseif ($reshook > 0) {
918 $formconfirm = $hookmanager->resPrint;
919 }
920
921 // Print form confirm
922 print $formconfirm;
923
924 print "</form>\n";
925 }
926}
927
928
932if (!GETPOST('action', 'aZ09')) {
933 if (empty($page) || $page == -1) {
934 $page = 0;
935 }
936 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
937 $offset = $limit * $page;
938
939 if (!$sortorder) {
940 $sortorder = 'DESC';
941 }
942 if (!$sortfield) {
943 $sortfield = 'p.datep';
944 }
945
946 $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
947 $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
948 $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
949 $sql .= ', '.MAIN_DB_PREFIX.'facture as f';
950 $sql .= ' WHERE p.fk_facture = f.rowid';
951 $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
952 if ($socid) {
953 $sql .= ' AND f.fk_soc = '.((int) $socid);
954 }
955
956 $sql .= $db->order($sortfield, $sortorder);
957 $sql .= $db->plimit($limit + 1, $offset);
958 $resql = $db->query($sql);
959
960 if ($resql) {
961 $num = $db->num_rows($resql);
962 $i = 0;
963
964 print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
965 print '<table class="noborder centpercent">';
966 print '<tr class="liste_titre">';
967 print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
968 print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
969 print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
970 print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
971 print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
972 print "</tr>\n";
973
974 while ($i < min($num, $limit)) {
975 $objp = $db->fetch_object($resql);
976
977 print '<tr class="oddeven">';
978 print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
979 print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
980 print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
981 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
982 print '<td>&nbsp;</td>';
983 print '</tr>';
984
985 $parameters = array();
986 $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
987
988 $i++;
989 }
990 print '</table>';
991 }
992}
993
994llxFooter();
995
996$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments of customer 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 informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.