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