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