dolibarr 21.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 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
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
34require_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");
66if (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;
72if (!$sortorder) {
73 $sortorder = "DESC";
74}
75if (!$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 a technical object to manage hooks of page. Note that conf->hooks_modules contains an 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
121if ($reshook < 0) {
122 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
123}
124
125if (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
186if ($search_ref) {
187 $sql .= natural_search('pd.rowid', $search_ref);
188}
189if ($search_date_start) {
190 $sql .= " AND pd.datep >= '" . $db->idate($search_date_start) . "'";
191}
192if ($search_date_end) {
193 $sql .= " AND pd.datep <= '" . $db->idate($search_date_end) . "'";
194}
195if ($search_account > 0) {
196 $sql .= " AND b.fk_account=".((int) $search_account);
197}
198if ($search_paymenttype != '') {
199 $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
200}
201if ($search_payment_num != '') {
202 $sql .= natural_search('pd.num_payment', $search_payment_num);
203}
204if ($search_amount) {
205 $sql .= natural_search('pd.amount', $search_amount, 1);
206}
207if ($search_company) {
208 $sql .= natural_search('s.nom', $search_company);
209}
210if ($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 = '';
221if (!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
243if ($limit) {
244 $sql .= $db->plimit($limit + 1, $offset);
245}
246
247$resql = $db->query($sql);
248
249if (!$resql) {
250 dol_print_error($db);
251 exit;
252}
253
254$num = $db->num_rows($resql);
255
256// Output page
257// --------------------------------------------------------------------
258
259llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
260
261$param = '';
262if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
263 $param .= '&contextpage='.urlencode($contextpage);
264}
265if ($limit > 0 && $limit != $conf->liste_limit) {
266 $param .= '&limit='.((int) $limit);
267}
268if ($search_ref) {
269 $param .= '&search_ref='.urlencode($search_ref);
270}
271if ($search_date_startday) {
272 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
273}
274if ($search_date_startmonth) {
275 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
276}
277if ($search_date_startyear) {
278 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
279}
280if ($search_date_endday) {
281 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
282}
283if ($search_date_endmonth) {
284 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
285}
286if ($search_date_endyear) {
287 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
288}
289if ($search_company) {
290 $param .= '&search_company='.urlencode($search_company);
291}
292if ($search_amount != '') {
293 $param .= '&search_amount='.urlencode($search_amount);
294}
295if ($search_paymenttype) {
296 $param .= '&search_paymenttype='.urlencode($search_paymenttype);
297}
298if ($search_account) {
299 $param .= '&search_account='.urlencode((string) ($search_account));
300}
301if ($search_payment_num) {
302 $param .= '&search_payment_num='.urlencode($search_payment_num);
303}
304if ($optioncss != '') {
305 $param .= '&optioncss='.urlencode($optioncss);
306}
307
308print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
309if ($optioncss != '') {
310 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
311}
312print '<input type="hidden" name="token" value="'.newToken().'">';
313print '<input type="hidden" name="action" value="list">';
314print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
315print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
316print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
317print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
318
319// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
320print_barre_liste($langs->trans("DonationPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
321
322if ($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 = '';
332if ($massactionbutton) {
333 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
334}
335
336$moreforfilter = '';
337print '<div class="div-table-responsive">';
338print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
339
340// Fields title search
341// --------------------------------------------------------------------
342print '<tr class="liste_titre_filter">';
343// Action column
344if (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
351if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
352 print '<td class="liste_titre">';
353 print '</td>';
354}
355
356if (!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
363if (!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
375if (!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
382if (!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
389if (!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)
396if (!empty($arrayfields['pd.num_paiement']['checked'])) {
397 print '<td class="liste_titre">';
398 print '</td>';
399}
400
401// Filter: Bank account
402if (!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
409if (!empty($arrayfields['pd.amount']['checked'])) {
410 print '<td class="liste_titre right">';
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
418print $hookmanager->resPrint;
419
420// Action column
421if (!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
428print '</tr>'."\n";
429
430$totalarray = array();
431$totalarray['nbfield'] = 0;
432
433// Fields title label
434// --------------------------------------------------------------------
435print '<tr class="liste_titre">';
436// Action column
437if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
438 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
439 $totalarray['nbfield']++;
440}
441if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
442 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
443 $totalarray['nbfield']++;
444}
445if (!empty($arrayfields['pd.rowid']['checked'])) {
446 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
447 print_liste_field_titre($arrayfields['pd.rowid']['label'], $_SERVER["PHP_SELF"], "pd.rowid", '', $param, '', $sortfield, $sortorder);
448 $totalarray['nbfield']++;
449}
450if (!empty($arrayfields['pd.datep']['checked'])) {
451 print_liste_field_titre($arrayfields['pd.datep']['label'], $_SERVER["PHP_SELF"], "pd.datep", '', $param, '', $sortfield, $sortorder);
452 $totalarray['nbfield']++;
453}
454if (!empty($arrayfields['s.nom']['checked'])) {
455 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
456 $totalarray['nbfield']++;
457}
458if (!empty($arrayfields['c.code']['checked'])) {
459 print_liste_field_titre($arrayfields['c.code']['label'], $_SERVER["PHP_SELF"], "c.code", '', $param, '', $sortfield, $sortorder);
460 $totalarray['nbfield']++;
461}
462if (!empty($arrayfields['pd.num_paiement']['checked'])) {
463 print_liste_field_titre($arrayfields['pd.num_paiement']['label'], $_SERVER["PHP_SELF"], "pd.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
464 $totalarray['nbfield']++;
465}
466if (!empty($arrayfields['transaction']['checked'])) {
467 print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
468 $totalarray['nbfield']++;
469}
470if (!empty($arrayfields['ba.label']['checked'])) {
471 print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], "ba.label", '', $param, '', $sortfield, $sortorder);
472 $totalarray['nbfield']++;
473}
474if (!empty($arrayfields['pd.amount']['checked'])) {
475 print_liste_field_titre($arrayfields['pd.amount']['label'], $_SERVER["PHP_SELF"], "pd.amount", '', $param, '', $sortfield, $sortorder, 'right ');
476 $totalarray['nbfield']++;
477}
478
479// Extra fields
480include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
481// Hook fields
482$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
483$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
484print $hookmanager->resPrint;
485// Action column
486if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
487 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
488 $totalarray['nbfield']++;
489}
490print '</tr>'."\n";
491
492// Detect if we need a fetch on each output line
493$needToFetchEachLine = 0;
494if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
495 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
496 if (!is_null($val) && preg_match('/\$object/', $val)) {
497 $needToFetchEachLine++; // There is at least one compute field that use $object
498 }
499 }
500}
501
502// Loop on record
503// --------------------------------------------------------------------
504$i = 0;
505$savnbfield = $totalarray['nbfield'];
506$totalarray = array();
507$totalarray['nbfield'] = 0;
508$imaxinloop = ($limit ? min($num, $limit) : $num);
509while ($i < $imaxinloop) {
510 $obj = $db->fetch_object($resql);
511
512 $companystatic->id = $obj->soc_id;
513 $companystatic->name = $obj->nom;
514
515 $company = new Societe($db);
516 $result = $company->fetch($obj->socid);
517
518 print '<tr class="oddeven">';
519 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
520 print '<td class="nowrap center">';
521 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
522 $selected = 0;
523 if (in_array($obj->id_paiement, $arrayofselected)) {
524 $selected = 1;
525 }
526 print '<input id="cb'.$obj->id_paiement.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id_paiement.'"'.($selected ? ' checked="checked"' : '').'>';
527 }
528 print '</td>';
529 if (!$i) {
530 $totalarray['nbfield']++;
531 }
532 }
533
534 // Ref
535 if (!empty($arrayfields['pd.rowid']['checked'])) {
536 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>';
537 if (!$i) {
538 $totalarray['nbfield']++;
539 }
540 }
541
542 // Date
543 if (!empty($arrayfields['pd.datep']['checked'])) {
544 $dateformatforpayment = 'dayhour';
545 print '<td class="nowraponall">'.dol_print_date($db->jdate($obj->datep), $dateformatforpayment, 'tzuser').'</td>';
546 if (!$i) {
547 $totalarray['nbfield']++;
548 }
549 }
550
551 // Thirdparty
552 if (!empty($arrayfields['s.nom']['checked'])) {
553 print '<td class="nowraponall">';
554 if ($obj->soc_id > 0) {
555 print $companystatic->getNomUrl(1, '', 24);
556 } else {
557 print $donationstatic->societe = $obj->societe;
558 }
559 print '</td>';
560 if (!$i) {
561 $totalarray['nbfield']++;
562 }
563 }
564
565 // Payment type
566 if (!empty($arrayfields['c.code']['checked'])) {
567 print '<td>'.$langs->trans("PaymentTypeShort".$obj->paiement_code).'</td>';
568 if (!$i) {
569 $totalarray['nbfield']++;
570 }
571 }
572
573 // Filter: Cheque number (fund transfer)
574 if (!empty($arrayfields['pd.num_paiement']['checked'])) {
575 print '<td>'.$obj->num_payment.'</td>';
576 if (!$i) {
577 $totalarray['nbfield']++;
578 }
579 }
580
581 // Bank transaction
582 if (!empty($arrayfields['transaction']['checked'])) {
583 print '<td class="tdoverflowmax125">';
584 if ($obj->fk_bank > 0) {
585 $test = $bankline->fetch($obj->fk_bank);
586 print $bankline->getNomUrl(1, 0);
587 }
588 print '</td>';
589 if (!$i) {
590 $totalarray['nbfield']++;
591 }
592 }
593
594 // Bank account
595 if (!empty($arrayfields['ba.label']['checked'])) {
596 print '<td>';
597 if ($obj->bid > 0) {
598 $accountstatic->id = $obj->bid;
599 $accountstatic->ref = $obj->bref;
600 $accountstatic->label = $obj->blabel;
601 $accountstatic->number = $obj->number;
602 $accountstatic->account_number = $obj->account_number;
603
604 $accountingjournal = new AccountingJournal($db);
605 $accountingjournal->fetch($obj->accountancy_journal);
606 $accountstatic->accountancy_journal = $accountingjournal->code;
607
608 print $accountstatic->getNomUrl(1);
609 }
610 if (!$i) {
611 $totalarray['nbfield']++;
612 }
613 }
614
615 // Amount
616 if (!empty($arrayfields['pd.amount']['checked'])) {
617 print '<td class="right"><span class="amount">' . price($obj->amount) . '</span></td>';
618 if (!$i) {
619 $totalarray['nbfield']++;
620 $totalarray['pos'][$totalarray['nbfield']] = 'amount';
621 }
622 if (empty($totalarray['val']['amount'])) {
623 $totalarray['val']['amount'] = $obj->amount;
624 } else {
625 $totalarray['val']['amount'] += $obj->amount;
626 }
627 }
628
629 $i++;
630}
631
632// Show total line
633include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
634
635// If no record found
636if ($num == 0) {
637 $colspan = 1;
638 foreach ($arrayfields as $key => $val) {
639 if (!empty($val['checked'])) {
640 $colspan++;
641 }
642 }
643 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
644}
645
646$db->free($resql);
647
648$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
649$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
650print $hookmanager->resPrint;
651
652print '</table>'."\n";
653print '</div>'."\n";
654
655print '</form>'."\n";
656
657llxFooter();
658$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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.
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.