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