dolibarr 21.0.0-alpha
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 a 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(0));
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 var_dump($paiement->amount);
287 var_dump($paiement->multicurrency_amount);
288 var_dump($paiement->multicurrency_currency);
289 */
290
291 if (!$error) {
292 $label = '(CustomerInvoicePayment)';
293 if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
294 $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
295 }
296
297 $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOSTINT('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank'));
298 if ($result < 0) {
299 setEventMessages($paiement->error, $paiement->errors, 'errors');
300 $error++;
301 }
302 }
303
304 if (!$error) {
305 $db->commit();
306
307 // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
308 $invoiceid = 0;
309 foreach ($paiement->amounts as $key => $amount) {
310 $facid = $key;
311 if (is_numeric($amount) && $amount != 0) {
312 if ($invoiceid != 0) {
313 $invoiceid = -1; // There is more than one invoice paid by this payment
314 } else {
315 $invoiceid = $facid;
316 }
317 }
318 }
319 if ($invoiceid > 0) {
320 $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid;
321 } else {
322 $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
323 }
324 header('Location: '.$loc);
325 exit;
326 } else {
327 $db->rollback();
328 }
329 }
330}
331
332
333/*
334 * View
335 */
336
337$form = new Form($db);
338
339
340llxHeader('', $langs->trans("Payment"));
341
342
343
344if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
345 $facture = new Facture($db);
346 $result = $facture->fetch($facid);
347
348 if ($result >= 0) {
349 $facture->fetch_thirdparty();
350
351 $title = '';
352 if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
353 $title .= $langs->trans("EnterPaymentReceivedFromCustomer");
354 }
355 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
356 $title .= $langs->trans("EnterPaymentDueToCustomer");
357 }
358 print load_fiche_titre($title);
359
360 // Initialize data for confirmation (this is used because data can be change during confirmation)
361 if ($action == 'add_paiement') {
362 $i = 0;
363
364 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id);
365 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid);
366 $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type);
367 }
368
369 // Invoice with Paypal transaction
370 // @TODO add hook here
371 if (isModEnabled('paypalplus') && getDolGlobalString('PAYPAL_ENABLE_TRANSACTION_MANAGEMENT') && !empty($facture->ref_ext)) {
372 if (getDolGlobalString('PAYPAL_BANK_ACCOUNT')) {
373 $accountid = getDolGlobalString('PAYPAL_BANK_ACCOUNT');
374 }
375 $paymentnum = $facture->ref_ext;
376 }
377
378 // Add realtime total information
379 if (!empty($conf->use_javascript_ajax)) {
380 print "\n".'<script type="text/javascript">';
381 print '$(document).ready(function () {
382 setPaiementCode();
383
384 $("#selectpaiementcode").change(function() {
385 setPaiementCode();
386 });
387
388 function setPaiementCode()
389 {
390 var code = $("#selectpaiementcode option:selected").val();
391 console.log("setPaiementCode code="+code);
392
393 if (code == \'CHQ\' || code == \'VIR\')
394 {
395 if (code == \'CHQ\')
396 {
397 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
398 }
399 if ($(\'#fieldchqemetteur\').val() == \'\')
400 {
401 var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'\' : jQuery(\'#thirdpartylabel\').val();
402 $(\'#fieldchqemetteur\').val(emetteur);
403 }
404 }
405 else
406 {
407 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
408 $(\'#fieldchqemetteur\').val(\'\');
409 }
410 }
411
412 function _elemToJson(selector)
413 {
414 var subJson = {};
415 $.map(selector.serializeArray(), function(n,i)
416 {
417 subJson[n["name"]] = n["value"];
418 });
419
420 return subJson;
421 }
422 function callForResult(imgId)
423 {
424 var json = {};
425 var form = $("#payment_form");
426
427 json["invoice_type"] = $("#invoice_type").val();
428 json["amountPayment"] = $("#amountpayment").attr("value");
429 json["amounts"] = _elemToJson(form.find("input.amount"));
430 json["remains"] = _elemToJson(form.find("input.remain"));
431 json["token"] = "'.currentToken().'";
432 if (imgId != null) {
433 json["imgClicked"] = imgId;
434 }
435
436 $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
437 {
438 json = $.parseJSON(data);
439
440 form.data(json);
441
442 for (var key in json)
443 {
444 if (key == "result") {
445 if (json["makeRed"]) {
446 $("#"+key).addClass("error");
447 } else {
448 $("#"+key).removeClass("error");
449 }
450 json[key]=json["label"]+" "+json[key];
451 $("#"+key).text(json[key]);
452 } else {console.log(key);
453 form.find("input[name*=\""+key+"\"]").each(function() {
454 $(this).attr("value", json[key]);
455 });
456 }
457 }
458 });
459 }
460 $("#payment_form").find("input.amount").change(function() {
461 callForResult();
462 });
463 $("#payment_form").find("input.amount").keyup(function() {
464 callForResult();
465 });
466 ';
467
468 print ' });'."\n";
469
470 //Add js for AutoFill
471 print ' $(document).ready(function () {';
472 print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
473 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
474 });';
475 print ' });'."\n";
476
477 print ' </script>'."\n";
478 }
479
480 print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
481 print '<input type="hidden" name="token" value="'.newToken().'">';
482 print '<input type="hidden" name="action" value="add_paiement">';
483 print '<input type="hidden" name="facid" value="'.$facture->id.'">';
484 print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
485 print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
486 print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).'">';
487 print '<input type="hidden" name="page_y" value="">';
488
489 print dol_get_fiche_head();
490
491 print '<table class="border centpercent">';
492
493 // Third party
494 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
495
496 // Date payment
497 print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
498 $datepayment = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
499 $datepayment = ($datepayment == '' ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $datepayment);
500 print $form->selectDate($datepayment, '', 0, 0, 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
501 print '</td></tr>';
502
503 // Payment mode
504 print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
505 $form->select_types_paiements((GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2);
506 print "</td>\n";
507 print '</tr>';
508
509 // Bank account
510 print '<tr>';
511 if (isModEnabled("bank")) {
512 if ($facture->type != 2) {
513 print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>';
514 }
515 if ($facture->type == 2) {
516 print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
517 }
518
519 print '<td>';
520 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
521 print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', (isModEnabled('multicurrency') ? 1 : 0), 'widthcentpercentminusx maxwidth500', 1);
522 print '</td>';
523 } else {
524 print '<td>&nbsp;</td>';
525 }
526 print "</tr>\n";
527
528 // Bank check number
529 print '<tr><td>'.$langs->trans('Numero');
530 print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
531 print '</td>';
532 print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
533
534 // Check transmitter
535 print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
536 print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
537 print '</td>';
538 print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
539
540 // Bank name
541 print '<tr><td>'.$langs->trans('Bank');
542 print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
543 print '</td>';
544 print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
545
546 // Comments
547 print '<tr><td>'.$langs->trans('Comments').'</td>';
548 print '<td class="tdtop">';
549 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
550 print '</td></tr>';
551
552 // Go Source Invoice (useful when there are many invoices)
553 if ($action != 'add_paiement' && getDolGlobalString('FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
554 print '<tr><td></td>';
555 print '<td class="tdtop right">';
556 print '<a class="right" href="#amount_'.$facid.'">'.$langs->trans("GoSourceInvoice").'</a>';
557 print '</td></tr>';
558 }
559
560 print '</table>';
561
562 print dol_get_fiche_end();
563
564
565 /*
566 * List of unpaid invoices
567 */
568
569 $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,';
570 $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
571 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
572 $sql .= ' WHERE f.entity IN ('.getEntity('facture').')';
573 $sql .= ' AND (f.fk_soc = '.((int) $facture->socid);
574 // Can pay invoices of all child of parent company
575 if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
576 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->parent).')';
577 }
578 // Can pay invoices of all child of myself
579 if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
580 $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->id).')';
581 }
582 $sql .= ') AND f.paye = 0';
583 $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
584 if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
585 $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
586 } else {
587 $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
588 }
589 // Sort invoices by date and serial number: the older one comes first
590 $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
591
592 $resql = $db->query($sql);
593 if ($resql) {
594 $num = $db->num_rows($resql);
595 if ($num > 0) {
596 $arraytitle = $langs->trans('Invoice');
597 if ($facture->type == 2) {
598 $arraytitle = $langs->trans("CreditNotes");
599 }
600 $alreadypayedlabel = $langs->trans('Received');
601 $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived');
602 if ($facture->type == 2) {
603 $alreadypayedlabel = $langs->trans("PaidBack");
604 $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack");
605 }
606 $remaindertopay = $langs->trans('RemainderToTake');
607 $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake');
608 if ($facture->type == 2) {
609 $remaindertopay = $langs->trans("RemainderToPayBack");
610 $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack");
611 }
612
613 $i = 0;
614 //print '<tr><td colspan="3">';
615 print '<br>';
616
617 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
618 print '<table class="noborder centpercent">';
619
620 print '<tr class="liste_titre">';
621 print '<td>'.$arraytitle.'</td>';
622 print '<td class="center">'.$langs->trans('Date').'</td>';
623 print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
624 if (isModEnabled('multicurrency')) {
625 print '<td>'.$langs->trans('Currency').'</td>';
626 print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
627 print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>';
628 print '<td class="right">'.$multicurrencyremaindertopay.'</td>';
629 print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
630 }
631 print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
632 print '<td class="right">'.$alreadypayedlabel.'</td>';
633 print '<td class="right">'.$remaindertopay.'</td>';
634 print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
635
636 $parameters = array();
637 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
638
639 print '<td align="right">&nbsp;</td>';
640 print "</tr>\n";
641
642 $total_ttc = 0;
643 $totalrecu = 0;
644 $totalrecucreditnote = 0;
645 $totalrecudeposits = 0;
646
647 while ($i < $num) {
648 $objp = $db->fetch_object($resql);
649
650 $sign = 1;
651 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
652 $sign = -1;
653 }
654
655 $soc = new Societe($db);
656 $soc->fetch($objp->socid);
657
658 $invoice = new Facture($db);
659 $invoice->fetch($objp->facid);
660 $paiement = $invoice->getSommePaiement();
661 $creditnotes = $invoice->getSumCreditNotesUsed();
662 $deposits = $invoice->getSumDepositsUsed();
663 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
664 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
665
666 // Multicurrency Price
667 if (isModEnabled('multicurrency')) {
668 $multicurrency_payment = $invoice->getSommePaiement(1);
669 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
670 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
671 $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
672 $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
673 // Multicurrency full amount tooltip
674 $tootltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
675 $tootltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
676 $tootltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
677 }
678
679 // Full amount tooltip
680 $tootltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
681 $tootltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
682 $tootltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
683
684 print '<tr class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
685
686 print '<td class="nowraponall">';
687 print $invoice->getNomUrl(1, '');
688 if ($objp->socid != $facture->thirdparty->id) {
689 print ' - '.$soc->getNomUrl(1).' ';
690 }
691 print "</td>\n";
692
693 // Date
694 print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
695
696 // Due date
697 if ($objp->dlr > 0) {
698 print '<td class="nowraponall center">';
699 print dol_print_date($db->jdate($objp->dlr), 'day');
700
701 if ($invoice->hasDelay()) {
702 print img_warning($langs->trans('Late'));
703 }
704
705 print '</td>';
706 } else {
707 print '<td align="center"></td>';
708 }
709
710 // Currency
711 if (isModEnabled('multicurrency')) {
712 print '<td class="center">'.$objp->multicurrency_code."</td>\n";
713 }
714
715 // Multicurrency full amount
716 if (isModEnabled('multicurrency')) {
717 print '<td class="right">';
718 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
719 print '<span class="amount classfortooltip" title="'.$tootltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc);
720 }
721 print '</span></td>';
722
723 // Multicurrency Price
724 print '<td class="right">';
725 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
726 print price($sign * $multicurrency_payment);
727 if ($multicurrency_creditnotes) {
728 print '+'.price($multicurrency_creditnotes);
729 }
730 if ($multicurrency_deposits) {
731 print '+'.price($multicurrency_deposits);
732 }
733 }
734 print '</td>';
735
736 // Multicurrency remain to pay
737 print '<td class="right">';
738 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
739 print price($sign * (float) $multicurrency_remaintopay);
740 }
741 print '</td>';
742
743 print '<td class="right nowraponall">';
744
745 // Add remind multicurrency amount
746 $namef = 'multicurrency_amount_'.$objp->facid;
747 $nameRemain = 'multicurrency_remain_'.$objp->facid;
748
749 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
750 if ($action != 'add_paiement') {
751 if (!empty($conf->use_javascript_ajax)) {
752 print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $multicurrency_remaintopay)."'");
753 }
754 print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.(GETPOST($namef) != '0' ? GETPOST($namef) : '').'">';
755 print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
756 } else {
757 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.(GETPOST($namef) != '0' ? GETPOST($namef) : '').'" disabled>';
758 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
759 }
760 }
761 print "</td>";
762 }
763
764 // Full amount
765 print '<td class="right"><span class="amount classfortooltip" title="'.$tootltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>';
766
767 // Received + already paid
768 print '<td class="right"><span class="amount">'.price($sign * $paiement);
769 if ($creditnotes) {
770 print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
771 }
772 if ($deposits) {
773 print '<span class="opacitymedium">+'.price($deposits).'</span>';
774 }
775 print '</span></td>';
776
777 // Remain to take or to pay back
778 print '<td class="right">';
779 print price($sign * (float) $remaintopay);
780 if (isModEnabled('prelevement')) {
781 $numdirectdebitopen = 0;
782 $totaldirectdebit = 0;
783 $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
784 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
785 $sql .= " WHERE fk_facture = ".((int) $objp->facid);
786 $sql .= " AND pfd.traite = 0";
787 $sql .= " AND pfd.ext_payment_id IS NULL";
788
789 $result_sql = $db->query($sql);
790 if ($result_sql) {
791 $obj = $db->fetch_object($result_sql);
792 $numdirectdebitopen = $obj->nb;
793 $totaldirectdebit = $obj->amount;
794 } else {
795 dol_print_error($db);
796 }
797 if ($numdirectdebitopen) {
798 $langs->load("withdrawals");
799 print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
800 }
801 }
802 print '</td>';
803 //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
804
805 // Amount
806 print '<td class="right nowraponall">';
807
808 // Add remind amount
809 $namef = 'amount_'.$objp->facid;
810 $nameRemain = 'remain_'.$objp->facid;
811
812 if ($action != 'add_paiement') {
813 if (!empty($conf->use_javascript_ajax)) {
814 print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $remaintopay)."'");
815 }
816 print '<input type="text" class="maxwidth75 amount" id="'.$namef.'" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
817 print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
818 } else {
819 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
820 print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
821 }
822 print "</td>";
823
824 $parameters = array();
825 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
826
827 // Warning
828 print '<td align="center" width="16">';
829 //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
830 if (!empty($amounts[$invoice->id]) && (abs((float) $amounts[$invoice->id]) > abs((float) $amountsresttopay[$invoice->id]))
831 || !empty($multicurrency_amounts[$invoice->id]) && (abs((float) $multicurrency_amounts[$invoice->id]) > abs((float) $multicurrency_amountsresttopay[$invoice->id]))) {
832 print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
833 }
834 print '</td>';
835
836 print "</tr>\n";
837
838 $total_ttc += $objp->total_ttc;
839 $totalrecu += $paiement;
840 $totalrecucreditnote += $creditnotes;
841 $totalrecudeposits += $deposits;
842 $i++;
843 }
844
845 if ($i > 1) {
846 // Print total
847 print '<tr class="liste_total">';
848 print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>';
849 if (isModEnabled('multicurrency')) {
850 print '<td></td>';
851 print '<td></td>';
852 print '<td></td>';
853 print '<td></td>';
854 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
855 }
856 print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
857 print '<td class="right"><b>'.price($sign * $totalrecu);
858 if ($totalrecucreditnote) {
859 print '+'.price($totalrecucreditnote);
860 }
861 if ($totalrecudeposits) {
862 print '+'.price($totalrecudeposits);
863 }
864 print '</b></td>';
865 print '<td class="right"><b>'.price($sign * (float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
866 print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
867 print '<td align="center">&nbsp;</td>';
868 print "</tr>\n";
869 }
870 print "</table>";
871 print "</div>\n";
872 }
873 $db->free($resql);
874 } else {
875 dol_print_error($db);
876 }
877
878 $formconfirm = '';
879
880 // Save button
881 if ($action != 'add_paiement') {
882 $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
883 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
884 $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
885 }
886 $buttontitle = $langs->trans('ToMakePayment');
887 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
888 $buttontitle = $langs->trans('ToMakePaymentBack');
889 }
890
891 print '<br><div class="center">';
892 print '<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices"><label for="closepaidinvoices"> '.$checkboxlabel.'</label>';
893 /*if (isModEnabled('prelevement')) {
894 $langs->load("withdrawals");
895 if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed");
896 }*/
897 print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
898 print '</div>';
899 }
900
901 // Form to confirm payment
902 if ($action == 'add_paiement') {
903 $preselectedchoice = $addwarning ? 'no' : 'yes';
904
905 print '<br>';
906 if (!empty($totalpayment)) {
907 $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency));
908 }
909 if (!empty($multicurrency_totalpayment)) {
910 $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
911 }
912 if (GETPOST('closepaidinvoices')) {
913 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
914 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
915 }
916 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
917 }
918
919 // Call Hook formConfirm
920 $parameters = array('formConfirm' => $formconfirm);
921 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
922 if (empty($reshook)) {
923 $formconfirm .= $hookmanager->resPrint;
924 } elseif ($reshook > 0) {
925 $formconfirm = $hookmanager->resPrint;
926 }
927
928 // Print form confirm
929 print $formconfirm;
930
931 print "</form>\n";
932 }
933}
934
935
939if (!GETPOST('action', 'aZ09')) {
940 if (empty($page) || $page == -1) {
941 $page = 0;
942 }
943 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
944 $offset = $limit * $page;
945
946 if (!$sortorder) {
947 $sortorder = 'DESC';
948 }
949 if (!$sortfield) {
950 $sortfield = 'p.datep';
951 }
952
953 $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
954 $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
955 $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
956 $sql .= ', '.MAIN_DB_PREFIX.'facture as f';
957 $sql .= ' WHERE p.fk_facture = f.rowid';
958 $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
959 if ($socid) {
960 $sql .= ' AND f.fk_soc = '.((int) $socid);
961 }
962
963 $sql .= $db->order($sortfield, $sortorder);
964 $sql .= $db->plimit($limit + 1, $offset);
965 $resql = $db->query($sql);
966
967 if ($resql) {
968 $num = $db->num_rows($resql);
969 $i = 0;
970
971 print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
972 print '<table class="noborder centpercent">';
973 print '<tr class="liste_titre">';
974 print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
975 print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
976 print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
977 print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
978 print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
979 print "</tr>\n";
980
981 while ($i < min($num, $limit)) {
982 $objp = $db->fetch_object($resql);
983
984 print '<tr class="oddeven">';
985 print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
986 print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
987 print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
988 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
989 print '<td>&nbsp;</td>';
990 print '</tr>';
991
992 $parameters = array();
993 $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
994
995 $i++;
996 }
997 print '</table>';
998 }
999}
1000
1001llxFooter();
1002
1003$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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...)
llxFooter()
Footer empty.
Definition document.php:107
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a 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.