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