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