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