dolibarr 23.0.3
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// Extra fields
134include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
135
136$object->fields = dol_sort_array($object->fields, 'position');
137$arrayfields = array();
138//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
139$arrayfields = dol_sort_array($arrayfields, 'position');
140
141
142// Security check
143$result = restrictedArea($user, 'don');
144
145$permissiontoread = $user->hasRight('don', 'read');
146$permissiontoadd = $user->hasRight('don', 'write');
147$permissiontodelete = $user->hasRight('don', 'delete');
148
149
150/*
151 * Actions
152 */
153
154if (GETPOST('cancel', 'alpha')) {
155 $action = 'list';
156 $massaction = '';
157}
158if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
159 $massaction = '';
160}
161
162$parameters = array('arrayfields' => &$arrayfields);
163$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
164if ($reshook < 0) {
165 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
166}
167
168if (empty($reshook)) {
169 // Selection of new fields
170 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
171
172 // Purge search criteria
173 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
174 foreach ($object->fields as $key => $val) {
175 $search[$key] = '';
176 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
177 $search[$key.'_dtstart'] = '';
178 $search[$key.'_dtend'] = '';
179 }
180 }
181
182 $search_all = "";
183 $search_ref = "";
184 $search_company = "";
185 $search_thirdparty = "";
186 $search_name = "";
187 $search_amount = "";
188 $search_status = '';
189 $search_date_startday = '';
190 $search_date_startmonth = '';
191 $search_date_startyear = '';
192 $search_date_endday = '';
193 $search_date_endmonth = '';
194 $search_date_endyear = '';
195 $search_date_start = '';
196 $search_date_end = '';
197 $toselect = array();
198 $search_array_options = array();
199 }
200 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
201 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
202 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
203 }
204
205 // Mass actions
206 $objectclass = 'Don';
207 $objectlabel = 'Don';
208 $uploaddir = $conf->don->dir_output;
209
210 global $error;
211 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
212
213 // You can add more action here
214 // if ($action == 'xxx' && $permissiontoxxx) ...
215}
216
217
218
219/*
220 * View
221 */
222
223$form = new Form($db);
224
225$now = dol_now();
226
227$donationstatic = new Don($db);
228$projectstatic = null;
229if (isModEnabled('project')) {
230 $projectstatic = new Project($db);
231}
232
233$title = $langs->trans("Donations");
234$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
235$morejs = array();
236$morecss = array();
237
238// Build and execute select
239// --------------------------------------------------------------------
240$sql = "SELECT d.rowid, d.ref, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
241$sql .= " d.amount, d.fk_statut as status, s.nom,";
242$sql .= " p.rowid as pid, p.ref as pref, p.title, p.public";
243// Add fields from hooks
244$parameters = array();
245$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
246$sql .= $hookmanager->resPrint;
247$sql = preg_replace('/,\s*$/', '', $sql);
248
249$sqlfields = $sql; // $sql fields to remove for count total
250
251$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
252$sql .= " ON p.rowid = d.fk_projet";
253$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe AS s ON s.rowid = d.fk_soc";
254$sql .= " WHERE d.entity IN (". getEntity('donation') . ")";
255
256if ($search_status != '' && $search_status != '-4') {
257 $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")";
258}
259if (trim($search_ref) != '') {
260 $sql .= natural_search(array('d.ref', "d.rowid"), $search_ref);
261}
262if (trim($search_all) != '') {
263 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
264}
265if (trim($search_company) != '') {
266 $sql .= natural_search('d.societe', $search_company);
267}
268if (trim($search_thirdparty) != '') {
269 $sql .= natural_search("s.nom", $search_thirdparty);
270}
271if (trim($search_name) != '') {
272 $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
273}
274if ($search_amount) {
275 $sql .= natural_search('d.amount', $search_amount, 1);
276}
277if ($search_date_start) {
278 $sql .= " AND d.datedon >= '".$db->idate($search_date_start)."'";
279}
280if ($search_date_end) {
281 $sql .= " AND d.datedon <= '".$db->idate($search_date_end)."'";
282}
283
284// Count total nb of records
285$nbtotalofrecords = '';
286if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
287 /* The fast and low memory method to get and count full list converts the sql into a sql count */
288 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
289 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
290 $resql = $db->query($sqlforcount);
291 if ($resql) {
292 $objforcount = $db->fetch_object($resql);
293 $nbtotalofrecords = $objforcount->nbtotalofrecords;
294 } else {
295 dol_print_error($db);
296 }
297
298 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
299 $page = 0;
300 $offset = 0;
301 }
302 $db->free($resql);
303}
304
305// Complete request and execute it with limit
306$sql .= $db->order($sortfield, $sortorder);
307if ($limit) {
308 $sql .= $db->plimit($limit + 1, $offset);
309}
310
311$resql = $db->query($sql);
312if (!$resql) {
313 dol_print_error($db);
314 exit;
315}
316
317$num = $db->num_rows($resql);
318
319// Direct jump if only one record found
320if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
321 $obj = $db->fetch_object($resql);
322 $id = $obj->rowid;
323 header("Location: ".dol_buildpath('/don/card.php', 1).'?id='.((int) $id));
324 exit;
325}
326
327
328// Output page
329// --------------------------------------------------------------------
330
331llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-donation page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
332
333// Example : Adding jquery code
334// print '<script type="text/javascript">
335// jQuery(document).ready(function() {
336// function init_myfunc()
337// {
338// jQuery("#myid").removeAttr(\'disabled\');
339// jQuery("#myid").attr(\'disabled\',\'disabled\');
340// }
341// init_myfunc();
342// jQuery("#mybutton").click(function() {
343// init_myfunc();
344// });
345// });
346// </script>';
347
348$arrayofselected = is_array($toselect) ? $toselect : array();
349
350$param = '';
351if (!empty($mode)) {
352 $param .= '&mode='.urlencode($mode);
353}
354if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
355 $param .= '&contextpage='.urlencode($contextpage);
356}
357if ($limit > 0 && $limit != $conf->liste_limit) {
358 $param .= '&limit='.((int) $limit);
359}
360if ($optioncss != '') {
361 $param .= '&optioncss='.urlencode($optioncss);
362}
363if ($groupby != '') {
364 $param .= '&groupby='.urlencode($groupby);
365}
366if ($search_status && $search_status != -1) {
367 $param .= '&search_status='.urlencode($search_status);
368}
369if ($search_ref) {
370 $param .= '&search_ref='.urlencode($search_ref);
371}
372if ($search_company) {
373 $param .= '&search_company='.urlencode($search_company);
374}
375if ($search_name) {
376 $param .= '&search_name='.urlencode($search_name);
377}
378if ($search_amount) {
379 $param .= '&search_amount='.urlencode($search_amount);
380}
381if ($search_date_startday) {
382 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
383}
384if ($search_date_startmonth) {
385 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
386}
387if ($search_date_startyear) {
388 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
389}
390if ($search_date_endday) {
391 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
392}
393if ($search_date_endmonth) {
394 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
395}
396if ($search_date_endyear) {
397 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
398}
399
400// Add $param from extra fields
401include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
402// Add $param from hooks
403$parameters = array('param' => &$param);
404$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
405$param .= $hookmanager->resPrint;
406
407
408// List of mass actions available
409$arrayofmassactions = array(
410 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
411 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
412 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
413 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
414);
415if (!empty($permissiontodelete)) {
416 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
417}
418if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
419 $arrayofmassactions = array();
420}
421$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
422
423print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
424if ($optioncss != '') {
425 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
426}
427print '<input type="hidden" name="token" value="'.newToken().'">';
428print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
429print '<input type="hidden" name="action" value="list">';
430print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
431print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
432print '<input type="hidden" name="page" value="'.$page.'">';
433print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
434print '<input type="hidden" name="page_y" value="">';
435print '<input type="hidden" name="mode" value="'.$mode.'">';
436print '<input type="hidden" name="type" value="'.$type.'">';
437
438$newcardbutton = '';
439$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'));
440$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'));
441$newcardbutton .= dolGetButtonTitleSeparator();
442$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create', '', $permissiontoadd);
443
444// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
445print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
446
447// Add code for pre mass action (confirmation or email presend form)
448$topicmail = "SendDonationRef";
449$modelmail = "don";
450$objecttmp = new Don($db);
451$trackid = 'don'.$object->id;
452include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
453
454if ($search_all) {
455 $setupstring = '';
456 foreach ($fieldstosearchall as $key => $val) {
457 $fieldstosearchall[$key] = $langs->trans($val);
458 $setupstring .= $key."=".$val.";";
459 }
460 print '<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
461 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
462}
463
464$moreforfilter = '';
465/*$moreforfilter.='<div class="divsearchfield">';
466$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
467$moreforfilter.= '</div>';*/
468
469$parameters = array();
470$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
471if (empty($reshook)) {
472 $moreforfilter .= $hookmanager->resPrint;
473} else {
474 $moreforfilter = $hookmanager->resPrint;
475}
476$parameters = array(
477 'arrayfields' => &$arrayfields,
478);
479
480if (!empty($moreforfilter)) {
481 print '<div class="liste_titre liste_titre_bydiv centpercent">';
482 print $moreforfilter;
483 print '</div>';
484}
485
486$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
487$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
488$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
489$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
490
491print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
492print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
493
494// Fields title search
495// --------------------------------------------------------------------
496print '<tr class="liste_titre_filter">';
497// Action column
498if ($conf->main_checkbox_left_column) {
499 print '<td class="liste_titre center maxwidthsearch">';
500 $searchpicto = $form->showFilterButtons('left');
501 print $searchpicto;
502 print '</td>';
503}
504print '<td class="liste_titre">';
505print '<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.'">';
506print '</td>';
507if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
508 print '<td class="liste_titre">';
509 print '<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.'">';
510 print '</td>';
511} else {
512 print '<td class="liste_titre">';
513 print '<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.'">';
514 print '</td>';
515}
516print '<td class="liste_titre">';
517print '<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.'">';
518print '</td>';
519// Date invoice
520print '<td class="liste_titre center">';
521print '<div class="nowrapfordate">';
522print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
523print '</div>';
524print '<div class="nowrapfordate">';
525print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
526print '</div>';
527print '</td>';
528if (isModEnabled('project')) {
529 print '<td class="liste_titre right">';
530 print '&nbsp;';
531 print '</td>';
532}
533print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
534print '<td class="liste_titre center parentonrightofpage">';
535$liststatus = array(
536 Don::STATUS_DRAFT => $langs->trans("DonationStatusPromiseNotValidated"),
537 Don::STATUS_VALIDATED => $langs->trans("DonationStatusPromiseValidated"),
538 Don::STATUS_PAID => $langs->trans("DonationStatusPaid"),
539 Don::STATUS_CANCELED => $langs->trans("Canceled")
540);
541// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
542print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage');
543print '</td>';
544// Action column
545if (!$conf->main_checkbox_left_column) {
546 print '<td class="liste_titre center maxwidthsearch">';
547 $searchpicto = $form->showFilterButtons();
548 print $searchpicto;
549 print '</td>';
550}
551print '</tr>'."\n";
552
553$totalarray = array();
554$totalarray['nbfield'] = 0;
555
556// Fields title label
557// --------------------------------------------------------------------
558print '<tr class="liste_titre">';
559// Action column
560if ($conf->main_checkbox_left_column) {
561 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
562 $totalarray['nbfield']++;
563}
564print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder);
565$totalarray['nbfield']++;
566if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
567 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
568 $totalarray['nbfield']++;
569} else {
570 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder);
571 $totalarray['nbfield']++;
572}
573print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
574$totalarray['nbfield']++;
575print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
576$totalarray['nbfield']++;
577if (isModEnabled('project')) {
578 $langs->load("projects");
579 print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
580 $totalarray['nbfield']++;
581}
582print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right ');
583$totalarray['nbfield']++;
584print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
585$totalarray['nbfield']++;
586// Action column
587if (!$conf->main_checkbox_left_column) {
588 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
589 $totalarray['nbfield']++;
590}
591print '</tr>'."\n";
592
593$i = 0;
594$savnbfield = $totalarray['nbfield'];
595$totalarray = array();
596$totalarray['nbfield'] = 0;
597$imaxinloop = ($limit ? min($num, $limit) : $num);
598while ($i < $imaxinloop) {
599 $obj = $db->fetch_object($resql);
600 if (empty($obj)) {
601 break; // Should not happen
602 }
603
604 $donationstatic->setVarsFromFetchObj($obj);
605
606 $donationstatic->id = $obj->rowid;
607 $donationstatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
608 $donationstatic->date = $db->jdate($obj->datedon);
609 $donationstatic->status = $obj->status;
610 $donationstatic->lastname = $obj->lastname;
611 $donationstatic->firstname = $obj->firstname;
612 $object = $donationstatic;
613
614 $company = new Societe($db);
615 $result = $company->fetch($obj->socid);
616
617
618 if ($mode == 'kanban') {
619 if ($i == 0) {
620 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
621 print '<div class="box-flex-container kanban">';
622 }
623 // Output Kanban
624 $donationstatic->amount = $obj->amount;
625
626 if (!empty($obj->socid) && $company->id > 0) {
627 $donationstatic->societe = $company->getNomUrl(1);
628 } else {
629 $donationstatic->societe = (string) $obj->societe; // Value from sql query
630 }
631
632 $object = $donationstatic;
633
634 $selected = -1;
635 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
636 $selected = 0;
637 if (in_array($object->id, $arrayofselected)) {
638 $selected = 1;
639 }
640 }
641 print $donationstatic->getKanbanView('', array('selected' => $selected));
642 if ($i == ($imaxinloop - 1)) {
643 print '</div>';
644 print '</td></tr>';
645 }
646 } else {
647 // Show line of result
648 $j = 0;
649 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
650
651 // Action column
652 if ($conf->main_checkbox_left_column) {
653 print '<td class="nowrap center">';
654 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
655 $selected = 0;
656 if (in_array($object->id, $arrayofselected)) {
657 $selected = 1;
658 }
659 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
660 }
661 print '</td>';
662 if (!$i) {
663 $totalarray['nbfield']++;
664 }
665 }
666
667 // Ref
668 print "<td>".$donationstatic->getNomUrl(1)."</td>";
669
670 // Company
671 if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
672 if (!empty($obj->socid) && $company->id > 0) {
673 print "<td>".$company->getNomUrl(1)."</td>";
674 } else {
675 print "<td>".((string) $obj->societe)."</td>";
676 }
677 } else {
678 print "<td>".((string) $obj->societe)."</td>";
679 }
680
681 // Donator
682 print "<td>".$donationstatic->getFullName($langs)."</td>";
683
684 // Date donation
685 print '<td class="center">'.dol_print_date($db->jdate($obj->datedon), 'day').'</td>';
686
687 if (isModEnabled('project')) {
688 print "<td>";
689 if ($obj->pid) {
690 $projectstatic->id = $obj->pid;
691 $projectstatic->ref = $obj->pref;
692 $projectstatic->public = $obj->public;
693 $projectstatic->title = $obj->title;
694 print $projectstatic->getNomUrl(1);
695 } else {
696 print '&nbsp;';
697 }
698 print "</td>\n";
699 }
700 print '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
701
702 // Status
703 print '<td class="center">'.$donationstatic->LibStatut($obj->status, 5).'</td>';
704
705 // Action column
706 if (empty($conf->main_checkbox_left_column)) {
707 print '<td class="nowrap center">';
708 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
709 $selected = 0;
710 if (in_array($object->id, $arrayofselected)) {
711 $selected = 1;
712 }
713 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
714 }
715 print '</td>';
716 if (!$i) {
717 $totalarray['nbfield']++;
718 }
719 }
720
721 print '</tr>'."\n";
722 }
723 $i++;
724}
725
726$db->free($resql);
727
728print '</table>'."\n";
729print '</div>'."\n";
730
731print '</form>'."\n";
732
733
734
735llxFooter();
736$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.