dolibarr 24.0.0-beta
paiement.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
7 * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9 * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
10 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2023-2026 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) {
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) {
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, multicurrency = 0)
434 {
435 var json = {};
436 var form = $("#payment_form");
437 var keyresult = "result";
438
439 json["invoice_type"] = $("#invoice_type").val();
440 if (multicurrency) {
441 keyresult = "multicurrency_result";
442 json["multicurrency"] = 1;
443 json["multicurrency_amountPayment"] = $("#multicurrency_amountpayment").attr("value");
444 json["multicurrency_amounts"] = _elemToJson(form.find("input.multicurrency_amount"));
445 json["multicurrency_remains"] = _elemToJson(form.find("input.multicurrency_remain"));
446 } else {
447 json["amountPayment"] = $("#amountpayment").attr("value");
448 json["amounts"] = _elemToJson(form.find("input.amount"));
449 json["remains"] = _elemToJson(form.find("input.remain"));
450 }
451 json["token"] = "'.currentToken().'";
452 if (imgId != null) {
453 json["imgClicked"] = imgId;
454 }
455
456 $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
457 {
458 json = $.parseJSON(data);
459
460 form.data(json);
461
462 for (var key in json)
463 {
464 if (key == keyresult) {
465 if (json["makeRed"]) {
466 $("#"+key).addClass("error");
467 } else {
468 $("#"+key).removeClass("error");
469 }
470 json[key]=json["label"]+" "+json[key];
471 $("#"+key).text(json[key]);
472 } else {console.log(key);
473 form.find("input[name*=\""+key+"\"]").each(function() {
474 $(this).attr("value", json[key]);
475 });
476 }
477 }
478 });
479 }
480 $("#payment_form").find("input.amount").change(function() {
481 callForResult();
482 });
483 $("#payment_form").find("input.amount").keyup(function() {
484 callForResult();
485 });
486 // Multicurrency LRR
487 $("#payment_form").find("input.multicurrency_amount").change(function() {
488 callForResult(null, 1);
489 });
490 $("#payment_form").find("input.multicurrency_amount").keyup(function() {
491 callForResult(null, 1);
492 });
493 ';
494
495 print ' });'."\n";
496
497 //Add js for AutoFill
498 print ' $(document).ready(function () {';
499 print ' $(".AutoFillAmount").on(\'click touchstart\', function(e){
500 e.preventDefault();
501 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
502 });';
503 print ' });'."\n";
504
505 print ' </script>'."\n";
506 }
507
508 print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
509 print '<input type="hidden" name="token" value="'.newToken().'">';
510 print '<input type="hidden" name="action" value="add_paiement">';
511 print '<input type="hidden" name="display-all-invoices" value="'.(int) $displayAllInvoices.'">';
512 print '<input type="hidden" name="facid" value="'.$facture->id.'">';
513 print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
514 print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
515 print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).'">';
516 print '<input type="hidden" name="page_y" value="">';
517
518 print dol_get_fiche_head();
519
520 print '<table class="border centpercent">';
521
522 // Third party
523 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
524
525 // Date payment
526 print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
527 $datepayment = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
528 $datepayment = ($datepayment == '' ? (getDolGlobalString('MAIN_AUTOFILL_DATE') ? '' : -1) : $datepayment);
529 $adddateof = array(array('adddateof'=>$facture->date));
530 $adddateof[] = array('adddateof'=>$facture->date_lim_reglement, 'labeladddateof'=>$langs->transnoentities('DateDue'));
531 print $form->selectDate($datepayment, '', 0, 0, 0, "add_paiement", 1, 1, 0, '', '', $adddateof);
532 print '</td></tr>';
533
534 // Payment mode
535 print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
536 $form->select_types_paiements((GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2);
537 print "</td>\n";
538 print '</tr>';
539
540 // Bank account
541 print '<tr>';
542 if (isModEnabled("bank")) {
543 if ($facture->type != 2) {
544 print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>';
545 }
546 if ($facture->type == 2) {
547 print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
548 }
549
550 print '<td>';
551 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
552 print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', (isModEnabled('multicurrency') ? 1 : 0), 'widthcentpercentminusx maxwidth500', 1);
553 print '</td>';
554 } else {
555 print '<td>&nbsp;</td>';
556 }
557 print "</tr>\n";
558
559 // Bank check number
560 print '<tr><td>'.$langs->trans('Numero');
561 print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
562 print '</td>';
563 print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'" spellcheck="false"></td></tr>';
564
565 // Check transmitter
566 print '<tr><td><span class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter').'</span>';
567 print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
568 print '</td>';
569 print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'" spellcheck="false"></td></tr>';
570
571 // Bank name
572 print '<tr><td>'.$langs->trans('Bank');
573 print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
574 print '</td>';
575 print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'" spellcheck="false"></td></tr>';
576
577 // Comments
578 print '<tr><td class="tdtop">'.$langs->trans('Comments').'</td>';
579 print '<td>';
580 print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
581 print '</td></tr>';
582
583 // Go Source Invoice (useful when there are many invoices)
584 if ($action != 'add_paiement' && getDolGlobalString('FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
585 print '<tr><td></td>';
586 print '<td class="tdtop right">';
587 print '<a class="right" href="#amount_'.$facid.'">'.$langs->trans("GoSourceInvoice").'</a>';
588 print '</td></tr>';
589 }
590
591 print '</table>';
592
593 print dol_get_fiche_end();
594
595
596 /*
597 * List of unpaid invoices
598 */
599
600 $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,";
601 $sql .= " f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr";
602 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
603 $sql .= " WHERE f.entity IN (".getEntity('facture').")";
604 $sql .= " AND (f.fk_soc = ".((int) $facture->socid);
605 // Can pay invoices of all child of parent company
606 if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
607 $sql .= " OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE parent = ".((int) $facture->thirdparty->parent).")";
608 }
609 // Can pay invoices of all child of myself
610 if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
611 $sql .= " OR f.fk_soc IN (SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE parent = ".((int) $facture->thirdparty->id).")";
612 }
613 $sql .= ") AND f.paye = 0";
614 $sql .= " AND f.fk_statut = 1"; // Statut=0 => not validated, Statut=2 => canceled
615
616 if (!$displayAllInvoices) {
617 if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
618 $sql .= " AND type IN (0,1,3,5)"; // Standard invoice, replacement, deposit, situation
619 } else {
620 $sql .= " AND type = 2"; // If paying back a credit note, we show all credit notes
621 }
622 }
623 if (!getDolGlobalInt('FACTURE_PAYMENTS_INVOICE_REQUESTED_SORT_FIRST')) {
624 // Sort invoices by date and serial number: the older one comes first
625 $sql .= " ORDER BY f.datef ASC, f.ref ASC";
626 } else {
627 // The requested invoice sort first
628 $sql .= " ORDER BY f.rowid = ".((int) $facid)." DESC, f.datef ASC, f.ref ASC";
629 }
630
631 $resql = $db->query($sql);
632 if ($resql) {
633 $num = $db->num_rows($resql);
634 $totalnboflines = $num = $db->num_rows($resql);
635 if ($num > 0) {
636 $arraytitle = $langs->trans('Invoice');
637 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
638 $arraytitle = $langs->trans("CreditNotes");
639 }
640 $alreadypayedlabel = $langs->trans('Received');
641 $multicurrencyalreadypayedlabel = $langs->trans('Received');
642 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
643 $alreadypayedlabel = $langs->trans("PaidBack");
644 $multicurrencyalreadypayedlabel = $langs->trans("PaidBack");
645 }
646 $remaindertopay = $langs->trans('RemainderToTake');
647 $multicurrencyremaindertopay = $langs->trans('RemainderToTake');
648 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
649 $remaindertopay = $langs->trans("RemainderToPayBack");
650 $multicurrencyremaindertopay = $langs->trans("RemainderToPayBack");
651 }
652
653 $i = 0;
654 //print '<tr><td colspan="3">';
655 print '<br>';
656
657 $moreHtmlRight = '';
658 if ($action=='create') {
659 $urlToggleDisplayMod = $_SERVER["PHP_SELF"].'?facid='.$facid.'&action='.$action.'&accountid='.$accountid.'&display-all-invoices=' . (intval(!$displayAllInvoices));
660
661 if (empty($displayAllInvoices)) {
662 $btnTitle = $langs->trans('DisplayOtherInvoicesToo');
663 if ($object->type != Facture::TYPE_CREDIT_NOTE) {
664 $btnTitle = $langs->trans('DisplayCreditNotesToo');
665 }
666 } else {
667 $btnTitle = $langs->trans('HideOtherInvoices');
668 if ($object->type != Facture::TYPE_CREDIT_NOTE) {
669 $btnTitle = $langs->trans('HideCreditNotes');
670 }
671 }
672
673 $btnIcon = empty($displayAllInvoices) ? 'fa fa-eye' : 'fa fa-eye-slash';
674 $moreHtmlRight.= dolGetButtonTitle($btnTitle, '', $btnIcon, $urlToggleDisplayMod);
675 }
676
677 print_barre_liste($langs->trans('Invoices'), 0, $_SERVER["PHP_SELF"], '', '', '', '', $num, $totalnboflines, 'bill', 0, $moreHtmlRight, '', 0, 0, 0, 1);
678
679 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
680 print '<table id="customer-invoices-paiments-list" class="noborder centpercent" data-display-all-invoices="' . (int) $displayAllInvoices . '" >';
681 print '<thead>';
682
683 print '<tr class="liste_titre">';
684 print '<td>'.$arraytitle.'</td>';
685 if ($displayAllInvoices) {
686 print '<td>' . $langs->trans('Type') . '</td>';
687 }
688 print '<td class="center">'.$langs->trans('Date').'</td>';
689 print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
690 if (isModEnabled("multicurrency")) {
691 $langs->load("multicurrency");
692 $labeltoshow = '<span class="small nowraponall">'.$langs->trans("MulticurrencyOriginalCurrency").'</span>';
693 print '<td>'.$langs->trans('Currency').'</th>';
694 print '<td class="right">'.$langs->trans('AmountTTC').' <span class="opacitymedium">('.$labeltoshow.')</span></td>';
695 print '<td class="right">'.$multicurrencyalreadypayedlabel.' <span class="opacitymedium">('.$labeltoshow.')</span></td>';
696 print '<td class="right">'.$multicurrencyremaindertopay.' <span class="opacitymedium">('.$labeltoshow.')</span></td>';
697 print '<td class="center">'.$langs->trans('PaymentAmount').' <span class="opacitymedium">('.$labeltoshow.')</span></td>';
698 }
699 print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
700 print '<td class="right">'.$alreadypayedlabel.'</td>';
701 print '<td class="right">'.$remaindertopay.'</td>';
702 print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
703
704 $parameters = array();
705 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
706
707 print '<td align="right">&nbsp;</td>';
708 print "</tr>\n";
709 print '</thead>';
710 $total_ttc = 0;
711 $totalrecu = 0;
712 $totalrecucreditnote = 0;
713 $totalrecudeposits = 0;
714 $multicurrency_total_ttc = 0;
715 $multicurrency_totalrecu = 0;
716 $multicurrency_totalrecucreditnote = 0;
717 $multicurrency_totalrecudeposits = 0;
718 $showtotalmulticurrency = true;
719 $sign = 1;
720
721 print '<tbody>';
722 while ($i < $num) {
723 $objp = $db->fetch_object($resql);
724
725 $sign = 1;
726 if ($facture->type == Facture::TYPE_CREDIT_NOTE && !$displayAllInvoices) {
727 $sign = -1;
728 }
729
730 $soc = new Societe($db);
731 $soc->fetch($objp->socid);
732
733 $invoice = new Facture($db);
734 $invoice->fetch($objp->facid);
735 $paiement = $invoice->getSommePaiement();
736 $creditnotes = $invoice->getSumCreditNotesUsed();
737 $deposits = $invoice->getSumDepositsUsed();
738 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
739 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
740
741 // Multicurrency Price
742 $tooltiponmulticurrencyfullamount = '';
743 $multicurrency_remaintopay = '';
744 $multicurrency_payment = 0;
745 $multicurrency_creditnotes = 0;
746 $multicurrency_deposits = 0;
747 if (isModEnabled('multicurrency')) {
748 $multicurrency_payment = $invoice->getSommePaiement(1);
749 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
750 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
751 $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
752 $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
753 // Multicurrency full amount tooltip
754 $tooltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
755 $tooltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
756 $tooltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
757 }
758
759 // Full amount tooltip
760 $tooltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
761 $tooltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
762 $tooltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
763
764 print '<tr data-row-type="'.$objp->type.'" class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
765
766 print '<td class="nowraponall">';
767 print $invoice->getNomUrl(1, '');
768 if ($objp->socid != $facture->thirdparty->id) {
769 print ' - '.$soc->getNomUrl(1).' ';
770 }
771 print "</td>\n";
772
773 // type
774 if ($displayAllInvoices) {
775 $typearray = [
776 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
777 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
778 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
779 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
780 ];
781 // Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
782 print '<td class="center nowraponall">' . $typearray[$objp->type] . '</td>';
783 }
784
785 // Date
786 print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
787
788 // Due date
789 if ($objp->dlr > 0) {
790 print '<td class="nowraponall center">';
791 print dol_print_date($db->jdate($objp->dlr), 'day');
792
793 if ($invoice->hasDelay()) {
794 print img_warning($langs->trans('Late'));
795 }
796
797 print '</td>';
798 } else {
799 print '<td align="center"></td>';
800 }
801
802 // Currency
803 if (isModEnabled('multicurrency')) {
804 print '<td class="center">'.$objp->multicurrency_code."</td>\n";
805 }
806
807 // Multicurrency full amount
808 if (isModEnabled('multicurrency')) {
809 print '<td class="right">';
810 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
811 print '<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc);
812 }
813 print '</span></td>';
814
815 // Multicurrency Price
816 print '<td class="right">';
817 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
818 print price($sign * $multicurrency_payment);
819 if ($multicurrency_creditnotes) {
820 print '+'.price($multicurrency_creditnotes);
821 }
822 if ($multicurrency_deposits) {
823 print '+'.price($multicurrency_deposits);
824 }
825 }
826 print '</td>';
827
828 // Multicurrency remain to pay
829 print '<td class="right">';
830 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
831 print price($sign * (float) $multicurrency_remaintopay);
832 }
833 print '</td>';
834
835 print '<td class="right nowraponall">';
836
837 // Add remind multicurrency amount
838 $namef = 'multicurrency_amount_'.$objp->facid;
839 $nameRemain = 'multicurrency_remain_'.$objp->facid;
840 $min = $max = '';
841 if ($displayAllInvoices) {
842 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
843 $max = ' max="0" ';
844 } else {
845 $min = ' min="0" ';
846 }
847 }
848
849 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
850 if ($action != 'add_paiement') {
851 if (!empty($conf->use_javascript_ajax)) {
852 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $multicurrency_remaintopay).'">';
853 print img_picto("Auto fill", 'rightarrow.png');
854 print '</button>';
855 }
856 print '<input '.$min.' '.$max.' type="text" class="multicurrency_amount maxwidth100" name="'.$namef.'" value="'.GETPOST($namef).'">';
857 print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
858 } else {
859 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.(GETPOST($namef) != '0' ? GETPOST($namef) : '').'" disabled>';
860 print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
861 }
862 }
863 print "</td>";
864 }
865
866 // Full amount
867 print '<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>';
868
869 // Received + already paid
870 print '<td class="right"><span class="amount">'.price($sign * $paiement);
871 if ($creditnotes) {
872 print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
873 }
874 if ($deposits) {
875 print '<span class="opacitymedium">+'.price($deposits).'</span>';
876 }
877 print '</span></td>';
878
879 // Remain to take or to pay back
880 print '<td class="right">';
881 print price($sign * (float) $remaintopay);
882 if (isModEnabled('prelevement')) {
883 $numdirectdebitopen = 0;
884 $totaldirectdebit = 0;
885 $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
886 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
887 $sql .= " WHERE fk_facture = ".((int) $objp->facid);
888 $sql .= " AND pfd.traite = 0";
889 $sql .= " AND pfd.ext_payment_id IS NULL";
890
891 $result_sql = $db->query($sql);
892 if ($result_sql) {
893 $obj = $db->fetch_object($result_sql);
894 $numdirectdebitopen = $obj->nb;
895 $totaldirectdebit = $obj->amount;
896 } else {
898 }
899 if ($numdirectdebitopen) {
900 $langs->load("withdrawals");
901 print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
902 }
903 }
904 print '</td>';
905 //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
906
907 // Amount
908 print '<td class="right nowraponall">';
909
910 // Add remind amount
911 $namef = 'amount_'.$objp->facid;
912 $nameRemain = 'remain_'.$objp->facid;
913
914 $min = $max = '';
915 if ($displayAllInvoices) {
916 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
917 $max = ' max="0" ';
918 } else {
919 $min = ' min="0" ';
920 }
921 }
922
923 if ($action != 'add_paiement') {
924 if (!empty($conf->use_javascript_ajax)) {
925 print '<button class="btn-low-emphasis --btn-icon AutoFillAmount" data-rowname="'.$namef.'" data-value="'.($sign * (float) $remaintopay).'">';
926 print img_picto("Auto fill", 'rightarrow.png');
927 print '</button>';
928 }
929 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();
930 print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
931 } else {
932 print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
933 print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
934 }
935 print "</td>";
936
937 $parameters = array();
938 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
939
940 // Warning
941 print '<td align="center" width="16">';
942 //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
943 if (!empty($amounts[$invoice->id]) && (abs((float) $amounts[$invoice->id]) > abs((float) $amountsresttopay[$invoice->id]))
944 || !empty($multicurrency_amounts[$invoice->id]) && (abs((float) $multicurrency_amounts[$invoice->id]) > abs((float) $multicurrency_amountsresttopay[$invoice->id]))) {
945 print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
946 }
947 print '</td>';
948
949 print "</tr>\n";
950
951 $total_ttc += $objp->total_ttc;
952 $totalrecu += $paiement;
953 $totalrecucreditnote += $creditnotes;
954 $totalrecudeposits += $deposits;
955
956 if (isModEnabled('multicurrency')) {
957 if (empty($objp->multicurrency_code) || $objp->multicurrency_code == getDolCurrency()) {
958 $showtotalmulticurrency = false;
959 }
960 $multicurrency_total_ttc += $objp->multicurrency_total_ttc;
961 $multicurrency_totalrecu += $multicurrency_payment;
962 $multicurrency_totalrecucreditnote += $multicurrency_creditnotes;
963 $multicurrency_totalrecudeposits += $multicurrency_deposits;
964 }
965
966 $i++;
967 }
968
969 if ($i > 1) {
970 $colspan = 3;
971
972 // type
973 if ($displayAllInvoices) {
974 $colspan++;
975 }
976
977 // Print total
978
979 print '<tr class="liste_total">';
980 print '<td colspan="'.$colspan.'" class="left">'.$langs->trans('TotalTTC').'</td>';
981 if (isModEnabled('multicurrency')) {
982 print '<td></td>';
983 if ($showtotalmulticurrency) {
984 print '<td class="right"><b>'.price($sign * $multicurrency_total_ttc).'</b></td>';
985 print '<td class="right"><b>'.price($sign * $multicurrency_totalrecu);
986 if ($multicurrency_totalrecucreditnote) {
987 print '+'.price($multicurrency_totalrecucreditnote);
988 }
989 if ($multicurrency_totalrecudeposits) {
990 print '+'.price($multicurrency_totalrecudeposits);
991 }
992 print '</b></td>';
993 print '<td class="right"><b>'.price($sign * (float) price2num($multicurrency_total_ttc - $multicurrency_totalrecu - $multicurrency_totalrecucreditnote - $multicurrency_totalrecudeposits, 'MT')).'</b></td>';
994 print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
995 } else {
996 print '<td></td>';
997 print '<td></td>';
998 print '<td></td>';
999 print '<td></td>';
1000 }
1001 }
1002 print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
1003 print '<td class="right"><b>'.price($sign * $totalrecu);
1004 if ($totalrecucreditnote) {
1005 print '+'.price($totalrecucreditnote);
1006 }
1007 if ($totalrecudeposits) {
1008 print '+'.price($totalrecudeposits);
1009 }
1010 print '</b></td>';
1011 print '<td class="right"><b>'.price($sign * (float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
1012 print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
1013 print '<td align="center">&nbsp;</td>';
1014 print "</tr>\n";
1015 }
1016
1017 print '</tbody>';
1018
1019 print "</table>";
1020 print "</div>\n";
1021 }
1022 $db->free($resql);
1023 } else {
1025 }
1026
1027 $formconfirm = '';
1028
1029 // Save button
1030 if ($action != 'add_paiement') {
1031 $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
1032 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
1033 $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
1034 }
1035 $buttontitle = $langs->trans('ToMakePayment');
1036 if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
1037 $buttontitle = $langs->trans('ToMakePaymentBack');
1038 }
1039
1040 print '<br><div class="center">';
1041 print '<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices" class="marginrightonly"><label for="closepaidinvoices" class="opacitymedium">'.$checkboxlabel.'</label>';
1042 print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
1043 print '</div>';
1044 }
1045
1046 // Form to confirm payment
1047 if ($action == 'add_paiement') {
1048 $preselectedchoice = $addwarning ? 'no' : 'yes';
1049
1050 print '<br>';
1051 $text = '';
1052 if (!empty($totalpayment)) {
1053 $text = $langs->trans('ConfirmCustomerPayment', (string) $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency));
1054 }
1055 if (!empty($multicurrency_totalpayment)) {
1056 $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', (string) $multicurrency_totalpayment, $langs->transnoentitiesnoconv("paymentInInvoiceCurrency"));
1057 }
1058 if (GETPOST('closepaidinvoices')) {
1059 $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
1060 print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
1061 }
1062 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
1063 }
1064
1065 // Call Hook formConfirm
1066 $parameters = array('formConfirm' => $formconfirm);
1067 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1068 if (empty($reshook)) {
1069 $formconfirm .= $hookmanager->resPrint;
1070 } elseif ($reshook > 0) {
1071 $formconfirm = $hookmanager->resPrint;
1072 }
1073
1074 // Print form confirm
1075 print $formconfirm;
1076
1077 print "</form>\n";
1078}
1079
1080
1081llxFooter();
1082
1083$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...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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 '.
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...
print $langs trans('Date')." left Ref 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 Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:487
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.