list.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  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. /**
  22. * \file htdocs/adherents/list.php
  23. * \ingroup member
  24. * \brief Page to list all members of foundation
  25. */
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.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.'/core/lib/company.lib.php';
  31. $langs->loadLangs(array("members","companies"));
  32. $action=GETPOST('action','aZ09');
  33. $massaction=GETPOST('massaction','alpha');
  34. $show_files=GETPOST('show_files','int');
  35. $confirm=GETPOST('confirm','alpha');
  36. $toselect = GETPOST('toselect', 'array');
  37. // Security check
  38. $result=restrictedArea($user,'adherent');
  39. $filter=GETPOST("filter",'alpha');
  40. $statut=GETPOST("statut",'intcomma');
  41. $search=GETPOST("search",'alpha');
  42. $search_ref=GETPOST("search_ref",'alpha');
  43. $search_lastname=GETPOST("search_lastname",'alpha');
  44. $search_firstname=GETPOST("search_firstname",'alpha');
  45. $search_civility=GETPOST("search_civility",'alpha');
  46. $search_login=GETPOST("search_login",'alpha');
  47. $search_address=GETPOST("search_address",'alpha');
  48. $search_zip=GETPOST("search_zip",'alpha');
  49. $search_town=GETPOST("search_town",'alpha');
  50. $search_state=GETPOST("search_state",'alpha');
  51. $search_country=GETPOST("search_country",'alpha');
  52. $search_phone=GETPOST("search_phone",'alpha');
  53. $search_phone_perso=GETPOST("search_phone_perso",'alpha');
  54. $search_phone_mobile=GETPOST("search_phone_mobile",'alpha');
  55. $search_type=GETPOST("search_type",'alpha');
  56. $search_email=GETPOST("search_email",'alpha');
  57. $search_categ = GETPOST("search_categ",'int');
  58. $catid = GETPOST("catid",'int');
  59. $optioncss = GETPOST('optioncss','alpha');
  60. $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
  61. if ($statut < -1) $statut = '';
  62. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  63. $sortfield = GETPOST("sortfield",'alpha');
  64. $sortorder = GETPOST("sortorder",'alpha');
  65. $page = GETPOST("page",'int');
  66. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  67. $offset = $limit * $page ;
  68. $pageprev = $page - 1;
  69. $pagenext = $page + 1;
  70. if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); }
  71. if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); }
  72. $object = new Adherent($db);
  73. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  74. $hookmanager->initHooks(array('memberlist'));
  75. $extrafields = new ExtraFields($db);
  76. // fetch optionals attributes and labels
  77. $extralabels = $extrafields->fetch_name_optionals_label('adherent');
  78. $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
  79. // List of fields to search into when doing a "search in all"
  80. $fieldstosearchall = array(
  81. 'd.rowid'=>'Ref',
  82. 'd.login'=>'Login',
  83. 'd.lastname'=>'Lastname',
  84. 'd.firstname'=>'Firstname',
  85. 'd.login'=>'Login',
  86. 'd.societe'=>"Company",
  87. 'd.email'=>'EMail',
  88. 'd.address'=>'Address',
  89. 'd.zip'=>'Zip',
  90. 'd.town'=>'Town',
  91. 'd.note_public'=>'NotePublic',
  92. 'd.note_private'=>'NotePrivate',
  93. );
  94. if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
  95. $arrayfields=array(
  96. 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  97. 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
  98. 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
  99. 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
  100. 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
  101. 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
  102. 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1),
  103. 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
  104. 'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
  105. 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
  106. 'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
  107. 'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
  108. 'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
  109. 'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
  110. 'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
  111. 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
  112. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  113. /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
  114. 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
  115. 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
  116. 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  117. 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  118. 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
  119. );
  120. // Extra fields
  121. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  122. {
  123. foreach($extrafields->attribute_label as $key => $val)
  124. {
  125. 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]));
  126. }
  127. }
  128. /*
  129. * Actions
  130. */
  131. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  132. if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
  133. $parameters=array('socid'=>$socid);
  134. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  135. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  136. if (empty($reshook))
  137. {
  138. // Selection of new fields
  139. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  140. // Purge search criteria
  141. 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
  142. {
  143. $search="";
  144. $search_ref="";
  145. $search_lastname="";
  146. $search_firstname="";
  147. $search_civility="";
  148. $search_login="";
  149. $search_company="";
  150. $search_type="";
  151. $search_email="";
  152. $search_address="";
  153. $search_zip="";
  154. $search_town="";
  155. $search_state="";
  156. $search_country='';
  157. $search_phone='';
  158. $search_phone_perso='';
  159. $search_phone_mobile='';
  160. $search_morphy="";
  161. $search_categ="";
  162. $catid="";
  163. $sall="";
  164. $statut='';
  165. $toselect='';
  166. $search_array_options=array();
  167. }
  168. // Mass actions
  169. $objectclass='Adherent';
  170. $objectlabel='Members';
  171. $permtoread = $user->rights->adherent->lire;
  172. $permtodelete = $user->rights->adherent->supprimer;
  173. $uploaddir = $conf->adherent->dir_output;
  174. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  175. }
  176. /*
  177. * View
  178. */
  179. $form=new Form($db);
  180. $formother=new FormOther($db);
  181. $membertypestatic=new AdherentType($db);
  182. $memberstatic=new Adherent($db);
  183. $now=dol_now();
  184. $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
  185. $sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
  186. $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,";
  187. $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
  188. $sql.= " t.libelle as type, t.subscription,";
  189. $sql.= " state.code_departement as state_code, state.nom as state_name";
  190. // Add fields from extrafields
  191. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  192. // Add fields from hooks
  193. $parameters=array();
  194. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  195. $sql.=$hookmanager->resPrint;
  196. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
  197. 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)";
  198. 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
  199. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
  200. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
  201. $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
  202. $sql.= " WHERE d.fk_adherent_type = t.rowid ";
  203. if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
  204. if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
  205. if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
  206. if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
  207. $sql.= " AND d.entity IN (".getEntity('adherent').")";
  208. if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
  209. if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
  210. if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
  211. if ($search_ref)
  212. {
  213. if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
  214. else $sql.=" AND 1 = 2"; // Always wrong
  215. }
  216. if ($search_civility) $sql.= natural_search("d.civility", $search_civility);
  217. if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname);
  218. if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
  219. if ($search_login) $sql.= natural_search("d.login", $search_login);
  220. if ($search_email) $sql.= natural_search("d.email", $search_email);
  221. if ($search_town) $sql.= natural_search("d.town",$search_town);
  222. if ($search_zip) $sql.= natural_search("d.zip",$search_zip);
  223. if ($search_state) $sql.= natural_search("state.nom",$search_state);
  224. if ($search_country) $sql .= " AND d.country IN (".$search_country.')';
  225. if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'";
  226. if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
  227. // Add where from extra fields
  228. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  229. // Add where from hooks
  230. $parameters=array();
  231. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  232. $sql.=$hookmanager->resPrint;
  233. $sql.= $db->order($sortfield,$sortorder);
  234. // Count total nb of records with no order and no limits
  235. $nbtotalofrecords = '';
  236. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  237. {
  238. $resql = $db->query($sql);
  239. if ($resql) $nbtotalofrecords = $db->num_rows($resql);
  240. else dol_print_error($db);
  241. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  242. {
  243. $page = 0;
  244. $offset = 0;
  245. }
  246. }
  247. // Add limit
  248. $sql.= $db->plimit($limit+1, $offset);
  249. dol_syslog("get list", LOG_DEBUG);
  250. $resql = $db->query($sql);
  251. if (! $resql)
  252. {
  253. dol_print_error($db);
  254. exit;
  255. }
  256. $num = $db->num_rows($resql);
  257. $arrayofselected=is_array($toselect)?$toselect:array();
  258. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
  259. {
  260. $obj = $db->fetch_object($resql);
  261. $id = $obj->rowid;
  262. header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
  263. exit;
  264. }
  265. llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  266. $titre=$langs->trans("MembersList");
  267. if (GETPOSTISSET("statut"))
  268. {
  269. if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
  270. if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); }
  271. if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
  272. if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
  273. if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
  274. if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); }
  275. }
  276. elseif ($action == 'search')
  277. {
  278. $titre=$langs->trans("MembersListQualified");
  279. }
  280. if ($search_type > 0)
  281. {
  282. $membertype=new AdherentType($db);
  283. $result=$membertype->fetch(GETPOST("type",'int'));
  284. $titre.=" (".$membertype->label.")";
  285. }
  286. $param='';
  287. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  288. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  289. if ($sall != "") $param.="&sall=".urlencode($sall);
  290. if ($statut != "") $param.="&statut=".urlencode($statut);
  291. if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
  292. if ($search_nom) $param.="&search_nom=".urlencode($search_nom);
  293. if ($search_civility) $param.="&search_civility=".urlencode($search_civility);
  294. if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname);
  295. if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname);
  296. if ($search_login) $param.="&search_login=".urlencode($search_login);
  297. if ($search_email) $param.="&search_email=".urlencode($search_email);
  298. if ($search_company) $param.="&search_company=".urlencode($search_company);
  299. if ($search_address != '') $param.= "&search_address=".urlencode($search_address);
  300. if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
  301. if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
  302. if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
  303. if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
  304. if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
  305. if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
  306. if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
  307. if ($filter) $param.="&filter=".urlencode($filter);
  308. if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
  309. if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
  310. // Add $param from extra fields
  311. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  312. // List of mass actions available
  313. $arrayofmassactions = array(
  314. //'presend'=>$langs->trans("SendByMail"),
  315. //'builddoc'=>$langs->trans("PDFMerge"),
  316. );
  317. if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
  318. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  319. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  320. $newcardbutton='';
  321. if ($user->rights->adherent->creer)
  322. {
  323. $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewMember').'</span>';
  324. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  325. $newcardbutton.= '</a>';
  326. }
  327. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  328. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  329. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  330. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  331. print '<input type="hidden" name="action" value="list">';
  332. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  333. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  334. print '<input type="hidden" name="page" value="'.$page.'">';
  335. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  336. print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
  337. $topicmail="Information";
  338. $modelmail="member";
  339. $objecttmp=new Adherent($db);
  340. $trackid='mem'.$object->id;
  341. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  342. if ($sall)
  343. {
  344. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  345. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
  346. }
  347. // Filter on categories
  348. $moreforfilter='';
  349. if (! empty($conf->categorie->enabled))
  350. {
  351. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  352. $moreforfilter.='<div class="divsearchfield">';
  353. $moreforfilter.=$langs->trans('Categories'). ': ';
  354. $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
  355. $moreforfilter.='</div>';
  356. }
  357. $parameters=array();
  358. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  359. if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
  360. else $moreforfilter = $hookmanager->resPrint;
  361. if (! empty($moreforfilter))
  362. {
  363. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  364. print $moreforfilter;
  365. print '</div>';
  366. }
  367. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  368. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  369. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  370. print '<div class="div-table-responsive">';
  371. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  372. // Line for filters fields
  373. print '<tr class="liste_titre_filter">';
  374. // Line numbering
  375. if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
  376. {
  377. print '<td class="liste_titre">&nbsp;</td>';
  378. }
  379. // Ref
  380. if (! empty($arrayfields['d.ref']['checked']))
  381. {
  382. print '<td class="liste_titre">';
  383. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  384. print '</td>';
  385. }
  386. if (! empty($arrayfields['d.civility']['checked']))
  387. {
  388. print '<td class="liste_titre" align="left">';
  389. print '<input class="flat maxwidth25" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
  390. }
  391. if (! empty($arrayfields['d.firstname']['checked']))
  392. {
  393. print '<td class="liste_titre" align="left">';
  394. print '<input class="flat maxwidth50" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
  395. }
  396. if (! empty($arrayfields['d.lastname']['checked']))
  397. {
  398. print '<td class="liste_titre" align="left">';
  399. print '<input class="flat maxwidth50" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
  400. }
  401. if (! empty($arrayfields['d.company']['checked']))
  402. {
  403. print '<td class="liste_titre" align="left">';
  404. print '<input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
  405. }
  406. if (! empty($arrayfields['d.login']['checked']))
  407. {
  408. print '<td class="liste_titre" align="left">';
  409. print '<input class="flat maxwidth50" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
  410. }
  411. if (! empty($arrayfields['d.morphy']['checked']))
  412. {
  413. print '<td class="liste_titre" align="left">';
  414. print '</td>';
  415. }
  416. if (! empty($arrayfields['t.libelle']['checked']))
  417. {
  418. print '<td class="liste_titre">';
  419. $listetype=$membertypestatic->liste_array();
  420. print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32);
  421. print '</td>';
  422. }
  423. if (! empty($arrayfields['d.address']['checked']))
  424. {
  425. print '<td class="liste_titre" align="left">';
  426. print '<input class="flat maxwidth50" type="text" name="search_address" value="'.$search_address.'"></td>';
  427. }
  428. if (! empty($arrayfields['d.zip']['checked']))
  429. {
  430. print '<td class="liste_titre" align="left">';
  431. print '<input class="flat maxwidth50" type="text" name="search_zip" value="'.$search_zip.'"></td>';
  432. }
  433. if (! empty($arrayfields['d.town']['checked']))
  434. {
  435. print '<td class="liste_titre" align="left">';
  436. print '<input class="flat maxwidth50" type="text" name="search_town" value="'.$search_town.'"></td>';
  437. }
  438. // State
  439. if (! empty($arrayfields['state.nom']['checked']))
  440. {
  441. print '<td class="liste_titre">';
  442. print '<input class="flat searchstring maxwidth50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  443. print '</td>';
  444. }
  445. // Country
  446. if (! empty($arrayfields['country.code_iso']['checked']))
  447. {
  448. print '<td class="liste_titre" align="center">';
  449. print $form->select_country($search_country,'search_country','',0,'maxwidth100');
  450. print '</td>';
  451. }
  452. // Phone pro
  453. if (! empty($arrayfields['d.phone']['checked']))
  454. {
  455. print '<td class="liste_titre" align="left">';
  456. print '<input class="flat maxwidth50" type="text" name="search_phone" value="'.$search_phone.'"></td>';
  457. }
  458. // Phone perso
  459. if (! empty($arrayfields['d.phone_perso']['checked']))
  460. {
  461. print '<td class="liste_titre" align="left">';
  462. print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>';
  463. }
  464. // Phone mobile
  465. if (! empty($arrayfields['d.phone_mobile']['checked']))
  466. {
  467. print '<td class="liste_titre" align="left">';
  468. print '<input class="flat maxwidth50" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>';
  469. }
  470. // Email
  471. if (! empty($arrayfields['d.email']['checked']))
  472. {
  473. print '<td class="liste_titre" align="left">';
  474. print '<input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>';
  475. }
  476. if (! empty($arrayfields['d.datefin']['checked']))
  477. {
  478. print '<td class="liste_titre" align="left">';
  479. print '</td>';
  480. }
  481. // Extra fields
  482. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  483. // Fields from hook
  484. $parameters=array('arrayfields'=>$arrayfields);
  485. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  486. print $hookmanager->resPrint;
  487. // Date creation
  488. if (! empty($arrayfields['d.datec']['checked']))
  489. {
  490. print '<td class="liste_titre">';
  491. print '</td>';
  492. }
  493. // Date modification
  494. if (! empty($arrayfields['d.tms']['checked']))
  495. {
  496. print '<td class="liste_titre">';
  497. print '</td>';
  498. }
  499. // Status
  500. if (! empty($arrayfields['d.statut']['checked']))
  501. {
  502. print '<td class="liste_titre maxwidthonsmartphone" align="right">';
  503. $liststatus=array(
  504. '-1'=>$langs->trans("Draft"),
  505. '1'=>$langs->trans("Validated"),
  506. '0'=>$langs->trans("Resiliated")
  507. );
  508. print $form->selectarray('statut', $liststatus, $statut, -2);
  509. print '</td>';
  510. }
  511. // Action column
  512. print '<td class="liste_titre" align="middle">';
  513. $searchpicto=$form->showFilterButtons();
  514. print $searchpicto;
  515. print '</td>';
  516. print "</tr>\n";
  517. print '<tr class="liste_titre">';
  518. if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID",$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
  519. if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder);
  520. if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'],$_SERVER["PHP_SELF"],'d.civility','',$param,'',$sortfield,$sortorder);
  521. if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder);
  522. if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder);
  523. if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder);
  524. if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder);
  525. if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder);
  526. if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder);
  527. if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder);
  528. if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder);
  529. if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder);
  530. if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
  531. 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);
  532. if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder);
  533. 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);
  534. 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);
  535. if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder);
  536. if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder);
  537. // Extra fields
  538. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  539. // Hook fields
  540. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  541. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  542. print $hookmanager->resPrint;
  543. 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);
  544. 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);
  545. if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder);
  546. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  547. print "</tr>\n";
  548. $i = 0;
  549. $totalarray=array();
  550. while ($i < min($num, $limit))
  551. {
  552. $obj = $db->fetch_object($resql);
  553. $datefin=$db->jdate($obj->datefin);
  554. $memberstatic->id=$obj->rowid;
  555. $memberstatic->ref=$obj->rowid;
  556. $memberstatic->civility_id=$obj->civility;
  557. $memberstatic->lastname=$obj->lastname;
  558. $memberstatic->firstname=$obj->firstname;
  559. $memberstatic->statut=$obj->statut;
  560. $memberstatic->datefin= $datefin;
  561. $memberstatic->socid = $obj->fk_soc;
  562. $memberstatic->photo = $obj->photo;
  563. if (! empty($obj->fk_soc)) {
  564. $memberstatic->fetch_thirdparty();
  565. $companyname=$memberstatic->thirdparty->name;
  566. } else {
  567. $companyname=$obj->company;
  568. }
  569. $memberstatic->societe = $companyname;
  570. print '<tr class="oddeven">';
  571. if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
  572. {
  573. print '<td align="center">'.$obj->rowid.'</td>';
  574. if (! $i) $totalarray['nbfield']++;
  575. }
  576. // Ref
  577. if (! empty($arrayfields['d.ref']['checked']))
  578. {
  579. print "<td>";
  580. print $memberstatic->getNomUrl(-1, 0, 'card', 'ref');
  581. print "</td>\n";
  582. if (! $i) $totalarray['nbfield']++;
  583. }
  584. // Civility
  585. if (! empty($arrayfields['d.civility']['checked']))
  586. {
  587. print "<td>";
  588. print $obj->civility;
  589. print "</td>\n";
  590. if (! $i) $totalarray['nbfield']++;
  591. }
  592. // Firstname
  593. if (! empty($arrayfields['d.firstname']['checked']))
  594. {
  595. print "<td>";
  596. print $obj->firstname;
  597. print "</td>\n";
  598. if (! $i) $totalarray['nbfield']++;
  599. }
  600. // Lastname
  601. if (! empty($arrayfields['d.lastname']['checked']))
  602. {
  603. print "<td>";
  604. print $obj->lastname;
  605. print "</td>\n";
  606. if (! $i) $totalarray['nbfield']++;
  607. }
  608. // Company
  609. if (! empty($arrayfields['d.company']['checked']))
  610. {
  611. print "<td>";
  612. print $companyname;
  613. print "</td>\n";
  614. }
  615. // Login
  616. if (! empty($arrayfields['d.login']['checked']))
  617. {
  618. print "<td>".$obj->login."</td>\n";
  619. if (! $i) $totalarray['nbfield']++;
  620. }
  621. // Moral/Physique
  622. if (! empty($arrayfields['d.morphy']['checked']))
  623. {
  624. print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n";
  625. if (! $i) $totalarray['nbfield']++;
  626. }
  627. // Type label
  628. if (! empty($arrayfields['t.libelle']['checked']))
  629. {
  630. $membertypestatic->id=$obj->type_id;
  631. $membertypestatic->label=$obj->type;
  632. print '<td class="nowrap">';
  633. print $membertypestatic->getNomUrl(1,32);
  634. print '</td>';
  635. if (! $i) $totalarray['nbfield']++;
  636. }
  637. // Address
  638. if (! empty($arrayfields['d.address']['checked']))
  639. {
  640. print '<td class="nocellnopadd">';
  641. print $obj->address;
  642. print '</td>';
  643. if (! $i) $totalarray['nbfield']++;
  644. }
  645. // Zip
  646. if (! empty($arrayfields['d.zip']['checked']))
  647. {
  648. print '<td class="nocellnopadd">';
  649. print $obj->zip;
  650. print '</td>';
  651. if (! $i) $totalarray['nbfield']++;
  652. }
  653. // Town
  654. if (! empty($arrayfields['d.town']['checked']))
  655. {
  656. print '<td class="nocellnopadd">';
  657. print $obj->town;
  658. print '</td>';
  659. if (! $i) $totalarray['nbfield']++;
  660. }
  661. // State
  662. if (! empty($arrayfields['state.nom']['checked']))
  663. {
  664. print "<td>".$obj->state_name."</td>\n";
  665. if (! $i) $totalarray['nbfield']++;
  666. }
  667. // Country
  668. if (! empty($arrayfields['country.code_iso']['checked']))
  669. {
  670. print '<td align="center">';
  671. $tmparray=getCountry($obj->country,'all');
  672. print $tmparray['label'];
  673. print '</td>';
  674. if (! $i) $totalarray['nbfield']++;
  675. }
  676. // Phone pro
  677. if (! empty($arrayfields['d.phone']['checked']))
  678. {
  679. print '<td class="nocellnopadd">';
  680. print $obj->phone;
  681. print '</td>';
  682. if (! $i) $totalarray['nbfield']++;
  683. }
  684. // Phone perso
  685. if (! empty($arrayfields['d.phone_perso']['checked']))
  686. {
  687. print '<td class="nocellnopadd">';
  688. print $obj->phone_perso;
  689. print '</td>';
  690. if (! $i) $totalarray['nbfield']++;
  691. }
  692. // Phone mobile
  693. if (! empty($arrayfields['d.phone_mobile']['checked']))
  694. {
  695. print '<td class="nocellnopadd">';
  696. print $obj->phone_mobile;
  697. print '</td>';
  698. if (! $i) $totalarray['nbfield']++;
  699. }
  700. // EMail
  701. if (! empty($arrayfields['d.email']['checked']))
  702. {
  703. print "<td>".dol_print_email($obj->email,0,0,1)."</td>\n";
  704. }
  705. // End of subscription date
  706. $datefin=$db->jdate($obj->datefin);
  707. if (! empty($arrayfields['d.datefin']['checked']))
  708. {
  709. if ($datefin)
  710. {
  711. print '<td align="center" class="nowrap">';
  712. print dol_print_date($datefin,'day');
  713. if ($memberstatic->hasDelay()) {
  714. $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").')';
  715. print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
  716. }
  717. print '</td>';
  718. }
  719. else
  720. {
  721. print '<td align="left" class="nowrap">';
  722. if ($obj->subscription == 'yes')
  723. {
  724. print $langs->trans("SubscriptionNotReceived");
  725. if ($obj->statut > 0) print " ".img_warning();
  726. }
  727. else
  728. {
  729. print '&nbsp;';
  730. }
  731. print '</td>';
  732. }
  733. }
  734. // Extra fields
  735. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  736. // Fields from hook
  737. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  738. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  739. print $hookmanager->resPrint;
  740. // Date creation
  741. if (! empty($arrayfields['d.datec']['checked']))
  742. {
  743. print '<td align="center" class="nowrap">';
  744. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  745. print '</td>';
  746. if (! $i) $totalarray['nbfield']++;
  747. }
  748. // Date modification
  749. if (! empty($arrayfields['d.tms']['checked']))
  750. {
  751. print '<td align="center" class="nowrap">';
  752. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  753. print '</td>';
  754. if (! $i) $totalarray['nbfield']++;
  755. }
  756. // Status
  757. if (! empty($arrayfields['d.statut']['checked']))
  758. {
  759. print '<td align="right" class="nowrap">';
  760. print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,5);
  761. print '</td>';
  762. if (! $i) $totalarray['nbfield']++;
  763. }
  764. // Action column
  765. print '<td align="center">';
  766. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  767. {
  768. $selected=0;
  769. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  770. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  771. }
  772. print '</td>';
  773. if (! $i) $totalarray['nbfield']++;
  774. print "</tr>\n";
  775. $i++;
  776. }
  777. // Show total line
  778. if (isset($totalarray['pos']))
  779. {
  780. print '<tr class="liste_total">';
  781. $i=0;
  782. while ($i < $totalarray['nbfield'])
  783. {
  784. $i++;
  785. if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
  786. else
  787. {
  788. if ($i == 1)
  789. {
  790. if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
  791. else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
  792. }
  793. else print '<td></td>';
  794. }
  795. }
  796. print '</tr>';
  797. }
  798. // If no record found
  799. if ($num == 0)
  800. {
  801. $colspan=1;
  802. foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
  803. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  804. }
  805. $db->free($resql);
  806. $parameters=array('sql' => $sql);
  807. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  808. print $hookmanager->resPrint;
  809. print "</table>\n";
  810. print "</div>";
  811. print '</form>';
  812. if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1);
  813. // End of page
  814. llxFooter();
  815. $db->close();