dolibarr 24.0.0-beta
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 dol_print_error($db, 'Payment '.$id.' not found in database');
287 exit;
288}
289
290$form = new Form($db);
291
292$head = payment_prepare_head($object);
293
294print dol_get_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment');
295
296// Confirmation of payment delete
297if ($action == 'delete') {
298 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
299}
300
301// Confirmation of payment validation
302if ($action == 'valide') {
303 $facid = GETPOSTINT('facid');
304 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.((int) $facid), $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2);
305}
306
307$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
308
309dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '');
310
311
312print '<div class="fichecenter">';
313print '<div class="underbanner clearboth"></div>';
314
315print '<table class="border tableforfield centpercent">'."\n";
316
317// Date payment
318print '<tr><td class="titlefield">'.$form->editfieldkey("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement')).'</td><td>';
319print $form->editfieldval("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement'), 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'), '', 0, '', 'id', 'tzuser');
320print '</td></tr>';
321
322// Payment type (VIR, LIQ, ...)
323$labeltype = $langs->trans("PaymentType".$object->type_code) != "PaymentType".$object->type_code ? $langs->trans("PaymentType".$object->type_code) : $object->type_label;
324print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'.$labeltype;
325print $object->num_payment ? ' - '.$object->num_payment : '';
326print '</td></tr>';
327
328// Amount
329print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
330
331$disable_delete = 0;
332$bankline = null;
333
334// Bank account
335if (isModEnabled("bank")) {
336 $bankline = new AccountLine($db);
337
338 if ($object->fk_account > 0) {
339 $bankline->fetch($object->bank_line);
340 if ($bankline->rappro) {
341 $disable_delete = 1;
342 $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
343 }
344
345 print '<tr>';
346 print '<td>'.$langs->trans('BankAccount').'</td>';
347 print '<td>';
348 $accountstatic = new Account($db);
349 $accountstatic->fetch($bankline->fk_account);
350 print $accountstatic->getNomUrl(1);
351 print '</td>';
352 print '</tr>';
353 }
354}
355
356// Payment numero
357/*
358$titlefield=$langs->trans('Numero').' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
359print '<tr><td>'.$form->editfieldkey($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
360print $form->editfieldval($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
361print '</td></tr>';
362
363// Check transmitter
364$titlefield=$langs->trans('CheckTransmitter').' <em>('.$langs->trans("ChequeMaker").')</em>';
365print '<tr><td>'.$form->editfieldkey($titlefield,'chqemetteur',$object->,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
366print $form->editfieldval($titlefield,'chqemetteur',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeMakeUpdateSucceeded'));
367print '</td></tr>';
368
369// Bank name
370$titlefield=$langs->trans('Bank').' <em>('.$langs->trans("ChequeBank").')</em>';
371print '<tr><td>'.$form->editfieldkey($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td>';
372print $form->editfieldval($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeBankUpdateSucceeded'));
373print '</td></tr>';
374*/
375
376// Bank account
377if (isModEnabled("bank")) {
378 if ($object->fk_account > 0) {
379 if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
380 include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
381 $bordereau = new RemiseCheque($db);
382 $bordereau->fetch($bankline->fk_bordereau);
383
384 print '<tr>';
385 print '<td>'.$langs->trans('CheckReceipt').'</td>';
386 print '<td>';
387 print $bordereau->getNomUrl(1);
388 print '</td>';
389 print '</tr>';
390 }
391 }
392
393 print '<tr>';
394 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
395 print '<td>';
396 if ($object->fk_account > 0 && $bankline !== null) {
397 print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted');
398 } else {
399 $langs->load("admin");
400 print '<span class="opacitymedium">';
401 print $langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name"));
402 print '</span>';
403 if ($user->hasRight('facture', 'paiement')) {
404 // Try to guess $bankaccountidofinvoices that is ID of bank account defined on invoice.
405 // 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.
406 $amountofpayments = $object->getAmountsArray();
407 $bankaccountidofinvoices = null;
408 foreach ($amountofpayments as $idinvoice => $amountofpayment) {
409 $tmpinvoice = new Facture($db);
410 $tmpinvoice->fetch($idinvoice);
411 if ($tmpinvoice->fk_account > 0 && $bankaccountidofinvoices !== 0) {
412 if (is_null($bankaccountidofinvoices)) {
413 $bankaccountidofinvoices = $tmpinvoice->fk_account;
414 } elseif ($bankaccountidofinvoices != $tmpinvoice->fk_account) {
415 $bankaccountidofinvoices = 0;
416 }
417 }
418 }
419
420 print '<form method="POST" name="createbankpayment">';
421 print '<input type="hidden" name="token" value="'.newToken().'">';
422 print '<input type="hidden" name="action" value="createbankpayment">';
423 print '<input type="hidden" name="id" value="'.$object->id.'">';
424 print ' '.$langs->trans("ToCreateRelatedRecordIntoBank").': ';
425 print $form->select_comptes($bankaccountidofinvoices, 'accountid', 0, '', 2, '', 0, '', 1);
426 //print '<span class="opacitymedium">';
427 print '<input type="submit" class="button small smallpaddingimp" name="createbankpayment" value="'.$langs->trans("ClickHere").'">';
428 //print '</span>';
429 print '</form>';
430 }
431 }
432 print '</td>';
433 print '</tr>';
434}
435
436// Comments
437print '<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">';
438print $form->editfieldval("Note", 'note', $object->note_private, $object, $user->hasRight('facture', 'paiement'), 'textarea:'.ROWS_3.':90%');
439print '</td></tr>';
440
441if (!empty($object->ext_payment_id)) {
442 // External payment ID
443 print '<tr><td class="tdtop">'.$langs->trans("StripePaymentId").'</td><td class="wordbreak">';
444 if (isModEnabled('stripe') && in_array($object->ext_payment_site, array('Stripe', 'StripeLive'))) {
445 $tmp1 = explode('@', $object->ext_payment_id);
446 $site_account_payment = '';
447 if (!empty($tmp1[1])) {
448 $site_account_payment = $tmp1[1]; // pk_live_...
449 }
450 $tmp2 = explode(':', $tmp1[0]);
451 if (!empty($tmp2[1])) {
452 $stripecu = $tmp2[1];
453 }
454
455 print dol_escape_htmltag($tmp1[0]);
456
457 $connect = '';
458 if (!empty($stripeacc)) {
459 $connect = $stripeacc.'/';
460 }
461
462 if ($stripecu) {
463 $url = 'https://dashboard.stripe.com/'.$connect.($object->ext_payment_site == 'Stripe' ? 'test/' : '').'customers/'.$stripecu;
464 if (!empty($stripearrayofkeysbyenv[1]['publishable_key']) && $stripearrayofkeysbyenv[1]['publishable_key'] == $site_account_payment) {
465 $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
466 }
467 } else {
468 $url = 'https://dashboard.stripe.com/'.($object->ext_payment_site == 'Stripe' ? 'test/' : '').'payments/'.$object->ext_payment_id;
469 }
470
471 print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$site_account_payment, 'globe').'</a>';
472 } else {
473 print dol_escape_htmltag($object->ext_payment_id);
474 }
475 print '</td></tr>';
476}
477
478// Other attributes
479$cols = 2;
480include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
481
482// Other attributes
483$parameters = array();
484$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
485print $hookmanager->resPrint;
486
487print '</table>';
488
489print '</div>';
490
491print dol_get_fiche_end();
492
493
494/*
495 * List of invoices
496 */
497
498$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';
499$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
500$sql .= ' WHERE pf.fk_facture = f.rowid';
501$sql .= ' AND f.fk_soc = s.rowid';
502$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
503$sql .= ' AND pf.fk_paiement = '.((int) $object->id);
504$resql = $db->query($sql);
505if ($resql) {
506 $num = $db->num_rows($resql);
507
508 $i = 0;
509 $total = 0;
510
511 print '<br>';
512
513 print '<div class="div-table-responsive">';
514 print '<table class="noborder centpercent">';
515
516 print '<tr class="liste_titre">';
517 print '<td>'.$langs->trans('Bill').'</td>';
518 print '<td>'.$langs->trans('Company').'</td>';
519 if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_INVOICE_SHARING_ENABLED')) {
520 print '<td>'.$langs->trans('Entity').'</td>';
521 }
522 //Add Margin
523 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) {
524 print '<td class="right">'.$langs->trans('Margin').'</td>';
525 }
526 print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
527 print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
528 print '<td class="right">'.$langs->trans('RemainderToPay').'</td>';
529 print '<td class="right">'.$langs->trans('Status').'</td>';
530
531 $parameters = array();
532 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
533
534 print "</tr>\n";
535
536 if ($num > 0) {
537 while ($i < $num) {
538 $objp = $db->fetch_object($resql);
539
540 $thirdpartystatic->fetch($objp->socid);
541
542 $invoice = new Facture($db);
543 $invoice->fetch($objp->facid);
544 $marginInfo = null;
545
546 // Add Margin
547 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) {
548 $formmargin = new FormMargin($db);
549 $marginInfo = array();
550 $invoice->fetch_lines();
551 $marginInfo = $formmargin->getMarginInfosArray($invoice);
552 }
553
554 $paiement = $invoice->getSommePaiement();
555 $creditnotes = $invoice->getSumCreditNotesUsed();
556 $deposits = $invoice->getSumDepositsUsed();
557 $alreadypaid = price2num($paiement + $creditnotes + $deposits, 'MT');
558 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
559
560 print '<tr class="oddeven">';
561
562 // Invoice
563 print '<td class="tdoverflowmax150">';
564 print $invoice->getNomUrl(1);
565 print "</td>\n";
566
567 // Third party
568 print '<td class="tdoverflowmax150">';
569 print $thirdpartystatic->getNomUrl(1);
570 print '</td>';
571
572 // Expected to pay
573 if (isModEnabled('multicompany') && isset($mc) && getDolGlobalString('MULTICOMPANY_INVOICE_SHARING_ENABLED')) {
574 print '<td>';
575 $mc->getInfo($objp->entity);
576 print $mc->label;
577 print '</td>';
578 }
579
580 // Add margin
581 if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT') && $marginInfo !== null) {
582 print '<td class="right">'.price($marginInfo['total_margin']).'</td>';
583 }
584
585 // Expected to pay
586 print '<td class="right"><span class="amount">'.price($objp->total_ttc).'</span></td>';
587
588 // Amount paid
589 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
590
591 // Remain to pay
592 print '<td class="right"><span class="amount">'.price($remaintopay).'</span></td>';
593
594 // Status
595 print '<td class="right">'.$invoice->getLibStatut(5, (float) $alreadypaid).'</td>';
596
597 $parameters = array('fk_paiement' => (int) $object->id);
598 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
599
600 print "</tr>\n";
601
602 // 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
603 if ($objp->paye == 1 && !getDolGlobalString('INVOICE_CAN_DELETE_PAYMENT_EVEN_IF_INVOICE_CLOSED')) {
604 $disable_delete = 1;
605 $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
606 }
607
608 $total += $objp->amount;
609 $i++;
610 }
611 }
612
613
614 print "</table>\n";
615 print '</div>';
616
617 $db->free($resql);
618} else {
620}
621
622
623
624/*
625 * Actions Buttons
626 */
627
628print '<div class="tabsAction">';
629
630if (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION')) {
631 if ($user->socid == 0 && $object->statut == 0 && $action == '') {
632 if ($user->hasRight('facture', 'paiement')) {
633 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&action=valide&token='.newToken().'">'.$langs->trans('Valid').'</a>';
634 }
635 }
636}
637
638$params = array();
639if (! empty($title_button)) {
640 $params['attr'] = array('title' => $title_button);
641}
642
643if ($user->socid == 0 && $action == '') {
644 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('facture', 'paiement') && !$disable_delete, $params);
645}
646
647print '</div>';
648
649// End of page
650llxFooter();
651$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.
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)
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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, $mode=0)
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.