dolibarr 25.0.0-alpha
orders_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2017 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) 2024-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
7 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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';
40require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
42
43// Load translation files required by the page
44$langs->loadLangs(array('banks', 'categories', 'withdrawals'));
45
46$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
49$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
50$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search
52$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
53$optioncss = GETPOST('optioncss', 'alpha');
54$mode = GETPOST('mode', 'alpha');
55
56// Get supervariables
57$search_ref = GETPOST('search_ref', 'alpha');
58$search_amount = GETPOST('search_amount', 'alpha');
59$search_status = GETPOSTISARRAY('search_status') ? GETPOST('search_status', 'array:int') : (GETPOSTISSET('search_status') ? GETPOST('search_status', 'array:intcomma') : array());
60$type = GETPOST('type', 'aZ09');
61
62// Load variable for pagination
63$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
64$sortfield = GETPOST('sortfield', 'aZ09comma');
65$sortorder = GETPOST('sortorder', 'aZ09comma');
66$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
67if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
68 // If $page is not defined, or '' or -1 or if we click on clear filters
69 $page = 0;
70}
71$offset = $limit * $page;
72$pageprev = $page - 1;
73$pagenext = $page + 1;
74if (!$sortorder) {
75 $sortorder = "DESC";
76}
77if (!$sortfield) {
78 $sortfield = "p.datec";
79}
80
81$object = new BonPrelevement($db);
82$hookmanager->initHooks(array('withdrawalsreceiptslist'));
83
84$usercancreate = $user->hasRight('prelevement', 'bons', 'creer');
85$permissiontodelete = $user->hasRight('prelevement', 'bons', 'creer');
86$permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
87if ($type == 'bank-transfer') {
88 $usercancreate = $user->hasRight('paymentbybanktransfer', 'create');
89 $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'create');
90 $permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
91}
92
93// Security check
94$socid = GETPOSTINT('socid');
95if ($user->socid) {
96 $socid = $user->socid;
97}
98if ($type == 'bank-transfer') {
99 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
100} else {
101 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
102}
103
104// Definition of array of fields for columns from ->fields
105$tableprefix = 't';
106$arrayfields = array();
107foreach ($object->fields as $key => $val) {
108 // If $val['visible']==0, then we never show the field
109 if (!empty($val['visible'])) {
110 $visible = (int) dol_eval((string) $val['visible'], 1);
111 $arrayfields[$tableprefix.'.'.$key] = array(
112 'label' => $val['label'],
113 'checked' => (($visible < 0) ? '0' : '1'),
114 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
115 'position' => $val['position'],
116 'help' => isset($val['help']) ? $val['help'] : ''
117 );
118 }
119}
120
121// Extra fields
122include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
123// Add hook to complete $arrayfield
124$parameters = array('arrayfields' => &$arrayfields);
125$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
126
127
128/*
129 * Actions
130 */
131$error = 0;
132
133if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
134 $search_ref = "";
135 $search_amount = "";
136 $search_status = array();
137}
138
139// Mass actions
140
141// Delete draft
142if (($massaction == "delete" || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) {
143 $TMsg = array();
144 $db->begin();
145 $objecttmp = new BonPrelevement($db);
146 $nbignored = 0;
147 $nbok = 0;
148 foreach ($toselect as $toselectid) {
149 $result = $objecttmp->fetch($toselectid);
150 if ($result > 0) {
151 if ($objecttmp->status != $objecttmp::STATUS_DRAFT || $objecttmp->credite > 0 || $objecttmp->date_creation != null) {
152 $langs->load("errors");
153 $nbignored++;
154 $TMsg[] = '<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'</div><br>';
155 continue;
156 }
157 $result = $objecttmp->delete($user);
158 if ($result < 0) { // if delete returns is < 0, there is an error, we break and rollback later
159 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
160 $error++;
161 break;
162 } else {
163 $nbok++;
164 }
165 } else {
166 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
167 $error++;
168 break;
169 }
170 }
171 if (empty($error)) {
172 // Message for elements well deleted
173 if ($nbok > 1) {
174 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
175 } elseif ($nbok > 0) {
176 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
177 } else {
178 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
179 }
180
181 // Message for elements which can't be deleted
182 if (!empty($TMsg)) {
183 sort($TMsg);
184 setEventMessages('', array_unique($TMsg), 'warnings');
185 }
186
187 $db->commit();
188 } else {
189 $db->rollback();
190 }
191 $massaction = '';
192}
193
194// Classify debited (at date of transfer) - bank transfer only
195// All or nothing: all selected receipts are checked before processing any of them
196if ($massaction == 'classdebited' && $type == 'bank-transfer' && $permissiontocreditdebit) {
197 $TMsg = array();
198 $objecttmp = new BonPrelevement($db);
199 $nbok = 0;
200
201 // First pass: check all selected receipts can be processed, no record is modified during this pass
202 $arrayofobjectids = array();
203 foreach ($toselect as $toselectid) {
204 $result = $objecttmp->fetch($toselectid);
205 if ($result > 0) {
206 if ($objecttmp->type != 'bank-transfer' || $objecttmp->status != BonPrelevement::STATUS_TRANSFERED || empty($objecttmp->date_trans)) {
207 $langs->load("errors");
208 $error++;
209 $TMsg[] = '<div class="error">'.$langs->trans('ErrorOnlyTransferredStatusCanBeDebitedInMassAction', $objecttmp->ref).'</div><br>';
210 continue;
211 }
212 $arrayofobjectids[] = $objecttmp->id;
213 } else {
214 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
215 $error++;
216 break;
217 }
218 }
219
220 // Second pass: process all receipts into a global transaction, all or nothing.
221 // Note: set_infocredit() calls begin()/commit()/rollback() but the database layer
222 // manages nested transactions, so the real COMMIT or ROLLBACK is done only at the end of this loop.
223 if (empty($error)) {
224 $db->begin();
225 foreach ($arrayofobjectids as $toselectid) {
226 $result = $objecttmp->fetch($toselectid);
227 if ($result > 0) {
228 $result = $objecttmp->set_infocredit($user, $objecttmp->date_trans, ($objecttmp->checkIfSalaryBonPrelevement() ? 'salary' : ''));
229 if ($result < 0) {
230 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
231 $error++;
232 break;
233 } else {
234 $nbok++;
235 }
236 } else {
237 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
238 $error++;
239 break;
240 }
241 }
242 if (empty($error)) {
243 $db->commit();
244 } else {
245 $db->rollback();
246 }
247 }
248
249 if (empty($error)) {
250 // Message for elements well updated
251 if ($nbok > 0) {
252 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
253 }
254
255 // Message for elements which can't be updated
256 if (!empty($TMsg)) {
257 sort($TMsg);
258 setEventMessages('', array_unique($TMsg), 'warnings');
259 }
260 } elseif (!empty($TMsg)) {
261 // Validation failed, no record was modified
262 sort($TMsg);
263 setEventMessages('', array_unique($TMsg), 'errors');
264 }
265 $massaction = '';
266}
267$objectclass = 'BonPrelevement';
268$objectlabel = 'BonPrelevement';
269if ($type == 'bank-transfer') {
270 $uploaddir = $conf->paymentbybanktransfer->dir_output;
271} else {
272 $uploaddir = $conf->prelevement->dir_output;
273}
274include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
275
276
277/*
278 * View
279 */
280
281$form = new Form($db);
282$directdebitorder = new BonPrelevement($db);
283
284$titlekey = "WithdrawalsReceipts";
285$title = $langs->trans("WithdrawalsReceipts");
286if ($type == 'bank-transfer') {
287 $titlekey = "BankTransferReceipts";
288 $title = $langs->trans("BankTransferReceipts");
289}
290$help_url = '';
291
292
293$sql = "SELECT p.rowid, p.ref, p.amount, p.statut as status, p.type, p.date_trans, p.method_trans, p.date_credit, p.fk_bank_account, p.datec, p.tms as datem";
294
295$sqlfields = $sql; // $sql fields to remove for count total
296
297$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
298$sql .= " WHERE p.entity IN (".getEntity('invoice').")";
299if ($type == 'bank-transfer') {
300 $sql .= " AND p.type = 'bank-transfer'";
301} else {
302 $sql .= " AND p.type = 'debit-order'";
303}
304if ($search_ref) {
305 $sql .= natural_search("p.ref", $search_ref);
306}
307if ($search_amount) {
308 $sql .= natural_search("p.amount", $search_amount, 1);
309}
310if (is_array($search_status)) {
311 if (!empty($search_status)) {
312 $sql .= natural_search("p.statut", implode(',', $search_status), 2);
313 }
314} elseif ((string) $search_status != '' && (string) $search_status != '-1') {
315 $sql .= natural_search("p.statut", $search_status, 1);
316}
317
318// Count total nb of records
319$nbtotalofrecords = '';
320if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
321 /* The fast and low memory method to get and count full list converts the sql into a sql count */
322 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
323 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
324 $resql = $db->query($sqlforcount);
325 if ($resql) {
326 $objforcount = $db->fetch_object($resql);
327 $nbtotalofrecords = $objforcount->nbtotalofrecords;
328 } else {
329 dol_print_error($db);
330 }
331
332 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
333 $page = 0;
334 $offset = 0;
335 }
336 $db->free($resql);
337}
338
339// Complete request and execute it with limit
340$sql .= $db->order($sortfield, $sortorder);
341if ($limit) {
342 $sql .= $db->plimit($limit + 1, $offset);
343}
344
345$resql = $db->query($sql);
346if (!$resql) {
347 dol_print_error($db);
348 exit;
349}
350
351$num = $db->num_rows($resql);
352
353// Output page
354// --------------------------------------------------------------------
355
356llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');
357
358$arrayofselected = is_array($toselect) ? $toselect : array();
359$query = [];
360if ($type == 'bank-transfer') {
361 $query += ['type' => 'bank-transfer'];
362}
363if (!empty($mode)) {
364 $query += ['mode' => $mode];
365}
366if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
367 $query += ['contextpage' => $contextpage];
368}
369if ($limit > 0 && $limit != $conf->liste_limit) {
370 $query += ['limit' => (int) $limit];
371}
372if ($optioncss != '') {
373 $query += ['optioncss' => $optioncss];
374}
375if ($search_amount) {
376 $query += ['search_amount' => $search_amount];
377}
378if (is_array($search_status)) {
379 if (!empty($search_status)) {
380 $query += ['search_status' => implode(',', $search_status)];
381 }
382} elseif ((string) $search_status != '' && (string) $search_status != '-1') {
383 $query += ['search_status' => (int) $search_status];
384}
385
386$arrayofmassactions = array(
387 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
388 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
389);
390if ($type == 'bank-transfer' && !empty($permissiontocreditdebit)) {
391 $arrayofmassactions['classdebited'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ClassifyDebitedAtDateOfTransfer");
392}
393if (!empty($permissiontodelete)) {
394 $arrayofmassactions['predeletedraft'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
395}
396$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
397
398print '<form method="POST" id="searchFormList" spellcheck="false" action="'.$_SERVER["PHP_SELF"].'">'."\n";
399print '<input type="hidden" name="token" value="'.newToken().'">';
400if ($optioncss != '') {
401 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
402}
403print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
404print '<input type="hidden" name="action" value="list">';
405print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
406print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
407print '<input type="hidden" name="page" value="'.$page.'">';
408print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
409print '<input type="hidden" name="page_y" value="">';
410print '<input type="hidden" name="mode" value="'.$mode.'">';
411
412if ($type != '') {
413 print '<input type="hidden" name="type" value="'.$type.'">';
414}
415$param = http_build_query($query);
416
417$newcardbutton = '';
418$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common&'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
419$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban&'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
420$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/stats.php', $query), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
421if ($usercancreate) {
422 $newcardbutton .= dolGetButtonTitleSeparator();
423 $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type='.urlencode($type));
424}
425
426print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1);
427
428include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
429
430
431$moreforfilter = '';
432/*$moreforfilter.='<div class="divsearchfield">';
433 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
434 $moreforfilter.= '</div>';*/
435
436$parameters = array();
437$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
438if (empty($reshook)) {
439 $moreforfilter .= $hookmanager->resPrint;
440} else {
441 $moreforfilter = $hookmanager->resPrint;
442}
443
444if (!empty($moreforfilter)) {
445 print '<div class="liste_titre liste_titre_bydiv centpercent">';
446 print $moreforfilter;
447 print '</div>';
448}
449
450$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
451$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
452$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
453$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
454
455print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
456print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
457
458// Fields title search
459// --------------------------------------------------------------------
460print '<tr class="liste_titre_filter">';
461// Action column
462if ($conf->main_checkbox_left_column) {
463 print '<td class="liste_titre center maxwidthsearch">';
464 $searchpicto = $form->showFilterButtons('left');
465 print $searchpicto;
466 print '</td>';
467}
468print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
469print '<td class="liste_titre">&nbsp;</td>';
470print '<td class="liste_titre">&nbsp;</td>';
471print '<td class="liste_titre">&nbsp;</td>';
472print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
473print '<td class="liste_titre">&nbsp;</td>';
474print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
475$arrayofstatus = array(
476 BonPrelevement::STATUS_DRAFT => $langs->trans('StatusWaiting'),
477 BonPrelevement::STATUS_TRANSFERED => $langs->trans('StatusTrans'),
478 BonPrelevement::STATUS_CREDITED => $langs->trans('Closed'),
479 BonPrelevement::STATUS_CANCELED => $langs->trans('Canceled')
480);
481print $form->multiselectarray('search_status', $arrayofstatus, $search_status, 0, 0, 'search_status width200 right onrightofpage', 0, 0, '');
482print '</td>';
483// Action column
484if (!$conf->main_checkbox_left_column) {
485 print '<td class="liste_titre center maxwidthsearch">';
486 $searchpicto = $form->showFilterButtons();
487 print $searchpicto;
488 print '</td>';
489}
490print '</tr>'."\n";
491
492$totalarray = array();
493$totalarray['nbfield'] = 0;
494
495// Fields title label
496// --------------------------------------------------------------------
497print '<tr class="liste_titre">';
498// Action column
499if ($conf->main_checkbox_left_column) {
500 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
501 $totalarray['nbfield']++;
502}
503print_liste_field_titre($titlekey, $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
504$totalarray['nbfield']++;
505print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center ');
506$totalarray['nbfield']++;
507print_liste_field_titre("TransData", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center ');
508$totalarray['nbfield']++;
509print_liste_field_titre("CreditDate", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center ');
510$totalarray['nbfield']++;
511print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, '', $sortfield, $sortorder, 'right ');
512$totalarray['nbfield']++;
513print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "p.fk_bank_account", "", $param, '', $sortfield, $sortorder);
514$totalarray['nbfield']++;
515print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
516$totalarray['nbfield']++;
517// Action column
518if (!$conf->main_checkbox_left_column) {
519 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
520 $totalarray['nbfield']++;
521}
522print '</tr>'."\n";
523
524// Loop on record
525// --------------------------------------------------------------------
526
527$i = 0;
528$savnbfield = $totalarray['nbfield'];
529$totalarray = array();
530$totalarray['nbfield'] = 0;
531
532$imaxinloop = ($limit ? min($num, $limit) : $num);
533while ($i < $imaxinloop) {
534 $obj = $db->fetch_object($resql);
535
536 $directdebitorder->id = $obj->rowid;
537 $directdebitorder->ref = $obj->ref;
538 $directdebitorder->date_creation = $db->jdate($obj->datec);
539 $directdebitorder->date_trans = $db->jdate($obj->date_trans);
540 $directdebitorder->date_credit = $db->jdate($obj->date_credit);
541 $directdebitorder->amount = $obj->amount;
542 $directdebitorder->status = $obj->status;
543 $directdebitorder->type = $obj->type;
544
545 $object = $directdebitorder;
546
547 if ($mode == 'kanban') {
548 if ($i == 0) {
549 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
550 print '<div class="box-flex-container kanban">';
551 }
552 // Output Kanban
553 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
554 $selected = 0;
555 if (in_array($object->id, $arrayofselected)) {
556 $selected = 1;
557 }
558 }
559 print $directdebitorder->getKanbanView('', array('selected' => in_array($obj->id, $arrayofselected)));
560 if ($i == ($imaxinloop - 1)) {
561 print '</div>';
562 print '</td></tr>';
563 }
564 } else {
565 // Show line of result
566 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
567
568 // Action column
569 if ($conf->main_checkbox_left_column) {
570 print '<td class="nowrap center">';
571 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
572 $selected = 0;
573 if (in_array($object->id, $arrayofselected)) {
574 $selected = 1;
575 }
576 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
577 }
578 print '</td>';
579 if (!$i) {
580 $totalarray['nbfield']++;
581 }
582 }
583
584 print '<td>';
585 print $directdebitorder->getNomUrl(1);
586 print "</td>\n";
587 if (!$i) {
588 $totalarray['nbfield']++;
589 }
590
591 print '<td class="center">'.dol_print_date($db->jdate($obj->datec), 'day')."</td>\n";
592 if (!$i) {
593 $totalarray['nbfield']++;
594 }
595
596 print '<td class="center">'.dol_print_date($db->jdate($obj->date_trans), 'day')."</td>\n";
597 if (!$i) {
598 $totalarray['nbfield']++;
599 }
600
601 print '<td class="center">'.dol_print_date($db->jdate($obj->date_credit), 'day')."</td>\n";
602 if (!$i) {
603 $totalarray['nbfield']++;
604 }
605
606 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
607 if (!$i) {
608 $totalarray['nbfield']++;
609 }
610
611 print '<td>';
612 if ($obj->fk_bank_account > 0) {
613 // TODO Use a cache here
614 $bankaccount = new Account($db);
615 $bankaccount->fetch($obj->fk_bank_account);
616 print $bankaccount->getNomUrl(1);
617 }
618 print "</td>";
619 if (!$i) {
620 $totalarray['nbfield']++;
621 }
622
623 print '<td class="center">';
624 print $object->LibStatut($obj->status, 5);
625 print '</td>';
626 if (!$i) {
627 $totalarray['nbfield']++;
628 }
629
630 // Action column
631 if (!$conf->main_checkbox_left_column) {
632 print '<td class="nowrap center">';
633 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
634 $selected = 0;
635 if (in_array($object->id, $arrayofselected)) {
636 $selected = 1;
637 }
638 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
639 }
640 print '</td>';
641 if (!$i) {
642 $totalarray['nbfield']++;
643 }
644 }
645
646 print '</tr>'."\n";
647 }
648 $i++;
649}
650
651if ($num == 0) {
652 print '<tr><td colspan="'.$savnbfield.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
653}
654
655$db->free($resql);
656
657$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
658$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
659print $hookmanager->resPrint;
660
661print '</table>'."\n";
662print '</div>'."\n";
663
664print '</form>'."\n";
665
666
667// End of page
668llxFooter();
669$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank accounts.
Class to manage withdrawal receipts.
Class to manage generation of HTML components Only common components must be here.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.