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