dolibarr  16.0.5
paiement.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 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) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
7  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
8  * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9  * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
10  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
11  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 require '../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency'));
41 
42 $action = GETPOST('action', 'alpha');
43 $confirm = GETPOST('confirm', 'alpha');
44 
45 $facid = GETPOST('facid', 'int');
46 $accountid = GETPOST('accountid', 'int');
47 $paymentnum = GETPOST('num_paiement', 'alpha');
48 $socid = GETPOST('socid', 'int');
49 
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 
54 $amounts = array();
55 $amountsresttopay = array();
56 $addwarning = 0;
57 
58 $multicurrency_amounts = array();
59 $multicurrency_amountsresttopay = array();
60 
61 // Security check
62 if ($user->socid > 0) {
63  $socid = $user->socid;
64 }
65 
66 $object = new Facture($db);
67 
68 // Load object
69 if ($facid > 0) {
70  $ret = $object->fetch($facid);
71 }
72 
73 // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
74 $hookmanager->initHooks(array('paiementcard', 'globalcard'));
75 
76 $formquestion = array();
77 
78 $usercanissuepayment = !empty($user->rights->facture->paiement);
79 
80 $fieldid = 'rowid';
81 $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
82 $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
83 
84 
85 /*
86  * Actions
87  */
88 
89 $parameters = array('socid'=>$socid);
90 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91 if ($reshook < 0) {
92  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 }
94 
95 if (empty($reshook)) {
96  if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) {
97  $error = 0;
98 
99  $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
100  $paiement_id = 0;
101  $totalpayment = 0;
102  $multicurrency_totalpayment = 0;
103  $atleastonepaymentnotnull = 0;
104  $formquestion = array();
105  $i = 0;
106 
107  // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
108  $tmpinvoice = new Facture($db);
109  foreach ($_POST as $key => $value) {
110  if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') {
111  $cursorfacid = substr($key, 7);
112  $amounts[$cursorfacid] = price2num(GETPOST($key));
113  $totalpayment = $totalpayment + $amounts[$cursorfacid];
114  if (!empty($amounts[$cursorfacid])) {
115  $atleastonepaymentnotnull++;
116  }
117  $result = $tmpinvoice->fetch($cursorfacid);
118  if ($result <= 0) {
119  dol_print_error($db);
120  }
121  $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
122  if ($amounts[$cursorfacid]) {
123  // Check amount
124  if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) {
125  $addwarning = 1;
126  $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
127  }
128  // Check date
129  if ($datepaye && ($datepaye < $tmpinvoice->date)) {
130  $langs->load("errors");
131  //$error++;
132  setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
133  }
134  }
135 
136  $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
137  } elseif (substr($key, 0, 21) == 'multicurrency_amount_') {
138  $cursorfacid = substr($key, 21);
139  $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key));
140  $multicurrency_totalpayment += floatval($multicurrency_amounts[$cursorfacid]);
141  if (!empty($multicurrency_amounts[$cursorfacid])) {
142  $atleastonepaymentnotnull++;
143  }
144  $result = $tmpinvoice->fetch($cursorfacid);
145  if ($result <= 0) {
146  dol_print_error($db);
147  }
148  $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
149  if ($multicurrency_amounts[$cursorfacid]) {
150  // Check amount
151  if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
152  $addwarning = 1;
153  $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
154  }
155  // Check date
156  if ($datepaye && ($datepaye < $tmpinvoice->date)) {
157  $langs->load("errors");
158  //$error++;
159  setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
160  }
161  }
162 
163  $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
164  }
165  }
166 
167  // Check parameters
168  if (!GETPOST('paiementcode')) {
169  setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
170  $error++;
171  }
172 
173  if (isModEnabled('banque')) {
174  // If bank module is on, account is required to enter a payment
175  if (GETPOST('accountid') <= 0) {
176  setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
177  $error++;
178  }
179  }
180 
181  if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
182  setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
183  $error++;
184  }
185 
186  if (empty($datepaye)) {
187  setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
188  $error++;
189  }
190 
191  // Check if payments in both currency
192  if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
193  $langs->load("errors");
194  setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
195  $error++;
196  }
197  }
198 
199  /*
200  * Action add_paiement
201  */
202  if ($action == 'add_paiement') {
203  if ($error) {
204  $action = 'create';
205  }
206  // The next of this action is displayed at the page's bottom.
207  }
208 
209  /*
210  * Action confirm_paiement
211  */
212  if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) {
213  $error = 0;
214 
215  $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzuser');
216 
217  $db->begin();
218 
219  $thirdparty = new Societe($db);
220  if ($socid > 0) {
221  $thirdparty->fetch($socid);
222  }
223 
224  $multicurrency_code = array();
225 
226  // Clean parameters amount if payment is for a credit note
227  foreach ($amounts as $key => $value) { // How payment is dispatched
228  $tmpinvoice = new Facture($db);
229  $tmpinvoice->fetch($key);
230  if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
231  $newvalue = price2num($value, 'MT');
232  $amounts[$key] = - abs($newvalue);
233  }
234  $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
235  }
236 
237  foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
238  $tmpinvoice = new Facture($db);
239  $tmpinvoice->fetch($key);
240  if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
241  $newvalue = price2num($value, 'MT');
242  $multicurrency_amounts[$key] = - abs($newvalue);
243  }
244  $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
245  }
246 
247  if (isModEnabled('banque')) {
248  // If the bank module is active, an account is required to input a payment
249  if (GETPOST('accountid', 'int') <= 0) {
250  setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
251  $error++;
252  }
253  }
254 
255  // Creation of payment line
256  $paiement = new Paiement($db);
257  $paiement->datepaye = $datepaye;
258  $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
259  $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
260  $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
261  $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
262  $paiement->num_payment = GETPOST('num_paiement', 'alpha');
263  $paiement->note_private = GETPOST('comment', 'alpha');
264  $paiement->fk_account = GETPOST('accountid', 'int');
265 
266  if (!$error) {
267  // Create payment and update this->multicurrency_amounts if this->amounts filled or
268  // this->amounts if this->multicurrency_amounts filled.
269  // This also set ->amount and ->multicurrency_amount
270  $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents
271  if ($paiement_id < 0) {
272  setEventMessages($paiement->error, $paiement->errors, 'errors');
273  $error++;
274  }
275  }
276 
277  if (!$error) {
278  $label = '(CustomerInvoicePayment)';
279  if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
280  $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
281  }
282  $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank'));
283  if ($result < 0) {
284  setEventMessages($paiement->error, $paiement->errors, 'errors');
285  $error++;
286  }
287  }
288 
289  if (!$error) {
290  $db->commit();
291 
292  // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
293  $invoiceid = 0;
294  foreach ($paiement->amounts as $key => $amount) {
295  $facid = $key;
296  if (is_numeric($amount) && $amount <> 0) {
297  if ($invoiceid != 0) {
298  $invoiceid = -1; // There is more than one invoice payed by this payment
299  } else {
300  $invoiceid = $facid;
301  }
302  }
303  }
304  if ($invoiceid > 0) {
305  $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid;
306  } else {
307  $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
308  }
309  header('Location: '.$loc);
310  exit;
311  } else {
312  $db->rollback();
313  }
314  }
315 }
316 
317 
318 /*
319  * View
320  */
321 
322 $form = new Form($db);
323 
324 
325 llxHeader('', $langs->trans("Payment"));
326 
327 
328 
329 if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
330  $facture = new Facture($db);
331  $result = $facture->fetch($facid);
332 
333  if ($result >= 0) {
334  $facture->fetch_thirdparty();
335 
336  $title = '';
337  if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
338  $title .= $langs->trans("EnterPaymentReceivedFromCustomer");
339  }
340  if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
341  $title .= $langs->trans("EnterPaymentDueToCustomer");
342  }
343  print load_fiche_titre($title);
344 
345  // Initialize data for confirmation (this is used because data can be change during confirmation)
346  if ($action == 'add_paiement') {
347  $i = 0;
348 
349  $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id);
350  $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid);
351  $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type);
352  }
353 
354  // Invoice with Paypal transaction
355  // TODO add hook here
356  if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) {
357  if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) {
358  $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
359  }
360  $paymentnum = $facture->ref_ext;
361  }
362 
363  // Add realtime total information
364  if (!empty($conf->use_javascript_ajax)) {
365  print "\n".'<script type="text/javascript">';
366  print '$(document).ready(function () {
367  setPaiementCode();
368 
369  $("#selectpaiementcode").change(function() {
370  setPaiementCode();
371  });
372 
373  function setPaiementCode()
374  {
375  var code = $("#selectpaiementcode option:selected").val();
376  console.log("setPaiementCode code="+code);
377 
378  if (code == \'CHQ\' || code == \'VIR\')
379  {
380  if (code == \'CHQ\')
381  {
382  $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
383  }
384  if ($(\'#fieldchqemetteur\').val() == \'\')
385  {
386  var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM)).'\' : jQuery(\'#thirdpartylabel\').val();
387  $(\'#fieldchqemetteur\').val(emetteur);
388  }
389  }
390  else
391  {
392  $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
393  $(\'#fieldchqemetteur\').val(\'\');
394  }
395  }
396 
397  function _elemToJson(selector)
398  {
399  var subJson = {};
400  $.map(selector.serializeArray(), function(n,i)
401  {
402  subJson[n["name"]] = n["value"];
403  });
404 
405  return subJson;
406  }
407  function callForResult(imgId)
408  {
409  var json = {};
410  var form = $("#payment_form");
411 
412  json["invoice_type"] = $("#invoice_type").val();
413  json["amountPayment"] = $("#amountpayment").attr("value");
414  json["amounts"] = _elemToJson(form.find("input.amount"));
415  json["remains"] = _elemToJson(form.find("input.remain"));
416  json["token"] = "'.currentToken().'";
417  if (imgId != null) {
418  json["imgClicked"] = imgId;
419  }
420 
421  $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
422  {
423  json = $.parseJSON(data);
424 
425  form.data(json);
426 
427  for (var key in json)
428  {
429  if (key == "result") {
430  if (json["makeRed"]) {
431  $("#"+key).addClass("error");
432  } else {
433  $("#"+key).removeClass("error");
434  }
435  json[key]=json["label"]+" "+json[key];
436  $("#"+key).text(json[key]);
437  } else {console.log(key);
438  form.find("input[name*=\""+key+"\"]").each(function() {
439  $(this).attr("value", json[key]);
440  });
441  }
442  }
443  });
444  }
445  $("#payment_form").find("input.amount").change(function() {
446  callForResult();
447  });
448  $("#payment_form").find("input.amount").keyup(function() {
449  callForResult();
450  });
451  ';
452 
453  print ' });'."\n";
454 
455  //Add js for AutoFill
456  print ' $(document).ready(function () {';
457  print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
458  $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
459  });';
460  print ' });'."\n";
461 
462  print ' </script>'."\n";
463  }
464 
465  print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
466  print '<input type="hidden" name="token" value="'.newToken().'">';
467  print '<input type="hidden" name="action" value="add_paiement">';
468  print '<input type="hidden" name="facid" value="'.$facture->id.'">';
469  print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
470  print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
471  print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).'">';
472 
473  print dol_get_fiche_head();
474 
475  print '<table class="border centpercent">';
476 
477  // Third party
478  print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
479 
480  // Date payment
481  print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
482  $datepayment = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
483  $datepayment = ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datepayment);
484  print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
485  print '</td></tr>';
486 
487  // Payment mode
488  print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
489  $form->select_types_paiements((GETPOST('paiementcode') ?GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2);
490  print "</td>\n";
491  print '</tr>';
492 
493  // Bank account
494  print '<tr>';
495  if (isModEnabled('banque')) {
496  if ($facture->type != 2) {
497  print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>';
498  }
499  if ($facture->type == 2) {
500  print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
501  }
502 
503  print '<td>';
504  print img_picto('', 'bank_account');
505  print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1);
506  print '</td>';
507  } else {
508  print '<td>&nbsp;</td>';
509  }
510  print "</tr>\n";
511 
512  // Bank check number
513  print '<tr><td>'.$langs->trans('Numero');
514  print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
515  print '</td>';
516  print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
517 
518  // Check transmitter
519  print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
520  print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
521  print '</td>';
522  print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
523 
524  // Bank name
525  print '<tr><td>'.$langs->trans('Bank');
526  print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
527  print '</td>';
528  print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
529 
530  // Comments
531  print '<tr><td>'.$langs->trans('Comments').'</td>';
532  print '<td class="tdtop">';
533  print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
534  print '</td></tr>';
535 
536  print '</table>';
537 
538  print dol_get_fiche_end();
539 
540 
541  /*
542  * List of unpaid invoices
543  */
544 
545  $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,';
546  $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
547  $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
548  $sql .= ' WHERE f.entity IN ('.getEntity('facture').')';
549  $sql .= ' AND (f.fk_soc = '.((int) $facture->socid);
550  // Can pay invoices of all child of parent company
551  if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
552  $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->parent).')';
553  }
554  // Can pay invoices of all child of myself
555  if (!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)) {
556  $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->id).')';
557  }
558  $sql .= ') AND f.paye = 0';
559  $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
560  if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
561  $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
562  } else {
563  $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
564  }
565  // Sort invoices by date and serial number: the older one comes first
566  $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
567 
568  $resql = $db->query($sql);
569  if ($resql) {
570  $num = $db->num_rows($resql);
571  if ($num > 0) {
572  $arraytitle = $langs->trans('Invoice');
573  if ($facture->type == 2) {
574  $arraytitle = $langs->trans("CreditNotes");
575  }
576  $alreadypayedlabel = $langs->trans('Received');
577  $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived');
578  if ($facture->type == 2) {
579  $alreadypayedlabel = $langs->trans("PaidBack");
580  $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack");
581  }
582  $remaindertopay = $langs->trans('RemainderToTake');
583  $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake');
584  if ($facture->type == 2) {
585  $remaindertopay = $langs->trans("RemainderToPayBack");
586  $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack");
587  }
588 
589  $i = 0;
590  //print '<tr><td colspan="3">';
591  print '<br>';
592 
593  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
594  print '<table class="noborder centpercent">';
595 
596  print '<tr class="liste_titre">';
597  print '<td>'.$arraytitle.'</td>';
598  print '<td class="center">'.$langs->trans('Date').'</td>';
599  print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
600  if (isModEnabled('multicurrency')) {
601  print '<td>'.$langs->trans('Currency').'</td>';
602  print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
603  print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>';
604  print '<td class="right">'.$multicurrencyremaindertopay.'</td>';
605  print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
606  }
607  print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
608  print '<td class="right">'.$alreadypayedlabel.'</td>';
609  print '<td class="right">'.$remaindertopay.'</td>';
610  print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
611 
612  $parameters = array();
613  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
614 
615  print '<td align="right">&nbsp;</td>';
616  print "</tr>\n";
617 
618  $total_ttc = 0;
619  $totalrecu = 0;
620  $totalrecucreditnote = 0;
621  $totalrecudeposits = 0;
622 
623  while ($i < $num) {
624  $objp = $db->fetch_object($resql);
625 
626  $sign = 1;
627  if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
628  $sign = -1;
629  }
630 
631  $soc = new Societe($db);
632  $soc->fetch($objp->socid);
633 
634  $invoice = new Facture($db);
635  $invoice->fetch($objp->facid);
636  $paiement = $invoice->getSommePaiement();
637  $creditnotes = $invoice->getSumCreditNotesUsed();
638  $deposits = $invoice->getSumDepositsUsed();
639  $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
640  $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
641 
642  // Multicurrency Price
643  if (isModEnabled('multicurrency')) {
644  $multicurrency_payment = $invoice->getSommePaiement(1);
645  $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
646  $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
647  $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
648  $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
649  }
650 
651 
652  print '<tr class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
653 
654  print '<td class="nowraponall">';
655  print $invoice->getNomUrl(1, '');
656  if ($objp->socid != $facture->thirdparty->id) {
657  print ' - '.$soc->getNomUrl(1).' ';
658  }
659  print "</td>\n";
660 
661  // Date
662  print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
663 
664  // Due date
665  if ($objp->dlr > 0) {
666  print '<td class="nowraponall center">';
667  print dol_print_date($db->jdate($objp->dlr), 'day');
668 
669  if ($invoice->hasDelay()) {
670  print img_warning($langs->trans('Late'));
671  }
672 
673  print '</td>';
674  } else {
675  print '<td align="center"></td>';
676  }
677 
678  // Currency
679  if (isModEnabled('multicurrency')) {
680  print '<td class="center">'.$objp->multicurrency_code."</td>\n";
681  }
682 
683  // Multicurrency Price
684  if (isModEnabled('multicurrency')) {
685  print '<td class="right">';
686  if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
687  print price($sign * $objp->multicurrency_total_ttc);
688  }
689  print '</td>';
690 
691  // Multicurrency Price
692  print '<td class="right">';
693  if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
694  print price($sign * $multicurrency_payment);
695  if ($multicurrency_creditnotes) {
696  print '+'.price($multicurrency_creditnotes);
697  }
698  if ($multicurrency_deposits) {
699  print '+'.price($multicurrency_deposits);
700  }
701  }
702  print '</td>';
703 
704  // Multicurrency remain to pay
705  print '<td class="right">';
706  if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
707  print price($sign * $multicurrency_remaintopay);
708  }
709  print '</td>';
710 
711  print '<td class="right nowraponall">';
712 
713  // Add remind multicurrency amount
714  $namef = 'multicurrency_amount_'.$objp->facid;
715  $nameRemain = 'multicurrency_remain_'.$objp->facid;
716 
717  if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
718  if ($action != 'add_paiement') {
719  if (!empty($conf->use_javascript_ajax)) {
720  print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'");
721  }
722  print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.GETPOST($namef).'">';
723  print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
724  } else {
725  print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.GETPOST($namef).'" disabled>';
726  print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
727  }
728  }
729  print "</td>";
730  }
731 
732  // Price
733  print '<td class="right"><span class="amount">'.price($sign * $objp->total_ttc).'</span></td>';
734 
735  // Received + already paid
736  print '<td class="right"><span class="amount">'.price($sign * $paiement);
737  if ($creditnotes) {
738  print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
739  }
740  if ($deposits) {
741  print '<span class="opacitymedium">+'.price($deposits).'</span>';
742  }
743  print '</span></td>';
744 
745  // Remain to take or to pay back
746  print '<td class="right">';
747  print price($sign * $remaintopay);
748  if (!empty($conf->prelevement->enabled)) {
749  $numdirectdebitopen = 0;
750  $totaldirectdebit = 0;
751  $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
752  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
753  $sql .= " WHERE fk_facture = ".((int) $objp->facid);
754  $sql .= " AND pfd.traite = 0";
755  $sql .= " AND pfd.ext_payment_id IS NULL";
756 
757  $result_sql = $db->query($sql);
758  if ($result_sql) {
759  $obj = $db->fetch_object($result_sql);
760  $numdirectdebitopen = $obj->nb;
761  $totaldirectdebit = $obj->amount;
762  } else {
763  dol_print_error($db);
764  }
765  if ($numdirectdebitopen) {
766  $langs->load("withdrawals");
767  print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
768  }
769  }
770  print '</td>';
771  //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
772 
773  // Amount
774  print '<td class="right nowraponall">';
775 
776  // Add remind amount
777  $namef = 'amount_'.$objp->facid;
778  $nameRemain = 'remain_'.$objp->facid;
779 
780  if ($action != 'add_paiement') {
781  if (!empty($conf->use_javascript_ajax)) {
782  print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
783  }
784  print '<input type="text" class="maxwidth75 amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
785  print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
786  } else {
787  print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
788  print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
789  }
790  print "</td>";
791 
792  $parameters = array();
793  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
794 
795  // Warning
796  print '<td align="center" width="16">';
797  //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
798  if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
799  || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) {
800  print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
801  }
802  print '</td>';
803 
804  print "</tr>\n";
805 
806  $total_ttc += $objp->total_ttc;
807  $totalrecu += $paiement;
808  $totalrecucreditnote += $creditnotes;
809  $totalrecudeposits += $deposits;
810  $i++;
811  }
812 
813  if ($i > 1) {
814  // Print total
815  print '<tr class="liste_total">';
816  print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>';
817  if (isModEnabled('multicurrency')) {
818  print '<td></td>';
819  print '<td></td>';
820  print '<td></td>';
821  print '<td></td>';
822  print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
823  }
824  print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
825  print '<td class="right"><b>'.price($sign * $totalrecu);
826  if ($totalrecucreditnote) {
827  print '+'.price($totalrecucreditnote);
828  }
829  if ($totalrecudeposits) {
830  print '+'.price($totalrecudeposits);
831  }
832  print '</b></td>';
833  print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
834  print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
835  print '<td align="center">&nbsp;</td>';
836  print "</tr>\n";
837  }
838  print "</table>";
839  print "</div>\n";
840  }
841  $db->free($resql);
842  } else {
843  dol_print_error($db);
844  }
845 
846  $formconfirm = '';
847 
848  // Save button
849  if ($action != 'add_paiement') {
850  $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
851  if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
852  $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
853  }
854  $buttontitle = $langs->trans('ToMakePayment');
855  if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
856  $buttontitle = $langs->trans('ToMakePaymentBack');
857  }
858 
859  print '<br><div class="center">';
860  print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
861  /*if (! empty($conf->prelevement->enabled))
862  {
863  $langs->load("withdrawals");
864  if (! empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed");
865  }*/
866  print '<br><input type="submit" class="button" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
867  print '</div>';
868  }
869 
870  // Form to confirm payment
871  if ($action == 'add_paiement') {
872  $preselectedchoice = $addwarning ? 'no' : 'yes';
873 
874  print '<br>';
875  if (!empty($totalpayment)) {
876  $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency));
877  }
878  if (!empty($multicurrency_totalpayment)) {
879  $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency"));
880  }
881  if (GETPOST('closepaidinvoices')) {
882  $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
883  print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
884  }
885  $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
886  }
887 
888  // Call Hook formConfirm
889  $parameters = array('formConfirm' => $formconfirm);
890  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
891  if (empty($reshook)) {
892  $formconfirm .= $hookmanager->resPrint;
893  } elseif ($reshook > 0) {
894  $formconfirm = $hookmanager->resPrint;
895  }
896 
897  // Print form confirm
898  print $formconfirm;
899 
900  print "</form>\n";
901  }
902 }
903 
904 
908 if (!GETPOST('action', 'aZ09')) {
909  if (empty($page) || $page == -1) {
910  $page = 0;
911  }
912  $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
913  $offset = $limit * $page;
914 
915  if (!$sortorder) {
916  $sortorder = 'DESC';
917  }
918  if (!$sortfield) {
919  $sortfield = 'p.datep';
920  }
921 
922  $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
923  $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
924  $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
925  $sql .= ', '.MAIN_DB_PREFIX.'facture as f';
926  $sql .= ' WHERE p.fk_facture = f.rowid';
927  $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
928  if ($socid) {
929  $sql .= ' AND f.fk_soc = '.((int) $socid);
930  }
931 
932  $sql .= $db->order($sortfield, $sortorder);
933  $sql .= $db->plimit($limit + 1, $offset);
934  $resql = $db->query($sql);
935 
936  if ($resql) {
937  $num = $db->num_rows($resql);
938  $i = 0;
939 
940  print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
941  print '<table class="noborder centpercent">';
942  print '<tr class="liste_titre">';
943  print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
944  print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
945  print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
946  print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
947  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
948  print "</tr>\n";
949 
950  while ($i < min($num, $limit)) {
951  $objp = $db->fetch_object($resql);
952 
953  print '<tr class="oddeven">';
954  print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
955  print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
956  print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
957  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
958  print '<td>&nbsp;</td>';
959  print '</tr>';
960 
961  $parameters = array();
962  $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
963 
964  $i++;
965  }
966  print '</table>';
967  }
968 }
969 
970 llxFooter();
971 
972 $db->close();
Facture\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: facture.class.php:412
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Facture
Class to manage invoices.
Definition: facture.class.php:60
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
dol_escape_js
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Definition: functions.lib.php:1423
dol_getIdFromCode
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
Definition: functions.lib.php:8535
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
Facture\TYPE_CREDIT_NOTE
const TYPE_CREDIT_NOTE
Credit note invoice.
Definition: facture.class.php:392
Paiement
Class to manage payments of customer invoices.
Definition: paiement.class.php:41
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
currentToken
currentToken()
Return the value of token currently saved into session with name 'token'.
Definition: functions.lib.php:10889
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59