conferenceorboothattendee_list.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/eventorganization/conferenceorboothattendee_list.php
  20. * \ingroup eventorganization
  21. * \brief List page for conferenceorboothattendee
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. if (isModEnabled('categorie')) {
  34. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  35. }
  36. global $dolibarr_main_url_root;
  37. // Load translation files required by the page
  38. $langs->loadLangs(array("eventorganization", "other", "projects", "bills"));
  39. // Get Paramters
  40. $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
  41. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  42. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  43. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  44. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  45. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  46. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
  47. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  48. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  49. $mode = GETPOST('mode', 'aZ');
  50. $id = GETPOST('id', 'int');
  51. $conf_or_booth_id = GETPOST('conforboothid', 'int');
  52. $withproject = GETPOST('withproject', 'int');
  53. $fk_project = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('projectid', 'int');
  54. $projectid = $fk_project;
  55. $withProjectUrl='';
  56. // Load variable for pagination
  57. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  58. $sortfield = GETPOST('sortfield', 'aZ09comma');
  59. $sortorder = GETPOST('sortorder', 'aZ09comma');
  60. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  61. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  62. // If $page is not defined, or '' or -1 or if we click on clear filters
  63. $page = 0;
  64. }
  65. $offset = $limit * $page;
  66. $pageprev = $page - 1;
  67. $pagenext = $page + 1;
  68. // Initialize technical objects
  69. $object = new ConferenceOrBoothAttendee($db);
  70. $extrafields = new ExtraFields($db);
  71. $projectstatic = new Project($db);
  72. $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
  73. $hookmanager->initHooks(array('conferenceorboothattendeelist')); // Note that conf->hooks_modules contains array
  74. // Fetch optionals attributes and labels
  75. $extrafields->fetch_name_optionals_label($object->table_element);
  76. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  77. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  78. // Default sort order (if not yet defined by previous GETPOST)
  79. if (!$sortfield) {
  80. reset($object->fields); // Reset is required to avoid key() to return null.
  81. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
  82. }
  83. if (!$sortorder) {
  84. $sortorder = "ASC";
  85. }
  86. // Initialize array of search criterias
  87. $search_all = GETPOST('search_all', 'alphanohtml');
  88. $search = array();
  89. foreach ($object->fields as $key => $val) {
  90. if (GETPOST('search_'.$key, 'alpha') !== '') {
  91. $search[$key] = GETPOST('search_'.$key, 'alpha');
  92. }
  93. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  94. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  95. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  96. }
  97. }
  98. // List of fields to search into when doing a "search in all"
  99. $fieldstosearchall = array();
  100. foreach ($object->fields as $key => $val) {
  101. if (!empty($val['searchall'])) {
  102. $fieldstosearchall['t.'.$key] = $val['label'];
  103. }
  104. }
  105. // Definition of array of fields for columns
  106. $arrayfields = array();
  107. foreach ($object->fields as $key => $val) {
  108. // If $val['visible']==0, then we never show the field
  109. if (!empty($val['visible'])) {
  110. $visible = (int) dol_eval($val['visible'], 1);
  111. $arrayfields['t.'.$key] = array(
  112. 'label'=>$val['label'],
  113. 'checked'=>(($visible < 0) ? 0 : 1),
  114. 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
  115. 'position'=>$val['position'],
  116. 'help'=> isset($val['help']) ? $val['help'] : ''
  117. );
  118. }
  119. }
  120. // Extra fields
  121. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  122. $object->fields = dol_sort_array($object->fields, 'position');
  123. $arrayfields = dol_sort_array($arrayfields, 'position');
  124. // Permissions
  125. $permissiontoread = $user->rights->eventorganization->read;
  126. $permissiontoadd = $user->rights->eventorganization->write;
  127. $permissiontodelete = $user->rights->eventorganization->delete;
  128. // Security check
  129. if (empty($conf->eventorganization->enabled)) {
  130. accessforbidden('Module not enabled');
  131. }
  132. $socid = 0;
  133. if ($user->socid > 0) { // Protection if external user
  134. //$socid = $user->socid;
  135. accessforbidden();
  136. }
  137. $result = restrictedArea($user, 'eventorganization');
  138. if (!$permissiontoread) accessforbidden();
  139. /*
  140. * Actions
  141. */
  142. if (preg_match('/^set/', $action) && $projectid > 0 && !empty($user->rights->eventorganization->write)) {
  143. $project = new Project($db);
  144. //If "set" fields keys is in projects fields
  145. $project_attr=preg_replace('/^set/', '', $action);
  146. if (array_key_exists($project_attr, $project->fields)) {
  147. $result = $project->fetch($projectid);
  148. if ($result < 0) {
  149. setEventMessages(null, $project->errors, 'errors');
  150. } else {
  151. $project->{$project_attr}=GETPOST($project_attr);
  152. $result=$project->update($user);
  153. if ($result < 0) {
  154. setEventMessages(null, $project->errors, 'errors');
  155. }
  156. }
  157. }
  158. }
  159. if (GETPOST('cancel', 'alpha')) {
  160. $action = 'list';
  161. $massaction = '';
  162. }
  163. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  164. $massaction = '';
  165. }
  166. $parameters = array();
  167. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  168. if ($reshook < 0) {
  169. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  170. }
  171. if (empty($reshook)) {
  172. // Selection of new fields
  173. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  174. // Purge search criteria
  175. 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
  176. foreach ($object->fields as $key => $val) {
  177. $search[$key] = '';
  178. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  179. $search[$key.'_dtstart'] = '';
  180. $search[$key.'_dtend'] = '';
  181. }
  182. }
  183. $toselect = array();
  184. $search_array_options = array();
  185. }
  186. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  187. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
  188. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  189. }
  190. // Mass actions
  191. $objectclass = 'ConferenceOrBoothAttendee';
  192. $objectlabel = 'ConferenceOrBoothAttendee';
  193. $uploaddir = $conf->eventorganization->dir_output;
  194. include DOL_DOCUMENT_ROOT.'/eventorganization/core/actions_massactions_mail.inc.php';
  195. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  196. }
  197. /*
  198. * View
  199. */
  200. $form = new Form($db);
  201. $now = dol_now();
  202. //$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee";
  203. $help_url = '';
  204. $morejs = array();
  205. $morecss = array();
  206. $confOrBooth = new ConferenceOrBooth($db);
  207. if ($conf_or_booth_id > 0) {
  208. $result = $confOrBooth->fetch($conf_or_booth_id);
  209. if ($result < 0) {
  210. setEventMessages(null, $confOrBooth->errors, 'errors');
  211. } else {
  212. $fk_project = $confOrBooth->fk_project;
  213. }
  214. }
  215. if ($fk_project > 0) {
  216. $result = $projectstatic->fetch($fk_project);
  217. if ($result < 0) {
  218. setEventMessages(null, $projectstatic->errors, 'errors');
  219. }
  220. }
  221. // Build and execute select
  222. // --------------------------------------------------------------------
  223. $sql = 'SELECT ';
  224. $sql .= $object->getFieldList('t');
  225. // Add fields from extrafields
  226. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  227. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  228. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  229. }
  230. }
  231. // Add fields from hooks
  232. $parameters = array();
  233. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  234. $sql .= $hookmanager->resPrint;
  235. $sql = preg_replace('/,\s*$/', '', $sql);
  236. //$sql .= ", COUNT(rc.rowid) as anotherfield";
  237. $sqlfields = $sql; // $sql fields to remove for count total
  238. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  239. if (!empty($confOrBooth->id)) {
  240. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".((int) $confOrBooth->id);
  241. }
  242. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  243. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
  244. }
  245. // Add table from hooks
  246. $parameters = array();
  247. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  248. $sql .= $hookmanager->resPrint;
  249. if ($object->ismultientitymanaged == 1) {
  250. $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
  251. } else {
  252. $sql .= " WHERE 1 = 1";
  253. }
  254. if (!empty($projectstatic->id)) {
  255. $sql .= " AND t.fk_project = ".((int) $projectstatic->id);
  256. }
  257. foreach ($search as $key => $val) {
  258. if (array_key_exists($key, $object->fields)) {
  259. if ($key == 'status' && $search[$key] == -1) {
  260. continue;
  261. }
  262. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  263. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  264. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  265. $search[$key] = '';
  266. }
  267. $mode_search = 2;
  268. }
  269. if ($search[$key] != '') {
  270. $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
  271. }
  272. } else {
  273. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  274. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  275. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  276. if (preg_match('/_dtstart$/', $key)) {
  277. $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
  278. }
  279. if (preg_match('/_dtend$/', $key)) {
  280. $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
  281. }
  282. }
  283. }
  284. }
  285. }
  286. if ($search_all) {
  287. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  288. }
  289. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  290. // Add where from extra fields
  291. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  292. // Add where from hooks
  293. $parameters = array();
  294. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  295. $sql .= $hookmanager->resPrint;
  296. // Count total nb of records
  297. $nbtotalofrecords = '';
  298. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  299. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  300. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  301. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  302. $resql = $db->query($sqlforcount);
  303. if ($resql) {
  304. $objforcount = $db->fetch_object($resql);
  305. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  306. } else {
  307. dol_print_error($db);
  308. }
  309. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
  310. $page = 0;
  311. $offset = 0;
  312. }
  313. $db->free($resql);
  314. }
  315. // Complete request and execute it with limit
  316. $sql .= $db->order($sortfield, $sortorder);
  317. if ($limit) {
  318. $sql .= $db->plimit($limit + 1, $offset);
  319. }
  320. $resql = $db->query($sql);
  321. if (!$resql) {
  322. dol_print_error($db);
  323. exit;
  324. }
  325. $num = $db->num_rows($resql);
  326. // Direct jump if only one record found
  327. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  328. $obj = $db->fetch_object($resql);
  329. $id = $obj->rowid;
  330. header("Location: ".DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.((int) $id));
  331. exit;
  332. }
  333. if ($confOrBooth->id > 0) {
  334. $title = $langs->trans('ListOfAttendeesPerConference');
  335. } else {
  336. $title = $langs->trans('ListOfAttendeesOfEvent');
  337. }
  338. // Output page
  339. // --------------------------------------------------------------------
  340. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  341. if ($projectstatic->id > 0 || $confOrBooth > 0) {
  342. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
  343. $projectstatic->fetchComments();
  344. }
  345. if (!empty($projectstatic->socid)) {
  346. $projectstatic->fetch_thirdparty();
  347. }
  348. $withProjectUrl='';
  349. $object->project = clone $projectstatic;
  350. if (!empty($withproject)) {
  351. // Tabs for project
  352. $tab = 'eventorganisation';
  353. $withProjectUrl = "&withproject=1";
  354. $head = project_prepare_head($projectstatic);
  355. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
  356. $param = ($mode == 'mine' ? '&mode=mine' : '');
  357. // Project card
  358. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  359. $morehtmlref = '<div class="refidno">';
  360. // Title
  361. $morehtmlref .= $projectstatic->title;
  362. // Thirdparty
  363. if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
  364. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  365. }
  366. $morehtmlref .= '</div>';
  367. // Define a complementary filter for search of next/prev ref.
  368. if (empty($user->rights->projet->all->lire)) {
  369. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  370. $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  371. }
  372. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  373. print '<div class="fichecenter">';
  374. print '<div class="fichehalfleft">';
  375. print '<div class="underbanner clearboth"></div>';
  376. print '<table class="border tableforfield centpercent">';
  377. // Usage
  378. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
  379. print '<tr><td class="tdtop">';
  380. print $langs->trans("Usage");
  381. print '</td>';
  382. print '<td>';
  383. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  384. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  385. $htmltext = $langs->trans("ProjectFollowOpportunity");
  386. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  387. print '<br>';
  388. }
  389. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  390. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  391. $htmltext = $langs->trans("ProjectFollowTasks");
  392. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  393. print '<br>';
  394. }
  395. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  396. print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
  397. $htmltext = $langs->trans("ProjectBillTimeDescription");
  398. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  399. print '<br>';
  400. }
  401. if (isModEnabled('eventorganization')) {
  402. print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> ';
  403. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  404. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  405. }
  406. print '</td></tr>';
  407. }
  408. // Visibility
  409. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  410. if ($projectstatic->public == 0) {
  411. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  412. print $langs->trans("PrivateProject");
  413. } else {
  414. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  415. print $langs->trans("SharedProject");
  416. }
  417. print '</td></tr>';
  418. // Budget
  419. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  420. if (strcmp($projectstatic->budget_amount, '')) {
  421. print '<span class="amount">'.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
  422. }
  423. print '</td></tr>';
  424. // Date start - end project
  425. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Project").')</td><td>';
  426. $start = dol_print_date($projectstatic->date_start, 'day');
  427. print ($start ? $start : '?');
  428. $end = dol_print_date($projectstatic->date_end, 'day');
  429. print ' - ';
  430. print ($end ? $end : '?');
  431. if ($projectstatic->hasDelay()) {
  432. print img_warning("Late");
  433. }
  434. print '</td></tr>';
  435. // Date start - end of event
  436. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Event").')</td><td>';
  437. $start = dol_print_date($projectstatic->date_start_event, 'day');
  438. print ($start ? $start : '?');
  439. $end = dol_print_date($projectstatic->date_end_event, 'day');
  440. print ' - ';
  441. print ($end ? $end : '?');
  442. if ($projectstatic->hasDelay()) {
  443. print img_warning("Late");
  444. }
  445. print '</td></tr>';
  446. // Location event
  447. print '<tr><td>'.$langs->trans("Location").'</td><td>';
  448. print $projectstatic->location;
  449. print '</td></tr>';
  450. // Other attributes
  451. $cols = 2;
  452. $objectconf = $object;
  453. $object = $projectstatic;
  454. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  455. $object = $objectconf;
  456. print '</table>';
  457. print '</div>';
  458. print '<div class="fichehalfright">';
  459. print '<div class="underbanner clearboth"></div>';
  460. print '<table class="border tableforfield centpercent">';
  461. // Description
  462. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  463. print nl2br($projectstatic->description);
  464. print '</td></tr>';
  465. // Categories
  466. if (isModEnabled('categorie')) {
  467. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  468. print $form->showCategories($projectstatic->id, 'project', 1);
  469. print "</td></tr>";
  470. }
  471. print '<tr><td class="nowrap">';
  472. $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : '');
  473. $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp");
  474. print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  475. print '</td><td>';
  476. print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  477. print "</td></tr>";
  478. print '<tr><td>';
  479. $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : '');
  480. $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp");
  481. print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  482. print '</td><td>';
  483. print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  484. print "</td></tr>";
  485. print '<tr><td>';
  486. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  487. print '</td><td>';
  488. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  489. print "</td></tr>";
  490. print '<tr><td>';
  491. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  492. print '</td><td>';
  493. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  494. print "</td></tr>";
  495. print '<tr><td class="titlefield">';
  496. print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $projectstatic, $permissiontoadd, 'integer:3', '&withproject=1', 0, 0, 'projectid');
  497. print '</td><td class="valuefield">';
  498. print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $projectstatic->max_attendees, $projectstatic, $permissiontoadd, 'integer:3', '', 0, 0, '&withproject=1', 0, '', 'projectid');
  499. print "</td></tr>";
  500. print '<tr><td valign="middle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
  501. // Define $urlwithroot
  502. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  503. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
  504. // Show message
  505. $message = '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : "");
  506. $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...');
  507. $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').'</a>';
  508. print $message;
  509. print "</td></tr>";
  510. // Link to the submit vote/register page
  511. print '<tr><td>';
  512. //print '<span class="opacitymedium">';
  513. print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
  514. //print '</span>';
  515. print '</td><td>';
  516. $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$projectstatic->id;
  517. $encodedsecurekey = dol_hash(getDolGlobalString("EVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5');
  518. $linksuggest .= '&securekey='.urlencode($encodedsecurekey);
  519. //print '<div class="urllink">';
  520. //print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  521. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'" class="quatrevingtpercent">'.$linksuggest.'</a></div>';
  522. print '<a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'">'.img_picto('', 'globe').'</a>';
  523. //print '</div>';
  524. //print ajax_autoselect("linkregister");
  525. print '</td></tr>';
  526. // Link to the subscribe
  527. print '<tr><td>';
  528. //print '<span class="opacitymedium">';
  529. print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
  530. //print '</span>';
  531. print '</td><td>';
  532. $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.$projectstatic->id.'&type=global';
  533. $encodedsecurekey = dol_hash(getDolGlobalString("EVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5');
  534. $link_subscription .= '&securekey='.urlencode($encodedsecurekey);
  535. //print '<div class="urllink">';
  536. //print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  537. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$link_subscription.'" class="quatrevingtpercent">'.$link_subscription.'</a></div>';
  538. print '<a target="_blank" rel="noopener noreferrer" href="'.$link_subscription.'">'.img_picto('', 'globe').'</a>';
  539. //print '</div>';
  540. //print ajax_autoselect("linkregister");
  541. print '</td></tr>';
  542. print '</table>';
  543. print '</div>';
  544. print '</div>';
  545. print '<div class="clearboth"></div>';
  546. print dol_get_fiche_end();
  547. if (empty($confOrBooth->id)) {
  548. $head = conferenceorboothProjectPrepareHead($projectstatic);
  549. $tab = 'attendees';
  550. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, (!empty($project->public) ? 'projectpub' : 'project'), 0, '', 'reposition');
  551. }
  552. }
  553. if ($confOrBooth->id > 0) {
  554. $head = conferenceorboothPrepareHead($confOrBooth, $withproject);
  555. print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
  556. $object_evt = $object;
  557. $object = $confOrBooth;
  558. dol_banner_tab($object, 'ref', '', 0);
  559. print '<div class="fichecenter">';
  560. print '<div class="fichehalfleft">';
  561. print '<div class="underbanner clearboth"></div>';
  562. print '<table class="border centpercent tableforfield">' . "\n";
  563. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
  564. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  565. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  566. $object = $object_evt;
  567. print '</table>';
  568. print '</div>';
  569. print '</div>';
  570. print '<div class="clearboth"></div>';
  571. print dol_get_fiche_end();
  572. }
  573. }
  574. $arrayofselected = is_array($toselect) ? $toselect : array();
  575. $param = '';
  576. if (!empty($mode)) {
  577. $param .= '&mode='.urlencode($mode);
  578. }
  579. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  580. $param .= '&contextpage='.urlencode($contextpage);
  581. }
  582. if ($limit > 0 && $limit != $conf->liste_limit) {
  583. $param .= '&limit='.((int) $limit);
  584. }
  585. if ($optioncss != '') {
  586. $param .= '&optioncss='.urlencode($optioncss);
  587. }
  588. foreach ($search as $key => $val) {
  589. if (is_array($search[$key])) {
  590. foreach ($search[$key] as $skey) {
  591. if ($skey != '') {
  592. $param .= '&search_'.$key.'[]='.urlencode($skey);
  593. }
  594. }
  595. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  596. $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
  597. $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
  598. $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
  599. } elseif ($search[$key] != '') {
  600. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  601. }
  602. }
  603. if ($confOrBooth->id > 0) {
  604. $param .= '&conforboothid='.urlencode($confOrBooth->id);
  605. }
  606. if ($projectstatic->id > 0) {
  607. $param .= '&fk_project='.urlencode($projectstatic->id);
  608. }
  609. $param .= $withProjectUrl;
  610. // Add $param from extra fields
  611. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  612. // Add $param from hooks
  613. $parameters = array();
  614. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  615. $param .= $hookmanager->resPrint;
  616. // List of mass actions available
  617. $arrayofmassactions = array(
  618. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  619. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  620. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  621. 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  622. );
  623. if (!empty($permissiontodelete)) {
  624. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  625. }
  626. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  627. $arrayofmassactions = array();
  628. }
  629. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  630. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].(!empty($conf_or_booth_id)?'?conforboothid='.$conf_or_booth_id:'').'">'."\n";
  631. if ($optioncss != '') {
  632. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  633. }
  634. print '<input type="hidden" name="token" value="'.newToken().'">';
  635. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  636. print '<input type="hidden" name="action" value="list">';
  637. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  638. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  639. print '<input type="hidden" name="page" value="'.$page.'">';
  640. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  641. print '<input type="hidden" name="withproject" value="'.$withproject.'">';
  642. print '<input type="hidden" name="fk_project" value="'.$fk_project.'">';
  643. print '<input type="hidden" name="page_y" value="">';
  644. print '<input type="hidden" name="mode" value="'.$mode.'">';
  645. $params = array('morecss'=>'reposition');
  646. $newcardbutton = '';
  647. $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.(empty($confOrBooth->id) ? '' : '&conforboothid='.$confOrBooth->id).$withProjectUrl), '', $permissiontoadd, $params);
  648. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  649. // Add code for pre mass action (confirmation or email presend form)
  650. $topicmail = $projectstatic->title;
  651. $modelmail = "conferenceorbooth";
  652. $objecttmp = new ConferenceOrBoothAttendee($db);
  653. $trackid = 'conferenceorbooth_'.$object->id;
  654. $withmaindocfilemail = 0;
  655. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  656. if ($search_all) {
  657. $setupstring = '';
  658. foreach ($fieldstosearchall as $key => $val) {
  659. $fieldstosearchall[$key] = $langs->trans($val);
  660. $setupstring .= $key."=".$val.";";
  661. }
  662. print '<!-- Search done like if CONFERENCEORBOOTHATTENDEE_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
  663. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  664. }
  665. $moreforfilter = '';
  666. /*$moreforfilter.='<div class="divsearchfield">';
  667. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  668. $moreforfilter.= '</div>';*/
  669. $parameters = array();
  670. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  671. if (empty($reshook)) {
  672. $moreforfilter .= $hookmanager->resPrint;
  673. } else {
  674. $moreforfilter = $hookmanager->resPrint;
  675. }
  676. if (!empty($moreforfilter)) {
  677. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  678. print $moreforfilter;
  679. $parameters = array();
  680. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  681. print $hookmanager->resPrint;
  682. print '</div>';
  683. }
  684. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  685. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  686. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  687. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  688. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  689. // Fields title search
  690. // --------------------------------------------------------------------
  691. print '<tr class="liste_titre_filter">';
  692. // Action column
  693. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  694. print '<td class="liste_titre center maxwidthsearch">';
  695. $searchpicto = $form->showFilterButtons('left');
  696. print $searchpicto;
  697. print '</td>';
  698. }
  699. foreach ($object->fields as $key => $val) {
  700. $searchkey = empty($search[$key]) ? '' : $search[$key];
  701. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  702. if ($key == 'status') {
  703. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  704. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  705. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  706. } elseif (in_array($val['type'], array('timestamp'))) {
  707. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  708. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  709. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  710. }
  711. if (!empty($arrayfields['t.'.$key]['checked'])) {
  712. print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
  713. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  714. print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
  715. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  716. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
  717. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  718. print '<div class="nowrap">';
  719. print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  720. print '</div>';
  721. print '<div class="nowrap">';
  722. print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  723. print '</div>';
  724. } elseif ($key == 'lang') {
  725. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  726. $formadmin = new FormAdmin($db);
  727. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  728. } else {
  729. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
  730. }
  731. print '</td>';
  732. }
  733. }
  734. // Extra fields
  735. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  736. // Fields from hook
  737. $parameters = array('arrayfields'=>$arrayfields);
  738. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  739. print $hookmanager->resPrint;
  740. // Action column
  741. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  742. print '<td class="liste_titre center maxwidthsearch">';
  743. $searchpicto = $form->showFilterButtons();
  744. print $searchpicto;
  745. print '</td>';
  746. }
  747. print '</tr>'."\n";
  748. $totalarray = array();
  749. $totalarray['nbfield'] = 0;
  750. // Fields title label
  751. // --------------------------------------------------------------------
  752. print '<tr class="liste_titre">';
  753. // Action column
  754. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  755. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  756. $totalarray['nbfield']++;
  757. }
  758. foreach ($object->fields as $key => $val) {
  759. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  760. if ($key == 'status') {
  761. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  762. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  763. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  764. } elseif (in_array($val['type'], array('timestamp'))) {
  765. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  766. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  767. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  768. }
  769. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  770. if (!empty($arrayfields['t.'.$key]['checked'])) {
  771. print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
  772. $totalarray['nbfield']++;
  773. }
  774. }
  775. // Extra fields
  776. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  777. // Hook fields
  778. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  779. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  780. print $hookmanager->resPrint;
  781. // Action column
  782. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  783. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  784. $totalarray['nbfield']++;
  785. }
  786. print '</tr>'."\n";
  787. // Detect if we need a fetch on each output line
  788. $needToFetchEachLine = 0;
  789. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  790. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  791. if ($val && preg_match('/\$object/', $val)) {
  792. $needToFetchEachLine++; // There is at least one compute field that use $object
  793. }
  794. }
  795. }
  796. // Loop on record
  797. // --------------------------------------------------------------------
  798. $i = 0;
  799. $savnbfield = $totalarray['nbfield'];
  800. $totalarray = array();
  801. $totalarray['nbfield'] = 0;
  802. $imaxinloop = ($limit ? min($num, $limit) : $num);
  803. while ($i < $imaxinloop) {
  804. $obj = $db->fetch_object($resql);
  805. if (empty($obj)) {
  806. break; // Should not happen
  807. }
  808. // Store properties in $object
  809. $object->setVarsFromFetchObj($obj);
  810. if ($mode == 'kanban') {
  811. if ($i == 0) {
  812. print '<tr><td colspan="'.$savnbfield.'">';
  813. print '<div class="box-flex-container kanban">';
  814. }
  815. // Output Kanban
  816. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  817. $selected = 0;
  818. if (in_array($object->id, $arrayofselected)) {
  819. $selected = 1;
  820. }
  821. }
  822. print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
  823. if ($i == ($imaxinloop - 1)) {
  824. print '</div>';
  825. print '</td></tr>';
  826. }
  827. } else {
  828. // Show here line of result
  829. $j = 0;
  830. print '<tr data-rowid="'.$object->id.'" class="oddeven">';
  831. // Action column
  832. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  833. print '<td class="nowrap center">';
  834. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  835. $selected = 0;
  836. if (in_array($object->id, $arrayofselected)) {
  837. $selected = 1;
  838. }
  839. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  840. }
  841. print '</td>';
  842. if (!$i) {
  843. $totalarray['nbfield']++;
  844. }
  845. }
  846. foreach ($object->fields as $key => $val) {
  847. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  848. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  849. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  850. } elseif ($key == 'status') {
  851. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  852. }
  853. if (in_array($val['type'], array('timestamp'))) {
  854. $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
  855. } elseif ($key == 'ref') {
  856. $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
  857. }
  858. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  859. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  860. }
  861. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  862. if (!empty($arrayfields['t.'.$key]['checked'])) {
  863. print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
  864. if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
  865. print ' title="'.dol_escape_htmltag($object->$key).'"';
  866. }
  867. print '>';
  868. if ($key == 'status') {
  869. print $object->getLibStatut(5);
  870. } elseif ($key == 'ref') {
  871. $optionLink = (!empty($withproject)?'conforboothidproject':'conforboothid');
  872. if (empty($confOrBooth->id)) {
  873. $optionLink='projectid';
  874. }
  875. print $object->getNomUrl(1, $optionLink);
  876. } else {
  877. print $object->showOutputField($val, $key, $object->$key, '');
  878. }
  879. print '</td>';
  880. if (!$i) {
  881. $totalarray['nbfield']++;
  882. }
  883. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  884. if (!$i) {
  885. $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
  886. }
  887. if (!isset($totalarray['val'])) {
  888. $totalarray['val'] = array();
  889. }
  890. if (!isset($totalarray['val']['t.'.$key])) {
  891. $totalarray['val']['t.'.$key] = 0;
  892. }
  893. $totalarray['val']['t.'.$key] += $object->$key;
  894. }
  895. }
  896. }
  897. // Extra fields
  898. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  899. // Fields from hook
  900. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  901. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  902. print $hookmanager->resPrint;
  903. // Action column
  904. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  905. print '<td class="nowrap center">';
  906. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  907. $selected = 0;
  908. if (in_array($object->id, $arrayofselected)) {
  909. $selected = 1;
  910. }
  911. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  912. }
  913. print '</td>';
  914. if (!$i) {
  915. $totalarray['nbfield']++;
  916. }
  917. }
  918. print '</tr>'."\n";
  919. }
  920. $i++;
  921. }
  922. // Show total line
  923. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  924. // If no record found
  925. if ($num == 0) {
  926. $colspan = 1;
  927. foreach ($arrayfields as $key => $val) {
  928. if (!empty($val['checked'])) {
  929. $colspan++;
  930. }
  931. }
  932. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  933. }
  934. $db->free($resql);
  935. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  936. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  937. print $hookmanager->resPrint;
  938. print '</table>'."\n";
  939. print '</div>'."\n";
  940. print '</form>'."\n";
  941. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  942. $hidegeneratedfilelistifempty = 1;
  943. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  944. $hidegeneratedfilelistifempty = 0;
  945. }
  946. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  947. $formfile = new FormFile($db);
  948. // Show list of available documents
  949. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  950. $urlsource .= str_replace('&amp;', '&', $param);
  951. $filedir = $diroutputmassaction;
  952. $genallowed = $permissiontoread;
  953. $delallowed = $permissiontoadd;
  954. print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  955. }
  956. // End of page
  957. llxFooter();
  958. $db->close();