dolibarr  17.0.4
prelevement.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
8  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
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 
30 // Load Dolibarr environment
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('bills', 'banks', 'withdrawals', 'companies'));
44 
45 $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
46 $ref = GETPOST('ref', 'alpha');
47 $socid = GETPOST('socid', 'int');
48 $action = GETPOST('action', 'aZ09');
49 $type = GETPOST('type', 'aZ09');
50 
51 $fieldid = (!empty($ref) ? 'ref' : 'rowid');
52 if ($user->socid) {
53  $socid = $user->socid;
54 }
55 
56 $moreparam = '';
57 if ($type == 'bank-transfer') {
58  $object = new FactureFournisseur($db);
59  $moreparam = '&type='.$type;
60 } else {
61  $object = new Facture($db);
62 }
63 
64 // Load object
65 if ($id > 0 || !empty($ref)) {
66  $ret = $object->fetch($id, $ref);
67  $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
68  if ($ret > 0) {
69  $object->fetch_thirdparty();
70  }
71 }
72 
73 $hookmanager->initHooks(array('directdebitcard', 'globalcard'));
74 
75 if ($type == 'bank-transfer') {
76  $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', $fieldid, $isdraft);
77  if (empty($user->rights->fournisseur->facture->lire)) {
79  }
80 } else {
81  $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);
82  if (!$user->rights->facture->lire) {
84  }
85 }
86 
87 if ($type == 'bank-transfer') {
88  $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
89 } else {
90  $usercancreate = $user->rights->facture->creer;
91 }
92 
93 
94 /*
95  * Actions
96  */
97 
98 $parameters = array('socid' => $socid);
99 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
100 if ($reshook < 0) {
101  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
102 }
103 
104 if (empty($reshook)) {
105  if ($action == "new" && $usercancreate) {
106  if ($object->id > 0) {
107  $db->begin();
108 
109  $newtype = $type;
110  $sourcetype = 'facture';
111  if ($type == 'bank-transfer') {
112  $sourcetype = 'supplier_invoice';
113  $newtype = 'bank-transfer';
114  }
115  $paymentservice = GETPOST('paymentservice');
116 
117  $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype);
118 
119  if ($result > 0) {
120  $db->commit();
121 
122  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
123  } else {
124  $db->rollback();
125  setEventMessages($object->error, $object->errors, 'errors');
126  }
127  }
128  $action = '';
129  }
130 
131  if ($action == "delete" && $usercancreate) {
132  if ($object->id > 0) {
133  $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
134  if ($result == 0) {
135  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type);
136  exit;
137  }
138  }
139  }
140 
141  // Payment with Direct Debit Stripe
142  if ($action == 'sepastripepayment' && $usercancreate) {
143  $result = $object->makeStripeSepaRequest($user, GETPOST('did', 'int'), 'direct-debit', 'facture');
144  if ($result < 0) {
145  setEventMessages($object->error, $object->errors, 'errors');
146  } else {
147  // We refresh object data
148  $ret = $object->fetch($id, $ref);
149  $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
150  if ($ret > 0) {
151  $object->fetch_thirdparty();
152  }
153  }
154  }
155 
156  // payments conditions
157  if ($action == 'setconditions' && $usercancreate) {
158  $object->fetch($id);
159  $object->cond_reglement_code = 0; // To clean property
160  $object->cond_reglement_id = 0; // To clean property
161 
162  $error = 0;
163 
164  $db->begin();
165 
166  if (!$error) {
167  $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
168  if ($result < 0) {
169  $error++;
170  setEventMessages($object->error, $object->errors, 'errors');
171  }
172  }
173 
174  if (!$error) {
175  $old_date_echeance = $object->date_echeance;
176  $new_date_echeance = $object->calculate_date_lim_reglement();
177  if ($new_date_echeance > $old_date_echeance) {
178  $object->date_echeance = $new_date_echeance;
179  }
180  if ($object->date_echeance < $object->date) {
181  $object->date_echeance = $object->date;
182  }
183  $result = $object->update($user);
184  if ($result < 0) {
185  $error++;
186  setEventMessages($object->error, $object->errors, 'errors');
187  }
188  }
189 
190  if ($error) {
191  $db->rollback();
192  } else {
193  $db->commit();
194  }
195  } elseif ($action == 'setmode' && $usercancreate) {
196  // payment mode
197  $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
198  } elseif ($action == 'setdatef' && $usercancreate) {
199  $newdate = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'), 'tzserver');
200  if ($newdate > (dol_now('tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
201  if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
202  setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
203  } else {
204  setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
205  }
206  }
207 
208  $object->date = $newdate;
209  $date_echence_calc = $object->calculate_date_lim_reglement();
210  if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
211  $object->date_echeance = $date_echence_calc;
212  }
213  if ($object->date_echeance && $object->date_echeance < $object->date) {
214  $object->date_echeance = $object->date;
215  }
216 
217  $result = $object->update($user);
218  if ($result < 0) {
219  dol_print_error($db, $object->error);
220  }
221  } elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
222  $object->date_echeance = dol_mktime(12, 0, 0, GETPOST('date_lim_reglementmonth', 'int'), GETPOST('date_lim_reglementday', 'int'), GETPOST('date_lim_reglementyear', 'int'));
223  if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
224  $object->date_echeance = $object->date;
225  setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings');
226  }
227  $result = $object->update($user);
228  if ($result < 0) {
229  dol_print_error($db, $object->error);
230  }
231  }
232 }
233 
234 
235 /*
236  * View
237  */
238 
239 $form = new Form($db);
240 
241 $now = dol_now();
242 
243 if ($type == 'bank-transfer') {
244  $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('CreditTransfer');
245  $helpurl = "";
246 } else {
247  $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders');
248  $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
249 }
250 
251 llxHeader('', $title, $helpurl);
252 
253 
254 if ($object->id > 0) {
255  $selleruserevenustamp = $mysoc->useRevenueStamp();
256 
257  $totalpaid = $object->getSommePaiement();
258  $totalcreditnotes = $object->getSumCreditNotesUsed();
259  $totaldeposits = $object->getSumDepositsUsed();
260  //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
261 
262  // We can also use bcadd to avoid pb with floating points
263  // For example print 239.2 - 229.3 - 9.9; does not return 0.
264  //$resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT);
265  //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
266  $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
267 
268  if ($object->paye) {
269  $resteapayer = 0;
270  }
271  $resteapayeraffiche = $resteapayer;
272 
273  if ($type == 'bank-transfer') {
274  if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
275  $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
276  $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
277  } else {
278  $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
279  $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
280  }
281 
282  $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
283  $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote, 0, 1);
284  $absolute_discount = price2num($absolute_discount, 'MT');
285  $absolute_creditnote = price2num($absolute_creditnote, 'MT');
286  } else {
287  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
288  $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
289  $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
290  } else {
291  $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
292  $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
293  }
294 
295  $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount);
296  $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote);
297  $absolute_discount = price2num($absolute_discount, 'MT');
298  $absolute_creditnote = price2num($absolute_creditnote, 'MT');
299  }
300 
301  $author = new User($db);
302  if ($object->fk_user_author) {
303  $author->fetch($object->fk_user_author);
304  }
305 
306  if ($type == 'bank-transfer') {
307  $head = facturefourn_prepare_head($object);
308  } else {
309  $head = facture_prepare_head($object);
310  }
311 
312  $numopen = 0;
313  $pending = 0;
314  $numclosed = 0;
315 
316  // How many Direct debit or Credit transfer open requests ?
317 
318  $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
319  $sql .= " , pfd.date_traite as date_traite";
320  $sql .= " , pfd.amount";
321  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
322  if ($type == 'bank-transfer') {
323  $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
324  } else {
325  $sql .= " WHERE fk_facture = ".((int) $object->id);
326  }
327  $sql .= " AND pfd.traite = 0";
328  $sql .= " AND pfd.ext_payment_id IS NULL";
329  $sql .= " ORDER BY pfd.date_demande DESC";
330 
331  $resql = $db->query($sql);
332  if ($resql) {
333  $num = $db->num_rows($resql);
334  $numopen = $num;
335  } else {
336  dol_print_error($db);
337  }
338 
339 
340  print dol_get_fiche_head($head, 'standingorders', $title, -1, ($type == 'bank-transfer' ? 'supplier_invoice' : 'bill'));
341 
342  // Invoice content
343  if ($type == 'bank-transfer') {
344  $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
345  } else {
346  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
347  }
348 
349  $morehtmlref = '<div class="refidno">';
350  // Ref customer
351  if ($type == 'bank-transfer') {
352  $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
353  $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
354  } else {
355  $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
356  $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
357  }
358  // Thirdparty
359  $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
360  if ($type == 'bank-transfer') {
361  if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
362  $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
363  }
364  } else {
365  if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
366  $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
367  }
368  }
369  // Project
370  if (isModEnabled('project')) {
371  $langs->load("projects");
372  $morehtmlref .= '<br>';
373  if (0) {
374  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
375  if ($action != 'classify') {
376  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
377  }
378  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
379  } else {
380  if (!empty($object->fk_project)) {
381  $proj = new Project($db);
382  $proj->fetch($object->fk_project);
383  $morehtmlref .= $proj->getNomUrl(1);
384  if ($proj->title) {
385  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
386  }
387  }
388  }
389  }
390  $morehtmlref .= '</div>';
391 
392  $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
393 
394  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $moreparam, 0, '', '');
395 
396  print '<div class="fichecenter">';
397  print '<div class="fichehalfleft">';
398  print '<div class="underbanner clearboth"></div>';
399 
400  print '<table class="border centpercent tableforfield">';
401 
402  // Type
403  print '<tr><td class="titlefield fieldname_type">'.$langs->trans('Type').'</td><td colspan="3">';
404  print '<span class="badgeneutral">';
405  print $object->getLibType();
406  print '</span>';
407  if ($object->module_source) {
408  print ' <span class="opacitymediumbycolor paddingleft">('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')</span>';
409  }
410  if ($object->type == $object::TYPE_REPLACEMENT) {
411  if ($type == 'bank-transfer') {
412  $facreplaced = new FactureFournisseur($db);
413  } else {
414  $facreplaced = new Facture($db);
415  }
416  $facreplaced->fetch($object->fk_facture_source);
417  print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).'</span>';
418  }
419  if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
420  if ($type == 'bank-transfer') {
421  $facusing = new FactureFournisseur($db);
422  } else {
423  $facusing = new Facture($db);
424  }
425  $facusing->fetch($object->fk_facture_source);
426  print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).'</span>';
427  }
428 
429  $facidavoir = $object->getListIdAvoirFromInvoice();
430  if (count($facidavoir) > 0) {
431  $invoicecredits = array();
432  foreach ($facidavoir as $facid) {
433  if ($type == 'bank-transfer') {
434  $facavoir = new FactureFournisseur($db);
435  } else {
436  $facavoir = new Facture($db);
437  }
438  $facavoir->fetch($facid);
439  $invoicecredits[] = $facavoir->getNomUrl(1);
440  }
441  print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("InvoiceHasAvoir");
442  print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits);
443  print '</span>';
444  }
445  /*
446  if ($objectidnext > 0) {
447  $facthatreplace=new Facture($db);
448  $facthatreplace->fetch($objectidnext);
449  print ' <span class="opacitymediumbycolor paddingleft">'.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).'</span>';
450  }
451  */
452  print '</td></tr>';
453 
454  // Relative and absolute discounts
455  print '<!-- Discounts -->'."\n";
456  print '<tr><td>'.$langs->trans('DiscountStillRemaining').'</td><td colspan="3">';
457 
458  if ($type == 'bank-transfer') {
459  //$societe = new Fournisseur($db);
460  //$result = $societe->fetch($object->socid);
461  $thirdparty = $object->thirdparty;
462  $discount_type = 1;
463  } else {
464  $thirdparty = $object->thirdparty;
465  $discount_type = 0;
466  }
467  $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id);
468  $cannotApplyDiscount = 1;
469  include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
470 
471  print '</td></tr>';
472 
473  // Label
474  if ($type == 'bank-transfer') {
475  print '<tr>';
476  print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td>';
477  print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, 0).'</td>';
478  print '</tr>';
479  }
480 
481  // Date invoice
482  print '<tr><td>';
483  print '<table class="nobordernopadding centpercent"><tr><td>';
484  print $langs->trans('DateInvoice');
485  print '</td>';
486  if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) {
487  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
488  }
489  print '</tr></table>';
490  print '</td><td colspan="3">';
491 
492  if ($object->type != $object::TYPE_CREDIT_NOTE) {
493  if ($action == 'editinvoicedate') {
494  print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate', 0, 0, 1, $type);
495  } else {
496  print dol_print_date($object->date, 'day');
497  }
498  } else {
499  print dol_print_date($object->date, 'day');
500  }
501  print '</td>';
502  print '</tr>';
503 
504  // Payment condition
505  print '<tr><td>';
506  print '<table class="nobordernopadding centpercent"><tr><td>';
507  print $langs->trans('PaymentConditionsShort');
508  print '</td>';
509  if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) {
510  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
511  }
512  print '</tr></table>';
513  print '</td><td colspan="3">';
514  if ($object->type != $object::TYPE_CREDIT_NOTE) {
515  if ($action == 'editconditions') {
516  $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, $type);
517  } else {
518  $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
519  }
520  } else {
521  print '&nbsp;';
522  }
523  print '</td></tr>';
524 
525  // Date payment term
526  print '<tr><td>';
527  print '<table class="nobordernopadding centpercent"><tr><td>';
528  print $langs->trans('DateMaxPayment');
529  print '</td>';
530  if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) {
531  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
532  }
533  print '</tr></table>';
534  print '</td><td colspan="3">';
535  if ($object->type != $object::TYPE_CREDIT_NOTE) {
536  $duedate = $object->date_lim_reglement;
537  if ($type == 'bank-transfer') {
538  $duedate = $object->date_echeance;
539  }
540 
541  if ($action == 'editpaymentterm') {
542  print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm', 0, 0, 1, $type);
543  } else {
544  print dol_print_date($duedate, 'day');
545  if ($object->hasDelay()) {
546  print img_warning($langs->trans('Late'));
547  }
548  }
549  } else {
550  print '&nbsp;';
551  }
552  print '</td></tr>';
553 
554  // Payment mode
555  print '<tr><td>';
556  print '<table class="nobordernopadding centpercent"><tr><td>';
557  print $langs->trans('PaymentMode');
558  print '</td>';
559  if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) {
560  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
561  }
562  print '</tr></table>';
563  print '</td><td colspan="3">';
564  $filtertype = 'CRDT';
565  if ($type == 'bank-transfer') {
566  $filtertype = 'DBIT';
567  }
568  if ($action == 'editmode') {
569  $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', $filtertype, 1, 0, $type);
570  } else {
571  $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
572  }
573  print '</td></tr>';
574 
575  // Bank Account
576  print '<tr><td class="nowrap">';
577  print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
578  print $langs->trans('BankAccount');
579  print '<td>';
580  if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) {
581  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
582  }
583  print '</tr></table>';
584  print '</td><td colspan="3">';
585  if ($action == 'editbankaccount') {
586  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
587  } else {
588  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
589  }
590  print "</td>";
591  print '</tr>';
592 
593  // IBAN of seller or supplier
594  $title = 'CustomerIBAN';
595  if ($type == 'bank-transfer') {
596  $title = 'SupplierIBAN';
597  }
598  print '<tr><td>'.$langs->trans($title).'</td><td colspan="3">';
599 
600  $bac = new CompanyBankAccount($db);
601  $bac->fetch(0, $object->thirdparty->id);
602 
603  print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
604  if (!empty($bac->iban)) {
605  if ($bac->verif() <= 0) {
606  print img_warning('Error on default bank number for IBAN : '.$bac->error_message);
607  }
608  } else {
609  if ($numopen || ($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) {
610  print img_warning($langs->trans("NoDefaultIBANFound"));
611  }
612  }
613 
614  print '</td></tr>';
615 
616  print '</table>';
617 
618  print '</div>';
619  print '<div class="fichehalfright">';
620  print '<div class="underbanner clearboth"></div>';
621 
622  print '<table class="border centpercent tableforfield">';
623 
624  if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
625  // Multicurrency Amount HT
626  print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
627  print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
628  print '</tr>';
629 
630  // Multicurrency Amount VAT
631  print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
632  print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
633  print '</tr>';
634 
635  // Multicurrency Amount TTC
636  print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
637  print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
638  print '</tr>';
639  }
640 
641  // Amount
642  print '<tr><td class="titlefield">'.$langs->trans('AmountHT').'</td>';
643  print '<td class="nowrap">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
644 
645  // Vat
646  print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3" class="nowrap">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
647  print '</tr>';
648 
649  // Amount Local Taxes
650  if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1
651  print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
652  print '<td class="nowrap">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
653  }
654  if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2
655  print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
656  print '<td class=nowrap">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
657  }
658 
659  // Revenue stamp
660  if ($selleruserevenustamp) { // Test company use revenue stamp
661  print '<tr><td>';
662  print '<table class="nobordernopadding" width="100%"><tr><td>';
663  print $langs->trans('RevenueStamp');
664  print '</td>';
665  if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) {
666  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editrevenuestamp&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'</a></td>';
667  }
668  print '</tr></table>';
669  print '</td><td>';
670  print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
671  print '</td></tr>';
672  }
673 
674  // Total with tax
675  print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="nowrap">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
676 
677  $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
678 
679  // TODO Replace this by an include with same code to show already done payment visible in invoice card
680  print '<tr><td>'.$langs->trans('RemainderToPay').'</td><td class="nowrap">'.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
681 
682  print '</table>';
683 
684  print '</div>';
685  print '</div>';
686 
687  print '<div class="clearboth"></div>';
688 
689 
690  print dol_get_fiche_end();
691 
692 
693  // For which amount ?
694 
695  $sql = "SELECT SUM(pfd.amount) as amount";
696  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
697  if ($type == 'bank-transfer') {
698  $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
699  } else {
700  $sql .= " WHERE fk_facture = ".((int) $object->id);
701  }
702  $sql .= " AND pfd.traite = 0";
703  $sql .= " AND pfd.ext_payment_id IS NULL";
704 
705  $resql = $db->query($sql);
706  if ($resql) {
707  $obj = $db->fetch_object($resql);
708  if ($obj) {
709  $pending = $obj->amount;
710  }
711  } else {
712  dol_print_error($db);
713  }
714 
715 
716  /*
717  * Buttons
718  */
719 
720  print "\n".'<div class="tabsAction">'."\n";
721 
722  $buttonlabel = $langs->trans("MakeWithdrawRequest");
723  $user_perms = $user->rights->prelevement->bons->creer;
724  if ($type == 'bank-transfer') {
725  $buttonlabel = $langs->trans("MakeBankTransferOrder");
726  $user_perms = $user->rights->paymentbybanktransfer->create;
727  }
728 
729  // Add a transfer request
730  if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) {
731  if ($resteapayer > 0) {
732  if ($user_perms) {
733  $remaintopaylesspendingdebit = $resteapayer - $pending;
734 
735  print '<form method="POST" action="">';
736  print '<input type="hidden" name="token" value="'.newToken().'" />';
737  print '<input type="hidden" name="id" value="'.$object->id.'" />';
738  print '<input type="hidden" name="type" value="'.$type.'" />';
739  print '<input type="hidden" name="action" value="new" />';
740  print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
741  print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
742  print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
743  print '</form>';
744 
745  if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT_SHOW_BUTTON)) {
746  // TODO Replace this with a checkbox for each payment mode: "Send request to PaymentModeManager immediatly..."
747  print "<br>";
748  //add stripe sepa button
749  $buttonlabel = $langs->trans("MakeWithdrawRequestStripe");
750  print '<form method="POST" action="">';
751  print '<input type="hidden" name="token" value="'.newToken().'" />';
752  print '<input type="hidden" name="id" value="'.$object->id.'" />';
753  print '<input type="hidden" name="type" value="'.$type.'" />';
754  print '<input type="hidden" name="action" value="new" />';
755  print '<input type="hidden" name="paymenservice" value="stripesepa" />';
756  print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
757  print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
758  print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
759  print '</form>';
760  }
761  } else {
762  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$buttonlabel.'</a>';
763  }
764  } else {
765  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AmountMustBePositive")).'">'.$buttonlabel.'</a>';
766  }
767  } else {
768  if ($num == 0) {
769  if ($object->statut > $object::STATUS_DRAFT) {
770  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPaid")).'">'.$buttonlabel.'</a>';
771  } else {
772  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$buttonlabel.'</a>';
773  }
774  } else {
775  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$buttonlabel.'</a>';
776  }
777  }
778 
779  print "</div>\n";
780 
781 
782  if ($type == 'bank-transfer') {
783  print '<div class="opacitymedium">'.$langs->trans("DoCreditTransferBeforePayments");
784  if (isModEnabled('stripe')) {
785  print ' '.$langs->trans("DoStandingOrdersBeforePayments2");
786  }
787  print ' '.$langs->trans("DoStandingOrdersBeforePayments3");
788  print '</div><br>';
789  } else {
790  print '<div class="opacitymedium">'.$langs->trans("DoStandingOrdersBeforePayments");
791  if (isModEnabled('stripe')) {
792  print ' '.$langs->trans("DoStandingOrdersBeforePayments2");
793  }
794  print ' '.$langs->trans("DoStandingOrdersBeforePayments3");
795  print '</div><br>';
796  }
797 
798  /*
799  * Withdrawals
800  */
801 
802  print '<div class="div-table-responsive-no-min">';
803  print '<table class="noborder centpercent">';
804 
805  print '<tr class="liste_titre">';
806  print '<td class="left">'.$langs->trans("DateRequest").'</td>';
807  print '<td class="center">'.$langs->trans("User").'</td>';
808  print '<td class="center">'.$langs->trans("Amount").'</td>';
809  print '<td class="center">'.$langs->trans("DateProcess").'</td>';
810  print '<td>&nbsp;</td>';
811  if ($type == 'bank-transfer') {
812  print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>';
813  } else {
814  print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>';
815  }
816  print '<td>&nbsp;</td>';
817  print '</tr>';
818 
819  $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
820  $sql .= " pfd.date_traite as date_traite, pfd.amount,";
821  $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
822  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
823  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
824  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
825  if ($type == 'bank-transfer') {
826  $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
827  } else {
828  $sql .= " WHERE fk_facture = ".((int) $object->id);
829  }
830  $sql .= " AND pfd.traite = 0";
831  $sql .= " AND pfd.ext_payment_id IS NULL";
832  $sql .= " ORDER BY pfd.date_demande DESC";
833 
834  $resql = $db->query($sql);
835 
836  $num = 0;
837  if ($resql) {
838  $i = 0;
839 
840  $tmpuser = new User($db);
841 
842  $num = $db->num_rows($result);
843  while ($i < $num) {
844  $obj = $db->fetch_object($resql);
845 
846  $tmpuser->id = $obj->user_id;
847  $tmpuser->login = $obj->login;
848  $tmpuser->ref = $obj->login;
849  $tmpuser->email = $obj->email;
850  $tmpuser->lastname = $obj->lastname;
851  $tmpuser->firstname = $obj->firstname;
852  $tmpuser->statut = $obj->user_status;
853 
854  print '<tr class="oddeven">';
855 
856  // Date
857  print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
858 
859  // User
860  print '<td align="center">';
861  print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
862  print '</td>';
863 
864  // Amount
865  print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
866 
867  // Ref of SEPA request
868  print '<td class="center"><span class="opacitymedium">'.$langs->trans("OrderWaiting").'</span></td>';
869 
870  print '<td>';
871  if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
872  $langs->load("stripe");
873  print '<a href="'.$_SERVER["PHP_SELF"].'?action=sepastripepayment&paymentservice=stripesepa&token='.newToken().'&did='.$obj->rowid.'&id='.$object->id.'&type='.urlencode($type).'">'.img_picto('', 'stripe', 'class="pictofixedwidth"').$langs->trans("RequestDirectDebitWithStripe").'</a>';
874  }
875  print '</td>';
876 
877  print '<td align="center">-</td>';
878 
879  print '<td class="right">';
880  print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'&did='.$obj->rowid.'&type='.$type.'">';
881  print img_delete();
882  print '</a></td>';
883 
884  print "</tr>\n";
885  $i++;
886  }
887 
888  $db->free($resql);
889  } else {
890  dol_print_error($db);
891  }
892 
893 
894  // Past requests
895 
896  $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
897  $sql .= " pb.ref,";
898  $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
899  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
900  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
901  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
902  if ($type == 'bank-transfer') {
903  $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
904  } else {
905  $sql .= " WHERE fk_facture = ".((int) $object->id);
906  }
907  $sql .= " AND pfd.traite = 1";
908  $sql .= " AND pfd.ext_payment_id IS NULL";
909  $sql .= " ORDER BY pfd.date_demande DESC";
910 
911  $result = $db->query($sql);
912  if ($result) {
913  $num = $db->num_rows($result);
914  $numclosed = $num;
915  $i = 0;
916 
917  $tmpuser = new User($db);
918 
919  while ($i < $num) {
920  $obj = $db->fetch_object($result);
921 
922  $tmpuser->id = $obj->user_id;
923  $tmpuser->login = $obj->login;
924  $tmpuser->ref = $obj->login;
925  $tmpuser->email = $obj->email;
926  $tmpuser->lastname = $obj->lastname;
927  $tmpuser->firstname = $obj->firstname;
928  $tmpuser->statut = $obj->user_status;
929 
930  print '<tr class="oddeven">';
931 
932  print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'day')."</td>\n";
933 
934  print '<td align="center">';
935  print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
936  print '</td>';
937 
938  // Amount
939  print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
940 
941  print '<td class="center">';
942  if ($obj->fk_prelevement_bons > 0) {
943  $withdrawreceipt = new BonPrelevement($db);
944  $withdrawreceipt->id = $obj->fk_prelevement_bons;
945  $withdrawreceipt->ref = $obj->ref;
946  print $withdrawreceipt->getNomUrl(1);
947  }
948  print "</td>\n";
949 
950  print '<td>&nbsp;</td>';
951 
952  print '<td class="center">'.dol_print_date($db->jdate($obj->date_traite), 'day')."</td>\n";
953 
954  print '<td>&nbsp;</td>';
955 
956  print "</tr>\n";
957  $i++;
958  }
959 
960  if (!$numopen && !$numclosed) {
961  print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
962  }
963 
964  $db->free($result);
965  } else {
966  dol_print_error($db);
967  }
968 
969  print "</table>";
970  print '</div>';
971 }
972 
973 // End of page
974 llxFooter();
975 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
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
facturefourn_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:35
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
Definition: invoice.lib.php:36
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.