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