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