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