dolibarr  20.0.0-beta
list.php
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
7  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 // Load Dolibarr environment
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('companies', 'donations'));
38 
39 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
40 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
41 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
42 $mode = GETPOST('mode', 'alpha');
43 
44 $paiementid = GETPOSTINT('paiementid');
45 
46 $search_ref = GETPOST("search_ref", "alpha");
47 $search_date_startday = GETPOSTINT('search_date_startday');
48 $search_date_startmonth = GETPOSTINT('search_date_startmonth');
49 $search_date_startyear = GETPOSTINT('search_date_startyear');
50 $search_date_endday = GETPOSTINT('search_date_endday');
51 $search_date_endmonth = GETPOSTINT('search_date_endmonth');
52 $search_date_endyear = GETPOSTINT('search_date_endyear');
53 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
54 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
55 $search_company = GETPOST("search_company", 'alpha');
56 $search_paymenttype = GETPOST("search_paymenttype", "intcomma");
57 $search_account = GETPOST("search_account", 'alpha');
58 $search_payment_num = GETPOST('search_payment_num', 'alpha');
59 $search_amount = GETPOST("search_amount", 'alpha');
60 $search_status = GETPOST('search_status', 'intcomma');
61 
62 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
63 $sortfield = GETPOST('sortfield', 'aZ09comma');
64 $sortorder = GETPOST('sortorder', 'aZ09comma');
65 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
66 if (empty($page) || $page == -1) {
67  $page = 0;
68 } // If $page is not defined, or '' or -1
69 $offset = $limit * $page;
70 $pageprev = $page - 1;
71 $pagenext = $page + 1;
72 if (!$sortorder) {
73  $sortorder = "DESC";
74 }
75 if (!$sortfield) {
76  $sortfield = "pd.rowid";
77 }
78 
79 $search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
80 
81 // List of fields to search into when doing a "search in all"
82 $fieldstosearchall = array(
83  'pd.rowid' => "RefPayment",
84  's.nom' => "ThirdParty",
85  'pd.num_paiement' => "Numero",
86  'pd.amount' => "Amount",
87 );
88 
89 $arrayfields = array(
90  'pd.rowid' => array('label' => "RefPayment", 'checked' => 1, 'position' => 10),
91  'pd.datep' => array('label' => "Date", 'checked' => 1, 'position' => 20),
92  's.nom' => array('label' => "ThirdParty", 'checked' => 1, 'position' => 30),
93  'c.code' => array('label' => "Type", 'checked' => 1, 'position' => 40),
94  'pd.num_paiement' => array('label' => "Numero", 'checked' => 1, 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
95  'transaction' => array('label' => "BankTransactionLine", 'checked' => 1, 'position' => 60, 'enabled' => (isModEnabled("bank"))),
96  'ba.label' => array('label' => "BankAccount", 'checked' => 1, 'position' => 70, 'enabled' => (isModEnabled("bank"))),
97  'pd.amount' => array('label' => "Amount", 'checked' => 1, 'position' => 80),
98 );
99 $arrayfields = dol_sort_array($arrayfields, 'position');
100 '@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
101 
102 $optioncss = GETPOST('optioncss', 'alpha');
103 $moreforfilter = GETPOST('moreforfilter', 'alpha');
104 
105 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
106 $hookmanager->initHooks(array('donationlist'));
107 
108 // Security check
109 $result = restrictedArea($user, 'don');
110 
111 $permissiontoread = $user->hasRight('don', 'read');
112 $permissiontoadd = $user->hasRight('don', 'write');
113 $permissiontodelete = $user->hasRight('don', 'delete');
114 
115 /*
116  * Actions
117  */
118 
119 $parameters = array('socid' => $paiementid);
120 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
121 if ($reshook < 0) {
122  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
123 }
124 
125 if (empty($reshook)) {
126  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
127 
128  // All tests are required to be compatible with all browsers
129  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
130  $search_ref = '';
131  $search_date_startday = '';
132  $search_date_startmonth = '';
133  $search_date_startyear = '';
134  $search_date_endday = '';
135  $search_date_endmonth = '';
136  $search_date_endyear = '';
137  $search_date_start = '';
138  $search_date_end = '';
139  $search_account = '';
140  $search_amount = '';
141  $search_paymenttype = '';
142  $search_payment_num = '';
143  $search_company = '';
144  $option = '';
145  $toselect = array();
146  $search_array_options = array();
147  }
148 }
149 
150 /*
151  * View
152  */
153 
154 $form = new Form($db);
155 $donationstatic = new Don($db);
156 $companystatic = new Societe($db);
157 $bankline = new AccountLine($db);
158 $accountstatic = new Account($db);
159 
160 $title = $langs->trans("Donations");
161 $help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
162 
163 // Build and execute select
164 // --------------------------------------------------------------------
165 $sql = "SELECT pd.rowid as payment_id, pd.amount, pd.datep, pd.fk_typepayment, pd.num_payment, pd.amount, pd.fk_bank, ";
166 $sql .= ' s.rowid as soc_id, s.nom, ';
167 $sql .= ' d.societe, ';
168 $sql .= ' c.code as paiement_code, ';
169 $sql .= ' d.rowid, ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal ';
170 
171 // Add fields from hooks
172 $parameters = array();
173 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
174 $sql .= $hookmanager->resPrint;
175 
176 $sqlfields = $sql; // $sql fields to remove for count total
177 
178 $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as pd";
179 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."don as d ON (d.rowid = pd.fk_donation)";
180 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = pd.fk_bank)";
181 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (ba.rowid = b.fk_account)";
182 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.rowid = d.fk_soc)";
183 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON (c.id = pd.fk_typepayment)";
184 $sql .= " WHERE d.entity IN (".getEntity('donation').")";
185 
186 if ($search_ref) {
187  $sql .= natural_search('pd.rowid', $search_ref);
188 }
189 if ($search_date_start) {
190  $sql .= " AND pd.datep >= '" . $db->idate($search_date_start) . "'";
191 }
192 if ($search_date_end) {
193  $sql .= " AND pd.datep <= '" . $db->idate($search_date_end) . "'";
194 }
195 if ($search_account > 0) {
196  $sql .= " AND b.fk_account=".((int) $search_account);
197 }
198 if ($search_paymenttype != '') {
199  $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
200 }
201 if ($search_payment_num != '') {
202  $sql .= natural_search('pd.num_payment', $search_payment_num);
203 }
204 if ($search_amount) {
205  $sql .= natural_search('pd.amount', $search_amount, 1);
206 }
207 if ($search_company) {
208  $sql .= natural_search('s.nom', $search_company);
209 }
210 if ($search_all) {
211  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
212 }
213 
214 // Add where from hooks
215 $parameters = array();
216 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
217 $sql .= $hookmanager->resPrint;
218 
219 // Count total nb of records
220 $nbtotalofrecords = '';
221 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
222  /* The fast and low memory method to get and count full list converts the sql into a sql count */
223  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
224  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
225  $resql = $db->query($sqlforcount);
226  if ($resql) {
227  $objforcount = $db->fetch_object($resql);
228  $nbtotalofrecords = $objforcount->nbtotalofrecords;
229  } else {
230  dol_print_error($db);
231  }
232 
233  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
234  $page = 0;
235  $offset = 0;
236  }
237  $db->free($resql);
238 }
239 
240 $sql .= $db->order($sortfield, $sortorder);
241 
242 // Complete request and execute it with limit
243 if ($limit) {
244  $sql .= $db->plimit($limit + 1, $offset);
245 }
246 
247 $resql = $db->query($sql);
248 
249 if (!$resql) {
250  dol_print_error($db);
251  exit;
252 }
253 
254 $num = $db->num_rows($resql);
255 
256 // Output page
257 // --------------------------------------------------------------------
258 
259 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
260 
261 $param = '';
262 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
263  $param .= '&contextpage='.urlencode($contextpage);
264 }
265 if ($limit > 0 && $limit != $conf->liste_limit) {
266  $param .= '&limit='.((int) $limit);
267 }
268 if ($search_ref) {
269  $param .= '&search_ref='.urlencode($search_ref);
270 }
271 if ($search_date_startday) {
272  $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
273 }
274 if ($search_date_startmonth) {
275  $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
276 }
277 if ($search_date_startyear) {
278  $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
279 }
280 if ($search_date_endday) {
281  $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
282 }
283 if ($search_date_endmonth) {
284  $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
285 }
286 if ($search_date_endyear) {
287  $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
288 }
289 if ($search_company) {
290  $param .= '&search_company='.urlencode($search_company);
291 }
292 if ($search_amount != '') {
293  $param .= '&search_amount='.urlencode($search_amount);
294 }
295 if ($search_paymenttype) {
296  $param .= '&search_paymenttype='.urlencode($search_paymenttype);
297 }
298 if ($search_account) {
299  $param .= '&search_account='.urlencode((string) ($search_account));
300 }
301 if ($search_payment_num) {
302  $param .= '&search_payment_num='.urlencode($search_payment_num);
303 }
304 if ($optioncss != '') {
305  $param .= '&optioncss='.urlencode($optioncss);
306 }
307 
308 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
309 if ($optioncss != '') {
310  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
311 }
312 print '<input type="hidden" name="token" value="'.newToken().'">';
313 print '<input type="hidden" name="action" value="list">';
314 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
315 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
316 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
317 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
318 
319 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
320 print_barre_liste($langs->trans("DonationPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
321 
322 if ($search_all) {
323  foreach ($fieldstosearchall as $key => $val) {
324  $fieldstosearchall[$key] = $langs->trans($val);
325  }
326  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
327 }
328 
329 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
330 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
331 $massactionbutton = '';
332 if ($massactionbutton) {
333  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
334 }
335 
336 $moreforfilter = '';
337 print '<div class="div-table-responsive">';
338 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
339 
340 // Fields title search
341 // --------------------------------------------------------------------
342 print '<tr class="liste_titre_filter">';
343 // Action column
344 if (getDolGlobalInt('MAIN_CHECKBOX_LEFT_COLUMN')) {
345  print '<td class="liste_titre center maxwidthsearch">';
346  $searchpicto = $form->showFilterButtons('left');
347  print $searchpicto;
348  print '</td>';
349 }
350 
351 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
352  print '<td class="liste_titre">';
353  print '</td>';
354 }
355 
356 if (!empty($arrayfields['pd.rowid']['checked'])) {
357  print '<td class="liste_titre left">';
358  print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
359  print '</td>';
360 }
361 
362 // Filter: Date
363 if (!empty($arrayfields['pd.datep']['checked'])) {
364  print '<td class="liste_titre">';
365  print '<div class="nowrapfordate">';
366  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
367  print '</div>';
368  print '<div class="nowrapfordate">';
369  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
370  print '</div>';
371  print '</td>';
372 }
373 
374 // Filter: Thirdparty
375 if (!empty($arrayfields['s.nom']['checked'])) {
376  print '<td class="liste_titre">';
377  print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
378  print '</td>';
379 }
380 
381 // Filter: Payment type
382 if (!empty($arrayfields['c.code']['checked'])) {
383  print '<td class="liste_titre">';
384  print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
385  print '</td>';
386 }
387 
388 // Filter: Bank transaction number
389 if (!empty($arrayfields['transaction']['checked'])) {
390  print '<td class="liste_titre">';
391  print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
392  print '</td>';
393 }
394 
395 // Filter: Cheque number (fund transfer)
396 if (!empty($arrayfields['pd.num_paiement']['checked'])) {
397  print '<td class="liste_titre">';
398  print '</td>';
399 }
400 
401 // Filter: Bank account
402 if (!empty($arrayfields['ba.label']['checked'])) {
403  print '<td class="liste_titre">';
404  $form->select_comptes($search_account, 'search_account', 0, '', 1);
405  print '</td>';
406 }
407 
408 // Filter: Amount
409 if (!empty($arrayfields['pd.amount']['checked'])) {
410  print '<td class="liste_titre">';
411  print '<input class="flat" type="text" size="6" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
412  print '</td>';
413 }
414 
415 // Fields from hook
416 $parameters = array('arrayfields' => $arrayfields);
417 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
418 print $hookmanager->resPrint;
419 
420 // Action column
421 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
422  print '<td class="liste_titre center maxwidthsearch">';
423  $searchpicto = $form->showFilterButtons();
424  print $searchpicto;
425  print '</td>';
426 }
427 
428 print '</tr>'."\n";
429 
430 $totalarray = array();
431 $totalarray['nbfield'] = 0;
432 
433 // Fields title label
434 // --------------------------------------------------------------------
435 print '<tr class="liste_titre">';
436 // Action column
437 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
438  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
439  $totalarray['nbfield']++;
440 }
441 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
442  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
443  $totalarray['nbfield']++;
444 }
445 if (!empty($arrayfields['pd.rowid']['checked'])) {
446  print_liste_field_titre($arrayfields['pd.rowid']['label'], $_SERVER["PHP_SELF"], "pd.rowid", '', $param, '', $sortfield, $sortorder);
447  $totalarray['nbfield']++;
448 }
449 if (!empty($arrayfields['pd.datep']['checked'])) {
450  print_liste_field_titre($arrayfields['pd.datep']['label'], $_SERVER["PHP_SELF"], "pd.datep", '', $param, '', $sortfield, $sortorder);
451  $totalarray['nbfield']++;
452 }
453 if (!empty($arrayfields['s.nom']['checked'])) {
454  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
455  $totalarray['nbfield']++;
456 }
457 if (!empty($arrayfields['c.code']['checked'])) {
458  print_liste_field_titre($arrayfields['c.code']['label'], $_SERVER["PHP_SELF"], "c.code", '', $param, '', $sortfield, $sortorder);
459  $totalarray['nbfield']++;
460 }
461 if (!empty($arrayfields['pd.num_paiement']['checked'])) {
462  print_liste_field_titre($arrayfields['pd.num_paiement']['label'], $_SERVER["PHP_SELF"], "pd.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
463  $totalarray['nbfield']++;
464 }
465 if (!empty($arrayfields['transaction']['checked'])) {
466  print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
467  $totalarray['nbfield']++;
468 }
469 if (!empty($arrayfields['ba.label']['checked'])) {
470  print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
471  $totalarray['nbfield']++;
472 }
473 if (!empty($arrayfields['pd.amount']['checked'])) {
474  print_liste_field_titre($arrayfields['pd.amount']['label'], $_SERVER["PHP_SELF"], "pd.amount", '', $param, '', $sortfield, $sortorder);
475  $totalarray['nbfield']++;
476 }
477 
478 // Extra fields
479 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
480 // Hook fields
481 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
482 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
483 print $hookmanager->resPrint;
484 // Action column
485 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
486  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
487  $totalarray['nbfield']++;
488 }
489 print '</tr>'."\n";
490 
491 // Detect if we need a fetch on each output line
492 $needToFetchEachLine = 0;
493 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
494  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
495  if (!is_null($val) && preg_match('/\$object/', $val)) {
496  $needToFetchEachLine++; // There is at least one compute field that use $object
497  }
498  }
499 }
500 
501 // Loop on record
502 // --------------------------------------------------------------------
503 $i = 0;
504 $savnbfield = $totalarray['nbfield'];
505 $totalarray = array();
506 $totalarray['nbfield'] = 0;
507 $imaxinloop = ($limit ? min($num, $limit) : $num);
508 while ($i < $imaxinloop) {
509  $obj = $db->fetch_object($resql);
510 
511  $companystatic->id = $obj->soc_id;
512  $companystatic->name = $obj->nom;
513 
514  $company = new Societe($db);
515  $result = $company->fetch($obj->socid);
516 
517  print '<tr class="oddeven">';
518  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
519  print '<td class="nowrap center">';
520  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
521  $selected = 0;
522  if (in_array($obj->id_paiement, $arrayofselected)) {
523  $selected = 1;
524  }
525  print '<input id="cb'.$obj->id_paiement.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id_paiement.'"'.($selected ? ' checked="checked"' : '').'>';
526  }
527  print '</td>';
528  if (!$i) {
529  $totalarray['nbfield']++;
530  }
531  }
532 
533  // Ref
534  if (!empty($arrayfields['pd.rowid']['checked'])) {
535  print '<td><a href="' . DOL_URL_ROOT . '/don/payment/card.php?id=' . $obj->payment_id . '">' . img_object($langs->trans("Payment"), "payment") . ' ' . $obj->payment_id . '</a></td>';
536  if (!$i) {
537  $totalarray['nbfield']++;
538  }
539  }
540 
541  // Date
542  if (!empty($arrayfields['pd.datep']['checked'])) {
543  $dateformatforpayment = 'dayhour';
544  print '<td class="nowraponall">'.dol_print_date($db->jdate($obj->datep), $dateformatforpayment, 'tzuser').'</td>';
545  if (!$i) {
546  $totalarray['nbfield']++;
547  }
548  }
549 
550  // Thirdparty
551  if (!empty($arrayfields['s.nom']['checked'])) {
552  print '<td class="nowraponall">';
553  if ($obj->soc_id > 0) {
554  print $companystatic->getNomUrl(1, '', 24);
555  } else {
556  print $donationstatic->societe = $obj->societe;
557  }
558  print '</td>';
559  if (!$i) {
560  $totalarray['nbfield']++;
561  }
562  }
563 
564  // Payment type
565  if (!empty($arrayfields['c.code']['checked'])) {
566  print '<td>'.$langs->trans("PaymentTypeShort".$obj->paiement_code).'</td>';
567  if (!$i) {
568  $totalarray['nbfield']++;
569  }
570  }
571 
572  // Filter: Cheque number (fund transfer)
573  if (!empty($arrayfields['pd.num_paiement']['checked'])) {
574  print '<td>'.$obj->num_payment.'</td>';
575  if (!$i) {
576  $totalarray['nbfield']++;
577  }
578  }
579 
580  // Bank transaction
581  if (!empty($arrayfields['transaction']['checked'])) {
582  print '<td class="tdoverflowmax125">';
583  if ($obj->fk_bank > 0) {
584  $test = $bankline->fetch($obj->fk_bank);
585  print $bankline->getNomUrl(1, 0);
586  }
587  print '</td>';
588  if (!$i) {
589  $totalarray['nbfield']++;
590  }
591  }
592 
593  // Bank account
594  if (!empty($arrayfields['ba.label']['checked'])) {
595  print '<td>';
596  if ($obj->bid > 0) {
597  $accountstatic->id = $obj->bid;
598  $accountstatic->ref = $obj->bref;
599  $accountstatic->label = $obj->blabel;
600  $accountstatic->number = $obj->number;
601  $accountstatic->account_number = $obj->account_number;
602 
603  $accountingjournal = new AccountingJournal($db);
604  $accountingjournal->fetch($obj->accountancy_journal);
605  $accountstatic->accountancy_journal = $accountingjournal->code;
606 
607  print $accountstatic->getNomUrl(1);
608  }
609  if (!$i) {
610  $totalarray['nbfield']++;
611  }
612  }
613 
614  // Amount
615  if (!empty($arrayfields['pd.amount']['checked'])) {
616  print '<td ><span class="amount">' . price($obj->amount) . '</span></td>';
617  if (!$i) {
618  $totalarray['nbfield']++;
619  $totalarray['pos'][$totalarray['nbfield']] = 'amount';
620  }
621  if (empty($totalarray['val']['amount'])) {
622  $totalarray['val']['amount'] = $obj->amount;
623  } else {
624  $totalarray['val']['amount'] += $obj->amount;
625  }
626  }
627 
628  $i++;
629 }
630 
631 // Show total line
632 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
633 
634 // If no record found
635 if ($num == 0) {
636  $colspan = 1;
637  foreach ($arrayfields as $key => $val) {
638  if (!empty($val['checked'])) {
639  $colspan++;
640  }
641  }
642  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
643 }
644 
645 $db->free($resql);
646 
647 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
648 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
649 print $hookmanager->resPrint;
650 
651 print '</table>'."\n";
652 print '</div>'."\n";
653 
654 print '</form>'."\n";
655 
656 llxFooter();
657 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting journals.
Class to manage donations.
Definition: don.class.php:41
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.