dolibarr 24.0.0-beta
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
41require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
42require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
43require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
44
45// Load translation files required by the page
46$langs->loadLangs(array("members", "companies", "banks"));
47
48$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
49$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
50$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
51$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
52$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
53$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
55$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
56$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
57$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
58
59$statut = (GETPOSTISSET("statut") ? GETPOST("statut", "alpha") : 1);
60$search_ref = GETPOST('search_ref', 'alpha');
61$search_type = GETPOSTINT('search_type');
62$search_lastname = GETPOST('search_lastname', 'alpha');
63$search_firstname = GETPOST('search_firstname', 'alpha');
64$search_login = GETPOST('search_login', 'alpha');
65$search_note = GETPOST('search_note', 'alpha');
66$search_account = GETPOST('search_account', 'alpha');
67$search_amount = GETPOST('search_amount', 'alpha');
68$search_all = trim(GETPOST('search_all', 'alphanohtml'));
69// Start Date (Subscription Date)
70$search_dateadh_startday = GETPOSTINT('search_dateadh_startday');
71$search_dateadh_startmonth = GETPOSTINT('search_dateadh_startmonth');
72$search_dateadh_startyear = GETPOSTINT('search_dateadh_startyear');
73$search_dateadh_endday = GETPOSTINT('search_dateadh_endday');
74$search_dateadh_endmonth = GETPOSTINT('search_dateadh_endmonth');
75$search_dateadh_endyear = GETPOSTINT('search_dateadh_endyear');
76$search_dateadh_start = dol_mktime(0, 0, 0, $search_dateadh_startmonth, $search_dateadh_startday, $search_dateadh_startyear);
77$search_dateadh_end = dol_mktime(23, 59, 59, $search_dateadh_endmonth, $search_dateadh_endday, $search_dateadh_endyear);
78// End Date (Expiration Date)
79$search_datef_startday = GETPOSTINT('search_datef_startday');
80$search_datef_startmonth = GETPOSTINT('search_datef_startmonth');
81$search_datef_startyear = GETPOSTINT('search_datef_startyear');
82$search_datef_endday = GETPOSTINT('search_datef_endday');
83$search_datef_endmonth = GETPOSTINT('search_datef_endmonth');
84$search_datef_endyear = GETPOSTINT('search_datef_endyear');
85$search_datef_start = dol_mktime(0, 0, 0, $search_datef_startmonth, $search_datef_startday, $search_datef_startyear);
86$search_datef_end = dol_mktime(23, 59, 59, $search_datef_endmonth, $search_datef_endday, $search_datef_endyear);
87
88$date_select = GETPOST("date_select", 'alpha');
89
90// Load variable for pagination
91$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
92$sortfield = GETPOST('sortfield', 'aZ09comma');
93$sortorder = GETPOST('sortorder', 'aZ09comma');
94$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
95if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
96 // If $page is not defined, or '' or -1 or if we click on clear filters
97 $page = 0;
98}
99$offset = $limit * $page;
100$pageprev = $page - 1;
101$pagenext = $page + 1;
102if (!$sortorder) {
103 $sortorder = "DESC";
104}
105if (!$sortfield) {
106 $sortfield = "c.dateadh";
107}
108
109// Initialize a technical objects
111$hookmanager->initHooks(array('subscriptionlist'));
112
113// Fetch optionals attributes and labels
114$extrafields->fetch_name_optionals_label($object->table_element);
115
116$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
117
118// List of fields to search into when doing a "search in all"
119$fieldstosearchall = array(
120 'c.rowid' => 'Ref',
121 'c.note' => "Label",
122);
123$arrayfields = array(
124 'd.ref' => array('label' => "Ref", 'checked' => '1'),
125 'd.fk_type' => array('label' => "Type", 'checked' => '1'),
126 'd.lastname' => array('label' => "Lastname", 'checked' => '1'),
127 'd.firstname' => array('label' => "Firstname", 'checked' => '1'),
128 'd.login' => array('label' => "Login", 'checked' => '1'),
129 'c.note' => array('label' => "Label", 'checked' => '1'),
130 'd.bank' => array('label' => "BankAccount", 'checked' => '1', 'enabled' => (string) (int) (isModEnabled('bank'))),
131 /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
132 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
133 'c.dateadh' => array('label' => "DateSubscription", 'checked' => '1', 'position' => 100),
134 'c.datef' => array('label' => "EndSubscription", 'checked' => '1', 'position' => 101),
135 'd.amount' => array('label' => "Amount", 'checked' => '1', 'position' => 102),
136 'c.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 500),
137 'c.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 500),
138// 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
139);
140
141// Security check
142restrictedArea($user, 'adherent', '', '', 'cotisation');
143
144$permissiontodelete = $user->hasRight('adherent', 'cotisation', 'creer');
145
146
147/*
148 * Actions
149 */
150
151if (GETPOST('cancel', 'alpha')) {
152 $action = 'list';
153 $massaction = '';
154}
155if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
156 $massaction = '';
157}
158
159$parameters = array('socid' => null);
160$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
161if ($reshook < 0) {
162 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
163}
164
165if (empty($reshook)) {
166 // Selection of new fields
167 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
168
169 // Purge search criteria
170 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
171 $search_type = "";
172 $search_ref = "";
173 $search_lastname = "";
174 $search_firstname = "";
175 $search_login = "";
176 $search_note = "";
177 $search_amount = "";
178 $search_account = "";
179 $toselect = array();
180 $search_array_options = array();
181 $search_dateadh_startday = '';
182 $search_dateadh_startmonth = '';
183 $search_dateadh_startyear = '';
184 $search_dateadh_endday = '';
185 $search_dateadh_endmonth = '';
186 $search_dateadh_endyear = '';
187 $search_dateadh_start = '';
188 $search_dateadh_end = '';
189 $search_datef_startday = '';
190 $search_datef_startmonth = '';
191 $search_datef_startyear = '';
192 $search_datef_endday = '';
193 $search_datef_endmonth = '';
194 $search_datef_endyear = '';
195 $search_datef_start = '';
196 $search_datef_end = '';
197 }
198 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
199 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
200 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
201 }
202
203 // Mass actions
204 $objectclass = 'Subscription';
205 $objectlabel = 'Subscription';
206 $uploaddir = $conf->member->dir_output;
207 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
208}
209
210
211/*
212 * View
213 */
214
215$form = new Form($db);
216$subscription = new Subscription($db);
217$adherent = new Adherent($db);
218$adht = new AdherentType($db);
219$accountstatic = new Account($db);
220
221$now = dol_now();
222
223// Build and execute select
224// --------------------------------------------------------------------
225$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut as status,";
226$sql .= " d.gender, d.email, d.morphy,";
227$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
228$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_modification,";
229$sql .= " c.fk_bank as bank, c.note as note_private,";
230$sql .= " b.fk_account";
231// Add fields from extrafields
232if (!empty($extrafields->attributes[$object->table_element]['label'])) {
233 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
234 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : "");
235 }
236}
237// Add fields from hooks
238$parameters = array();
239$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
240$sql .= $hookmanager->resPrint;
241$sql = preg_replace('/,\s*$/', '', $sql);
242
243$sqlfields = $sql; // $sql fields to remove for count total
244
245$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
246$sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent";
247$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
248$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
249$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
250if (isset($date_select) && $date_select != '') {
251 $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
252 $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
253}
254if ($search_ref) {
255 if (is_numeric($search_ref)) {
256 $sql .= " AND c.rowid = ".((int) $search_ref);
257 } else {
258 $sql .= " AND 1 = 2"; // Always wrong
259 }
260}
261if ($search_type > 0) {
262 $sql .= natural_search(array('c.fk_type'), (string) $search_type);
263}
264if ($search_lastname) {
265 $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
266}
267if ($search_firstname) {
268 $sql .= natural_search(array('d.firstname'), $search_firstname);
269}
270if ($search_login) {
271 $sql .= natural_search('d.login', $search_login);
272}
273if ($search_note) {
274 $sql .= natural_search('c.note', $search_note);
275}
276if ($search_account > 0) {
277 $sql .= " AND b.fk_account = ".((int) $search_account);
278}
279if ($search_amount) {
280 $sql .= natural_search('c.subscription', $search_amount, 1);
281}
282if ($search_all) {
283 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
284}
285if ($search_dateadh_start) {
286 $sql .= " AND c.dateadh >= '".$db->idate($search_dateadh_start)."'";
287}
288if ($search_dateadh_end) {
289 $sql .= " AND c.dateadh <= '".$db->idate($search_dateadh_end)."'";
290}
291if ($search_datef_start) {
292 $sql .= " AND c.datef >= '".$db->idate($search_datef_start)."'";
293}
294if ($search_datef_end) {
295 $sql .= " AND c.datef <= '".$db->idate($search_datef_end)."'";
296}
297// Add where from extra fields
298include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
299// Add where from hooks
300$parameters = array();
301$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
302$sql .= $hookmanager->resPrint;
303
304// Count total nb of records
305$nbtotalofrecords = '';
306if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
307 /* The fast and low memory method to get and count full list converts the sql into a sql count */
308 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
309 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
310 $resql = $db->query($sqlforcount);
311 if ($resql) {
312 $objforcount = $db->fetch_object($resql);
313 $nbtotalofrecords = $objforcount->nbtotalofrecords;
314 } else {
316 }
317
318 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
319 $page = 0;
320 $offset = 0;
321 }
322 $db->free($resql);
323}
324
325// Complete request and execute it with limit
326$sql .= $db->order($sortfield, $sortorder);
327if ($limit) {
328 $sql .= $db->plimit($limit + 1, $offset);
329}
330
331$resql = $db->query($sql);
332if (!$resql) {
334 exit;
335}
336
337$num = $db->num_rows($resql);
338
339
340// Direct jump if only one record found
341if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
342 $obj = $db->fetch_object($resql);
343 $id = $obj->rowid;
344 header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id);
345 exit;
346}
347
348// Output page
349// --------------------------------------------------------------------
350
351$title = $langs->trans("Subscriptions");
352if (!empty($date_select)) {
353 $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
354}
355$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
356
357llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-subscription-list bodyforlist');
358
359$arrayofselected = is_array($toselect) ? $toselect : array();
360
361$param = '';
362if (!empty($mode)) {
363 $param .= '&mode='.urlencode($mode);
364}
365if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
366 $param .= '&contextpage='.urlencode($contextpage);
367}
368if ($limit > 0 && $limit != $conf->liste_limit) {
369 $param .= '&limit='.((int) $limit);
370}
371if ($statut != '') {
372 $param .= "&statut=".urlencode($statut);
373}
374if ($search_type) {
375 $param .= "&search_type=".((int) $search_type);
376}
377if ($date_select) {
378 $param .= "&date_select=".urlencode($date_select);
379}
380if ($search_lastname) {
381 $param .= "&search_lastname=".urlencode($search_lastname);
382}
383if ($search_login) {
384 $param .= "&search_login=".urlencode($search_login);
385}
386if ($search_account) {
387 $param .= "&search_account=".urlencode($search_account);
388}
389if ($search_amount) {
390 $param .= "&search_amount=".urlencode($search_amount);
391}
392if ($optioncss != '') {
393 $param .= '&optioncss='.urlencode($optioncss);
394}
395// Subscription Start Date (dateadh)
396if ($search_dateadh_startday) $param .= '&search_dateadh_startday='.urlencode((string) $search_dateadh_startday);
397if ($search_dateadh_startmonth) $param .= '&search_dateadh_startmonth='.urlencode((string) $search_dateadh_startmonth);
398if ($search_dateadh_startyear) $param .= '&search_dateadh_startyear='.urlencode((string) $search_dateadh_startyear);
399
400// Subscription End Date (dateadh)
401if ($search_dateadh_endday) $param .= '&search_dateadh_endday='.urlencode((string) $search_dateadh_endday);
402if ($search_dateadh_endmonth) $param .= '&search_dateadh_endmonth='.urlencode((string) $search_dateadh_endmonth);
403if ($search_dateadh_endyear) $param .= '&search_dateadh_endyear='.urlencode((string) $search_dateadh_endyear);
404
405// End Subscription Start Date (datef)
406if ($search_datef_startday) $param .= '&search_datef_startday='.urlencode((string) $search_datef_startday);
407if ($search_datef_startmonth) $param .= '&search_datef_startmonth='.urlencode((string) $search_datef_startmonth);
408if ($search_datef_startyear) $param .= '&search_datef_startyear='.urlencode((string) $search_datef_startyear);
409
410// End Subscription End Date (datef)
411if ($search_datef_endday) $param .= '&search_datef_endday='.urlencode((string) $search_datef_endday);
412if ($search_datef_endmonth) $param .= '&search_datef_endmonth='.urlencode((string) $search_datef_endmonth);
413if ($search_datef_endyear) $param .= '&search_datef_endyear='.urlencode((string) $search_datef_endyear);
414
415// Add $param from extra fields
416include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
417// Add $param from hooks
418$parameters = array('param' => &$param);
419$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
420$param .= $hookmanager->resPrint;
421
422// List of mass actions available
423$arrayofmassactions = array(
424 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
425 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
426);
427if (!empty($permissiontodelete)) {
428 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
429}
430if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
431 $arrayofmassactions = array();
432}
433$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
434
435print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
436if ($optioncss != '') {
437 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
438}
439print '<input type="hidden" name="token" value="'.newToken().'">';
440print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
441print '<input type="hidden" name="action" value="list">';
442print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
443print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
444print '<input type="hidden" name="page" value="'.$page.'">';
445print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
446print '<input type="hidden" name="date_select" value="'.$date_select.'">';
447print '<input type="hidden" name="page_y" value="">';
448print '<input type="hidden" name="mode" value="'.$mode.'">';
449
450$newcardbutton = '';
451$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'));
452$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'));
453$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', dol_buildpath('/adherents/stats/index.php', 1).'?objecttype=adherent@adherent'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
454if ($user->hasRight('adherent', 'cotisation', 'creer')) {
455 $newcardbutton .= dolGetButtonTitleSeparator();
456 $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
457}
458
459print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
460
461$topicmail = "Information";
462$modelmail = "subscription";
463$objecttmp = new Subscription($db);
464$trackid = 'sub'.$object->id;
465include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
466
467if ($search_all) {
468 $setupstring = '';
469 foreach ($fieldstosearchall as $key => $val) {
470 $fieldstosearchall[$key] = $langs->trans($val);
471 $setupstring .= $key."=".$val.";";
472 }
473 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
474 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
475}
476
477$moreforfilter = '';
478/*$moreforfilter.='<div class="divsearchfield">';
479 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
480 $moreforfilter.= '</div>';*/
481
482$parameters = array();
483$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
484if (empty($reshook)) {
485 $moreforfilter .= $hookmanager->resPrint;
486} else {
487 $moreforfilter = $hookmanager->resPrint;
488}
489
490if (!empty($moreforfilter)) {
491 print '<div class="liste_titre liste_titre_bydiv centpercent">';
492 print $moreforfilter;
493 print '</div>';
494}
495
496$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
497$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
498$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
499$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
500
501print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
502print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
503
504// Fields title search
505// --------------------------------------------------------------------
506print '<tr class="liste_titre_filter">';
507// Action column
508if ($conf->main_checkbox_left_column) {
509 print '<td class="liste_titre center maxwidthsearch">';
510 $searchpicto = $form->showFilterButtons('left');
511 print $searchpicto;
512 print '</td>';
513}
514// Line numbering
515if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
516 print '<td class="liste_titre">&nbsp;</td>';
517}
518
519// Ref
520if (!empty($arrayfields['d.ref']['checked'])) {
521 print '<td class="liste_titre left">';
522 print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
523}
524
525// Type
526if (!empty($arrayfields['d.fk_type']['checked'])) {
527 print '<td class="liste_titre left">';
528 print $form->selectarray("search_type", $adht->liste_array(), $search_type, 1);
529 print'</td>';
530}
531
532if (!empty($arrayfields['d.lastname']['checked'])) {
533 print '<td class="liste_titre left">';
534 print '<input class="flat maxwidth75" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
535}
536
537if (!empty($arrayfields['d.firstname']['checked'])) {
538 print '<td class="liste_titre left">';
539 print '<input class="flat maxwidth75" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
540}
541
542if (!empty($arrayfields['d.login']['checked'])) {
543 print '<td class="liste_titre left">';
544 print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
545}
546
547if (!empty($arrayfields['c.note']['checked'])) {
548 print '<td class="liste_titre">';
549 print '<input class="flat maxwidth100" type="text" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>';
550 print '</td>';
551}
552
553if (!empty($arrayfields['d.bank']['checked'])) {
554 print '<td class="liste_titre">';
555 $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100');
556 print '</td>';
557}
558
559if (!empty($arrayfields['c.dateadh']['checked'])) {
560 print '<td class="liste_titre center">';
561 print $form->selectDate($search_dateadh_start, 'search_dateadh_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
562 print '<br>';
563 print $form->selectDate($search_dateadh_end, 'search_dateadh_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'));
564 print '</td>';
565}
566
567if (!empty($arrayfields['c.datef']['checked'])) {
568 print '<td class="liste_titre center">';
569 print $form->selectDate($search_datef_start, 'search_datef_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
570 print '<br>';
571 print $form->selectDate($search_datef_end, 'search_datef_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'));
572 print '</td>';
573}
574
575if (!empty($arrayfields['d.amount']['checked'])) {
576 print '<td class="liste_titre right">';
577 print '<input class="flat" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'" size="4">';
578 print '</td>';
579}
580// Extra fields
581include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
582
583// Fields from hook
584$parameters = array('arrayfields' => $arrayfields);
585$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
586print $hookmanager->resPrint;
587// Date creation
588if (!empty($arrayfields['c.datec']['checked'])) {
589 print '<td class="liste_titre">';
590 print '</td>';
591}
592// Date modification
593if (!empty($arrayfields['c.tms']['checked'])) {
594 print '<td class="liste_titre">';
595 print '</td>';
596}
597
598// Action column
599if (!$conf->main_checkbox_left_column) {
600 print '<td class="liste_titre center maxwidthsearch">';
601 $searchpicto = $form->showFilterButtons();
602 print $searchpicto;
603 print '</td>';
604}
605print '</tr>'."\n";
606
607$totalarray = array();
608$totalarray['nbfield'] = 0;
609
610// Fields title label
611// --------------------------------------------------------------------
612print '<tr class="liste_titre">';
613// Action column
614if ($conf->main_checkbox_left_column) {
615 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
616 $totalarray['nbfield']++;
617}
618if (!empty($arrayfields['d.ref']['checked'])) {
619 print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", "", $param, "", $sortfield, $sortorder);
620 $totalarray['nbfield']++;
621}
622if (!empty($arrayfields['d.fk_type']['checked'])) {
623 print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", "", $param, "", $sortfield, $sortorder);
624 $totalarray['nbfield']++;
625}
626if (!empty($arrayfields['d.lastname']['checked'])) {
627 print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
628 $totalarray['nbfield']++;
629}
630if (!empty($arrayfields['d.firstname']['checked'])) {
631 print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", "", $param, "", $sortfield, $sortorder);
632 $totalarray['nbfield']++;
633}
634if (!empty($arrayfields['d.login']['checked'])) {
635 print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", "", $param, "", $sortfield, $sortorder);
636 $totalarray['nbfield']++;
637}
638if (!empty($arrayfields['c.note']['checked'])) {
639 print_liste_field_titre($arrayfields['c.note']['label'], $_SERVER["PHP_SELF"], "c.note", "", $param, '', $sortfield, $sortorder);
640 $totalarray['nbfield']++;
641}
642if (!empty($arrayfields['d.bank']['checked'])) {
643 print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", "", $param, "", $sortfield, $sortorder);
644 $totalarray['nbfield']++;
645}
646if (!empty($arrayfields['c.dateadh']['checked'])) {
647 print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
648 $totalarray['nbfield']++;
649}
650if (!empty($arrayfields['c.datef']['checked'])) {
651 print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", "", $param, '', $sortfield, $sortorder, 'center nowraponall ');
652 $totalarray['nbfield']++;
653}
654if (!empty($arrayfields['d.amount']['checked'])) {
655 print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", "", $param, '', $sortfield, $sortorder, 'right ');
656 $totalarray['nbfield']++;
657}
658
659// Extra fields
660include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
661
662// Hook fields
663$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
664$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
665print $hookmanager->resPrint;
666if (!empty($arrayfields['c.datec']['checked'])) {
667 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
668}
669if (!empty($arrayfields['c.tms']['checked'])) {
670 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
671}
672// Action column
673if (!$conf->main_checkbox_left_column) {
674 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
675 $totalarray['nbfield']++;
676}
677print '</tr>'."\n";
678
679// Loop on record
680// --------------------------------------------------------------------
681$i = 0;
682$savnbfield = $totalarray['nbfield'];
683$totalarray = array();
684$totalarray['nbfield'] = 0;
685$imaxinloop = ($limit ? min($num, $limit) : $num);
686while ($i < $imaxinloop) {
687 $obj = $db->fetch_object($resql);
688 if (empty($obj)) {
689 break; // Should not happen
690 }
691
692 $subscription->ref = $obj->crowid;
693 $subscription->id = $obj->crowid;
694 $subscription->dateh = $db->jdate($obj->dateadh);
695 $subscription->datef = $db->jdate($obj->datef);
696 $subscription->amount = $obj->subscription;
697 $subscription->fk_adherent = $obj->rowid;
698
699 $adherent->lastname = $obj->lastname;
700 $adherent->firstname = $obj->firstname;
701 $adherent->company = $obj->societe;
702 $adherent->ref = $obj->rowid;
703 $adherent->id = $obj->rowid;
704 $adherent->statut = $obj->status;
705 $adherent->status = $obj->status;
706 $adherent->login = $obj->login;
707 $adherent->photo = $obj->photo;
708 $adherent->gender = $obj->gender;
709 $adherent->morphy = $obj->morphy;
710 $adherent->email = $obj->email;
711 $adherent->typeid = $obj->fk_type;
712 $adherent->datefin = $db->jdate($obj->datef);
713
714 $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
715 $adht = new AdherentType($db);
716 $adht->fetch($typeid);
717
718 $adherent->need_subscription = (int) $adht->subscription;
719
720 if ($mode == 'kanban') {
721 if ($i == 0) {
722 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
723 print '<div class="box-flex-container kanban">';
724 }
725 // Output Kanban
726 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
727 $selected = 0;
728 if (in_array($object->id, $arrayofselected)) {
729 $selected = 1;
730 }
731 }
732
733 //fetch information needs on this mode
734
735 if ($obj->fk_account > 0) {
736 $accountstatic->id = $obj->fk_account;
737 $accountstatic->fetch($obj->fk_account);
738 }
739 // Output Kanban
740 print $subscription->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected), 'adherent_type' => $adht, 'member' => $adherent, 'bank' => ($obj->fk_account > 0 ? $accountstatic : null)));
741 if ($i == ($imaxinloop - 1)) {
742 print '</div>';
743 print '</td></tr>';
744 }
745 } else {
746 // Show here line of result
747 $j = 0;
748 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
749 // Action column
750 if ($conf->main_checkbox_left_column) {
751 print '<td class="nowrap center">';
752 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
753 $selected = 0;
754 if (in_array($obj->crowid, $arrayofselected)) {
755 $selected = 1;
756 }
757 print '<input id="cb'.$obj->crowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->crowid.'"'.($selected ? ' checked="checked"' : '').'>';
758 }
759 print '</td>';
760 if (!$i) {
761 $totalarray['nbfield']++;
762 }
763 }
764 // Ref
765 if (!empty($arrayfields['d.ref']['checked'])) {
766 print '<td class="nowraponall">'.$subscription->getNomUrl(1).'</td>';
767 if (!$i) {
768 $totalarray['nbfield']++;
769 }
770 }
771 // Type
772 if (!empty($arrayfields['d.fk_type']['checked'])) {
773 print '<td class="tdoverflowmax100">';
774 if ($typeid > 0) {
775 print $adht->getNomUrl(1);
776 }
777 print '</td>';
778 if (!$i) {
779 $totalarray['nbfield']++;
780 }
781 }
782
783 // Lastname
784 if (!empty($arrayfields['d.lastname']['checked'])) {
785 print '<td class="tdoverflowmax125">'.$adherent->getNomUrl(-1, 0, 'card', 'lastname').'</td>';
786 if (!$i) {
787 $totalarray['nbfield']++;
788 }
789 }
790 // Firstname
791 if (!empty($arrayfields['d.firstname']['checked'])) {
792 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($adherent->firstname).'">'.dol_escape_htmltag($adherent->firstname).'</td>';
793 if (!$i) {
794 $totalarray['nbfield']++;
795 }
796 }
797
798 // Login
799 if (!empty($arrayfields['d.login']['checked'])) {
800 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($adherent->login).'">'.dol_escape_htmltag($adherent->login).'</td>';
801 if (!$i) {
802 $totalarray['nbfield']++;
803 }
804 }
805
806 // Label
807 if (!empty($arrayfields['c.note']['checked'])) {
808 print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->note_private).'">';
809 print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private));
810 print '</td>';
811 if (!$i) {
812 $totalarray['nbfield']++;
813 }
814 }
815
816 // Banque
817 if (!empty($arrayfields['d.bank']['checked'])) {
818 print '<td class="tdoverflowmax100">';
819 if ($obj->fk_account > 0) {
820 $accountstatic->id = $obj->fk_account;
821 $accountstatic->fetch($obj->fk_account);
822 //$accountstatic->label=$obj->label;
823 print $accountstatic->getNomUrl(1);
824 }
825 print "</td>\n";
826 if (!$i) {
827 $totalarray['nbfield']++;
828 }
829 }
830
831 // Date start
832 if (!empty($arrayfields['c.dateadh']['checked'])) {
833 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
834 if (!$i) {
835 $totalarray['nbfield']++;
836 }
837 }
838 // Date end
839 if (!empty($arrayfields['c.datef']['checked'])) {
840 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
841 if (!$i) {
842 $totalarray['nbfield']++;
843 }
844 }
845 // Price
846 if (!empty($arrayfields['d.amount']['checked'])) {
847 print '<td class="right amount">'.price($obj->subscription).'</td>';
848 if (!$i) {
849 $totalarray['nbfield']++;
850 }
851 if (!$i) {
852 $totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
853 }
854 if (empty($totalarray['val']['d.amount'])) {
855 $totalarray['val']['d.amount'] = $obj->subscription;
856 } else {
857 $totalarray['val']['d.amount'] += $obj->subscription;
858 }
859 }
860 // Extra fields
861 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
862 // Fields from hook
863 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
864 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
865 print $hookmanager->resPrint;
866 // Date creation
867 if (!empty($arrayfields['c.datec']['checked'])) {
868 print '<td class="nowrap center">';
869 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
870 print '</td>';
871 if (!$i) {
872 $totalarray['nbfield']++;
873 }
874 }
875 // Date modification
876 if (!empty($arrayfields['c.tms']['checked'])) {
877 print '<td class="nowrap center">';
878 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
879 print '</td>';
880 if (!$i) {
881 $totalarray['nbfield']++;
882 }
883 }
884 // Action column
885 if (!$conf->main_checkbox_left_column) {
886 print '<td class="nowrap center">';
887 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
888 $selected = 0;
889 if (in_array($obj->crowid, $arrayofselected)) {
890 $selected = 1;
891 }
892 print '<input id="cb'.$obj->crowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->crowid.'"'.($selected ? ' checked="checked"' : '').'>';
893 }
894 print '</td>';
895 if (!$i) {
896 $totalarray['nbfield']++;
897 }
898 }
899
900 print '</tr>'."\n";
901 }
902 $i++;
903}
904
905// Show total line
906include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
907
908
909// If no record found
910if ($num == 0) {
911 $colspan = 1;
912 foreach ($arrayfields as $key => $val) {
913 if (!empty($val['checked'])) {
914 $colspan++;
915 }
916 }
917 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
918}
919
920$db->free($resql);
921
922$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
923$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
924print $hookmanager->resPrint;
925
926print '</table>'."\n";
927print '</div>'."\n";
928
929print '</form>'."\n";
930
931// End of page
932llxFooter();
933$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 bank accounts.
Class to manage members of a foundation.
Class to manage members type.
Class to manage generation of HTML components Only common components must be here.
Class to manage subscriptions of foundation members.
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.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
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.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.