list.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  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') {
  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 = array();
  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) && $search_categ > 0) || !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) && $search_categ > 0) || !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("MenuMembersValidated");
  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($search_type);
  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 > 0 || $search_categ == -2) {
  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 != -3) {
  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"').$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 center">';
  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, '', $sortfield, $sortorder, 'center ');
  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, '', $sortfield, $sortorder, 'center ');
  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. print '<td class="nowrap center">';
  1035. if ($datefin) {
  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. } else {
  1042. if (!empty($obj->subscription)) {
  1043. print $langs->trans("SubscriptionNotReceived");
  1044. if ($obj->statut > 0) {
  1045. print " ".img_warning();
  1046. }
  1047. } else {
  1048. print '&nbsp;';
  1049. }
  1050. }
  1051. print '</td>';
  1052. }
  1053. // Extra fields
  1054. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1055. // Fields from hook
  1056. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1057. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1058. print $hookmanager->resPrint;
  1059. // Date creation
  1060. if (!empty($arrayfields['d.datec']['checked'])) {
  1061. print '<td class="nowrap center">';
  1062. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1063. print '</td>';
  1064. if (!$i) {
  1065. $totalarray['nbfield']++;
  1066. }
  1067. }
  1068. // Birth
  1069. if (!empty($arrayfields['d.birth']['checked'])) {
  1070. print '<td class="nowrap center">';
  1071. print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
  1072. print '</td>';
  1073. if (!$i) {
  1074. $totalarray['nbfield']++;
  1075. }
  1076. }
  1077. // Date modification
  1078. if (!empty($arrayfields['d.tms']['checked'])) {
  1079. print '<td class="nowrap center">';
  1080. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1081. print '</td>';
  1082. if (!$i) {
  1083. $totalarray['nbfield']++;
  1084. }
  1085. }
  1086. // Status
  1087. if (!empty($arrayfields['d.statut']['checked'])) {
  1088. print '<td class="nowrap right">';
  1089. print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
  1090. print '</td>';
  1091. if (!$i) {
  1092. $totalarray['nbfield']++;
  1093. }
  1094. }
  1095. // Action column
  1096. print '<td class="center">';
  1097. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1098. $selected = 0;
  1099. if (in_array($obj->rowid, $arrayofselected)) {
  1100. $selected = 1;
  1101. }
  1102. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
  1103. }
  1104. print '</td>';
  1105. if (!$i) {
  1106. $totalarray['nbfield']++;
  1107. }
  1108. print "</tr>\n";
  1109. $i++;
  1110. }
  1111. // Show total line
  1112. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1113. // If no record found
  1114. if ($num == 0) {
  1115. $colspan = 1;
  1116. foreach ($arrayfields as $key => $val) {
  1117. if (!empty($val['checked'])) {
  1118. $colspan++;
  1119. }
  1120. }
  1121. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
  1122. }
  1123. $db->free($resql);
  1124. $parameters = array('sql' => $sql);
  1125. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1126. print $hookmanager->resPrint;
  1127. print "</table>\n";
  1128. print "</div>";
  1129. print '</form>';
  1130. // End of page
  1131. llxFooter();
  1132. $db->close();