list.php 46 KB

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