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