dolibarr 23.0.4
list.php
Go to the documentation of this file.
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-2025 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
41if (isModEnabled('project')) {
42 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
43}
44
45// Load translation files required by the page
46$langs->loadLangs(array('companies', 'donations'));
47
48// Get parameters
49$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
50$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
51$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
52$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
53$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
54$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
56$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
57$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
58$mode = GETPOST('mode', 'aZ'); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
59$groupby = GETPOST('groupby', 'aZ09'); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
60
61$type = GETPOST('type', 'aZ');
62
63$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4";
64$search_all = trim(GETPOST('search_all', 'alphanohtml'));
65$search_ref = GETPOST('search_ref', 'alpha');
66$search_company = GETPOST('search_company', 'alpha');
67$search_thirdparty = GETPOST('search_thirdparty', 'alpha');
68$search_name = GETPOST('search_name', 'alpha');
69$search_amount = GETPOST('search_amount', 'alpha');
70$search_date_startday = GETPOSTINT('search_date_startday');
71$search_date_startmonth = GETPOSTINT('search_date_startmonth');
72$search_date_startyear = GETPOSTINT('search_date_startyear');
73$search_date_endday = GETPOSTINT('search_date_endday');
74$search_date_endmonth = GETPOSTINT('search_date_endmonth');
75$search_date_endyear = GETPOSTINT('search_date_endyear');
76$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
77$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78$moreforfilter = GETPOST('moreforfilter', 'alpha');
79
80// Load variable for pagination
81$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
82$sortfield = GETPOST('sortfield', 'aZ09comma');
83$sortorder = GETPOST('sortorder', 'aZ09comma');
84$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
85if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
86 // If $page is not defined, or '' or -1 or if we click on clear filters
87 $page = 0;
88}
89$offset = $limit * $page;
90$pageprev = $page - 1;
91$pagenext = $page + 1;
92
93// Initialize a technical objects
94$object = new Don($db);
95$extrafields = new ExtraFields($db);
96$diroutputmassaction = $conf->don->dir_output.'/temp/massgeneration/'.$user->id;
97$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
98
99// Fetch optionals attributes and labels
100$extrafields->fetch_name_optionals_label($object->table_element);
101//$extrafields->fetch_name_optionals_label($object->table_element_line);
102
103$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
104
105// Default sort order (if not yet defined by previous GETPOST)
106if (!$sortorder) {
107 $sortorder = "DESC";
108}
109if (!$sortfield) {
110 $sortfield = "d.datedon";
111}
112
113// Initialize array of search criteria
114$search_all = trim(GETPOST('search_all', 'alphanohtml'));
115$search = array();
116foreach ($object->fields as $key => $val) {
117 if (GETPOST('search_'.$key, 'alpha') !== '') {
118 $search[$key] = GETPOST('search_'.$key, 'alpha');
119 }
120 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
121 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
122 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
123 }
124}
125
126// List of fields to search into when doing a "search in all"
127$fieldstosearchall = array(
128 'd.rowid' => 'Id',
129 'd.ref' => 'Ref',
130 'd.lastname' => 'Lastname',
131 'd.firstname' => 'Firstname',
132);
133
134$arrayfields = array();
135
136// Extra fields
137include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
138
139$object->fields = dol_sort_array($object->fields, 'position');
140//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
141$arrayfields = dol_sort_array($arrayfields, 'position');
142
143
144// Security check
145$result = restrictedArea($user, 'don');
146
147$permissiontoread = $user->hasRight('don', 'read');
148$permissiontoadd = $user->hasRight('don', 'write');
149$permissiontodelete = $user->hasRight('don', 'delete');
150
151
152/*
153 * Actions
154 */
155
156if (GETPOST('cancel', 'alpha')) {
157 $action = 'list';
158 $massaction = '';
159}
160if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
161 $massaction = '';
162}
163
164$parameters = array('arrayfields' => &$arrayfields);
165$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
166if ($reshook < 0) {
167 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
168}
169
170if (empty($reshook)) {
171 // Selection of new fields
172 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
173
174 // Purge search criteria
175 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
176 foreach ($object->fields as $key => $val) {
177 $search[$key] = '';
178 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
179 $search[$key.'_dtstart'] = '';
180 $search[$key.'_dtend'] = '';
181 }
182 }
183
184 $search_all = "";
185 $search_ref = "";
186 $search_company = "";
187 $search_thirdparty = "";
188 $search_name = "";
189 $search_amount = "";
190 $search_status = '';
191 $search_date_startday = '';
192 $search_date_startmonth = '';
193 $search_date_startyear = '';
194 $search_date_endday = '';
195 $search_date_endmonth = '';
196 $search_date_endyear = '';
197 $search_date_start = '';
198 $search_date_end = '';
199 $toselect = array();
200 $search_array_options = array();
201 }
202 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
203 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
204 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
205 }
206
207 // Mass actions
208 $objectclass = 'Don';
209 $objectlabel = 'Don';
210 $uploaddir = $conf->don->dir_output;
211
212 global $error;
213 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
214
215 // You can add more action here
216 // if ($action == 'xxx' && $permissiontoxxx) ...
217}
218
219
220
221/*
222 * View
223 */
224
225$form = new Form($db);
226
227$now = dol_now();
228
229$donationstatic = new Don($db);
230$projectstatic = null;
231if (isModEnabled('project')) {
232 $projectstatic = new Project($db);
233}
234
235$title = $langs->trans("Donations");
236$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
237$morejs = array();
238$morecss = array();
239
240// Build and execute select
241// --------------------------------------------------------------------
242$sql = "SELECT d.rowid, d.ref, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
243$sql .= " d.amount, d.fk_statut as status, s.nom,";
244$sql .= " p.rowid as pid, p.ref as pref, p.title, p.public";
245// Add fields from hooks
246$parameters = array();
247$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
248$sql .= $hookmanager->resPrint;
249$sql = preg_replace('/,\s*$/', '', $sql);
250
251$sqlfields = $sql; // $sql fields to remove for count total
252
253$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
254$sql .= " ON p.rowid = d.fk_projet";
255$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe AS s ON s.rowid = d.fk_soc";
256$sql .= " WHERE d.entity IN (". getEntity('donation') . ")";
257
258if ($search_status != '' && $search_status != '-4') {
259 $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")";
260}
261if (trim($search_ref) != '') {
262 $sql .= natural_search(array('d.ref', "d.rowid"), $search_ref);
263}
264if (trim($search_all) != '') {
265 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
266}
267if (trim($search_company) != '') {
268 $sql .= natural_search('d.societe', $search_company);
269}
270if (trim($search_thirdparty) != '') {
271 $sql .= natural_search("s.nom", $search_thirdparty);
272}
273if (trim($search_name) != '') {
274 $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
275}
276if ($search_amount) {
277 $sql .= natural_search('d.amount', $search_amount, 1);
278}
279if ($search_date_start) {
280 $sql .= " AND d.datedon >= '".$db->idate($search_date_start)."'";
281}
282if ($search_date_end) {
283 $sql .= " AND d.datedon <= '".$db->idate($search_date_end)."'";
284}
285
286// Count total nb of records
287$nbtotalofrecords = '';
288if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
289 /* The fast and low memory method to get and count full list converts the sql into a sql count */
290 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
291 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
292 $resql = $db->query($sqlforcount);
293 if ($resql) {
294 $objforcount = $db->fetch_object($resql);
295 $nbtotalofrecords = $objforcount->nbtotalofrecords;
296 } else {
297 dol_print_error($db);
298 }
299
300 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
301 $page = 0;
302 $offset = 0;
303 }
304 $db->free($resql);
305}
306
307// Complete request and execute it with limit
308$sql .= $db->order($sortfield, $sortorder);
309if ($limit) {
310 $sql .= $db->plimit($limit + 1, $offset);
311}
312
313$resql = $db->query($sql);
314if (!$resql) {
315 dol_print_error($db);
316 exit;
317}
318
319$num = $db->num_rows($resql);
320
321// Direct jump if only one record found
322if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
323 $obj = $db->fetch_object($resql);
324 $id = $obj->rowid;
325 header("Location: ".dol_buildpath('/don/card.php', 1).'?id='.((int) $id));
326 exit;
327}
328
329
330// Output page
331// --------------------------------------------------------------------
332
333llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-donation page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
334
335// Example : Adding jquery code
336// print '<script type="text/javascript">
337// jQuery(document).ready(function() {
338// function init_myfunc()
339// {
340// jQuery("#myid").removeAttr(\'disabled\');
341// jQuery("#myid").attr(\'disabled\',\'disabled\');
342// }
343// init_myfunc();
344// jQuery("#mybutton").click(function() {
345// init_myfunc();
346// });
347// });
348// </script>';
349
350$arrayofselected = is_array($toselect) ? $toselect : array();
351
352$param = '';
353if (!empty($mode)) {
354 $param .= '&mode='.urlencode($mode);
355}
356if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
357 $param .= '&contextpage='.urlencode($contextpage);
358}
359if ($limit > 0 && $limit != $conf->liste_limit) {
360 $param .= '&limit='.((int) $limit);
361}
362if ($optioncss != '') {
363 $param .= '&optioncss='.urlencode($optioncss);
364}
365if ($groupby != '') {
366 $param .= '&groupby='.urlencode($groupby);
367}
368if ($search_status && $search_status != -1) {
369 $param .= '&search_status='.urlencode($search_status);
370}
371if ($search_ref) {
372 $param .= '&search_ref='.urlencode($search_ref);
373}
374if ($search_company) {
375 $param .= '&search_company='.urlencode($search_company);
376}
377if ($search_name) {
378 $param .= '&search_name='.urlencode($search_name);
379}
380if ($search_amount) {
381 $param .= '&search_amount='.urlencode($search_amount);
382}
383if ($search_date_startday) {
384 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
385}
386if ($search_date_startmonth) {
387 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
388}
389if ($search_date_startyear) {
390 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
391}
392if ($search_date_endday) {
393 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
394}
395if ($search_date_endmonth) {
396 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
397}
398if ($search_date_endyear) {
399 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
400}
401
402// Add $param from extra fields
403include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
404// Add $param from hooks
405$parameters = array('param' => &$param);
406$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
407$param .= $hookmanager->resPrint;
408
409
410// List of mass actions available
411$arrayofmassactions = array(
412 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
413 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
414 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
415 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
416);
417if (!empty($permissiontodelete)) {
418 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
419}
420if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
421 $arrayofmassactions = array();
422}
423$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
424
425print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
426if ($optioncss != '') {
427 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
428}
429print '<input type="hidden" name="token" value="'.newToken().'">';
430print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
431print '<input type="hidden" name="action" value="list">';
432print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
433print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
434print '<input type="hidden" name="page" value="'.$page.'">';
435print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
436print '<input type="hidden" name="page_y" value="">';
437print '<input type="hidden" name="mode" value="'.$mode.'">';
438print '<input type="hidden" name="type" value="'.$type.'">';
439
440$newcardbutton = '';
441$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
442$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
443$newcardbutton .= dolGetButtonTitleSeparator();
444$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create', '', $permissiontoadd);
445
446// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
447print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
448
449// Add code for pre mass action (confirmation or email presend form)
450$topicmail = "SendDonationRef";
451$modelmail = "don";
452$objecttmp = new Don($db);
453$trackid = 'don'.$object->id;
454include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
455
456if ($search_all) {
457 $setupstring = '';
458 foreach ($fieldstosearchall as $key => $val) {
459 $fieldstosearchall[$key] = $langs->trans($val);
460 $setupstring .= $key."=".$val.";";
461 }
462 print '<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
463 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
464}
465
466$moreforfilter = '';
467/*$moreforfilter.='<div class="divsearchfield">';
468$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
469$moreforfilter.= '</div>';*/
470
471$parameters = array();
472$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
473if (empty($reshook)) {
474 $moreforfilter .= $hookmanager->resPrint;
475} else {
476 $moreforfilter = $hookmanager->resPrint;
477}
478$parameters = array(
479 'arrayfields' => &$arrayfields,
480);
481
482if (!empty($moreforfilter)) {
483 print '<div class="liste_titre liste_titre_bydiv centpercent">';
484 print $moreforfilter;
485 print '</div>';
486}
487
488$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
489$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
490$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
491$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
492
493print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
494print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
495
496// Fields title search
497// --------------------------------------------------------------------
498print '<tr class="liste_titre_filter">';
499// Action column
500if ($conf->main_checkbox_left_column) {
501 print '<td class="liste_titre center maxwidthsearch">';
502 $searchpicto = $form->showFilterButtons('left');
503 print $searchpicto;
504 print '</td>';
505}
506print '<td class="liste_titre">';
507print '<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.'">';
508print '</td>';
509if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
510 print '<td class="liste_titre">';
511 print '<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.'">';
512 print '</td>';
513} else {
514 print '<td class="liste_titre">';
515 print '<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.'">';
516 print '</td>';
517}
518print '<td class="liste_titre">';
519print '<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.'">';
520print '</td>';
521// Date invoice
522print '<td class="liste_titre center">';
523print '<div class="nowrapfordate">';
524print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
525print '</div>';
526print '<div class="nowrapfordate">';
527print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
528print '</div>';
529print '</td>';
530if (isModEnabled('project')) {
531 print '<td class="liste_titre right">';
532 print '&nbsp;';
533 print '</td>';
534}
535print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
536print '<td class="liste_titre center parentonrightofpage">';
537$liststatus = array(
538 Don::STATUS_DRAFT => $langs->trans("DonationStatusPromiseNotValidated"),
539 Don::STATUS_VALIDATED => $langs->trans("DonationStatusPromiseValidated"),
540 Don::STATUS_PAID => $langs->trans("DonationStatusPaid"),
541 Don::STATUS_CANCELED => $langs->trans("Canceled")
542);
543// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
544print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage');
545print '</td>';
546// Action column
547if (!$conf->main_checkbox_left_column) {
548 print '<td class="liste_titre center maxwidthsearch">';
549 $searchpicto = $form->showFilterButtons();
550 print $searchpicto;
551 print '</td>';
552}
553print '</tr>'."\n";
554
555$totalarray = array();
556$totalarray['nbfield'] = 0;
557
558// Fields title label
559// --------------------------------------------------------------------
560print '<tr class="liste_titre">';
561// Action column
562if ($conf->main_checkbox_left_column) {
563 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
564 $totalarray['nbfield']++;
565}
566print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder);
567$totalarray['nbfield']++;
568if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
569 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
570 $totalarray['nbfield']++;
571} else {
572 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder);
573 $totalarray['nbfield']++;
574}
575print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
576$totalarray['nbfield']++;
577print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
578$totalarray['nbfield']++;
579if (isModEnabled('project')) {
580 $langs->load("projects");
581 print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
582 $totalarray['nbfield']++;
583}
584print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right ');
585$totalarray['nbfield']++;
586print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
587$totalarray['nbfield']++;
588// Action column
589if (!$conf->main_checkbox_left_column) {
590 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
591 $totalarray['nbfield']++;
592}
593print '</tr>'."\n";
594
595$i = 0;
596$savnbfield = $totalarray['nbfield'];
597$totalarray = array();
598$totalarray['nbfield'] = 0;
599$imaxinloop = ($limit ? min($num, $limit) : $num);
600while ($i < $imaxinloop) {
601 $obj = $db->fetch_object($resql);
602 if (empty($obj)) {
603 break; // Should not happen
604 }
605
606 $donationstatic->setVarsFromFetchObj($obj);
607
608 $donationstatic->id = $obj->rowid;
609 $donationstatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
610 $donationstatic->date = $db->jdate($obj->datedon);
611 $donationstatic->status = $obj->status;
612 $donationstatic->lastname = $obj->lastname;
613 $donationstatic->firstname = $obj->firstname;
614 $object = $donationstatic;
615
616 $company = new Societe($db);
617 $result = $company->fetch($obj->socid);
618
619
620 if ($mode == 'kanban') {
621 if ($i == 0) {
622 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
623 print '<div class="box-flex-container kanban">';
624 }
625 // Output Kanban
626 $donationstatic->amount = $obj->amount;
627
628 if (!empty($obj->socid) && $company->id > 0) {
629 $donationstatic->societe = $company->getNomUrl(1);
630 } else {
631 $donationstatic->societe = (string) $obj->societe; // Value from sql query
632 }
633
634 $object = $donationstatic;
635
636 $selected = -1;
637 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
638 $selected = 0;
639 if (in_array($object->id, $arrayofselected)) {
640 $selected = 1;
641 }
642 }
643 print $donationstatic->getKanbanView('', array('selected' => $selected));
644 if ($i == ($imaxinloop - 1)) {
645 print '</div>';
646 print '</td></tr>';
647 }
648 } else {
649 // Show line of result
650 $j = 0;
651 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
652
653 // Action column
654 if ($conf->main_checkbox_left_column) {
655 print '<td class="nowrap center">';
656 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
657 $selected = 0;
658 if (in_array($object->id, $arrayofselected)) {
659 $selected = 1;
660 }
661 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
662 }
663 print '</td>';
664 if (!$i) {
665 $totalarray['nbfield']++;
666 }
667 }
668
669 // Ref
670 print "<td>".$donationstatic->getNomUrl(1)."</td>";
671
672 // Company
673 if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
674 if (!empty($obj->socid) && $company->id > 0) {
675 print "<td>".$company->getNomUrl(1)."</td>";
676 } else {
677 print "<td>".((string) $obj->societe)."</td>";
678 }
679 } else {
680 print "<td>".((string) $obj->societe)."</td>";
681 }
682
683 // Donator
684 print "<td>".$donationstatic->getFullName($langs)."</td>";
685
686 // Date donation
687 print '<td class="center">'.dol_print_date($db->jdate($obj->datedon), 'day').'</td>';
688
689 if (isModEnabled('project')) {
690 print "<td>";
691 if ($obj->pid) {
692 $projectstatic->id = $obj->pid;
693 $projectstatic->ref = $obj->pref;
694 $projectstatic->public = $obj->public;
695 $projectstatic->title = $obj->title;
696 print $projectstatic->getNomUrl(1);
697 } else {
698 print '&nbsp;';
699 }
700 print "</td>\n";
701 }
702 print '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
703
704 // Status
705 print '<td class="center">'.$donationstatic->LibStatut($obj->status, 5).'</td>';
706
707 // Action column
708 if (empty($conf->main_checkbox_left_column)) {
709 print '<td class="nowrap center">';
710 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
711 $selected = 0;
712 if (in_array($object->id, $arrayofselected)) {
713 $selected = 1;
714 }
715 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
716 }
717 print '</td>';
718 if (!$i) {
719 $totalarray['nbfield']++;
720 }
721 }
722
723 print '</tr>'."\n";
724 }
725 $i++;
726}
727
728$db->free($resql);
729
730print '</table>'."\n";
731print '</div>'."\n";
732
733print '</form>'."\n";
734
735
736
737llxFooter();
738$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition export.php:1216
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 donations.
Definition don.class.php:41
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_now($mode='gmt')
Return date for now.
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...
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.