dolibarr 18.0.6
create.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
8 * Copyright (C) 2019 Markus Welters <markus@welters.de>
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.'/compta/prelevement/class/bonprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
34require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills'));
43
44$type = GETPOST('type', 'aZ09');
45
46// Get supervariables
47$action = GETPOST('action', 'aZ09');
48$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
49$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
50
51$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
52$format = GETPOST('format', 'aZ09');
53$id_bankaccount = GETPOST('id_bankaccount', 'int');
54$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
55
56$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
57$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
58if (empty($page) || $page == -1) {
59 $page = 0;
60} // If $page is not defined, or '' or -1
61$offset = $limit * $page;
62
63$hookmanager->initHooks(array('directdebitcreatecard', 'globalcard'));
64
65// Security check
66$socid = GETPOST('socid', 'int');
67if ($user->socid) {
68 $socid = $user->socid;
69}
70if ($type == 'bank-transfer') {
71 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
72} else {
73 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
74}
75
76$error = 0;
77$option = "";
78$mesg = '';
79
80
81/*
82 * Actions
83 */
84
85if (GETPOST('cancel', 'alpha')) {
86 $massaction = '';
87}
88
89$parameters = array('mode' => $mode, 'format' => $format, 'limit' => $limit, 'page' => $page, 'offset' => $offset);
90$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91if ($reshook < 0) {
92 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93}
94
95if (empty($reshook)) {
96 // Change customer bank information to withdraw
97 if ($action == 'modify') {
98 for ($i = 1; $i < 9; $i++) {
99 dolibarr_set_const($db, GETPOST("nom".$i), GETPOST("value".$i), 'chaine', 0, '', $conf->entity);
100 }
101 }
102 if ($action == 'create') {
103 $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
104
105 //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit;
106
107 if ($id_bankaccount != getDolGlobalInt($default_account)) {
108 $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default
109 }
110
111 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
112 $bank = new Account($db);
113 $bank->fetch($conf->global->{$default_account});
114 // ICS is not mandatory with payment by bank transfer
115 /*if ((empty($bank->ics) && $type !== 'bank-transfer')
116 || (empty($bank->ics_transfer) && $type === 'bank-transfer')
117 ) {*/
118 if (empty($bank->ics) && $type !== 'bank-transfer') {
119 $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}'));
120 setEventMessages($errormessage, null, 'errors');
121 $action = '';
122 $error++;
123 }
124
125
126 $bprev = new BonPrelevement($db);
127
128 if (!$error) {
129 // getDolGlobalString('PRELEVEMENT_CODE_BANQUE') and getDolGlobalString('PRELEVEMENT_CODE_GUICHET') should be empty (we don't use them anymore)
130 $result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type);
131 if ($result < 0) {
132 setEventMessages($bprev->error, $bprev->errors, 'errors');
133 } elseif ($result == 0) {
134 $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
135 setEventMessages($mesg, null, 'errors');
136 $mesg .= '<br>'."\n";
137 foreach ($bprev->invoice_in_error as $key => $val) {
138 $mesg .= '<span class="warning">'.$val."</span><br>\n";
139 }
140 } else {
141 if ($type != 'bank-transfer') {
142 $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
143 $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
144 setEventMessages($texttoshow, null);
145 } else {
146 $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
147 $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
148 setEventMessages($texttoshow, null);
149 }
150
151 header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type));
152 exit;
153 }
154 }
155 }
156 $objectclass = "BonPrelevement";
157 if ($type == 'bank-transfer') {
158 $uploaddir = $conf->paymentbybanktransfer->dir_output;
159 } else {
160 $uploaddir = $conf->prelevement->dir_output;
161 }
162 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
163}
164
165
166/*
167 * View
168 */
169
170$form = new Form($db);
171
172$thirdpartystatic = new Societe($db);
173if ($type != 'bank-transfer') {
174 $invoicestatic = new Facture($db);
175} else {
176 $invoicestatic = new FactureFournisseur($db);
177}
178$bprev = new BonPrelevement($db);
179$arrayofselected = is_array($toselect) ? $toselect : array();
180// List of mass actions available
181$arrayofmassactions = array(
182);
183if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
184 $arrayofmassactions = array();
185}
186$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
187
188if (prelevement_check_config($type) < 0) {
189 $langs->load("errors");
190 $modulenametoshow = "Withdraw";
191 if ($type == 'bank-transfer') {
192 $modulenametoshow = "PaymentByBankTransfer";
193 }
194 setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv($modulenametoshow)), null, 'errors');
195}
196
197
198$title = $langs->trans("NewStandingOrder");
199if ($type == 'bank-transfer') {
200 $title = $langs->trans("NewPaymentByBankTransfer");
201}
202
203llxHeader('', $title);
204
205print load_fiche_titre($title);
206
207print dol_get_fiche_head();
208
209$nb = $bprev->nbOfInvoiceToPay($type);
210$pricetowithdraw = $bprev->SommeAPrelever($type);
211if ($nb < 0) {
212 dol_print_error($bprev->error);
213}
214print '<table class="border centpercent tableforfield">';
215
216$labeltoshow = $langs->trans("NbOfInvoiceToWithdraw");
217if ($type == 'bank-transfer') {
218 $labeltoshow = $langs->trans("NbOfInvoiceToPayByBankTransfer");
219}
220
221print '<tr><td class="titlefield">'.$labeltoshow.'</td>';
222print '<td class="nowraponall">';
223print dol_escape_htmltag($nb);
224print '</td></tr>';
225
226print '<tr><td>'.$langs->trans("AmountTotal").'</td>';
227print '<td class="amount nowraponall">';
228print price($pricetowithdraw, 0, $langs, 1, -1, -1, $conf->currency);
229print '</td>';
230print '</tr>';
231
232print '</table>';
233print '</div>';
234
235if ($mesg) {
236 print $mesg;
237}
238
239print '<div class="tabsAction">'."\n";
240
241print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
242print '<input type="hidden" name="token" value="'.newToken().'">';
243print '<input type="hidden" name="type" value="'.$type.'">';
244if ($nb) {
245 if ($pricetowithdraw) {
246 $title = $langs->trans('BankToReceiveWithdraw').': ';
247 if ($type == 'bank-transfer') {
248 $title = $langs->trans('BankToPayCreditTransfer').': ';
249 }
250 print '<span class="hideonsmartphone">'.$title.'</span>';
251 print img_picto('', 'bank_account');
252
253 $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
254
255 print $form->select_comptes(getDolGlobalInt($default_account), 'id_bankaccount', 0, "courant=1", 0, '', 0, 'widthcentpercentminusx maxwidth300', 1);
256 print ' &nbsp; &nbsp; ';
257
258 if (empty($executiondate)) {
259 $delayindays = 0;
260 if ($type != 'bank-transfer') {
261 $delayindays = getDolGlobalInt('PRELEVEMENT_ADDDAYS');
262 } else {
263 $delayindays = getDolGlobalInt('PAYMENTBYBANKTRANSFER_ADDDAYS');
264 }
265
266 $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd');
267 }
268
269 print $langs->trans('ExecutionDate').' ';
270 $datere = $executiondate;
271 print $form->selectDate($datere, 're');
272
273
274 if ($mysoc->isInEEC()) {
275 $title = $langs->trans("CreateForSepa");
276 if ($type == 'bank-transfer') {
277 $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
278 }
279
280 if ($type != 'bank-transfer') {
281 print '<select name="format">';
282 print '<option value="FRST"'.($format == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
283 print '<option value="RCUR"'.($format == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
284 print '</select>';
285 }
286 print '<input type="submit" class="butAction margintoponly maringbottomonly" value="'.$title.'"/>';
287 } else {
288 $title = $langs->trans("CreateAll");
289 if ($type == 'bank-transfer') {
290 $title = $langs->trans("CreateFileForPaymentByBankTransfer");
291 }
292 print '<input type="hidden" name="format" value="ALL">'."\n";
293 print '<input type="submit" class="butAction margintoponly maringbottomonly" value="'.$title.'">'."\n";
294 }
295 } else {
296 if ($mysoc->isInEEC()) {
297 $title = $langs->trans("CreateForSepaFRST");
298 if ($type == 'bank-transfer') {
299 $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
300 }
301 print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.$langs->trans("AmountMustBePositive").'">'.$title."</a>\n";
302
303 if ($type != 'bank-transfer') {
304 $title = $langs->trans("CreateForSepaRCUR");
305 print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.$langs->trans("AmountMustBePositive").'">'.$title."</a>\n";
306 }
307 } else {
308 $title = $langs->trans("CreateAll");
309 if ($type == 'bank-transfer') {
310 $title = $langs->trans("CreateFileForPaymentByBankTransfer");
311 }
312 print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#">'.$title."</a>\n";
313 }
314 }
315} else {
316 $titlefortab = $langs->transnoentitiesnoconv("StandingOrders");
317 $title = $langs->trans("CreateAll");
318 if ($type == 'bank-transfer') {
319 $titlefortab = $langs->transnoentitiesnoconv("PaymentByBankTransfers");
320 $title = $langs->trans("CreateFileForPaymentByBankTransfer");
321 }
322 print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw", $titlefortab, $titlefortab)).'">';
323 print $title;
324 print "</a>\n";
325}
326
327print "</form>\n";
328
329print "</div>\n";
330print '</form>';
331print '<br>';
332
333
334/*
335 * Invoices waiting for withdraw
336 */
337
338$sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
339if ($type == 'bank-transfer') {
340 $sql .= " f.ref_supplier,";
341}
342$sql .= " pfd.rowid as request_row_id, pfd.date_demande, pfd.amount";
343if ($type == 'bank-transfer') {
344 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
345} else {
346 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
347}
348$sql .= " ".MAIN_DB_PREFIX."societe as s,";
349$sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd";
350$sql .= " WHERE s.rowid = f.fk_soc";
351$sql .= " AND f.entity IN (".getEntity('invoice').")";
352if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
353 $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
354}
355//$sql .= " AND pfd.amount > 0";
356$sql .= " AND f.total_ttc > 0"; // Avoid credit notes
357$sql .= " AND pfd.traite = 0";
358$sql .= " AND pfd.ext_payment_id IS NULL";
359if ($type == 'bank-transfer') {
360 $sql .= " AND pfd.fk_facture_fourn = f.rowid";
361} else {
362 $sql .= " AND pfd.fk_facture = f.rowid";
363}
364if ($socid > 0) {
365 $sql .= " AND f.fk_soc = ".((int) $socid);
366}
367
368$nbtotalofrecords = '';
369if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
370 $result = $db->query($sql);
371 $nbtotalofrecords = $db->num_rows($result);
372 if (($page * $limit) > $nbtotalofrecords) {
373 // if total resultset is smaller then paging size (filtering), goto and load page 0
374 $page = 0;
375 $offset = 0;
376 }
377}
378
379$sql .= $db->plimit($limit + 1, $offset);
380
381$resql = $db->query($sql);
382if ($resql) {
383 $num = $db->num_rows($resql);
384 $i = 0;
385
386 $param = '';
387 if ($limit > 0 && $limit != $conf->liste_limit) {
388 $param .= '&limit='.((int) $limit);
389 }
390 if ($socid) {
391 $param .= '&socid='.urlencode($socid);
392 }
393 if ($option) {
394 $param .= "&option=".urlencode($option);
395 }
396
397 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
398 print '<input type="hidden" name="token" value="'.newToken().'">';
399 print '<input type="hidden" name="page" value="'.$page.'">';
400 if (!empty($limit)) {
401 print '<input type="hidden" name="limit" value="'.$limit.'"/>';
402 }
403 if ($type != '') {
404 print '<input type="hidden" name="type" value="'.$type.'">';
405 }
406
407 $title = $langs->trans("InvoiceWaitingWithdraw");
408 if ($type == 'bank-transfer') {
409 $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
410 }
411 print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
412
413 $tradinvoice = "Invoice";
414 if ($type == 'bank-transfer') {
415 $tradinvoice = "SupplierInvoice";
416 }
417
418 print '<div class="div-table-responsive-no-min">';
419 print '<table class="noborder centpercent">';
420 print '<tr class="liste_titre">';
421 // Action column
422 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
423 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
424 print '<td align="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
425 }
426 }
427 print '<td>'.$langs->trans($tradinvoice).'</td>';
428 if ($type == 'bank-transfer') {
429 print '<td>'.$langs->trans("RefSupplier").'</td>';
430 }
431 print '<td>'.$langs->trans("ThirdParty").'</td>';
432 print '<td>'.$langs->trans("RIB").'</td>';
433 print '<td>'.$langs->trans("RUM").'</td>';
434 print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
435 print '<td class="right">'.$langs->trans("DateRequest").'</td>';
436 // Action column
437 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
438 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
439 print '<td align="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
440 }
441 }
442 print '</tr>';
443
444 if ($num) {
445 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
446
447 while ($i < $num && $i < $limit) {
448 $obj = $db->fetch_object($resql);
449
450 $bac = new CompanyBankAccount($db); // Must include the new in loop so the fetch is clean
451 $bac->fetch(0, $obj->socid);
452
453 $invoicestatic->id = $obj->rowid;
454 $invoicestatic->ref = $obj->ref;
455 $invoicestatic->ref_supplier = $obj->ref_supplier;
456
457 print '<tr class="oddeven">';
458
459 // Action column
460 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
461 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
462 print '<td class="nowrap center">';
463 $selected = 0;
464 if (in_array($obj->request_row_id, $arrayofselected)) {
465 $selected = 1;
466 }
467 print '<input id="cb'.$obj->request_row_id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->request_row_id.'"'.($selected ? ' checked="checked"' : '').'>';
468 print '</td>';
469 }
470 }
471
472 // Ref invoice
473 print '<td class="tdoverflowmax150">';
474 print $invoicestatic->getNomUrl(1, 'withdraw');
475 print '</td>';
476
477 if ($type == 'bank-transfer') {
478 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($invoicestatic->ref_supplier).'">';
479 print dol_escape_htmltag($invoicestatic->ref_supplier);
480 print '</td>';
481 }
482
483 // Thirdparty
484 print '<td class="tdoverflowmax100">';
485 $thirdpartystatic->fetch($obj->socid);
486 print $thirdpartystatic->getNomUrl(1, 'ban');
487 print '</td>';
488
489 // RIB
490 print '<td>';
491 if ($bac->id > 0) {
492 if (!empty($bac->iban) || !empty($bac->bic)) {
493 print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
494 if ($bac->verif() <= 0) {
495 print img_warning('Error on default bank number for IBAN : '.$langs->trans($bac->error_message));
496 }
497 } else {
498 print img_warning($langs->trans("IBANNotDefined"));
499 }
500 } else {
501 print img_warning($langs->trans("NoBankAccountDefined"));
502 }
503 print '</td>';
504
505 // RUM
506 print '<td>';
507 $rumtoshow = $thirdpartystatic->display_rib('rum');
508 if ($rumtoshow) {
509 print $rumtoshow;
510 $format = $thirdpartystatic->display_rib('format');
511 if ($type != 'bank-transfer') {
512 if ($format) {
513 print ' ('.$format.')';
514 }
515 }
516 } else {
517 print img_warning($langs->trans("NoBankAccountDefined"));
518 }
519 print '</td>';
520 // Amount
521 print '<td class="right amount">';
522 print price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);
523 print '</td>';
524 // Date
525 print '<td class="right">';
526 print dol_print_date($db->jdate($obj->date_demande), 'day');
527 print '</td>';
528 // Action column
529 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
530 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
531 print '<td class="nowrap center">';
532 $selected = 0;
533 if (in_array($obj->request_row_id, $arrayofselected)) {
534 $selected = 1;
535 }
536 print '<input id="cb'.$obj->request_row_id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->request_row_id.'"'.($selected ? ' checked="checked"' : '').'>';
537 print '</td>';
538 }
539 }
540 print '</tr>';
541 $i++;
542 }
543 } else {
544 $colspan = 6;
545 if ($type == 'bank-transfer') {
546 $colspan++;
547 }
548 if ($massactionbutton || $massaction) {
549 $colspan++;
550 }
551 print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
552 }
553 print "</table>";
554 print "</div>";
555
556 print "</form>";
557 print "<br>\n";
558} else {
559 dol_print_error($db);
560}
561
562
563/*
564 * List of latest withdraws
565 */
566/*
567$limit=5;
568
569print load_fiche_titre($langs->trans("LastWithdrawalReceipts",$limit),'','');
570
571$sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
572$sql.= ", p.datec";
573$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
574$sql.= " WHERE p.entity IN (".getEntity('invoice').")";
575$sql.= " ORDER BY datec DESC";
576$sql.=$db->plimit($limit);
577
578$result = $db->query($sql);
579if ($result)
580{
581 $num = $db->num_rows($result);
582 $i = 0;
583
584 print"\n<!-- debut table -->\n";
585 print '<table class="noborder centpercent">';
586 print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td>';
587 print '<td class="center">'.$langs->trans("Date").'</td><td class="right">'.$langs->trans("Amount").'</td>';
588 print '</tr>';
589
590 while ($i < min($num,$limit))
591 {
592 $obj = $db->fetch_object($result);
593
594
595 print '<tr class="oddeven">';
596
597 print "<td>";
598 $bprev->id=$obj->rowid;
599 $bprev->ref=$obj->ref;
600 print $bprev->getNomUrl(1);
601 print "</td>\n";
602
603 print '<td class="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
604
605 print '<td class="right"><span class="amount">'.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."</span></td>\n";
606
607 print "</tr>\n";
608 $i++;
609 }
610 print "</table><br>";
611 $db->free($result);
612}
613else
614{
615 dol_print_error($db);
616}
617*/
618
619// End of page
620llxFooter();
621$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage bank accounts.
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:123
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning 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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
prelevement_check_config($type='direct-debit')
Check need data to create standigns orders receipt file.
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.