list.php 47 KB

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