list.php 53 KB

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