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