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