list.php 34 KB

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