dolibarr 25.0.0-alpha
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-2025 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.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.'/don/class/don.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
36
45// Load translation files required by the page
46$langs->loadLangs(array('companies', 'donations'));
47
48$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
49$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
50$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
51$mode = GETPOST('mode', 'alpha');
52$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
53
54$paiementid = GETPOSTINT('paiementid');
55
56$search_ref = GETPOST("search_ref", "alpha");
57$search_date_startday = GETPOSTINT('search_date_startday');
58$search_date_startmonth = GETPOSTINT('search_date_startmonth');
59$search_date_startyear = GETPOSTINT('search_date_startyear');
60$search_date_endday = GETPOSTINT('search_date_endday');
61$search_date_endmonth = GETPOSTINT('search_date_endmonth');
62$search_date_endyear = GETPOSTINT('search_date_endyear');
63$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
64$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
65$search_company = GETPOST("search_company", 'alpha');
66$search_paymenttype = GETPOST("search_paymenttype", "intcomma");
67$search_account = GETPOST("search_account", 'alpha');
68$search_payment_num = GETPOST('search_payment_num', 'alpha');
69$search_amount = GETPOST("search_amount", 'alpha');
70$search_status = GETPOST('search_status', 'intcomma');
71
72$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
73$sortfield = GETPOST('sortfield', 'aZ09comma');
74$sortorder = GETPOST('sortorder', 'aZ09comma');
75$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
76if (empty($page) || $page == -1) {
77 $page = 0;
78} // If $page is not defined, or '' or -1
79$offset = $limit * $page;
80$pageprev = $page - 1;
81$pagenext = $page + 1;
82if (!$sortorder) {
83 $sortorder = "DESC";
84}
85if (!$sortfield) {
86 $sortfield = "pd.rowid";
87}
88
89$search_all = trim(GETPOST('search_all', 'alphanohtml'));
90
91$object = new Don($db);
92
93$morejs = array();
94$morecss = array();
95
96// List of fields to search into when doing a "search in all"
97$fieldstosearchall = array(
98 'pd.rowid' => "RefPayment",
99 's.nom' => "ThirdParty",
100 'pd.num_paiement' => "Numero",
101 'pd.amount' => "Amount",
102);
103
104$arrayfields = array(
105 'pd.rowid' => array('label' => "RefPayment", 'checked' => '1', 'position' => 10),
106 'pd.datep' => array('label' => "Date", 'checked' => '1', 'position' => 20),
107 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 30),
108 'c.code' => array('label' => "Type", 'checked' => '1', 'position' => 40),
109 'pd.num_paiement' => array('label' => "Numero", 'checked' => '1', 'position' => 50, 'tooltip' => "ChequeOrTransferNumber"),
110 'transaction' => array('label' => "BankTransactionLine", 'checked' => '1', 'position' => 60, 'enabled' => (string) (int) (isModEnabled("bank"))),
111 'ba.label' => array('label' => "BankAccount", 'checked' => '1', 'position' => 70, 'enabled' => (string) (int) (isModEnabled("bank"))),
112 'pd.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 80),
113);
114// Add hook to complete $arrayfield
115$parameters = array('arrayfields' => &$arrayfields);
116$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
117$arrayfields = dol_sort_array($arrayfields, 'position');
118
119$optioncss = GETPOST('optioncss', 'alpha');
120$moreforfilter = GETPOST('moreforfilter', 'alpha');
121
122// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
123$hookmanager->initHooks(array('donationlist'));
124
125// Security check
126$result = restrictedArea($user, 'don');
127
128$permissiontoread = $user->hasRight('don', 'read');
129$permissiontoadd = $user->hasRight('don', 'write');
130$permissiontodelete = $user->hasRight('don', 'delete');
131
132/*
133 * Actions
134 */
135
136$parameters = array('socid' => $paiementid);
137$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
138if ($reshook < 0) {
139 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140}
141
142if (empty($reshook)) {
143 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
144
145 // All tests are required to be compatible with all browsers
146 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
147 $search_ref = '';
148 $search_date_startday = '';
149 $search_date_startmonth = '';
150 $search_date_startyear = '';
151 $search_date_endday = '';
152 $search_date_endmonth = '';
153 $search_date_endyear = '';
154 $search_date_start = '';
155 $search_date_end = '';
156 $search_account = '';
157 $search_amount = '';
158 $search_paymenttype = '';
159 $search_payment_num = '';
160 $search_company = '';
161 $option = '';
162 $toselect = array();
163 $search_array_options = array();
164 }
165}
166
167/*
168 * View
169 */
170
171$form = new Form($db);
172$companystatic = new Societe($db);
173$bankline = new AccountLine($db);
174$accountstatic = new Account($db);
175
176$title = $langs->trans("Donations");
177$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
178
179// Build and execute select
180// --------------------------------------------------------------------
181$sql = "SELECT pd.rowid as payment_id, pd.amount, pd.datep, pd.fk_typepayment, pd.num_payment, pd.amount, pd.fk_bank, ";
182$sql .= ' s.rowid as soc_id, s.nom, ';
183$sql .= ' d.societe, ';
184$sql .= ' c.code as paiement_code, ';
185$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 ';
186
187// Add fields from hooks
188$parameters = array();
189$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
190$sql .= $hookmanager->resPrint;
191
192$sqlfields = $sql; // $sql fields to remove for count total
193
194$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as pd";
195$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."don as d ON (d.rowid = pd.fk_donation)";
196$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = pd.fk_bank)";
197$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (ba.rowid = b.fk_account)";
198$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.rowid = d.fk_soc)";
199$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON (c.id = pd.fk_typepayment)";
200$sql .= " WHERE d.entity IN (".getEntity('donation').")";
201
202if ($search_ref) {
203 $sql .= natural_search('pd.rowid', $search_ref);
204}
205if ($search_date_start) {
206 $sql .= " AND pd.datep >= '" . $db->idate($search_date_start) . "'";
207}
208if ($search_date_end) {
209 $sql .= " AND pd.datep <= '" . $db->idate($search_date_end) . "'";
210}
211if ($search_account > 0) {
212 $sql .= " AND b.fk_account=".((int) $search_account);
213}
214if ($search_paymenttype != '') {
215 $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
216}
217if ($search_payment_num != '') {
218 $sql .= natural_search('pd.num_payment', $search_payment_num);
219}
220if ($search_amount) {
221 $sql .= natural_search('pd.amount', $search_amount, 1);
222}
223if ($search_company) {
224 $sql .= natural_search('s.nom', $search_company);
225}
226if ($search_all) {
227 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
228}
229
230// Add where from hooks
231$parameters = array();
232$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
233$sql .= $hookmanager->resPrint;
234
235// Count total nb of records
236$nbtotalofrecords = '';
237if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
238 /* The fast and low memory method to get and count full list converts the sql into a sql count */
239 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
240 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
241 $resql = $db->query($sqlforcount);
242 if ($resql) {
243 $objforcount = $db->fetch_object($resql);
244 $nbtotalofrecords = $objforcount->nbtotalofrecords;
245 } else {
247 }
248
249 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
250 $page = 0;
251 $offset = 0;
252 }
253 $db->free($resql);
254}
255
256$sql .= $db->order($sortfield, $sortorder);
257
258// Complete request and execute it with limit
259if ($limit) {
260 $sql .= $db->plimit($limit + 1, $offset);
261}
262
263$resql = $db->query($sql);
264
265if (!$resql) {
267 exit;
268}
269
270$num = $db->num_rows($resql);
271
272// Output page
273// --------------------------------------------------------------------
274
275llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
276
277$arrayofselected = is_array($toselect) ? $toselect : array();
278$param = '';
279if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
280 $param .= '&contextpage='.urlencode($contextpage);
281}
282if ($limit > 0 && $limit != $conf->liste_limit) {
283 $param .= '&limit='.((int) $limit);
284}
285if ($search_ref) {
286 $param .= '&search_ref='.urlencode($search_ref);
287}
288if ($search_date_startday) {
289 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
290}
291if ($search_date_startmonth) {
292 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
293}
294if ($search_date_startyear) {
295 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
296}
297if ($search_date_endday) {
298 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
299}
300if ($search_date_endmonth) {
301 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
302}
303if ($search_date_endyear) {
304 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
305}
306if ($search_company) {
307 $param .= '&search_company='.urlencode($search_company);
308}
309if ($search_amount != '') {
310 $param .= '&search_amount='.urlencode($search_amount);
311}
312if ($search_paymenttype) {
313 $param .= '&search_paymenttype='.urlencode($search_paymenttype);
314}
315if ($search_account) {
316 $param .= '&search_account='.urlencode((string) ($search_account));
317}
318if ($search_payment_num) {
319 $param .= '&search_payment_num='.urlencode($search_payment_num);
320}
321if ($optioncss != '') {
322 $param .= '&optioncss='.urlencode($optioncss);
323}
324
325print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
326if ($optioncss != '') {
327 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
328}
329print '<input type="hidden" name="token" value="'.newToken().'">';
330print '<input type="hidden" name="action" value="list">';
331print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
332print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
333print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
334print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
335
336// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
337print_barre_liste($langs->trans("DonationPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
338
339if ($search_all) {
340 foreach ($fieldstosearchall as $key => $val) {
341 $fieldstosearchall[$key] = $langs->trans($val);
342 }
343 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
344}
345
346$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
347$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
348// $massactionbutton = '';
349// if ($massactionbutton) {
350// $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
351// }
352
353$moreforfilter = '';
354print '<div class="div-table-responsive">';
355print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
356
357// Fields title search
358// --------------------------------------------------------------------
359print '<tr class="liste_titre_filter">';
360// Action column
361if ($conf->main_checkbox_left_column) {
362 print '<td class="liste_titre center maxwidthsearch">';
363 $searchpicto = $form->showFilterButtons('left');
364 print $searchpicto;
365 print '</td>';
366}
367
368if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
369 print '<td class="liste_titre">';
370 print '</td>';
371}
372
373if (!empty($arrayfields['pd.rowid']['checked'])) {
374 print '<td class="liste_titre left">';
375 print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
376 print '</td>';
377}
378
379// Filter: Date
380if (!empty($arrayfields['pd.datep']['checked'])) {
381 print '<td class="liste_titre">';
382 print '<div class="nowrapfordate">';
383 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
384 print '</div>';
385 print '<div class="nowrapfordate">';
386 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
387 print '</div>';
388 print '</td>';
389}
390
391// Filter: Thirdparty
392if (!empty($arrayfields['s.nom']['checked'])) {
393 print '<td class="liste_titre">';
394 print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
395 print '</td>';
396}
397
398// Filter: Payment type
399if (!empty($arrayfields['c.code']['checked'])) {
400 print '<td class="liste_titre">';
401 print $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1, 0, 1, 'maxwidth100', 1);
402 print '</td>';
403}
404
405// Filter: Bank transaction number
406if (!empty($arrayfields['transaction']['checked'])) {
407 print '<td class="liste_titre">';
408 print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
409 print '</td>';
410}
411
412// Filter: Cheque number (fund transfer)
413if (!empty($arrayfields['pd.num_paiement']['checked'])) {
414 print '<td class="liste_titre">';
415 print '</td>';
416}
417
418// Filter: Bank account
419if (!empty($arrayfields['ba.label']['checked'])) {
420 print '<td class="liste_titre">';
421 $form->select_comptes($search_account, 'search_account', 0, '', 1);
422 print '</td>';
423}
424
425// Filter: Amount
426if (!empty($arrayfields['pd.amount']['checked'])) {
427 print '<td class="liste_titre right">';
428 print '<input class="flat" type="text" size="6" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
429 print '</td>';
430}
431
432// Fields from hook
433$parameters = array('arrayfields' => $arrayfields);
434$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
435print $hookmanager->resPrint;
436
437// Action column
438if (!$conf->main_checkbox_left_column) {
439 print '<td class="liste_titre center maxwidthsearch">';
440 $searchpicto = $form->showFilterButtons();
441 print $searchpicto;
442 print '</td>';
443}
444
445print '</tr>'."\n";
446
447$totalarray = array();
448$totalarray['nbfield'] = 0;
449
450// Fields title label
451// --------------------------------------------------------------------
452print '<tr class="liste_titre">';
453// Action column
454if ($conf->main_checkbox_left_column) {
455 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
456 $totalarray['nbfield']++;
457}
458if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
459 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
460 $totalarray['nbfield']++;
461}
462if (!empty($arrayfields['pd.rowid']['checked'])) {
463 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
464 print_liste_field_titre($arrayfields['pd.rowid']['label'], $_SERVER["PHP_SELF"], "pd.rowid", '', $param, '', $sortfield, $sortorder);
465 $totalarray['nbfield']++;
466}
467if (!empty($arrayfields['pd.datep']['checked'])) {
468 print_liste_field_titre($arrayfields['pd.datep']['label'], $_SERVER["PHP_SELF"], "pd.datep", '', $param, '', $sortfield, $sortorder);
469 $totalarray['nbfield']++;
470}
471if (!empty($arrayfields['s.nom']['checked'])) {
472 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
473 $totalarray['nbfield']++;
474}
475if (!empty($arrayfields['c.code']['checked'])) {
476 print_liste_field_titre($arrayfields['c.code']['label'], $_SERVER["PHP_SELF"], "c.code", '', $param, '', $sortfield, $sortorder);
477 $totalarray['nbfield']++;
478}
479if (!empty($arrayfields['pd.num_paiement']['checked'])) {
480 print_liste_field_titre($arrayfields['pd.num_paiement']['label'], $_SERVER["PHP_SELF"], "pd.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pd.num_paiement']['tooltip']);
481 $totalarray['nbfield']++;
482}
483if (!empty($arrayfields['transaction']['checked'])) {
484 print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
485 $totalarray['nbfield']++;
486}
487if (!empty($arrayfields['ba.label']['checked'])) {
488 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
489 $totalarray['nbfield']++;
490}
491if (!empty($arrayfields['pd.amount']['checked'])) {
492 print_liste_field_titre($arrayfields['pd.amount']['label'], $_SERVER["PHP_SELF"], "pd.amount", '', $param, '', $sortfield, $sortorder, 'right ');
493 $totalarray['nbfield']++;
494}
495
496// Extra fields
497include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
498// Hook fields
499$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
500$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
501print $hookmanager->resPrint;
502// Action column
503if (!$conf->main_checkbox_left_column) {
504 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
505 $totalarray['nbfield']++;
506}
507print '</tr>'."\n";
508
509// Detect if we need a fetch on each output line
510$needToFetchEachLine = 0;
511if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
512 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
513 if (!is_null($val) && preg_match('/\$object/', $val)) {
514 $needToFetchEachLine++; // There is at least one compute field that use $object
515 }
516 }
517}
518
519// Loop on record
520// --------------------------------------------------------------------
521$i = 0;
522$savnbfield = $totalarray['nbfield'];
523$totalarray = array();
524$totalarray['nbfield'] = 0;
525$imaxinloop = ($limit ? min($num, $limit) : $num);
526while ($i < $imaxinloop) {
527 $obj = $db->fetch_object($resql);
528
529 $companystatic->id = $obj->soc_id;
530 $companystatic->name = $obj->nom;
531
532 $company = new Societe($db);
533 $result = $company->fetch($obj->socid);
534
535 print '<tr class="oddeven">';
536 if ($conf->main_checkbox_left_column) {
537 print '<td class="nowrap center">';
538 if (/* $massactionbutton || */ $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
539 $selected = 0;
540 if (in_array($obj->id_paiement, $arrayofselected)) {
541 $selected = 1;
542 }
543 print '<input id="cb'.$obj->id_paiement.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id_paiement.'"'.($selected ? ' checked="checked"' : '').'>';
544 }
545 print '</td>';
546 if (!$i) {
547 $totalarray['nbfield']++;
548 }
549 }
550
551 // Ref
552 if (!empty($arrayfields['pd.rowid']['checked'])) {
553 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>';
554 if (!$i) {
555 $totalarray['nbfield']++;
556 }
557 }
558
559 // Date
560 if (!empty($arrayfields['pd.datep']['checked'])) {
561 $dateformatforpayment = 'dayhour';
562 print '<td class="nowraponall">'.dol_print_date($db->jdate($obj->datep), $dateformatforpayment, 'tzuser').'</td>';
563 if (!$i) {
564 $totalarray['nbfield']++;
565 }
566 }
567
568 // Thirdparty
569 if (!empty($arrayfields['s.nom']['checked'])) {
570 print '<td class="nowraponall">';
571 if ($obj->soc_id > 0) {
572 print $companystatic->getNomUrl(1, '', 24);
573 } else {
574 print $object->societe = $obj->societe;
575 }
576 print '</td>';
577 if (!$i) {
578 $totalarray['nbfield']++;
579 }
580 }
581
582 // Payment type
583 if (!empty($arrayfields['c.code']['checked'])) {
584 print '<td>'.$langs->trans("PaymentTypeShort".$obj->paiement_code).'</td>';
585 if (!$i) {
586 $totalarray['nbfield']++;
587 }
588 }
589
590 // Filter: Cheque number (fund transfer)
591 if (!empty($arrayfields['pd.num_paiement']['checked'])) {
592 print '<td>'.$obj->num_payment.'</td>';
593 if (!$i) {
594 $totalarray['nbfield']++;
595 }
596 }
597
598 // Bank transaction
599 if (!empty($arrayfields['transaction']['checked'])) {
600 print '<td class="tdoverflowmax125">';
601 if ($obj->fk_bank > 0) {
602 $test = $bankline->fetch($obj->fk_bank);
603 print $bankline->getNomUrl(1, 0);
604 }
605 print '</td>';
606 if (!$i) {
607 $totalarray['nbfield']++;
608 }
609 }
610
611 // Bank account
612 if (!empty($arrayfields['ba.label']['checked'])) {
613 print '<td>';
614 if ($obj->bid > 0) {
615 $accountstatic->id = $obj->bid;
616 $accountstatic->ref = $obj->bref;
617 $accountstatic->label = $obj->blabel;
618 $accountstatic->number = $obj->number;
619 $accountstatic->account_number = $obj->account_number;
620
621 $accountingjournal = new AccountingJournal($db);
622 $accountingjournal->fetch($obj->accountancy_journal);
623 $accountstatic->accountancy_journal = $accountingjournal->code;
624
625 print $accountstatic->getNomUrl(1);
626 }
627 if (!$i) {
628 $totalarray['nbfield']++;
629 }
630 }
631
632 // Amount
633 if (!empty($arrayfields['pd.amount']['checked'])) {
634 print '<td class="right"><span class="amount">' . price($obj->amount) . '</span></td>';
635 if (!$i) {
636 $totalarray['nbfield']++;
637 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
638 }
639 if (empty($totalarray['val']['amount'])) {
640 $totalarray['val']['amount'] = $obj->amount;
641 } else {
642 $totalarray['val']['amount'] += $obj->amount;
643 }
644 }
645
646 if (!$conf->main_checkbox_left_column) {
647 print '<td class="nowrap center">';
648 if (/* $massactionbutton || */ $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
649 $selected = 0;
650 if (in_array($obj->id_paiement, $arrayofselected)) {
651 $selected = 1;
652 }
653 print '<input id="cb'.$obj->id_paiement.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id_paiement.'"'.($selected ? ' checked="checked"' : '').'>';
654 }
655 print '</td>';
656 if (!$i) {
657 $totalarray['nbfield']++;
658 }
659 }
660
661 $i++;
662}
663
664// Show total line
665include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
666
667// If no record found
668if ($num == 0) {
669 $colspan = 1;
670 foreach ($arrayfields as $key => $val) {
671 if (!empty($val['checked'])) {
672 $colspan++;
673 }
674 }
675 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
676}
677
678$db->free($resql);
679
680$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
681$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
682print $hookmanager->resPrint;
683
684print '</table>'."\n";
685print '</div>'."\n";
686
687print '</form>'."\n";
688
689llxFooter();
690$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
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
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('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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...
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.
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.
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...
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.