dolibarr 24.0.2
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2023 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) 2013 Marcos García <marcosgdf@gmail.com>
7 * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
32// Load Dolibarr environment
33require '../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
42require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
45if (isModEnabled("bank")) {
46 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
47}
48if (isModEnabled('margin')) {
49 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
50}
51
52// Load translation files required by the page
53$langs->loadLangs(array('bills', 'banks', 'companies'));
54
55$id = GETPOSTINT('id');
56$ref = GETPOST('ref', 'alpha');
57$action = GETPOST('action', 'aZ09');
58$confirm = GETPOST('confirm', 'alpha');
59$backtopage = GETPOST('backtopage', 'alpha');
60
61$socid = GETPOSTINT('socid');
62if ($socid < 0) {
63 $socid = 0;
64}
65
66$object = new Paiement($db);
67// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
68$hookmanager->initHooks(array('paymentcard', 'globalcard'));
69
70// Load object
71include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
72
73$result = restrictedArea($user, $object->element, $object->id, 'paiement'); // This also test permission on read invoice
74
75// Security check
76if ($user->socid) {
77 $socid = $user->socid;
78}
79// Now check also permission on thirdparty of invoices of payments. Thirdparty were loaded by the fetch_object before based on first invoice.
80// It should be enough because all payments are done on invoices of the same thirdparty.
81if ($socid && $socid != $object->thirdparty->id) {
83}
84
85$stripecu = null;
86$stripeacc = null;
87
88// Init Stripe objects
89if (isModEnabled('stripe')) {
90 require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
91
92 $service = 'StripeTest';
93 $servicestatus = 0;
94 if (getDolGlobalString('STRIPE_LIVE')/* && !GETPOST('forcesandbox', 'alpha')*/) {
95 $service = 'StripeLive';
96 $servicestatus = 1;
97 }
98
99 // Force to use the correct API key
100 global $stripearrayofkeysbyenv;
101 $site_account = $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
102
103 $stripe = new Stripe($db);
104 $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here)
105}
106
107$error = 0;
108
109/*
110 * Actions
111 */
112$parameters = array('socid' => $socid);
113$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
114if ($reshook < 0) {
115 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
116}
117
118if (empty($reshook)) {
119 if ($action == 'setnote' && $user->hasRight('facture', 'paiement')) {
120 $db->begin();
121
122 $result = $object->update_note(GETPOST('note', 'restricthtml'));
123 if ($result > 0) {
124 $db->commit();
125 $action = '';
126 } else {
127 setEventMessages($object->error, $object->errors, 'errors');
128 $db->rollback();
129 }
130 }
131
132 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) {
133 $db->begin();
134
135 $result = $object->delete($user);
136 if ($result > 0) {
137 $db->commit();
138
139 if ($backtopage) {
140 header("Location: ".$backtopage);
141 exit;
142 } else {
143 header("Location: list.php");
144 exit;
145 }
146 } else {
147 $langs->load("errors");
148 setEventMessages($object->error, $object->errors, 'errors');
149 $db->rollback();
150 }
151 }
152
153 if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) {
154 $db->begin();
155
156 if ($object->validate($user) > 0) {
157 $db->commit();
158
159 // Loop on each invoice linked to this payment to rebuild PDF
160 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
161 $outputlangs = $langs;
162 if (GETPOST('lang_id', 'aZ09')) {
163 $outputlangs = new Translate("", $conf);
164 $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
165 }
166
167 $hidedetails = getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0;
168 $hidedesc = getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0;
169 $hideref = getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0;
170
171 $sql = 'SELECT f.rowid as facid';
172 $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
173 $sql .= ' WHERE pf.fk_facture = f.rowid';
174 $sql .= ' AND f.fk_soc = s.rowid';
175 $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
176 $sql .= ' AND pf.fk_paiement = '.((int) $object->id);
177 $resql = $db->query($sql);
178 if ($resql) {
179 $i = 0;
180 $num = $db->num_rows($resql);
181
182 if ($num > 0) {
183 while ($i < $num) {
184 $objp = $db->fetch_object($resql);
185
186 $invoice = new Facture($db);
187
188 if ($invoice->fetch($objp->facid) <= 0) {
189 $error++;
190 setEventMessages($invoice->error, $invoice->errors, 'errors');
191 break;
192 }
193
194 if ($invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) {
195 $error++;
196 setEventMessages($invoice->error, $invoice->errors, 'errors');
197 break;
198 }
199
200 $i++;
201 }
202 }
203
204 $db->free($resql);
205 } else {
206 $error++;
207 setEventMessages($db->error, $db->errors, 'errors');
208 }
209 }
210
211 if (! $error) {
212 header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
213 exit;
214 }
215 } else {
216 $db->rollback();
217
218 $langs->load("errors");
219 setEventMessages($object->error, $object->errors, 'errors');
220 }
221 }
222
223 if ($action == 'setnum_paiement' && GETPOST('num_paiement') && $user->hasRight('facture', 'paiement')) {
224 $res = $object->update_num(GETPOST('num_paiement'));
225 if ($res === 0) {
226 setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs');
227 } else {
228 setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors');
229 }
230 }
231
232 if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('facture', 'paiement')) {
233 $datepaye = dol_mktime(GETPOSTINT('datephour'), GETPOSTINT('datepmin'), GETPOSTINT('datepsec'), GETPOSTINT('datepmonth'), GETPOSTINT('datepday'), GETPOSTINT('datepyear'));
234 $res = $object->update_date($datepaye);
235 if ($res === 0) {
236 setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs');
237 } else {
238 setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors');
239 }
240 }
241
242 if ($action == 'createbankpayment' && $user->hasRight('facture', 'paiement')) {
243 $db->begin();
244
245 // Create the record into bank for the amount of payment $object
246 if (!$error) {
247 $label = '(CustomerInvoicePayment)';
248 if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
249 $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
250 }
251
252 $bankaccountid = GETPOSTINT('accountid');
253 if ($bankaccountid > 0) {
254 $object->paiementcode = $object->type_code;
255 $object->amounts = $object->getAmountsArray();
256
257 $result = $object->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
258 if ($result < 0) {
259 setEventMessages($object->error, $object->errors, 'errors');
260 $error++;
261 }
262 } else {
263 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
264 $error++;
265 }
266 }
267
268 if (!$error) {
269 $db->commit();
270 } else {
271 $db->rollback();
272 }
273 }
274}
275
276/*
277 * View
278 */
279
280llxHeader('', $langs->trans("Payment"));
281
282$thirdpartystatic = new Societe($db);
283
284$result = $object->fetch($id, $ref);
285if ($result <= 0) {
286 recordNotFound('', 0);
287}
288
289$form = new Form($db);
290
291$head = payment_prepare_head($object);
292
293print dol_get_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment');
294
295// Confirmation of payment delete
296if ($action == 'delete') {
297 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
298}
299
300// Confirmation of payment validation
301if ($action == 'valide') {
302 $facid = GETPOSTINT('facid');
303 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.((int) $facid), $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2);
304}
305
306$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
307
308dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '');
309
310
311print '<div class="fichecenter">';
312print '<div class="underbanner clearboth"></div>';
313
314print '<table class="border tableforfield centpercent">'."\n";
315
316// Date payment
317print '<tr><td class="titlefield">'.$form->editfieldkey("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement')).'</td><td>';
318print $form->editfieldval("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement'), 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'), '', 0, '', 'id', 'tzuser');
319print '</td></tr>';
320
321// Payment type (VIR, LIQ, ...)
322$labeltype = $langs->trans("PaymentType".$object->type_code) != "PaymentType".$object->type_code ? $langs->trans("PaymentType".$object->type_code) : $object->type_label;
323print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'.$labeltype;
324print $object->num_payment ? ' - '.$object->num_payment : '';
325print '</td></tr>';
326
327// Amount
328print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
329
330$disable_delete = 0;
331$bankline = null;
332
333// Bank account
334if (isModEnabled("bank")) {
335 $bankline = new AccountLine($db);
336
337 if ($object->fk_account > 0) {
338 $bankline->fetch($object->bank_line);
339 if ($bankline->rappro) {
340 $disable_delete = 1;
341 $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
342 }
343
344 print '<tr>';
345 print '<td>'.$langs->trans('BankAccount').'</td>';
346 print '<td>';
347 $accountstatic = new Account($db);
348 $accountstatic->fetch($bankline->fk_account);
349 print $accountstatic->getNomUrl(1);
350 print '</td>';
351 print '</tr>';
352 }
353}
354
355// Payment numero
356/*
357$titlefield=$langs->trans('Numero').' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
358print '<tr><td>'.$form->editfieldkey($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
359print $form->editfieldval($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
360print '</td></tr>';
361
362// Check transmitter
363$titlefield=$langs->trans('CheckTransmitter').' <em>('.$langs->trans("ChequeMaker").')</em>';
364print '<tr><td>'.$form->editfieldkey($titlefield,'chqemetteur',$object->,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
365print $form->editfieldval($titlefield,'chqemetteur',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeMakeUpdateSucceeded'));
366print '</td></tr>';
367
368// Bank name
369$titlefield=$langs->trans('Bank').' <em>('.$langs->trans("ChequeBank").')</em>';
370print '<tr><td>'.$form->editfieldkey($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
371print $form->editfieldval($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeBankUpdateSucceeded'));
372print '</td></tr>';
373*/
374
375// Bank account
376if (isModEnabled("bank")) {
377 if ($object->fk_account > 0) {
378 if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
379 include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
380 $bordereau = new RemiseCheque($db);
381 $bordereau->fetch($bankline->fk_bordereau);
382
383 print '<tr>';
384 print '<td>'.$langs->trans('CheckReceipt').'</td>';
385 print '<td>';
386 print $bordereau->getNomUrl(1);
387 print '</td>';
388 print '</tr>';
389 }
390 }
391
392 print '<tr>';
393 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
394 print '<td>';
395 if ($object->fk_account > 0 && $bankline !== null) {
396 print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted');
397 } else {
398 $langs->load("admin");
399 print '<span class="opacitymedium">';
400 print $langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name"));
401 print '</span>';
402 if ($user->hasRight('facture', 'paiement')) {
403 // Try to guess $bankaccountidofinvoices that is ID of bank account defined on invoice.
404 // Return null if not found, return 0 if it has different value for at least 2 invoices, return the value if same on all invoices where a bank is defined.
405 $amountofpayments = $object->getAmountsArray();
406 $bankaccountidofinvoices = null;
407 foreach ($amountofpayments as $idinvoice => $amountofpayment) {
408 $tmpinvoice = new Facture($db);
409 $tmpinvoice->fetch($idinvoice);
410 if ($tmpinvoice->fk_account > 0 && $bankaccountidofinvoices !== 0) {
411 if (is_null($bankaccountidofinvoices)) {
412 $bankaccountidofinvoices = $tmpinvoice->fk_account;
413 } elseif ($bankaccountidofinvoices != $tmpinvoice->fk_account) {
414 $bankaccountidofinvoices = 0;
415 }
416 }
417 }
418
419 print '<form method="POST" name="createbankpayment">';
420 print '<input type="hidden" name="token" value="'.newToken().'">';
421 print '<input type="hidden" name="action" value="createbankpayment">';
422 print '<input type="hidden" name="id" value="'.$object->id.'">';
423 print ' '.$langs->trans("ToCreateRelatedRecordIntoBank").': ';
424 print $form->select_comptes($bankaccountidofinvoices, 'accountid', 0, '', 2, '', 0, '', 1);
425 //print '<span class="opacitymedium">';
426 print '<input type="submit" class="button small smallpaddingimp" name="createbankpayment" value="'.$langs->trans("ClickHere").'">';
427 //print '</span>';
428 print '</form>';
429 }
430 }
431 print '</td>';
432 print '</tr>';
433}
434
435// Comments
436print '<tr><td class="'.($user->hasRight('facture', 'paiement') ? 'tdtop' : '').'">'.$form->editfieldkey("Comments", 'note', $object->note_private, $object, $user->hasRight('facture', 'paiement'), 'string', '', 0, 0).'</td><td class="wordbreak">';
437print $form->editfieldval("Note", 'note', $object->note_private, $object, $user->hasRight('facture', 'paiement'), 'textarea:'.ROWS_3.':90%');
438print '</td></tr>';
439
440if (!empty($object->ext_payment_id)) {
441 // External payment ID
442 print '<tr><td class="tdtop">'.$langs->trans("StripePaymentId").'</td><td class="wordbreak">';
443 if (isModEnabled('stripe') && in_array($object->ext_payment_site, array('Stripe', 'StripeLive'))) {
444 $tmp1 = explode('@', $object->ext_payment_id);
445 $site_account_payment = '';
446 if (!empty($tmp1[1])) {
447 $site_account_payment = $tmp1[1]; // pk_live_...
448 }
449 $tmp2 = explode(':', $tmp1[0]);
450 if (!empty($tmp2[1])) {
451 $stripecu = $tmp2[1];
452 }
453
454 print dol_escape_htmltag($tmp1[0]);
455
456 $connect = '';
457 if (!empty($stripeacc)) {
458 $connect = $stripeacc.'/';
459 }
460
461 if ($stripecu) {
462 $url = 'https://dashboard.stripe.com/'.$connect.($object->ext_payment_site == 'Stripe' ? 'test/' : '').'customers/'.$stripecu;
463 if (!empty($stripearrayofkeysbyenv[1]['publishable_key']) && $stripearrayofkeysbyenv[1]['publishable_key'] == $site_account_payment) {
464 $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
465 }
466 } else {
467 $url = 'https://dashboard.stripe.com/'.($object->ext_payment_site == 'Stripe' ? 'test/' : '').'payments/'.$object->ext_payment_id;
468 }
469
470 print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$site_account_payment, 'globe').'</a>';
471 } else {
472 print dol_escape_htmltag($object->ext_payment_id);
473 }
474 print '</td></tr>';
475}
476
477// Other attributes
478$cols = 2;
479include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
480
481// Other attributes
482$parameters = array();
483$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
484print $hookmanager->resPrint;
485
486print '</table>';
487
488print '</div>';
489
490print dol_get_fiche_end();
491
492
493/*
494 * List of invoices
495 */
496
497$sql = 'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.entity, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid';
498$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
499$sql .= ' WHERE pf.fk_facture = f.rowid';
500$sql .= ' AND f.fk_soc = s.rowid';
501$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
502$sql .= ' AND pf.fk_paiement = '.((int) $object->id);
503$resql = $db->query($sql);
504if ($resql) {
505 $num = $db->num_rows($resql);
506
507 $i = 0;
508 $total = 0;
509
510 print '<br>';
511
512 print '<div class="div-table-responsive">';
513 print '<table class="noborder centpercent">';
514
515 print '<tr class="liste_titre">';
516 print '<td>'.$langs->trans('Bill').'</td>';
517 print '<td>'.$langs->trans('Company').'</td>';
518 if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_INVOICE_SHARING_ENABLED')) {
519 print '<td>'.$langs->trans('Entity').'</td>';
520 }
521 //Add Margin
522 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) {
523 print '<td class="right">'.$langs->trans('Margin').'</td>';
524 }
525 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
526 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
527 print '<td class="right">'.$langs->trans('RemainderToPay').'</td>';
528 print '<td class="right">'.$langs->trans('Status').'</td>';
529
530 $parameters = array();
531 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
532
533 print "</tr>\n";
534
535 if ($num > 0) {
536 while ($i < $num) {
537 $objp = $db->fetch_object($resql);
538
539 $thirdpartystatic->fetch($objp->socid);
540
541 $invoice = new Facture($db);
542 $invoice->fetch($objp->facid);
543 $marginInfo = null;
544
545 // Add Margin
546 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) {
547 $formmargin = new FormMargin($db);
548 $marginInfo = array();
549 $invoice->fetch_lines();
550 $marginInfo = $formmargin->getMarginInfosArray($invoice);
551 }
552
553 $paiement = $invoice->getSommePaiement();
554 $creditnotes = $invoice->getSumCreditNotesUsed();
555 $deposits = $invoice->getSumDepositsUsed();
556 $alreadypaid = price2num($paiement + $creditnotes + $deposits, 'MT');
557 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
558
559 print '<tr class="oddeven">';
560
561 // Invoice
562 print '<td class="tdoverflowmax150">';
563 print $invoice->getNomUrl(1);
564 print "</td>\n";
565
566 // Third party
567 print '<td class="tdoverflowmax150">';
568 print $thirdpartystatic->getNomUrl(1);
569 print '</td>';
570
571 // Expected to pay
572 if (isModEnabled('multicompany') && isset($mc) && getDolGlobalString('MULTICOMPANY_INVOICE_SHARING_ENABLED')) {
573 print '<td>';
574 $mc->getInfo($objp->entity);
575 print $mc->label;
576 print '</td>';
577 }
578
579 // Add margin
580 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT') && $marginInfo !== null) {
581 print '<td class="right">'.price($marginInfo['total_margin']).'</td>';
582 }
583
584 // Expected to pay
585 print '<td class="right"><span class="amount">'.price($objp->total_ttc).'</span></td>';
586
587 // Amount paid
588 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
589
590 // Remain to pay
591 print '<td class="right"><span class="amount">'.price($remaintopay).'</span></td>';
592
593 // Status
594 print '<td class="right">'.$invoice->getLibStatut(5, (float) $alreadypaid).'</td>';
595
596 $parameters = array('fk_paiement' => (int) $object->id);
597 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
598
599 print "</tr>\n";
600
601 // If at least one invoice is paid, disable delete. INVOICE_CAN_DELETE_PAYMENT_EVEN_IF_INVOICE_CLOSED Can be use for maintenance purpose. Never use this in production
602 if ($objp->paye == 1 && !getDolGlobalString('INVOICE_CAN_DELETE_PAYMENT_EVEN_IF_INVOICE_CLOSED')) {
603 $disable_delete = 1;
604 $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
605 }
606
607 $total += $objp->amount;
608 $i++;
609 }
610 }
611
612
613 print "</table>\n";
614 print '</div>';
615
616 $db->free($resql);
617} else {
619}
620
621
622
623/*
624 * Actions Buttons
625 */
626
627print '<div class="tabsAction">';
628
629if (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION')) {
630 if ($user->socid == 0 && $object->statut == 0 && $action == '') {
631 if ($user->hasRight('facture', 'paiement')) {
632 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&action=valide&token='.newToken().'">'.$langs->trans('Valid').'</a>';
633 }
634 }
635}
636
637$params = array();
638if (! empty($title_button)) {
639 $params['attr'] = array('title' => $title_button);
640}
641
642if ($user->socid == 0 && $action == '') {
643 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('facture', 'paiement') && !$disable_delete, $params);
644}
645
646print '</div>';
647
648// End of page
649llxFooter();
650$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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 bank accounts.
Class to manage bank transaction lines.
Class to manage invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class to manage "other" html components Only common components are here.
Class to manage payments of customer invoices.
Class to manage cheque delivery receipts.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
Class to manage translations.
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.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.