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