dolibarr 24.0.0-beta
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// 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 {
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) {
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$arrayofselected = is_array($toselect) ? $toselect : array();
334
335$param = '';
336if (!empty($mode)) {
337 $param .= '&mode='.urlencode($mode);
338}
339if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
340 $param .= '&contextpage='.urlencode($contextpage);
341}
342if ($limit > 0 && $limit != $conf->liste_limit) {
343 $param .= '&limit='.((int) $limit);
344}
345if ($optioncss != '') {
346 $param .= '&optioncss='.urlencode($optioncss);
347}
348if ($groupby != '') {
349 $param .= '&groupby='.urlencode($groupby);
350}
351if ($search_status && $search_status != -1) {
352 $param .= '&search_status='.urlencode($search_status);
353}
354if ($search_ref) {
355 $param .= '&search_ref='.urlencode($search_ref);
356}
357if ($search_company) {
358 $param .= '&search_company='.urlencode($search_company);
359}
360if ($search_name) {
361 $param .= '&search_name='.urlencode($search_name);
362}
363if ($search_amount) {
364 $param .= '&search_amount='.urlencode($search_amount);
365}
366if ($search_date_startday) {
367 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
368}
369if ($search_date_startmonth) {
370 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
371}
372if ($search_date_startyear) {
373 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
374}
375if ($search_date_endday) {
376 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
377}
378if ($search_date_endmonth) {
379 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
380}
381if ($search_date_endyear) {
382 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
383}
384
385// Add $param from extra fields
386include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
387// Add $param from hooks
388$parameters = array('param' => &$param);
389$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
390$param .= $hookmanager->resPrint;
391
392
393// List of mass actions available
394$arrayofmassactions = array(
395 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
396 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
397 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
398 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
399);
400if (!empty($permissiontodelete)) {
401 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
402}
403if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
404 $arrayofmassactions = array();
405}
406$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
407
408print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
409if ($optioncss != '') {
410 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
411}
412print '<input type="hidden" name="token" value="'.newToken().'">';
413print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
414print '<input type="hidden" name="action" value="list">';
415print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
416print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
417print '<input type="hidden" name="page" value="'.$page.'">';
418print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
419print '<input type="hidden" name="page_y" value="">';
420print '<input type="hidden" name="mode" value="'.$mode.'">';
421print '<input type="hidden" name="type" value="'.$type.'">';
422
423$newcardbutton = '';
424$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'));
425$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'));
426$newcardbutton .= dolGetButtonTitleSeparator();
427$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create', '', $permissiontoadd);
428
429// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
430print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
431
432// Add code for pre mass action (confirmation or email presend form)
433$topicmail = "SendDonationRef";
434$modelmail = "don";
435$objecttmp = new Don($db);
436$trackid = 'don'.$object->id;
437include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
438
439if ($search_all) {
440 $setupstring = '';
441 foreach ($fieldstosearchall as $key => $val) {
442 $fieldstosearchall[$key] = $langs->trans($val);
443 $setupstring .= $key."=".$val.";";
444 }
445 print '<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
446 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
447}
448
449$moreforfilter = '';
450/*$moreforfilter.='<div class="divsearchfield">';
451$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
452$moreforfilter.= '</div>';*/
453
454$parameters = array();
455$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
456if (empty($reshook)) {
457 $moreforfilter .= $hookmanager->resPrint;
458} else {
459 $moreforfilter = $hookmanager->resPrint;
460}
461$parameters = array(
462 'arrayfields' => &$arrayfields,
463);
464
465if (!empty($moreforfilter)) {
466 print '<div class="liste_titre liste_titre_bydiv centpercent">';
467 print $moreforfilter;
468 print '</div>';
469}
470
471$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
472$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column ? 'left' : ''); // This also change content of $arrayfields with user setup
473$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
474$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
475
476print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
477print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
478
479// Fields title search
480// --------------------------------------------------------------------
481print '<tr class="liste_titre_filter">';
482// Action column
483if ($conf->main_checkbox_left_column) {
484 print '<td class="liste_titre center maxwidthsearch">';
485 $searchpicto = $form->showFilterButtons('left');
486 print $searchpicto;
487 print '</td>';
488}
489print '<td class="liste_titre">';
490print '<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.'">';
491print '</td>';
492if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
493 print '<td class="liste_titre">';
494 print '<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.'">';
495 print '</td>';
496} else {
497 print '<td class="liste_titre">';
498 print '<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.'">';
499 print '</td>';
500}
501print '<td class="liste_titre">';
502print '<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.'">';
503print '</td>';
504// Date invoice
505print '<td class="liste_titre center">';
506print '<div class="nowrapfordate">';
507print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
508print '</div>';
509print '<div class="nowrapfordate">';
510print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
511print '</div>';
512print '</td>';
513if (isModEnabled('project')) {
514 print '<td class="liste_titre right">';
515 print '&nbsp;';
516 print '</td>';
517}
518print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
519print '<td class="liste_titre center parentonrightofpage">';
520$liststatus = array(
521 Don::STATUS_DRAFT => $langs->trans("DonationStatusPromiseNotValidated"),
522 Don::STATUS_VALIDATED => $langs->trans("DonationStatusPromiseValidated"),
523 Don::STATUS_PAID => $langs->trans("DonationStatusPaid"),
524 Don::STATUS_CANCELED => $langs->trans("Canceled")
525);
526// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
527print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage');
528print '</td>';
529// Action column
530if (!$conf->main_checkbox_left_column) {
531 print '<td class="liste_titre center maxwidthsearch">';
532 $searchpicto = $form->showFilterButtons();
533 print $searchpicto;
534 print '</td>';
535}
536print '</tr>'."\n";
537
538$totalarray = array();
539$totalarray['nbfield'] = 0;
540
541// Fields title label
542// --------------------------------------------------------------------
543print '<tr class="liste_titre">';
544// Action column
545if ($conf->main_checkbox_left_column) {
546 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
547 $totalarray['nbfield']++;
548}
549print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder);
550$totalarray['nbfield']++;
551if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
552 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
553 $totalarray['nbfield']++;
554} else {
555 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder);
556 $totalarray['nbfield']++;
557}
558print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
559$totalarray['nbfield']++;
560print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
561$totalarray['nbfield']++;
562if (isModEnabled('project')) {
563 $langs->load("projects");
564 print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
565 $totalarray['nbfield']++;
566}
567print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right ');
568$totalarray['nbfield']++;
569print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
570$totalarray['nbfield']++;
571// Action column
572if (!$conf->main_checkbox_left_column) {
573 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
574 $totalarray['nbfield']++;
575}
576print '</tr>'."\n";
577
578$i = 0;
579$savnbfield = $totalarray['nbfield'];
580$totalarray = array();
581$totalarray['nbfield'] = 0;
582$imaxinloop = ($limit ? min($num, $limit) : $num);
583while ($i < $imaxinloop) {
584 $obj = $db->fetch_object($resql);
585 if (empty($obj)) {
586 break; // Should not happen
587 }
588
589 $donationstatic->setVarsFromFetchObj($obj);
590
591 $donationstatic->id = (int) $obj->rowid;
592 $donationstatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
593 $donationstatic->date = $db->jdate($obj->datedon);
594 $donationstatic->status = (int) $obj->status;
595 $donationstatic->lastname = $obj->lastname;
596 $donationstatic->firstname = $obj->firstname;
597 $object = $donationstatic;
598
599 $company = new Societe($db);
600 $result = $company->fetch($obj->socid);
601
602
603 if ($mode == 'kanban') {
604 if ($i == 0) {
605 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
606 print '<div class="box-flex-container kanban">';
607 }
608 // Output Kanban
609 $donationstatic->amount = $obj->amount;
610
611 if (!empty($obj->socid) && $company->id > 0) {
612 $donationstatic->societe = $company->getNomUrl(1);
613 } else {
614 $donationstatic->societe = (string) $obj->societe; // Value from sql query
615 }
616
617 $object = $donationstatic;
618
619 $selected = -1;
620 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
621 $selected = 0;
622 if (in_array($object->id, $arrayofselected)) {
623 $selected = 1;
624 }
625 }
626 print $donationstatic->getKanbanView('', array('selected' => $selected));
627 if ($i == ($imaxinloop - 1)) {
628 print '</div>';
629 print '</td></tr>';
630 }
631 } else {
632 // Show line of result
633 $j = 0;
634 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
635
636 // Action column
637 if ($conf->main_checkbox_left_column) {
638 print '<td class="nowrap center">';
639 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
640 $selected = 0;
641 if (in_array($object->id, $arrayofselected)) {
642 $selected = 1;
643 }
644 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
645 }
646 print '</td>';
647 if (!$i) {
648 $totalarray['nbfield']++;
649 }
650 }
651
652 // Ref
653 print "<td>".$donationstatic->getNomUrl(1)."</td>";
654
655 // Company
656 if (getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
657 if (!empty($obj->socid) && $company->id > 0) {
658 print "<td>".$company->getNomUrl(1)."</td>";
659 } else {
660 print "<td>".((string) $obj->societe)."</td>";
661 }
662 } else {
663 print "<td>".((string) $obj->societe)."</td>";
664 }
665
666 // Donator
667 print "<td>".$donationstatic->getFullName($langs)."</td>";
668
669 // Date donation
670 print '<td class="center">'.dol_print_date($db->jdate($obj->datedon), 'day').'</td>';
671
672 if (isModEnabled('project')) {
673 print "<td>";
674 if ($obj->pid) {
675 $projectstatic->id = $obj->pid;
676 $projectstatic->ref = $obj->pref;
677 $projectstatic->public = $obj->public;
678 $projectstatic->title = $obj->title;
679 print $projectstatic->getNomUrl(1);
680 } else {
681 print '&nbsp;';
682 }
683 print "</td>\n";
684 }
685 print '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
686
687 // Status
688 print '<td class="center">'.$donationstatic->LibStatut($donationstatic->status, 5).'</td>';
689
690 // Action column
691 if (empty($conf->main_checkbox_left_column)) {
692 print '<td class="nowrap center">';
693 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
694 $selected = 0;
695 if (in_array($object->id, $arrayofselected)) {
696 $selected = 1;
697 }
698 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
699 }
700 print '</td>';
701 if (!$i) {
702 $totalarray['nbfield']++;
703 }
704 }
705
706 print '</tr>'."\n";
707 }
708 $i++;
709}
710
711$db->free($resql);
712
713print '</table>'."\n";
714print '</div>'."\n";
715
716print '</form>'."\n";
717
718
719
720llxFooter();
721$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:497
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...
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.
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.
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.
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
buildzip.php
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.