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