list.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  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. * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
  8. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/adherents/list.php
  25. * \ingroup member
  26. * \brief Page to list all members of foundation
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  33. $langs->loadLangs(array("members", "companies"));
  34. $action = GETPOST('action', 'aZ09');
  35. $massaction = GETPOST('massaction', 'alpha');
  36. $show_files = GETPOST('show_files', 'int');
  37. $confirm = GETPOST('confirm', 'alpha');
  38. $toselect = GETPOST('toselect', 'array');
  39. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search
  40. $search = GETPOST("search", 'alpha');
  41. $search_ref = GETPOST("search_ref", 'alpha');
  42. $search_lastname = GETPOST("search_lastname", 'alpha');
  43. $search_firstname = GETPOST("search_firstname", 'alpha');
  44. $search_gender = GETPOST("search_gender", 'alpha');
  45. $search_civility = GETPOST("search_civility", 'alpha');
  46. $search_company = GETPOST('search_company', 'alphanohtml');
  47. $search_login = GETPOST("search_login", 'alpha');
  48. $search_address = GETPOST("search_address", 'alpha');
  49. $search_zip = GETPOST("search_zip", 'alpha');
  50. $search_town = GETPOST("search_town", 'alpha');
  51. $search_state = GETPOST("search_state", 'alpha');
  52. $search_country = GETPOST("search_country", 'alpha');
  53. $search_phone = GETPOST("search_phone", 'alpha');
  54. $search_phone_perso = GETPOST("search_phone_perso", 'alpha');
  55. $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha');
  56. $search_type = GETPOST("search_type", 'alpha');
  57. $search_email = GETPOST("search_email", 'alpha');
  58. $search_categ = GETPOST("search_categ", 'int');
  59. $search_filter = GETPOST("search_filter", 'alpha');
  60. $search_status = GETPOST("search_status", 'intcomma');
  61. $catid = GETPOST("catid", 'int');
  62. $optioncss = GETPOST('optioncss', 'alpha');
  63. $socid = GETPOST('socid', 'int');
  64. $filter = GETPOST("filter", 'alpha');
  65. if ($filter) {
  66. $search_filter = $filter; // For backward compatibility
  67. }
  68. $statut = GETPOST("statut", 'alpha');
  69. if ($statut != '') {
  70. $search_status = $statut; // For backward compatibility
  71. }
  72. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  73. if ($search_status < -2) {
  74. $search_status = '';
  75. }
  76. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  77. $sortfield = GETPOST('sortfield', 'aZ09comma');
  78. $sortorder = GETPOST('sortorder', 'aZ09comma');
  79. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  80. if (empty($page) || $page == -1) {
  81. $page = 0;
  82. } // If $page is not defined, or '' or -1
  83. $offset = $limit * $page;
  84. $pageprev = $page - 1;
  85. $pagenext = $page + 1;
  86. if (!$sortorder) {
  87. $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC");
  88. }
  89. if (!$sortfield) {
  90. $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname");
  91. }
  92. $object = new Adherent($db);
  93. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  94. $hookmanager->initHooks(array('memberlist'));
  95. $extrafields = new ExtraFields($db);
  96. // fetch optionals attributes and labels
  97. $extrafields->fetch_name_optionals_label($object->table_element);
  98. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  99. // List of fields to search into when doing a "search in all"
  100. $fieldstosearchall = array(
  101. 'd.ref'=>'Ref',
  102. 'd.login'=>'Login',
  103. 'd.lastname'=>'Lastname',
  104. 'd.firstname'=>'Firstname',
  105. 'd.login'=>'Login',
  106. 'd.societe'=>"Company",
  107. 'd.email'=>'EMail',
  108. 'd.address'=>'Address',
  109. 'd.zip'=>'Zip',
  110. 'd.town'=>'Town',
  111. 'd.phone'=>"Phone",
  112. 'd.phone_perso'=>"PhonePerso",
  113. 'd.phone_mobile'=>"PhoneMobile",
  114. 'd.note_public'=>'NotePublic',
  115. 'd.note_private'=>'NotePrivate',
  116. );
  117. if ($db->type == 'pgsql') {
  118. unset($fieldstosearchall['d.rowid']);
  119. }
  120. $arrayfields = array(
  121. 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
  122. 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
  123. 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
  124. 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
  125. 'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0),
  126. 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
  127. 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
  128. 'd.morphy'=>array('label'=>$langs->trans("MemberNature"), 'checked'=>1),
  129. 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
  130. 'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
  131. 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
  132. 'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
  133. 'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
  134. 'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
  135. 'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
  136. 'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
  137. 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
  138. 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
  139. /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
  140. 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
  141. 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
  142. 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
  143. 'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500),
  144. 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
  145. 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
  146. );
  147. // Extra fields
  148. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  149. // Security check
  150. $result = restrictedArea($user, 'adherent');
  151. /*
  152. * Actions
  153. */
  154. if (GETPOST('cancel', 'alpha')) {
  155. $action = 'list'; $massaction = '';
  156. }
  157. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
  158. $massaction = '';
  159. }
  160. $parameters = array('socid'=>isset($socid) ? $socid : null);
  161. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  162. if ($reshook < 0) {
  163. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  164. }
  165. if (empty($reshook)) {
  166. // Selection of new fields
  167. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  168. // Purge search criteria
  169. 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
  170. $statut = '';
  171. $filter = '';
  172. $search = "";
  173. $search_ref = "";
  174. $search_lastname = "";
  175. $search_firstname = "";
  176. $search_gender = "";
  177. $search_civility = "";
  178. $search_login = "";
  179. $search_company = "";
  180. $search_type = "";
  181. $search_email = "";
  182. $search_address = "";
  183. $search_zip = "";
  184. $search_town = "";
  185. $search_state = "";
  186. $search_country = '';
  187. $search_phone = '';
  188. $search_phone_perso = '';
  189. $search_phone_mobile = '';
  190. $search_morphy = "";
  191. $search_categ = "";
  192. $search_filter = "";
  193. $search_status = "";
  194. $catid = "";
  195. $sall = "";
  196. $toselect = '';
  197. $search_array_options = array();
  198. }
  199. // Close
  200. if ($massaction == 'close' && $user->rights->adherent->creer) {
  201. $tmpmember = new Adherent($db);
  202. $error = 0;
  203. $nbclose = 0;
  204. $db->begin();
  205. foreach ($toselect as $idtoclose) {
  206. $tmpmember->fetch($idtoclose);
  207. $result = $tmpmember->resiliate($user);
  208. if ($result < 0 && !count($tmpmember->errors)) {
  209. setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
  210. } else {
  211. if ($result > 0) {
  212. $nbclose++;
  213. }
  214. }
  215. }
  216. if (!$error) {
  217. setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
  218. $db->commit();
  219. } else {
  220. $db->rollback();
  221. }
  222. }
  223. // Create external user
  224. if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) {
  225. $tmpmember = new Adherent($db);
  226. $error = 0;
  227. $nbcreated = 0;
  228. $db->begin();
  229. foreach ($toselect as $idtoclose) {
  230. $tmpmember->fetch($idtoclose);
  231. if (!empty($tmpmember->fk_soc)) {
  232. $nuser = new User($db);
  233. $tmpuser = dol_clone($tmpmember);
  234. $result = $nuser->create_from_member($tmpuser, $tmpmember->login);
  235. if ($result < 0 && !count($tmpmember->errors)) {
  236. setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
  237. } else {
  238. if ($result > 0) {
  239. $nbcreated++;
  240. }
  241. }
  242. }
  243. }
  244. if (!$error) {
  245. setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs');
  246. $db->commit();
  247. } else {
  248. $db->rollback();
  249. }
  250. }
  251. // Mass actions
  252. $objectclass = 'Adherent';
  253. $objectlabel = 'Members';
  254. $permissiontoread = $user->rights->adherent->lire;
  255. $permissiontodelete = $user->rights->adherent->supprimer;
  256. $permissiontoadd = $user->rights->adherent->creer;
  257. $uploaddir = $conf->adherent->dir_output;
  258. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  259. }
  260. /*
  261. * View
  262. */
  263. $form = new Form($db);
  264. $formother = new FormOther($db);
  265. $membertypestatic = new AdherentType($db);
  266. $memberstatic = new Adherent($db);
  267. $now = dol_now();
  268. if (!empty($search_categ) || !empty($catid)) {
  269. $sql = "SELECT DISTINCT";
  270. } else {
  271. $sql = "SELECT";
  272. }
  273. $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
  274. $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
  275. $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,";
  276. $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
  277. $sql .= " d.note_private, d.note_public,";
  278. $sql .= " s.nom,";
  279. $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,";
  280. $sql .= " t.libelle as type, t.subscription,";
  281. $sql .= " state.code_departement as state_code, state.nom as state_name,";
  282. // Add fields from extrafields
  283. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  284. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  285. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : '');
  286. }
  287. }
  288. // Add fields from hooks
  289. $parameters = array();
  290. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
  291. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  292. $sql = preg_replace('/,\s*$/', '', $sql);
  293. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
  294. if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  295. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
  296. }
  297. if (!empty($search_categ) || !empty($catid)) {
  298. // We need this table joined to the select in order to filter by categ
  299. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
  300. }
  301. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
  302. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
  303. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
  304. $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
  305. $sql .= " WHERE d.fk_adherent_type = t.rowid";
  306. if ($catid > 0) {
  307. $sql .= " AND cm.fk_categorie = ".((int) $catid);
  308. }
  309. if ($catid == -2) {
  310. $sql .= " AND cm.fk_categorie IS NULL";
  311. }
  312. if ($search_categ > 0) {
  313. $sql .= " AND cm.fk_categorie = ".((int) $search_categ);
  314. }
  315. if ($search_categ == -2) {
  316. $sql .= " AND cm.fk_categorie IS NULL";
  317. }
  318. $sql .= " AND d.entity IN (".getEntity('adherent').")";
  319. if ($sall) {
  320. $sql .= natural_search(array_keys($fieldstosearchall), $sall);
  321. }
  322. if ($search_type > 0) {
  323. $sql .= " AND t.rowid=".((int) $search_type);
  324. }
  325. if ($search_filter == 'withoutsubscription') {
  326. $sql .= " AND (datefin IS NULL OR t.subscription = '0')";
  327. }
  328. if ($search_filter == 'uptodate') {
  329. $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = '0')";
  330. }
  331. if ($search_filter == 'outofdate') {
  332. $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = '1')";
  333. }
  334. if ($search_status != '') {
  335. // Peut valoir un nombre ou liste de nombre separes par virgules
  336. $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
  337. }
  338. if ($search_ref) {
  339. $sql .= natural_search("d.ref", $search_ref);
  340. }
  341. if ($search_civility) {
  342. $sql .= natural_search("d.civility", $search_civility);
  343. }
  344. if ($search_firstname) {
  345. $sql .= natural_search("d.firstname", $search_firstname);
  346. }
  347. if ($search_lastname) {
  348. $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
  349. }
  350. if ($search_gender != '' && $search_gender != '-1') {
  351. $sql .= natural_search("d.gender", $search_gender);
  352. }
  353. if ($search_login) {
  354. $sql .= natural_search("d.login", $search_login);
  355. }
  356. if ($search_company) {
  357. $sql .= natural_search("s.nom", $search_company);
  358. }
  359. if ($search_email) {
  360. $sql .= natural_search("d.email", $search_email);
  361. }
  362. if ($search_address) {
  363. $sql .= natural_search("d.address", $search_address);
  364. }
  365. if ($search_town) {
  366. $sql .= natural_search("d.town", $search_town);
  367. }
  368. if ($search_zip) {
  369. $sql .= natural_search("d.zip", $search_zip);
  370. }
  371. if ($search_state) {
  372. $sql .= natural_search("state.nom", $search_state);
  373. }
  374. if ($search_phone) {
  375. $sql .= natural_search("d.phone", $search_phone);
  376. }
  377. if ($search_phone_perso) {
  378. $sql .= natural_search("d.phone_perso", $search_phone_perso);
  379. }
  380. if ($search_phone_mobile) {
  381. $sql .= natural_search("d.phone_mobile", $search_phone_mobile);
  382. }
  383. if ($search_country) {
  384. $sql .= " AND d.country IN (".$db->sanitize($search_country).')';
  385. }
  386. // Add where from extra fields
  387. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  388. // Add where from hooks
  389. $parameters = array();
  390. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
  391. $sql .= $hookmanager->resPrint;
  392. $sql .= $db->order($sortfield, $sortorder);
  393. // Count total nb of records with no order and no limits
  394. $nbtotalofrecords = '';
  395. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  396. $resql = $db->query($sql);
  397. if ($resql) {
  398. $nbtotalofrecords = $db->num_rows($resql);
  399. } else {
  400. dol_print_error($db);
  401. }
  402. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  403. $page = 0;
  404. $offset = 0;
  405. }
  406. }
  407. // Add limit
  408. $sql .= $db->plimit($limit + 1, $offset);
  409. dol_syslog("get list", LOG_DEBUG);
  410. $resql = $db->query($sql);
  411. if (!$resql) {
  412. dol_print_error($db);
  413. exit;
  414. }
  415. $num = $db->num_rows($resql);
  416. $arrayofselected = is_array($toselect) ? $toselect : array();
  417. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
  418. $obj = $db->fetch_object($resql);
  419. $id = $obj->rowid;
  420. header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id);
  421. exit;
  422. }
  423. llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  424. $titre = $langs->trans("MembersList");
  425. if (GETPOSTISSET("search_status")) {
  426. if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED
  427. $titre = $langs->trans("MembersListQualified");
  428. }
  429. if ($search_status == Adherent::STATUS_DRAFT) {
  430. $titre = $langs->trans("MembersListToValid");
  431. }
  432. if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') {
  433. $titre = $langs->trans("MembersValidated");
  434. }
  435. if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') {
  436. $titre = $langs->trans("MembersWithSubscriptionToReceive");
  437. }
  438. if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'uptodate') {
  439. $titre = $langs->trans("MembersListUpToDate");
  440. }
  441. if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'outofdate') {
  442. $titre = $langs->trans("MembersListNotUpToDate");
  443. }
  444. if ((string) $search_status == (string) Adherent::STATUS_RESILIATED) { // The cast to string is required to have test false when search_status is ''
  445. $titre = $langs->trans("MembersListResiliated");
  446. }
  447. if ($search_status == Adherent::STATUS_EXCLUDED) {
  448. $titre = $langs->trans("MembersListExcluded");
  449. }
  450. } elseif ($action == 'search') {
  451. $titre = $langs->trans("MembersListQualified");
  452. }
  453. if ($search_type > 0) {
  454. $membertype = new AdherentType($db);
  455. $result = $membertype->fetch(GETPOST("type", 'int'));
  456. $titre .= " (".$membertype->label.")";
  457. }
  458. $param = '';
  459. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  460. $param .= '&contextpage='.urlencode($contextpage);
  461. }
  462. if ($limit > 0 && $limit != $conf->liste_limit) {
  463. $param .= '&limit='.urlencode($limit);
  464. }
  465. if ($sall != "") {
  466. $param .= "&sall=".urlencode($sall);
  467. }
  468. if ($search_ref) {
  469. $param .= "&search_ref=".urlencode($search_ref);
  470. }
  471. if ($search_civility) {
  472. $param .= "&search_civility=".urlencode($search_civility);
  473. }
  474. if ($search_firstname) {
  475. $param .= "&search_firstname=".urlencode($search_firstname);
  476. }
  477. if ($search_lastname) {
  478. $param .= "&search_lastname=".urlencode($search_lastname);
  479. }
  480. if ($search_gender) {
  481. $param .= "&search_gender=".urlencode($search_gender);
  482. }
  483. if ($search_login) {
  484. $param .= "&search_login=".urlencode($search_login);
  485. }
  486. if ($search_email) {
  487. $param .= "&search_email=".urlencode($search_email);
  488. }
  489. if ($search_categ) {
  490. $param .= "&search_categ=".urlencode($search_categ);
  491. }
  492. if ($search_company) {
  493. $param .= "&search_company=".urlencode($search_company);
  494. }
  495. if ($search_address != '') {
  496. $param .= "&search_address=".urlencode($search_address);
  497. }
  498. if ($search_town != '') {
  499. $param .= "&search_town=".urlencode($search_town);
  500. }
  501. if ($search_zip != '') {
  502. $param .= "&search_zip=".urlencode($search_zip);
  503. }
  504. if ($search_state != '') {
  505. $param .= "&search_state=".urlencode($search_state);
  506. }
  507. if ($search_country != '') {
  508. $param .= "&search_country=".urlencode($search_country);
  509. }
  510. if ($search_phone != '') {
  511. $param .= "&search_phone=".urlencode($search_phone);
  512. }
  513. if ($search_phone_perso != '') {
  514. $param .= "&search_phone_perso=".urlencode($search_phone_perso);
  515. }
  516. if ($search_phone_mobile != '') {
  517. $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
  518. }
  519. if ($search_filter && $search_filter != '-1') {
  520. $param .= "&search_filter=".urlencode($search_filter);
  521. }
  522. if ($search_status != "" && $search_status != Adherent::STATUS_DRAFT) {
  523. $param .= "&search_status=".urlencode($search_status);
  524. }
  525. if ($search_type > 0) {
  526. $param .= "&search_type=".urlencode($search_type);
  527. }
  528. if ($optioncss != '') {
  529. $param .= '&optioncss='.urlencode($optioncss);
  530. }
  531. // Add $param from extra fields
  532. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  533. // List of mass actions available
  534. $arrayofmassactions = array(
  535. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').'&ensp;'.$langs->trans("SendByMail"),
  536. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  537. );
  538. if ($user->rights->adherent->creer) {
  539. $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Resiliate");
  540. }
  541. if ($user->rights->adherent->supprimer) {
  542. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  543. }
  544. if ($user->rights->societe->creer) {
  545. $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
  546. }
  547. if ($user->rights->adherent->creer && $user->rights->user->user->creer) {
  548. $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
  549. }
  550. if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
  551. $arrayofmassactions = array();
  552. }
  553. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  554. $newcardbutton = '';
  555. if ($user->rights->adherent->creer) {
  556. $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create');
  557. }
  558. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  559. if ($optioncss != '') {
  560. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  561. }
  562. print '<input type="hidden" name="token" value="'.newToken().'">';
  563. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  564. print '<input type="hidden" name="action" value="list">';
  565. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  566. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  567. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  568. print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  569. $topicmail = "Information";
  570. $modelmail = "member";
  571. $objecttmp = new Adherent($db);
  572. $trackid = 'mem'.$object->id;
  573. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  574. if ($sall) {
  575. foreach ($fieldstosearchall as $key => $val) {
  576. $fieldstosearchall[$key] = $langs->trans($val);
  577. }
  578. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
  579. }
  580. // Filter on categories
  581. $moreforfilter = '';
  582. if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
  583. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  584. $moreforfilter .= '<div class="divsearchfield">';
  585. $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
  586. $moreforfilter .= '</div>';
  587. }
  588. $parameters = array();
  589. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  590. if (empty($reshook)) {
  591. $moreforfilter .= $hookmanager->resPrint;
  592. } else {
  593. $moreforfilter = $hookmanager->resPrint;
  594. }
  595. if (!empty($moreforfilter)) {
  596. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  597. print $moreforfilter;
  598. print '</div>';
  599. }
  600. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  601. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  602. if ($massactionbutton) {
  603. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  604. }
  605. print '<div class="div-table-responsive">';
  606. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  607. // Line for filters fields
  608. print '<tr class="liste_titre_filter">';
  609. // Line numbering
  610. if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
  611. print '<td class="liste_titre">&nbsp;</td>';
  612. }
  613. // Ref
  614. if (!empty($arrayfields['d.ref']['checked'])) {
  615. print '<td class="liste_titre">';
  616. print '<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  617. print '</td>';
  618. }
  619. if (!empty($arrayfields['d.civility']['checked'])) {
  620. print '<td class="liste_titre left">';
  621. print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>';
  622. }
  623. if (!empty($arrayfields['d.firstname']['checked'])) {
  624. print '<td class="liste_titre left">';
  625. print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
  626. }
  627. if (!empty($arrayfields['d.lastname']['checked'])) {
  628. print '<td class="liste_titre left">';
  629. print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
  630. }
  631. if (!empty($arrayfields['d.gender']['checked'])) {
  632. print '<td class="liste_titre">';
  633. $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
  634. print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
  635. print '</td>';
  636. }
  637. if (!empty($arrayfields['d.company']['checked'])) {
  638. print '<td class="liste_titre left">';
  639. print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
  640. }
  641. if (!empty($arrayfields['d.login']['checked'])) {
  642. print '<td class="liste_titre left">';
  643. print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
  644. }
  645. if (!empty($arrayfields['d.morphy']['checked'])) {
  646. print '<td class="liste_titre left">';
  647. print '</td>';
  648. }
  649. if (!empty($arrayfields['t.libelle']['checked'])) {
  650. print '<td class="liste_titre">';
  651. $listetype = $membertypestatic->liste_array();
  652. print $form->selectarray("search_type", $listetype, $search_type, 1, 0, 0, '', 0, 32);
  653. print '</td>';
  654. }
  655. if (!empty($arrayfields['d.address']['checked'])) {
  656. print '<td class="liste_titre left">';
  657. print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'"></td>';
  658. }
  659. if (!empty($arrayfields['d.zip']['checked'])) {
  660. print '<td class="liste_titre left">';
  661. print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
  662. }
  663. if (!empty($arrayfields['d.town']['checked'])) {
  664. print '<td class="liste_titre left">';
  665. print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
  666. }
  667. // State
  668. if (!empty($arrayfields['state.nom']['checked'])) {
  669. print '<td class="liste_titre">';
  670. print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  671. print '</td>';
  672. }
  673. // Country
  674. if (!empty($arrayfields['country.code_iso']['checked'])) {
  675. print '<td class="liste_titre center">';
  676. print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
  677. print '</td>';
  678. }
  679. // Phone pro
  680. if (!empty($arrayfields['d.phone']['checked'])) {
  681. print '<td class="liste_titre left">';
  682. print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'"></td>';
  683. }
  684. // Phone perso
  685. if (!empty($arrayfields['d.phone_perso']['checked'])) {
  686. print '<td class="liste_titre left">';
  687. print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.dol_escape_htmltag($search_phone_perso).'"></td>';
  688. }
  689. // Phone mobile
  690. if (!empty($arrayfields['d.phone_mobile']['checked'])) {
  691. print '<td class="liste_titre left">';
  692. print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'"></td>';
  693. }
  694. // Email
  695. if (!empty($arrayfields['d.email']['checked'])) {
  696. print '<td class="liste_titre left">';
  697. print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
  698. }
  699. // End of subscription date
  700. if (!empty($arrayfields['d.datefin']['checked'])) {
  701. print '<td class="liste_titre left">';
  702. $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
  703. print $form->selectarray('search_filter', $selectarray, $search_filter);
  704. print '</td>';
  705. }
  706. // Extra fields
  707. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  708. // Fields from hook
  709. $parameters = array('arrayfields'=>$arrayfields);
  710. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  711. print $hookmanager->resPrint;
  712. // Date creation
  713. if (!empty($arrayfields['d.datec']['checked'])) {
  714. print '<td class="liste_titre">';
  715. print '</td>';
  716. }
  717. // Birthday
  718. if (!empty($arrayfields['d.birth']['checked'])) {
  719. print '<td class="liste_titre">';
  720. print '</td>';
  721. }
  722. // Date modification
  723. if (!empty($arrayfields['d.tms']['checked'])) {
  724. print '<td class="liste_titre">';
  725. print '</td>';
  726. }
  727. // Status
  728. if (!empty($arrayfields['d.statut']['checked'])) {
  729. print '<td class="liste_titre right maxwidthonsmartphone">';
  730. $liststatus = array(
  731. Adherent::STATUS_DRAFT => $langs->trans("Draft"),
  732. Adherent::STATUS_VALIDATED => $langs->trans("Validated"),
  733. Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"),
  734. Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort")
  735. );
  736. print $form->selectarray('search_status', $liststatus, $search_status, -3);
  737. print '</td>';
  738. }
  739. // Action column
  740. print '<td class="liste_titre middle">';
  741. $searchpicto = $form->showFilterButtons();
  742. print $searchpicto;
  743. print '</td>';
  744. print "</tr>\n";
  745. print '<tr class="liste_titre">';
  746. if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
  747. print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
  748. }
  749. if (!empty($arrayfields['d.ref']['checked'])) {
  750. print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
  751. }
  752. if (!empty($arrayfields['d.civility']['checked'])) {
  753. print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
  754. }
  755. if (!empty($arrayfields['d.firstname']['checked'])) {
  756. print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
  757. }
  758. if (!empty($arrayfields['d.lastname']['checked'])) {
  759. print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
  760. }
  761. if (!empty($arrayfields['d.gender']['checked'])) {
  762. print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
  763. }
  764. if (!empty($arrayfields['d.company']['checked'])) {
  765. print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'companyname', '', $param, '', $sortfield, $sortorder);
  766. }
  767. if (!empty($arrayfields['d.login']['checked'])) {
  768. print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
  769. }
  770. if (!empty($arrayfields['d.morphy']['checked'])) {
  771. print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
  772. }
  773. if (!empty($arrayfields['t.libelle']['checked'])) {
  774. print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
  775. }
  776. if (!empty($arrayfields['d.address']['checked'])) {
  777. print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
  778. }
  779. if (!empty($arrayfields['d.zip']['checked'])) {
  780. print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
  781. }
  782. if (!empty($arrayfields['d.town']['checked'])) {
  783. print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
  784. }
  785. if (!empty($arrayfields['state.nom']['checked'])) {
  786. print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
  787. }
  788. if (!empty($arrayfields['country.code_iso']['checked'])) {
  789. print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
  790. }
  791. if (!empty($arrayfields['d.phone']['checked'])) {
  792. print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
  793. }
  794. if (!empty($arrayfields['d.phone_perso']['checked'])) {
  795. print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
  796. }
  797. if (!empty($arrayfields['d.phone_mobile']['checked'])) {
  798. print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
  799. }
  800. if (!empty($arrayfields['d.email']['checked'])) {
  801. print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
  802. }
  803. if (!empty($arrayfields['d.datefin']['checked'])) {
  804. print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
  805. }
  806. // Extra fields
  807. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  808. // Hook fields
  809. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  810. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  811. print $hookmanager->resPrint;
  812. if (!empty($arrayfields['d.datec']['checked'])) {
  813. print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  814. }
  815. if (!empty($arrayfields['d.birth']['checked'])) {
  816. print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  817. }
  818. if (!empty($arrayfields['d.tms']['checked'])) {
  819. print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
  820. }
  821. if (!empty($arrayfields['d.statut']['checked'])) {
  822. print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
  823. }
  824. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  825. print "</tr>\n";
  826. $i = 0;
  827. $totalarray = array();
  828. $totalarray['nbfield'] = 0;
  829. while ($i < min($num, $limit)) {
  830. $obj = $db->fetch_object($resql);
  831. $datefin = $db->jdate($obj->datefin);
  832. $memberstatic->id = $obj->rowid;
  833. $memberstatic->ref = $obj->ref;
  834. $memberstatic->civility_id = $obj->civility;
  835. $memberstatic->login = $obj->login;
  836. $memberstatic->lastname = $obj->lastname;
  837. $memberstatic->firstname = $obj->firstname;
  838. $memberstatic->gender = $obj->gender;
  839. $memberstatic->statut = $obj->statut;
  840. $memberstatic->datefin = $datefin;
  841. $memberstatic->socid = $obj->fk_soc;
  842. $memberstatic->photo = $obj->photo;
  843. $memberstatic->email = $obj->email;
  844. $memberstatic->morphy = $obj->morphy;
  845. $memberstatic->note_public = $obj->note_public;
  846. $memberstatic->note_private = $obj->note_private;
  847. if (!empty($obj->fk_soc)) {
  848. $memberstatic->fetch_thirdparty();
  849. if ($memberstatic->thirdparty->id > 0) {
  850. $companyname = $memberstatic->thirdparty->name;
  851. $companynametoshow = $memberstatic->thirdparty->getNomUrl(1);
  852. }
  853. } else {
  854. $companyname = $obj->company;
  855. $companynametoshow = $obj->company;
  856. }
  857. $memberstatic->company = $companyname;
  858. print '<tr class="oddeven">';
  859. if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
  860. print '<td class="center">'.$obj->rowid.'</td>';
  861. if (!$i) {
  862. $totalarray['nbfield']++;
  863. }
  864. }
  865. // Ref
  866. if (!empty($arrayfields['d.ref']['checked'])) {
  867. print "<td>";
  868. print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
  869. print "</td>\n";
  870. if (!$i) {
  871. $totalarray['nbfield']++;
  872. }
  873. }
  874. // Civility
  875. if (!empty($arrayfields['d.civility']['checked'])) {
  876. print "<td>";
  877. print $obj->civility;
  878. print "</td>\n";
  879. if (!$i) {
  880. $totalarray['nbfield']++;
  881. }
  882. }
  883. // Firstname
  884. if (!empty($arrayfields['d.firstname']['checked'])) {
  885. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->firstname).'">';
  886. print $memberstatic->getNomUrl(0, 0, 'card', 'firstname');
  887. //print $obj->firstname;
  888. print "</td>\n";
  889. if (!$i) {
  890. $totalarray['nbfield']++;
  891. }
  892. }
  893. // Lastname
  894. if (!empty($arrayfields['d.lastname']['checked'])) {
  895. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->lastname).'">';
  896. print $memberstatic->getNomUrl(0, 0, 'card', 'lastname');
  897. //print $obj->lastname;
  898. print "</td>\n";
  899. if (!$i) {
  900. $totalarray['nbfield']++;
  901. }
  902. }
  903. // Gender
  904. if (!empty($arrayfields['d.gender']['checked'])) {
  905. print '<td>';
  906. if ($obj->gender) {
  907. print $langs->trans("Gender".$obj->gender);
  908. }
  909. print '</td>';
  910. if (!$i) {
  911. $totalarray['nbfield']++;
  912. }
  913. }
  914. // Company
  915. if (!empty($arrayfields['d.company']['checked'])) {
  916. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companyname).'">';
  917. print $companynametoshow;
  918. print "</td>\n";
  919. }
  920. // Login
  921. if (!empty($arrayfields['d.login']['checked'])) {
  922. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).'">'.$obj->login."</td>\n";
  923. if (!$i) {
  924. $totalarray['nbfield']++;
  925. }
  926. }
  927. // Nature (Moral/Physical)
  928. if (!empty($arrayfields['d.morphy']['checked'])) {
  929. print '<td class="center">';
  930. $s = '';
  931. if ($obj->morphy == 'phy') {
  932. $s .= '<span class="customer-back" title="'.$langs->trans("Physical").'">'.dol_substr($langs->trans("Physical"), 0, 1).'</span>';
  933. }
  934. if ($obj->morphy == 'mor') {
  935. $s .= '<span class="vendor-back" title="'.$langs->trans("Moral").'">'.dol_substr($langs->trans("Moral"), 0, 1).'</span>';
  936. }
  937. print $s;
  938. print "</td>\n";
  939. if (!$i) {
  940. $totalarray['nbfield']++;
  941. }
  942. }
  943. // Type label
  944. if (!empty($arrayfields['t.libelle']['checked'])) {
  945. $membertypestatic->id = $obj->type_id;
  946. $membertypestatic->label = $obj->type;
  947. print '<td class="nowraponall">';
  948. print $membertypestatic->getNomUrl(1, 32);
  949. print '</td>';
  950. if (!$i) {
  951. $totalarray['nbfield']++;
  952. }
  953. }
  954. // Address
  955. if (!empty($arrayfields['d.address']['checked'])) {
  956. print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->address).'">';
  957. print $obj->address;
  958. print '</td>';
  959. if (!$i) {
  960. $totalarray['nbfield']++;
  961. }
  962. }
  963. // Zip
  964. if (!empty($arrayfields['d.zip']['checked'])) {
  965. print '<td class="nocellnopadd">';
  966. print $obj->zip;
  967. print '</td>';
  968. if (!$i) {
  969. $totalarray['nbfield']++;
  970. }
  971. }
  972. // Town
  973. if (!empty($arrayfields['d.town']['checked'])) {
  974. print '<td class="nocellnopadd">';
  975. print $obj->town;
  976. print '</td>';
  977. if (!$i) {
  978. $totalarray['nbfield']++;
  979. }
  980. }
  981. // State
  982. if (!empty($arrayfields['state.nom']['checked'])) {
  983. print "<td>".$obj->state_name."</td>\n";
  984. if (!$i) {
  985. $totalarray['nbfield']++;
  986. }
  987. }
  988. // Country
  989. if (!empty($arrayfields['country.code_iso']['checked'])) {
  990. print '<td class="center">';
  991. $tmparray = getCountry($obj->country, 'all');
  992. print $tmparray['label'];
  993. print '</td>';
  994. if (!$i) {
  995. $totalarray['nbfield']++;
  996. }
  997. }
  998. // Phone pro
  999. if (!empty($arrayfields['d.phone']['checked'])) {
  1000. print '<td class="nocellnopadd">';
  1001. print $obj->phone;
  1002. print '</td>';
  1003. if (!$i) {
  1004. $totalarray['nbfield']++;
  1005. }
  1006. }
  1007. // Phone perso
  1008. if (!empty($arrayfields['d.phone_perso']['checked'])) {
  1009. print '<td class="nocellnopadd">';
  1010. print $obj->phone_perso;
  1011. print '</td>';
  1012. if (!$i) {
  1013. $totalarray['nbfield']++;
  1014. }
  1015. }
  1016. // Phone mobile
  1017. if (!empty($arrayfields['d.phone_mobile']['checked'])) {
  1018. print '<td class="nocellnopadd">';
  1019. print $obj->phone_mobile;
  1020. print '</td>';
  1021. if (!$i) {
  1022. $totalarray['nbfield']++;
  1023. }
  1024. }
  1025. // EMail
  1026. if (!empty($arrayfields['d.email']['checked'])) {
  1027. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->email).'">';
  1028. print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1);
  1029. print "</td>\n";
  1030. }
  1031. // End of subscription date
  1032. $datefin = $db->jdate($obj->datefin);
  1033. if (!empty($arrayfields['d.datefin']['checked'])) {
  1034. if ($datefin) {
  1035. print '<td class="nowrap center">';
  1036. print dol_print_date($datefin, 'day');
  1037. if ($memberstatic->hasDelay()) {
  1038. $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").')';
  1039. print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
  1040. }
  1041. print '</td>';
  1042. } else {
  1043. print '<td class="nowrap left">';
  1044. if (!empty($obj->subscription)) {
  1045. print $langs->trans("SubscriptionNotReceived");
  1046. if ($obj->statut > 0) {
  1047. print " ".img_warning();
  1048. }
  1049. } else {
  1050. print '&nbsp;';
  1051. }
  1052. print '</td>';
  1053. }
  1054. }
  1055. // Extra fields
  1056. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1057. // Fields from hook
  1058. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1059. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1060. print $hookmanager->resPrint;
  1061. // Date creation
  1062. if (!empty($arrayfields['d.datec']['checked'])) {
  1063. print '<td class="nowrap center">';
  1064. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1065. print '</td>';
  1066. if (!$i) {
  1067. $totalarray['nbfield']++;
  1068. }
  1069. }
  1070. // Birth
  1071. if (!empty($arrayfields['d.birth']['checked'])) {
  1072. print '<td class="nowrap center">';
  1073. print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
  1074. print '</td>';
  1075. if (!$i) {
  1076. $totalarray['nbfield']++;
  1077. }
  1078. }
  1079. // Date modification
  1080. if (!empty($arrayfields['d.tms']['checked'])) {
  1081. print '<td class="nowrap center">';
  1082. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1083. print '</td>';
  1084. if (!$i) {
  1085. $totalarray['nbfield']++;
  1086. }
  1087. }
  1088. // Status
  1089. if (!empty($arrayfields['d.statut']['checked'])) {
  1090. print '<td class="nowrap right">';
  1091. print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
  1092. print '</td>';
  1093. if (!$i) {
  1094. $totalarray['nbfield']++;
  1095. }
  1096. }
  1097. // Action column
  1098. print '<td class="center">';
  1099. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1100. $selected = 0;
  1101. if (in_array($obj->rowid, $arrayofselected)) {
  1102. $selected = 1;
  1103. }
  1104. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1105. }
  1106. print '</td>';
  1107. if (!$i) {
  1108. $totalarray['nbfield']++;
  1109. }
  1110. print "</tr>\n";
  1111. $i++;
  1112. }
  1113. // Show total line
  1114. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1115. // If no record found
  1116. if ($num == 0) {
  1117. $colspan = 1;
  1118. foreach ($arrayfields as $key => $val) {
  1119. if (!empty($val['checked'])) {
  1120. $colspan++;
  1121. }
  1122. }
  1123. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  1124. }
  1125. $db->free($resql);
  1126. $parameters = array('sql' => $sql);
  1127. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1128. print $hookmanager->resPrint;
  1129. print "</table>\n";
  1130. print "</div>";
  1131. print '</form>';
  1132. // End of page
  1133. llxFooter();
  1134. $db->close();