dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2013-2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
6  * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 
34 $langs->loadLangs(array("members","companies"));
35 
36 $action=GETPOST('action','aZ09');
37 $massaction=GETPOST('massaction','alpha');
38 $show_files=GETPOST('show_files','int');
39 $confirm=GETPOST('confirm','alpha');
40 $toselect = GETPOST('toselect', 'array');
41 
42 // Security check
43 $result=restrictedArea($user,'adherent');
44 
45 $filter=GETPOST("filter",'alpha');
46 $statut=GETPOST("statut",'intcomma');
47 $search=GETPOST("search",'alpha');
48 $search_ref=GETPOST("search_ref",'alpha');
49 $search_lastname=GETPOST("search_lastname",'alpha');
50 $search_firstname=GETPOST("search_firstname",'alpha');
51 $search_civility=GETPOST("search_civility",'alpha');
52 $search_login=GETPOST("search_login",'alpha');
53 $search_address=GETPOST("search_address",'alpha');
54 $search_zip=GETPOST("search_zip",'alpha');
55 $search_town=GETPOST("search_town",'alpha');
56 $search_state=GETPOST("search_state",'alpha');
57 $search_country=GETPOST("search_country",'alpha');
58 $search_phone=GETPOST("search_phone",'alpha');
59 $search_phone_perso=GETPOST("search_phone_perso",'alpha');
60 $search_phone_mobile=GETPOST("search_phone_mobile",'alpha');
61 $search_type=GETPOST("search_type",'alpha');
62 $search_email=GETPOST("search_email",'alpha');
63 $search_categ = GETPOST("search_categ",'int');
64 $catid = GETPOST("catid",'int');
65 $optioncss = GETPOST('optioncss','alpha');
66 
67 $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
68 
69 if ($statut < -1) $statut = '';
70 
71 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
72 $sortfield = GETPOST("sortfield",'alpha');
73 $sortorder = GETPOST("sortorder",'alpha');
74 $page = GETPOST("page",'int');
75 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
76 $offset = $limit * $page ;
77 $pageprev = $page - 1;
78 $pagenext = $page + 1;
79 if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); }
80 if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); }
81 
82 $object = new Adherent($db);
83 
84 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
85 $hookmanager->initHooks(array('memberlist'));
86 $extrafields = new ExtraFields($db);
87 
88 // fetch optionals attributes and labels
89 $extralabels = $extrafields->fetch_name_optionals_label('adherent');
90 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
91 
92 // List of fields to search into when doing a "search in all"
93 $fieldstosearchall = array(
94  'd.rowid'=>'Ref',
95  'd.login'=>'Login',
96  'd.lastname'=>'Lastname',
97  'd.firstname'=>'Firstname',
98  'd.login'=>'Login',
99  'd.societe'=>"Company",
100  'd.email'=>'EMail',
101  'd.address'=>'Address',
102  'd.zip'=>'Zip',
103  'd.town'=>'Town',
104  'd.note_public'=>'NotePublic',
105  'd.note_private'=>'NotePrivate',
106 );
107 if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
108 $arrayfields=array(
109  'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
110  'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
111  'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
112  'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
113  'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
114  'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
115  'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1),
116  't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
117  'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
118  'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
119  'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
120  'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
121  'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
122  'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
123  'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
124  'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
125  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
126  /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
127  'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
128  'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
129  'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
130  'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
131  'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
132 );
133 // Extra fields
134 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
135 {
136  foreach($extrafields->attribute_label as $key => $val)
137  {
138  if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
139  }
140 }
141 
142 
143 /*
144  * Actions
145  */
146 
147 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
148 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
149 
150 $parameters=array('socid'=>$socid);
151 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
152 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
153 
154 if (empty($reshook))
155 {
156  // Selection of new fields
157  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
158 
159  // Purge search criteria
160  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
161  {
162  $search="";
163  $search_ref="";
164  $search_lastname="";
165  $search_firstname="";
166  $search_civility="";
167  $search_login="";
168  $search_company="";
169  $search_type="";
170  $search_email="";
171  $search_address="";
172  $search_zip="";
173  $search_town="";
174  $search_state="";
175  $search_country='';
176  $search_phone='';
177  $search_phone_perso='';
178  $search_phone_mobile='';
179  $search_morphy="";
180  $search_categ="";
181  $catid="";
182  $sall="";
183  $statut='';
184  $toselect='';
185  $search_array_options=array();
186  }
187 
188  // Mass actions
189  $objectclass='Adherent';
190  $objectlabel='Members';
191  $permtoread = $user->rights->adherent->lire;
192  $permtodelete = $user->rights->adherent->supprimer;
193  $uploaddir = $conf->adherent->dir_output;
194  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
195 }
196 
197 
198 /*
199  * View
200  */
201 
202 $form=new Form($db);
203 $formother=new FormOther($db);
204 $membertypestatic=new AdherentType($db);
205 $memberstatic=new Adherent($db);
206 
207 $now=dol_now();
208 
209 $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
210 $sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
211 $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,";
212 $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
213 $sql.= " t.libelle as type, t.subscription,";
214 $sql.= " state.code_departement as state_code, state.nom as state_name";
215 // Add fields from extrafields
216 foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
217 // Add fields from hooks
218 $parameters=array();
219 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
220 $sql.=$hookmanager->resPrint;
221 $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
222 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
223 if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
224 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
225 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
226 $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
227 $sql.= " WHERE d.fk_adherent_type = t.rowid ";
228 if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
229 if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
230 if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
231 if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
232 $sql.= " AND d.entity IN (".getEntity('adherent').")";
233 if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
234 if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
235 if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
236 if ($search_ref)
237 {
238  if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
239  else $sql.=" AND 1 = 2"; // Always wrong
240 }
241 if ($search_civility) $sql.= natural_search("d.civility", $search_civility);
242 if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname);
243 if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
244 if ($search_login) $sql.= natural_search("d.login", $search_login);
245 if ($search_email) $sql.= natural_search("d.email", $search_email);
246 if ($search_town) $sql.= natural_search("d.town",$search_town);
247 if ($search_zip) $sql.= natural_search("d.zip",$search_zip);
248 if ($search_state) $sql.= natural_search("state.nom",$search_state);
249 if ($search_country) $sql .= " AND d.country IN (".$search_country.')';
250 if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'";
251 if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
252 
253 // Add where from extra fields
254 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
255 
256 // Add where from hooks
257 $parameters=array();
258 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
259 $sql.=$hookmanager->resPrint;
260 
261 $sql.= $db->order($sortfield,$sortorder);
262 
263 // Count total nb of records with no order and no limits
264 $nbtotalofrecords = '';
265 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
266 {
267  $resql = $db->query($sql);
268  if ($resql) $nbtotalofrecords = $db->num_rows($resql);
269  else dol_print_error($db);
270  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
271  {
272  $page = 0;
273  $offset = 0;
274  }
275 }
276 // Add limit
277 $sql.= $db->plimit($limit+1, $offset);
278 
279 dol_syslog("get list", LOG_DEBUG);
280 $resql = $db->query($sql);
281 if (! $resql)
282 {
283  dol_print_error($db);
284  exit;
285 }
286 
287 $num = $db->num_rows($resql);
288 
289 $arrayofselected=is_array($toselect)?$toselect:array();
290 
291 if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
292 {
293  $obj = $db->fetch_object($resql);
294  $id = $obj->rowid;
295  header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
296  exit;
297 }
298 
299 llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
300 
301 $titre=$langs->trans("MembersList");
302 if (GETPOSTISSET("statut"))
303 {
304  if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
305  if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); }
306  if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
307  if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
308  if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
309  if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); }
310 }
311 elseif ($action == 'search')
312 {
313  $titre=$langs->trans("MembersListQualified");
314 }
315 
316 if ($search_type > 0)
317 {
318  $membertype=new AdherentType($db);
319  $result=$membertype->fetch(GETPOST("type",'int'));
320  $titre.=" (".$membertype->label.")";
321 }
322 
323 $param='';
324 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
325 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
326 if ($sall != "") $param.="&sall=".urlencode($sall);
327 if ($statut != "") $param.="&statut=".urlencode($statut);
328 if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
329 if ($search_nom) $param.="&search_nom=".urlencode($search_nom);
330 if ($search_civility) $param.="&search_civility=".urlencode($search_civility);
331 if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname);
332 if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname);
333 if ($search_login) $param.="&search_login=".urlencode($search_login);
334 if ($search_email) $param.="&search_email=".urlencode($search_email);
335 if ($search_company) $param.="&search_company=".urlencode($search_company);
336 if ($search_address != '') $param.= "&search_address=".urlencode($search_address);
337 if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
338 if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
339 if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
340 if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
341 if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
342 if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
343 if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
344 if ($filter) $param.="&filter=".urlencode($filter);
345 if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
346 if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
347 // Add $param from extra fields
348 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
349 
350 // List of mass actions available
351 $arrayofmassactions = array(
352  //'presend'=>$langs->trans("SendByMail"),
353  //'builddoc'=>$langs->trans("PDFMerge"),
354 );
355 if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
356 if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
357 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
358 
359 $newcardbutton='';
360 if ($user->rights->adherent->creer)
361 {
362  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewMember').'</span>';
363  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
364  $newcardbutton.= '</a>';
365 }
366 
367 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
368 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
369 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
370 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
371 print '<input type="hidden" name="action" value="list">';
372 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
373 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
374 print '<input type="hidden" name="page" value="'.$page.'">';
375 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
376 
377 print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
378 
379 $topicmail="Information";
380 $modelmail="member";
381 $objecttmp=new Adherent($db);
382 $trackid='mem'.$object->id;
383 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
384 
385 if ($sall)
386 {
387  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
388  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
389 }
390 
391 // Filter on categories
392 $moreforfilter='';
393 if (! empty($conf->categorie->enabled))
394 {
395  require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
396  $moreforfilter.='<div class="divsearchfield">';
397  $moreforfilter.=$langs->trans('Categories'). ': ';
398  $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
399  $moreforfilter.='</div>';
400 }
401 $parameters=array();
402 $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
403 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
404 else $moreforfilter = $hookmanager->resPrint;
405 if (! empty($moreforfilter))
406 {
407  print '<div class="liste_titre liste_titre_bydiv centpercent">';
408  print $moreforfilter;
409  print '</div>';
410 }
411 
412 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
413 $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
414 if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
415 
416 print '<div class="div-table-responsive">';
417 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
418 
419 
420 // Line for filters fields
421 print '<tr class="liste_titre_filter">';
422 
423 // Line numbering
424 if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
425 {
426  print '<td class="liste_titre">&nbsp;</td>';
427 }
428 
429 // Ref
430 if (! empty($arrayfields['d.ref']['checked']))
431 {
432  print '<td class="liste_titre">';
433  print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
434  print '</td>';
435 }
436 if (! empty($arrayfields['d.civility']['checked']))
437 {
438  print '<td class="liste_titre" align="left">';
439  print '<input class="flat maxwidth25" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
440 }
441 if (! empty($arrayfields['d.firstname']['checked']))
442 {
443  print '<td class="liste_titre" align="left">';
444  print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
445 }
446 if (! empty($arrayfields['d.lastname']['checked']))
447 {
448  print '<td class="liste_titre" align="left">';
449  print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
450 }
451 if (! empty($arrayfields['d.company']['checked']))
452 {
453  print '<td class="liste_titre" align="left">';
454  print '<input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
455 }
456 if (! empty($arrayfields['d.login']['checked']))
457 {
458  print '<td class="liste_titre" align="left">';
459  print '<input class="flat maxwidth50" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
460 }
461 if (! empty($arrayfields['d.morphy']['checked']))
462 {
463  print '<td class="liste_titre" align="left">';
464  print '</td>';
465 }
466 if (! empty($arrayfields['t.libelle']['checked']))
467 {
468  print '<td class="liste_titre">';
469  $listetype=$membertypestatic->liste_array();
470  print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32);
471  print '</td>';
472 }
473 
474 if (! empty($arrayfields['d.address']['checked']))
475 {
476  print '<td class="liste_titre" align="left">';
477  print '<input class="flat maxwidth50" type="text" name="search_address" value="'.$search_address.'"></td>';
478 }
479 
480 if (! empty($arrayfields['d.zip']['checked']))
481 {
482  print '<td class="liste_titre" align="left">';
483  print '<input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
484 }
485 if (! empty($arrayfields['d.town']['checked']))
486 {
487  print '<td class="liste_titre" align="left">';
488  print '<input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
489 }
490 // State
491 if (! empty($arrayfields['state.nom']['checked']))
492 {
493  print '<td class="liste_titre">';
494  print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
495  print '</td>';
496 }
497 // Country
498 if (! empty($arrayfields['country.code_iso']['checked']))
499 {
500  print '<td class="liste_titre" align="center">';
501  print $form->select_country($search_country,'search_country','',0,'maxwidth100');
502  print '</td>';
503 }
504 // Phone pro
505 if (! empty($arrayfields['d.phone']['checked']))
506 {
507  print '<td class="liste_titre" align="left">';
508  print '<input class="flat maxwidth50" type="text" name="search_phone" value="'.$search_phone.'"></td>';
509 }
510 // Phone perso
511 if (! empty($arrayfields['d.phone_perso']['checked']))
512 {
513  print '<td class="liste_titre" align="left">';
514  print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>';
515 }
516 // Phone mobile
517 if (! empty($arrayfields['d.phone_mobile']['checked']))
518 {
519  print '<td class="liste_titre" align="left">';
520  print '<input class="flat maxwidth50" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>';
521 }
522 // Email
523 if (! empty($arrayfields['d.email']['checked']))
524 {
525  print '<td class="liste_titre" align="left">';
526  print '<input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>';
527 }
528 
529 if (! empty($arrayfields['d.datefin']['checked']))
530 {
531  print '<td class="liste_titre" align="left">';
532  print '</td>';
533 }
534 // Extra fields
535 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
536 
537 // Fields from hook
538 $parameters=array('arrayfields'=>$arrayfields);
539 $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
540 print $hookmanager->resPrint;
541 // Date creation
542 if (! empty($arrayfields['d.datec']['checked']))
543 {
544  print '<td class="liste_titre">';
545  print '</td>';
546 }
547 // Date modification
548 if (! empty($arrayfields['d.tms']['checked']))
549 {
550  print '<td class="liste_titre">';
551  print '</td>';
552 }
553 // Status
554 if (! empty($arrayfields['d.statut']['checked']))
555 {
556  print '<td class="liste_titre maxwidthonsmartphone" align="right">';
557  $liststatus=array(
558  '-1'=>$langs->trans("Draft"),
559  '1'=>$langs->trans("Validated"),
560  '0'=>$langs->trans("Resiliated")
561  );
562  print $form->selectarray('statut', $liststatus, $statut, -2);
563  print '</td>';
564 }
565 // Action column
566 print '<td class="liste_titre" align="middle">';
567 $searchpicto=$form->showFilterButtons();
568 print $searchpicto;
569 print '</td>';
570 
571 print "</tr>\n";
572 
573 print '<tr class="liste_titre">';
574 if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID",$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
575 if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder);
576 if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'],$_SERVER["PHP_SELF"],'d.civility','',$param,'',$sortfield,$sortorder);
577 if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder);
578 if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder);
579 if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder);
580 if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder);
581 if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder);
582 if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder);
583 if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder);
584 if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder);
585 if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder);
586 if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
587 if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
588 if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder);
589 if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'],$_SERVER["PHP_SELF"],'d.phone_perso','',$param,'',$sortfield,$sortorder);
590 if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'],$_SERVER["PHP_SELF"],'d.phone_mobile','',$param,'',$sortfield,$sortorder);
591 if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder);
592 if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder);
593 // Extra fields
594 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
595 
596 // Hook fields
597 $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
598 $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
599 print $hookmanager->resPrint;
600 if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
601 if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
602 if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder);
603 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
604 print "</tr>\n";
605 
606 $i = 0;
607 $totalarray=array();
608 while ($i < min($num, $limit))
609 {
610  $obj = $db->fetch_object($resql);
611 
612  $datefin=$db->jdate($obj->datefin);
613  $memberstatic->id=$obj->rowid;
614  $memberstatic->ref=$obj->rowid;
615  $memberstatic->civility_id=$obj->civility;
616  $memberstatic->lastname=$obj->lastname;
617  $memberstatic->firstname=$obj->firstname;
618  $memberstatic->statut=$obj->statut;
619  $memberstatic->datefin= $datefin;
620  $memberstatic->socid = $obj->fk_soc;
621  $memberstatic->photo = $obj->photo;
622 
623  if (! empty($obj->fk_soc)) {
624  $memberstatic->fetch_thirdparty();
625  $companyname=$memberstatic->thirdparty->name;
626  } else {
627  $companyname=$obj->company;
628  }
629  $memberstatic->societe = $companyname;
630 
631  print '<tr class="oddeven">';
632 
633  if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
634  {
635  print '<td align="center">'.$obj->rowid.'</td>';
636  if (! $i) $totalarray['nbfield']++;
637  }
638 
639  // Ref
640  if (! empty($arrayfields['d.ref']['checked']))
641  {
642  print "<td>";
643  print $memberstatic->getNomUrl(-1, 0, 'card', 'ref');
644  print "</td>\n";
645  if (! $i) $totalarray['nbfield']++;
646  }
647  // Civility
648  if (! empty($arrayfields['d.civility']['checked']))
649  {
650  print "<td>";
651  print $obj->civility;
652  print "</td>\n";
653  if (! $i) $totalarray['nbfield']++;
654  }
655  // Firstname
656  if (! empty($arrayfields['d.firstname']['checked']))
657  {
658  print "<td>";
659  print $obj->firstname;
660  print "</td>\n";
661  if (! $i) $totalarray['nbfield']++;
662  }
663  // Lastname
664  if (! empty($arrayfields['d.lastname']['checked']))
665  {
666  print "<td>";
667  print $obj->lastname;
668  print "</td>\n";
669  if (! $i) $totalarray['nbfield']++;
670  }
671  // Company
672  if (! empty($arrayfields['d.company']['checked']))
673  {
674  print "<td>";
675  print $companyname;
676  print "</td>\n";
677  }
678  // Login
679  if (! empty($arrayfields['d.login']['checked']))
680  {
681  print "<td>".$obj->login."</td>\n";
682  if (! $i) $totalarray['nbfield']++;
683  }
684  // Moral/Physique
685  if (! empty($arrayfields['d.morphy']['checked']))
686  {
687  print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n";
688  if (! $i) $totalarray['nbfield']++;
689  }
690  // Type label
691  if (! empty($arrayfields['t.libelle']['checked']))
692  {
693  $membertypestatic->id=$obj->type_id;
694  $membertypestatic->label=$obj->type;
695  print '<td class="nowrap">';
696  print $membertypestatic->getNomUrl(1,32);
697  print '</td>';
698  if (! $i) $totalarray['nbfield']++;
699  }
700  // Address
701  if (! empty($arrayfields['d.address']['checked']))
702  {
703  print '<td class="nocellnopadd">';
704  print $obj->address;
705  print '</td>';
706  if (! $i) $totalarray['nbfield']++;
707  }
708  // Zip
709  if (! empty($arrayfields['d.zip']['checked']))
710  {
711  print '<td class="nocellnopadd">';
712  print $obj->zip;
713  print '</td>';
714  if (! $i) $totalarray['nbfield']++;
715  }
716  // Town
717  if (! empty($arrayfields['d.town']['checked']))
718  {
719  print '<td class="nocellnopadd">';
720  print $obj->town;
721  print '</td>';
722  if (! $i) $totalarray['nbfield']++;
723  }
724  // State
725  if (! empty($arrayfields['state.nom']['checked']))
726  {
727  print "<td>".$obj->state_name."</td>\n";
728  if (! $i) $totalarray['nbfield']++;
729  }
730  // Country
731  if (! empty($arrayfields['country.code_iso']['checked']))
732  {
733  print '<td align="center">';
734  $tmparray=getCountry($obj->country,'all');
735  print $tmparray['label'];
736  print '</td>';
737  if (! $i) $totalarray['nbfield']++;
738  }
739  // Phone pro
740  if (! empty($arrayfields['d.phone']['checked']))
741  {
742  print '<td class="nocellnopadd">';
743  print $obj->phone;
744  print '</td>';
745  if (! $i) $totalarray['nbfield']++;
746  }
747  // Phone perso
748  if (! empty($arrayfields['d.phone_perso']['checked']))
749  {
750  print '<td class="nocellnopadd">';
751  print $obj->phone_perso;
752  print '</td>';
753  if (! $i) $totalarray['nbfield']++;
754  }
755  // Phone mobile
756  if (! empty($arrayfields['d.phone_mobile']['checked']))
757  {
758  print '<td class="nocellnopadd">';
759  print $obj->phone_mobile;
760  print '</td>';
761  if (! $i) $totalarray['nbfield']++;
762  }
763  // EMail
764  if (! empty($arrayfields['d.email']['checked']))
765  {
766  print "<td>".dol_print_email($obj->email,0,0,1)."</td>\n";
767  }
768  // End of subscription date
769  $datefin=$db->jdate($obj->datefin);
770  if (! empty($arrayfields['d.datefin']['checked']))
771  {
772  if ($datefin)
773  {
774  print '<td align="center" class="nowrap">';
775  print dol_print_date($datefin,'day');
776  if ($memberstatic->hasDelay()) {
777  $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay/60/60/24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay/60/60/24).' '.$langs->trans("days").')';
778  print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
779  }
780  print '</td>';
781  }
782  else
783  {
784  print '<td align="left" class="nowrap">';
785  if ($obj->subscription == 'yes')
786  {
787  print $langs->trans("SubscriptionNotReceived");
788  if ($obj->statut > 0) print " ".img_warning();
789  }
790  else
791  {
792  print '&nbsp;';
793  }
794  print '</td>';
795  }
796  }
797  // Extra fields
798  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
799  // Fields from hook
800  $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
801  $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
802  print $hookmanager->resPrint;
803  // Date creation
804  if (! empty($arrayfields['d.datec']['checked']))
805  {
806  print '<td align="center" class="nowrap">';
807  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
808  print '</td>';
809  if (! $i) $totalarray['nbfield']++;
810  }
811  // Date modification
812  if (! empty($arrayfields['d.tms']['checked']))
813  {
814  print '<td align="center" class="nowrap">';
815  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
816  print '</td>';
817  if (! $i) $totalarray['nbfield']++;
818  }
819  // Status
820  if (! empty($arrayfields['d.statut']['checked']))
821  {
822  print '<td align="right" class="nowrap">';
823  print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,5);
824  print '</td>';
825  if (! $i) $totalarray['nbfield']++;
826  }
827  // Action column
828  print '<td align="center">';
829  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
830  {
831  $selected=0;
832  if (in_array($obj->rowid, $arrayofselected)) $selected=1;
833  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
834  }
835  print '</td>';
836  if (! $i) $totalarray['nbfield']++;
837 
838  print "</tr>\n";
839  $i++;
840 }
841 
842 // Show total line
843 if (isset($totalarray['pos']))
844 {
845  print '<tr class="liste_total">';
846  $i=0;
847  while ($i < $totalarray['nbfield'])
848  {
849  $i++;
850  if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
851  else
852  {
853  if ($i == 1)
854  {
855  if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
856  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
857  }
858  else print '<td></td>';
859  }
860  }
861  print '</tr>';
862 }
863 
864 // If no record found
865 if ($num == 0)
866 {
867  $colspan=1;
868  foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
869  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
870 }
871 
872 $db->free($resql);
873 
874 $parameters=array('sql' => $sql);
875 $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
876 print $hookmanager->resPrint;
877 
878 print "</table>\n";
879 print "</div>";
880 print '</form>';
881 
882 if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1);
883 
884 // End of page
885 llxFooter();
886 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting a parameter.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Classe permettant la generation de composants html autre Only common components are here...
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:44
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='gmt')
Return date for now.
Class to manage members type.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.