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