list.php 35 KB

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