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