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