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 *
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 = GETPOST('search_type', 'alpha');
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 a 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$accountstatic = new Account($db);
172
173$now = dol_now();
174
175// List of subscriptions
176$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut as status,";
177$sql .= " d.gender, d.email, d.morphy,";
178$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
179$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_modification,";
180$sql .= " c.fk_bank as bank, c.note as note_private,";
181$sql .= " b.fk_account";
182// Add fields from extrafields
183if (!empty($extrafields->attributes[$object->table_element]['label'])) {
184 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
185 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
186 }
187}
188// Add fields from hooks
189$parameters = array();
190$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
191$sql .= $hookmanager->resPrint;
192$sql = preg_replace('/,\s*$/', '', $sql);
193
194$sqlfields = $sql; // $sql fields to remove for count total
195
196$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
197$sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent";
198$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
199$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
200$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
201if (isset($date_select) && $date_select != '') {
202 $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
203 $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
204}
205if ($search_ref) {
206 if (is_numeric($search_ref)) {
207 $sql .= " AND c.rowid = ".((int) $search_ref);
208 } else {
209 $sql .= " AND 1 = 2"; // Always wrong
210 }
211}
212if ($search_type) {
213 $sql .= natural_search(array('c.fk_type'), $search_type);
214}
215if ($search_lastname) {
216 $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
217}
218if ($search_firstname) {
219 $sql .= natural_search(array('d.firstname'), $search_firstname);
220}
221if ($search_login) {
222 $sql .= natural_search('d.login', $search_login);
223}
224if ($search_note) {
225 $sql .= natural_search('c.note', $search_note);
226}
227if ($search_account > 0) {
228 $sql .= " AND b.fk_account = ".((int) $search_account);
229}
230if ($search_amount) {
231 $sql .= natural_search('c.subscription', $search_amount, 1);
232}
233if ($search_all) {
234 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
235}
236// Add where from extra fields
237include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
238// Add where from hooks
239$parameters = array();
240$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
241$sql .= $hookmanager->resPrint;
242
243// Count total nb of records
244$nbtotalofrecords = '';
245if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
246 /* The fast and low memory method to get and count full list converts the sql into a sql count */
247 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
248 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
249 $resql = $db->query($sqlforcount);
250 if ($resql) {
251 $objforcount = $db->fetch_object($resql);
252 $nbtotalofrecords = $objforcount->nbtotalofrecords;
253 } else {
254 dol_print_error($db);
255 }
256
257 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
258 $page = 0;
259 $offset = 0;
260 }
261 $db->free($resql);
262}
263
264// Complete request and execute it with limit
265$sql .= $db->order($sortfield, $sortorder);
266if ($limit) {
267 $sql .= $db->plimit($limit + 1, $offset);
268}
269
270$resql = $db->query($sql);
271if (!$resql) {
272 dol_print_error($db);
273 exit;
274}
275
276$num = $db->num_rows($resql);
277
278
279// Direct jump if only one record found
280if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
281 $obj = $db->fetch_object($resql);
282 $id = $obj->rowid;
283 header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id);
284 exit;
285}
286
287// Output page
288// --------------------------------------------------------------------
289
290$title = $langs->trans("Subscriptions");
291if (!empty($date_select)) {
292 $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
293}
294$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
295
296llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-subscription-list bodyforlist');
297
298$arrayofselected = is_array($toselect) ? $toselect : array();
299
300$param = '';
301if (!empty($mode)) {
302 $param .= '&mode='.urlencode($mode);
303}
304if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
305 $param .= '&contextpage='.urlencode($contextpage);
306}
307if ($limit > 0 && $limit != $conf->liste_limit) {
308 $param .= '&limit='.((int) $limit);
309}
310if ($statut != '') {
311 $param .= "&statut=".urlencode($statut);
312}
313if ($search_type) {
314 $param .= "&search_type=".urlencode($search_type);
315}
316if ($date_select) {
317 $param .= "&date_select=".urlencode($date_select);
318}
319if ($search_lastname) {
320 $param .= "&search_lastname=".urlencode($search_lastname);
321}
322if ($search_login) {
323 $param .= "&search_login=".urlencode($search_login);
324}
325if ($search_account) {
326 $param .= "&search_account=".urlencode($search_account);
327}
328if ($search_amount) {
329 $param .= "&search_amount=".urlencode($search_amount);
330}
331if ($optioncss != '') {
332 $param .= '&optioncss='.urlencode($optioncss);
333}
334// Add $param from extra fields
335include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
336// Add $param from hooks
337$parameters = array('param' => &$param);
338$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
339$param .= $hookmanager->resPrint;
340
341// List of mass actions available
342$arrayofmassactions = array(
343 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
344 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
345);
346if (!empty($permissiontodelete)) {
347 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
348}
349if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
350 $arrayofmassactions = array();
351}
352$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
353
354print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
355if ($optioncss != '') {
356 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
357}
358print '<input type="hidden" name="token" value="'.newToken().'">';
359print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
360print '<input type="hidden" name="action" value="list">';
361print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
362print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
363print '<input type="hidden" name="page" value="'.$page.'">';
364print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
365print '<input type="hidden" name="date_select" value="'.$date_select.'">';
366print '<input type="hidden" name="page_y" value="">';
367print '<input type="hidden" name="mode" value="'.$mode.'">';
368
369$newcardbutton = '';
370$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'));
371$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'));
372if ($user->hasRight('adherent', 'cotisation', 'creer')) {
373 $newcardbutton .= dolGetButtonTitleSeparator();
374 $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
375}
376
377print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
378
379$topicmail = "Information";
380$modelmail = "subscription";
381$objecttmp = new Subscription($db);
382$trackid = 'sub'.$object->id;
383include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
384
385if ($search_all) {
386 $setupstring = '';
387 foreach ($fieldstosearchall as $key => $val) {
388 $fieldstosearchall[$key] = $langs->trans($val);
389 $setupstring .= $key."=".$val.";";
390 }
391 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
392 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
393}
394
395$moreforfilter = '';
396/*$moreforfilter.='<div class="divsearchfield">';
397 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
398 $moreforfilter.= '</div>';*/
399
400$parameters = array();
401$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
402if (empty($reshook)) {
403 $moreforfilter .= $hookmanager->resPrint;
404} else {
405 $moreforfilter = $hookmanager->resPrint;
406}
407
408if (!empty($moreforfilter)) {
409 print '<div class="liste_titre liste_titre_bydiv centpercent">';
410 print $moreforfilter;
411 $parameters = array();
412 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
413 print $hookmanager->resPrint;
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 '<input class="flat maxwidth50" type="text" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
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();
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
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.