dolibarr 23.0.3
paiement.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
7 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2018-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';
47require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
48require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
49require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
50require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
51
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$displayAllInvoices = getDolGlobalInt('MAIN_PAIMENTS_SHOW_ALL_INVOICE_TYPES', 0);
68if (GETPOSTISSET('display-all-invoices')) {
69 $displayAllInvoices = GETPOSTINT('display-all-invoices');
70}
71
72
73$amounts = array();
74$amountsresttopay = array();
75$addwarning = 0;
76
77$multicurrency_amounts = array();
78$multicurrency_amountsresttopay = array();
79
80// Security check
81if ($user->socid > 0) {
82 $socid = $user->socid;
83}
84
85$object = new Facture($db);
86
87// Load object
88if ($facid > 0) {
89 $ret = $object->fetch($facid);
90}
91
92// Initialize a technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
93$hookmanager->initHooks(array('paiementcard', 'globalcard'));
94
95$formquestion = array();
96
97$usercanissuepayment = $user->hasRight('facture', 'paiement');
98
99$fieldid = 'rowid';
100$isdraft = (($object->status == Facture::STATUS_DRAFT) ? 1 : 0);
101$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
102
103
104/*
105 * Actions
106 */
107$error = 0;
108
109$parameters = array('socid' => $socid);
110$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
111if ($reshook < 0) {
112 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113}
114
115$paiement_id = 0;
116if (empty($reshook)) {
117 if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) {
118 $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
119 $totalpayment = 0;
120 $multicurrency_totalpayment = 0;
121 $atleastonepaymentnotnull = 0;
122 $formquestion = array();
123 $i = 0;
124
125 // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
126 $tmpinvoice = new Facture($db);
127 foreach ($_POST as $key => $value) {
128 if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') {
129 $cursorfacid = (int) substr($key, 7);
130 $amounts[$cursorfacid] = price2num(GETPOST($key));
131 if (!empty($amounts[$cursorfacid])) {
132 $totalpayment += (float) $amounts[$cursorfacid];
133 $atleastonepaymentnotnull++;
134 }
135 $result = $tmpinvoice->fetch($cursorfacid);
136 if ($result <= 0) {
137 dol_print_error($db);
138 }
139 $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
140 if ($amounts[$cursorfacid]) {
141 // Check amount
142 if ($amounts[$cursorfacid] && (abs((float) $amounts[$cursorfacid]) > abs((float) $amountsresttopay[$cursorfacid]))) {
143 $addwarning = 1;
144 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
145 }
146 // Check date
147 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
148 $langs->load("errors");
149 //$error++;
150 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
151 }
152 }
153
154 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
155 } elseif (substr($key, 0, 21) == 'multicurrency_amount_') {
156 $cursorfacid = (int) substr($key, 21);
157 $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key));
158 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
159 if (!empty($multicurrency_amounts[$cursorfacid])) {
160 $atleastonepaymentnotnull++;
161 }
162 $result = $tmpinvoice->fetch($cursorfacid);
163 if ($result <= 0) {
164 dol_print_error($db);
165 }
166 $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
167 if ($multicurrency_amounts[$cursorfacid]) {
168 // Check amount
169 if ($multicurrency_amounts[$cursorfacid] && (abs((float) $multicurrency_amounts[$cursorfacid]) > abs((float) $multicurrency_amountsresttopay[$cursorfacid]))) {
170 $addwarning = 1;
171 $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
172 }
173 // Check date
174 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
175 $langs->load("errors");
176 //$error++;
177 setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
178 }
179 }
180
181 $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
182 }
183 }
184
185 // Check parameters
186 if (!GETPOST('paiementcode')) {
187 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
188 $error++;
189 }
190
191 if (isModEnabled("bank")) {
192 // If bank module is on, account is required to enter a payment
193 if (GETPOST('accountid') <= 0) {
194 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
195 $error++;
196 }
197 }
198
199 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
200 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
201 $error++;
202 }
203
204 if (empty($datepaye)) {
205 setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
206 $error++;
207 }
208
209 // Check if payments in both currency
210 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
211 $langs->load("errors");
212 setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
213 $error++;
214 }
215 }
216
217 /*
218 * Action add_paiement
219 */
220 if ($action == 'add_paiement') { // Test on permission not required
221 if ($error) {
222 $action = 'create';
223 }
224 // The next of this action is displayed at the page's bottom.
225 }
226
227 /*
228 * Action confirm_paiement
229 */
230 if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) {
231 $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzuser');
232
233 $db->begin();
234
235 $thirdparty = new Societe($db);
236 if ($socid > 0) {
237 $thirdparty->fetch($socid);
238 }
239
240 $multicurrency_code = array();
241 $multicurrency_tx = array();
242
243 // Clean parameters amount if payment is for a credit note
244 foreach ($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 $amounts[$key] = - abs((float) $newvalue);
250 }
251 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
252 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
253 }
254
255 foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
256 $tmpinvoice = new Facture($db);
257 $tmpinvoice->fetch((int) $key);
258 if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
259 $newvalue = price2num($value, 'MT');
260 $multicurrency_amounts[$key] = - abs((float) $newvalue);
261 }
262 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
263 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
264 }
265
266 if (isModEnabled("bank")) {
267 // If the bank module is active, an account is required to input a payment
268 if (GETPOSTINT('accountid') <= 0) {
269 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
270 $error++;
271 }
272 }
273
274 // Creation of payment line
275 $paiement = new Paiement($db);
276 $paiement->datepaye = $datepaye;
277 $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
278 $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
279 $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
280 $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching
281 $paiement->paiementcode = GETPOST('paiementcode', 'alpha');
282 $paiement->paiementid = dol_getIdFromCode($db, $paiement->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.'" spellcheck="false"></td></tr>';
548
549 // Check transmitter
550 print '<tr><td><span class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter').'</span>';
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').'" spellcheck="false"></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').'" spellcheck="false"></td></tr>';
560
561 // Comments
562 print '<tr><td class="tdtop">'.$langs->trans('Comments').'</td>';
563 print '<td>';
564 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.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('Received');
626 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
627 $alreadypayedlabel = $langs->trans("PaidBack");
628 $multicurrencyalreadypayedlabel = $langs->trans("PaidBack");
629 }
630 $remaindertopay = $langs->trans('RemainderToTake');
631 $multicurrencyremaindertopay = $langs->trans('RemainderToTake');
632 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
633 $remaindertopay = $langs->trans("RemainderToPayBack");
634 $multicurrencyremaindertopay = $langs->trans("RemainderToPayBack");
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 $langs->load("multicurrency");
676 $labeltoshow = '<span class="small nowraponall">'.$langs->trans("MulticurrencyOriginalCurrency").'</span>';
677 print '<th>'.$langs->trans('Currency').'</th>';
678 print '<th class="right">'.$langs->trans('AmountTTC').' <span class="opacitymedium">('.$labeltoshow.')</span></th>';
679 print '<th class="right">'.$multicurrencyalreadypayedlabel.' <span class="opacitymedium">('.$labeltoshow.')</span></th>';
680 print '<th class="right">'.$multicurrencyremaindertopay.' <span class="opacitymedium">('.$labeltoshow.')</span></th>';
681 print '<th class="center">'.$langs->trans('PaymentAmount').' <span class="opacitymedium">('.$labeltoshow.')</span></th>';
682 }
683 print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
684 print '<td class="right">'.$alreadypayedlabel.'</td>';
685 print '<td class="right">'.$remaindertopay.'</td>';
686 print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
687
688 $parameters = array();
689 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
690
691 print '<td align="right">&nbsp;</td>';
692 print "</tr>\n";
693 print '</thead>';
694 $total_ttc = 0;
695 $totalrecu = 0;
696 $totalrecucreditnote = 0;
697 $totalrecudeposits = 0;
698 $multicurrency_total_ttc = 0;
699 $multicurrency_totalrecu = 0;
700 $multicurrency_totalrecucreditnote = 0;
701 $multicurrency_totalrecudeposits = 0;
702 $showtotalmulticurrency = true;
703 $sign = 1;
704
705 print '<tbody>';
706 while ($i < $num) {
707 $objp = $db->fetch_object($resql);
708
709 $sign = 1;
710 if ($facture->type == Facture::TYPE_CREDIT_NOTE && !$displayAllInvoices) {
711 $sign = -1;
712 }
713
714 $soc = new Societe($db);
715 $soc->fetch($objp->socid);
716
717 $invoice = new Facture($db);
718 $invoice->fetch($objp->facid);
719 $paiement = $invoice->getSommePaiement();
720 $creditnotes = $invoice->getSumCreditNotesUsed();
721 $deposits = $invoice->getSumDepositsUsed();
722 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
723 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
724
725 // Multicurrency Price
726 $tooltiponmulticurrencyfullamount = '';
727 $multicurrency_remaintopay = '';
728 $multicurrency_payment = 0;
729 $multicurrency_creditnotes = 0;
730 $multicurrency_deposits = 0;
731 if (isModEnabled('multicurrency')) {
732 $multicurrency_payment = $invoice->getSommePaiement(1);
733 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
734 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
735 $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
736 $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
737 // Multicurrency full amount tooltip
738 $tooltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
739 $tooltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
740 $tooltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
741 }
742
743 // Full amount tooltip
744 $tooltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
745 $tooltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
746 $tooltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
747
748 print '<tr data-row-type="'.$objp->type.'" class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
749
750 print '<td class="nowraponall">';
751 print $invoice->getNomUrl(1, '');
752 if ($objp->socid != $facture->thirdparty->id) {
753 print ' - '.$soc->getNomUrl(1).' ';
754 }
755 print "</td>\n";
756
757 // type
758 if ($displayAllInvoices) {
759 $typearray = [
760 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
761 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
762 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
763 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
764 ];
765 // Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
766 print '<td class="center nowraponall">' . $typearray[$objp->type] . '</td>';
767 }
768
769 // Date
770 print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
771
772 // Due date
773 if ($objp->dlr > 0) {
774 print '<td class="nowraponall center">';
775 print dol_print_date($db->jdate($objp->dlr), 'day');
776
777 if ($invoice->hasDelay()) {
778 print img_warning($langs->trans('Late'));
779 }
780
781 print '</td>';
782 } else {
783 print '<td align="center"></td>';
784 }
785
786 // Currency
787 if (isModEnabled('multicurrency')) {
788 print '<td class="center">'.$objp->multicurrency_code."</td>\n";
789 }
790
791 // Multicurrency full amount
792 if (isModEnabled('multicurrency')) {
793 print '<td class="right">';
794 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
795 print '<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc);
796 }
797 print '</span></td>';
798
799 // Multicurrency Price
800 print '<td class="right">';
801 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
802 print price($sign * $multicurrency_payment);
803 if ($multicurrency_creditnotes) {
804 print '+'.price($multicurrency_creditnotes);
805 }
806 if ($multicurrency_deposits) {
807 print '+'.price($multicurrency_deposits);
808 }
809 }
810 print '</td>';
811
812 // Multicurrency remain to pay
813 print '<td class="right">';
814 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
815 print price($sign * (float) $multicurrency_remaintopay);
816 }
817 print '</td>';
818
819 print '<td class="right nowraponall">';
820
821 // Add remind multicurrency amount
822 $namef = 'multicurrency_amount_'.$objp->facid;
823 $nameRemain = 'multicurrency_remain_'.$objp->facid;
824 $min = $max = '';
825 if ($displayAllInvoices) {
826 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
827 $max = ' max="0" ';
828 } else {
829 $min = ' min="0" ';
830 }
831 }
832
833 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
834 if ($action != 'add_paiement') {
835 if (!empty($conf->use_javascript_ajax)) {
836 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $multicurrency_remaintopay).'">';
837 print img_picto("Auto fill", 'rightarrow.png');
838 print '</button>';
839 }
840 print '<input '.$min.' '.$max.' type="text" class="multicurrency_amount maxwidth100" name="'.$namef.'" value="'.GETPOST($namef).'">';
841 print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
842 } else {
843 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.(GETPOST($namef) != '0' ? GETPOST($namef) : '').'" disabled>';
844 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
845 }
846 }
847 print "</td>";
848 }
849
850 // Full amount
851 print '<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>';
852
853 // Received + already paid
854 print '<td class="right"><span class="amount">'.price($sign * $paiement);
855 if ($creditnotes) {
856 print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
857 }
858 if ($deposits) {
859 print '<span class="opacitymedium">+'.price($deposits).'</span>';
860 }
861 print '</span></td>';
862
863 // Remain to take or to pay back
864 print '<td class="right">';
865 print price($sign * (float) $remaintopay);
866 if (isModEnabled('prelevement')) {
867 $numdirectdebitopen = 0;
868 $totaldirectdebit = 0;
869 $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
870 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
871 $sql .= " WHERE fk_facture = ".((int) $objp->facid);
872 $sql .= " AND pfd.traite = 0";
873 $sql .= " AND pfd.ext_payment_id IS NULL";
874
875 $result_sql = $db->query($sql);
876 if ($result_sql) {
877 $obj = $db->fetch_object($result_sql);
878 $numdirectdebitopen = $obj->nb;
879 $totaldirectdebit = $obj->amount;
880 } else {
881 dol_print_error($db);
882 }
883 if ($numdirectdebitopen) {
884 $langs->load("withdrawals");
885 print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
886 }
887 }
888 print '</td>';
889 //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
890
891 // Amount
892 print '<td class="right nowraponall">';
893
894 // Add remind amount
895 $namef = 'amount_'.$objp->facid;
896 $nameRemain = 'remain_'.$objp->facid;
897
898 $min = $max = '';
899 if ($displayAllInvoices) {
900 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
901 $max = ' max="0" ';
902 } else {
903 $min = ' min="0" ';
904 }
905 }
906
907 if ($action != 'add_paiement') {
908 if (!empty($conf->use_javascript_ajax)) {
909 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $remaintopay).'">';
910 print img_picto("Auto fill", 'rightarrow.png');
911 print '</button>';
912 }
913 print '<input '.$max.' '.$min.' type="text" class="amount maxwidth100" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">'; // class is required to be used by javascript callForResult();
914 print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
915 } else {
916 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
917 print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
918 }
919 print "</td>";
920
921 $parameters = array();
922 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
923
924 // Warning
925 print '<td align="center" width="16">';
926 //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
927 if (!empty($amounts[$invoice->id]) && (abs((float) $amounts[$invoice->id]) > abs((float) $amountsresttopay[$invoice->id]))
928 || !empty($multicurrency_amounts[$invoice->id]) && (abs((float) $multicurrency_amounts[$invoice->id]) > abs((float) $multicurrency_amountsresttopay[$invoice->id]))) {
929 print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
930 }
931 print '</td>';
932
933 print "</tr>\n";
934
935 $total_ttc += $objp->total_ttc;
936 $totalrecu += $paiement;
937 $totalrecucreditnote += $creditnotes;
938 $totalrecudeposits += $deposits;
939
940 if (isModEnabled('multicurrency')) {
941 if (empty($objp->multicurrency_code) || $objp->multicurrency_code == getDolCurrency()) {
942 $showtotalmulticurrency = false;
943 }
944 $multicurrency_total_ttc += $objp->multicurrency_total_ttc;
945 $multicurrency_totalrecu += $multicurrency_payment;
946 $multicurrency_totalrecucreditnote += $multicurrency_creditnotes;
947 $multicurrency_totalrecudeposits += $multicurrency_deposits;
948 }
949
950 $i++;
951 }
952
953 if ($i > 1) {
954 $colspan = 3;
955
956 // type
957 if ($displayAllInvoices) {
958 $colspan++;
959 }
960
961 // Print total
962
963 print '<tr class="liste_total">';
964 print '<td colspan="'.$colspan.'" class="left">'.$langs->trans('TotalTTC').'</td>';
965 if (isModEnabled('multicurrency')) {
966 print '<td></td>';
967 if ($showtotalmulticurrency) {
968 print '<td class="right"><b>'.price($sign * $multicurrency_total_ttc).'</b></td>';
969 print '<td class="right"><b>'.price($sign * $multicurrency_totalrecu);
970 if ($multicurrency_totalrecucreditnote) {
971 print '+'.price($multicurrency_totalrecucreditnote);
972 }
973 if ($multicurrency_totalrecudeposits) {
974 print '+'.price($multicurrency_totalrecudeposits);
975 }
976 print '</b></td>';
977 print '<td class="right"><b>'.price($sign * (float) price2num($multicurrency_total_ttc - $multicurrency_totalrecu - $multicurrency_totalrecucreditnote - $multicurrency_totalrecudeposits, 'MT')).'</b></td>';
978 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
979 } else {
980 print '<td></td>';
981 print '<td></td>';
982 print '<td></td>';
983 print '<td></td>';
984 }
985 }
986 print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
987 print '<td class="right"><b>'.price($sign * $totalrecu);
988 if ($totalrecucreditnote) {
989 print '+'.price($totalrecucreditnote);
990 }
991 if ($totalrecudeposits) {
992 print '+'.price($totalrecudeposits);
993 }
994 print '</b></td>';
995 print '<td class="right"><b>'.price($sign * (float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
996 print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
997 print '<td align="center">&nbsp;</td>';
998 print "</tr>\n";
999 }
1000
1001 print '</tbody>';
1002
1003 print "</table>";
1004 print "</div>\n";
1005 }
1006 $db->free($resql);
1007 } else {
1008 dol_print_error($db);
1009 }
1010
1011 $formconfirm = '';
1012
1013 // Save button
1014 if ($action != 'add_paiement') {
1015 $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
1016 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
1017 $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
1018 }
1019 $buttontitle = $langs->trans('ToMakePayment');
1020 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
1021 $buttontitle = $langs->trans('ToMakePaymentBack');
1022 }
1023
1024 print '<br><div class="center">';
1025 print '<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$checkboxlabel.'</label>';
1026 print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
1027 print '</div>';
1028 }
1029
1030 // Form to confirm payment
1031 if ($action == 'add_paiement') {
1032 $preselectedchoice = $addwarning ? 'no' : 'yes';
1033
1034 print '<br>';
1035 $text = '';
1036 if (!empty($totalpayment)) {
1037 $text = $langs->trans('ConfirmCustomerPayment', (string) $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency));
1038 }
1039 if (!empty($multicurrency_totalpayment)) {
1040 $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', (string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
1041 }
1042 if (GETPOST('closepaidinvoices')) {
1043 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
1044 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
1045 }
1046 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
1047 }
1048
1049 // Call Hook formConfirm
1050 $parameters = array('formConfirm' => $formconfirm);
1051 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1052 if (empty($reshook)) {
1053 $formconfirm .= $hookmanager->resPrint;
1054 } elseif ($reshook > 0) {
1055 $formconfirm = $hookmanager->resPrint;
1056 }
1057
1058 // Print form confirm
1059 print $formconfirm;
1060
1061 print "</form>\n";
1062}
1063
1064
1065llxFooter();
1066
1067$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
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.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:464
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.