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