conferenceorboothattendee_list.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  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') : 'conferenceorboothattendeelist'; // 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. $id = GETPOST('id', 'int');
  50. $conf_or_booth_id = GETPOST('conforboothid', 'int');
  51. $withproject = GETPOST('withproject', 'int');
  52. $fk_project = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('projectid', 'int');
  53. $projectid = $fk_project;
  54. $withProjectUrl='';
  55. // Load variable for pagination
  56. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  57. $sortfield = GETPOST('sortfield', 'aZ09comma');
  58. $sortorder = GETPOST('sortorder', 'aZ09comma');
  59. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  60. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  61. $page = 0;
  62. } // If $page is not defined, or '' or -1 or if we click on clear filters
  63. $offset = $limit * $page;
  64. $pageprev = $page - 1;
  65. $pagenext = $page + 1;
  66. // Initialize technical objects
  67. $object = new ConferenceOrBoothAttendee($db);
  68. $extrafields = new ExtraFields($db);
  69. $projectstatic = new Project($db);
  70. $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
  71. $hookmanager->initHooks(array('conferenceorboothattendeelist')); // Note that conf->hooks_modules contains array
  72. // Fetch optionals attributes and labels
  73. $extrafields->fetch_name_optionals_label($object->table_element);
  74. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  75. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  76. // Default sort order (if not yet defined by previous GETPOST)
  77. if (!$sortfield) {
  78. reset($object->fields); // Reset is required to avoid key() to return null.
  79. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
  80. }
  81. if (!$sortorder) {
  82. $sortorder = "ASC";
  83. }
  84. // Initialize array of search criterias
  85. $search_all = GETPOST('search_all', 'alphanohtml');
  86. $search = array();
  87. foreach ($object->fields as $key => $val) {
  88. if (GETPOST('search_'.$key, 'alpha') !== '') {
  89. $search[$key] = GETPOST('search_'.$key, 'alpha');
  90. }
  91. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  92. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  93. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  94. }
  95. }
  96. // List of fields to search into when doing a "search in all"
  97. $fieldstosearchall = array();
  98. foreach ($object->fields as $key => $val) {
  99. if (!empty($val['searchall'])) {
  100. $fieldstosearchall['t.'.$key] = $val['label'];
  101. }
  102. }
  103. // Definition of array of fields for columns
  104. $arrayfields = array();
  105. foreach ($object->fields as $key => $val) {
  106. // If $val['visible']==0, then we never show the field
  107. if (!empty($val['visible'])) {
  108. $visible = (int) dol_eval($val['visible'], 1, 1, '1');
  109. $arrayfields['t.'.$key] = array(
  110. 'label'=>$val['label'],
  111. 'checked'=>(($visible < 0) ? 0 : 1),
  112. 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
  113. 'position'=>$val['position'],
  114. 'help'=> isset($val['help']) ? $val['help'] : ''
  115. );
  116. }
  117. }
  118. // Extra fields
  119. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  120. $object->fields = dol_sort_array($object->fields, 'position');
  121. $arrayfields = dol_sort_array($arrayfields, 'position');
  122. // Permissions
  123. $permissiontoread = $user->rights->eventorganization->read;
  124. $permissiontoadd = $user->rights->eventorganization->write;
  125. $permissiontodelete = $user->rights->eventorganization->delete;
  126. // Security check
  127. if (empty($conf->eventorganization->enabled)) {
  128. accessforbidden('Module not enabled');
  129. }
  130. $socid = 0;
  131. if ($user->socid > 0) { // Protection if external user
  132. //$socid = $user->socid;
  133. accessforbidden();
  134. }
  135. $result = restrictedArea($user, 'eventorganization');
  136. if (!$permissiontoread) accessforbidden();
  137. /*
  138. * Actions
  139. */
  140. if (preg_match('/^set/', $action) && $projectid > 0 && !empty($user->rights->eventorganization->write)) {
  141. $project = new Project($db);
  142. //If "set" fields keys is in projects fields
  143. $project_attr=preg_replace('/^set/', '', $action);
  144. if (array_key_exists($project_attr, $project->fields)) {
  145. $result = $project->fetch($projectid);
  146. if ($result < 0) {
  147. setEventMessages(null, $project->errors, 'errors');
  148. } else {
  149. $project->{$project_attr}=GETPOST($project_attr);
  150. $result=$project->update($user);
  151. if ($result < 0) {
  152. setEventMessages(null, $project->errors, 'errors');
  153. }
  154. }
  155. }
  156. }
  157. if (GETPOST('cancel', 'alpha')) {
  158. $action = 'list';
  159. $massaction = '';
  160. }
  161. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend'
  162. && $massaction != 'presend'
  163. && $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. if ($confOrBooth->id > 0) {
  205. $title = $langs->trans('ListOfAttendeesPerConference');
  206. } else {
  207. $title = $langs->trans('ListOfAttendeesOfEvent');
  208. }
  209. $morejs = array();
  210. $morecss = array();
  211. $confOrBooth = new ConferenceOrBooth($db);
  212. if ($conf_or_booth_id > 0) {
  213. $result = $confOrBooth->fetch($conf_or_booth_id);
  214. if ($result < 0) {
  215. setEventMessages(null, $confOrBooth->errors, 'errors');
  216. } else {
  217. $fk_project = $confOrBooth->fk_project;
  218. }
  219. }
  220. if ($fk_project > 0) {
  221. $result = $projectstatic->fetch($fk_project);
  222. if ($result < 0) {
  223. setEventMessages(null, $projectstatic->errors, 'errors');
  224. }
  225. }
  226. // Build and execute select
  227. // --------------------------------------------------------------------
  228. $sql = 'SELECT ';
  229. $sql .= $object->getFieldList('t');
  230. // Add fields from extrafields
  231. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  232. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  233. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  234. }
  235. }
  236. // Add fields from hooks
  237. $parameters = array();
  238. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  239. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  240. $sql = preg_replace('/,\s*$/', '', $sql);
  241. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
  242. if (!empty($confOrBooth->id)) {
  243. $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".((int) $confOrBooth->id);
  244. }
  245. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  246. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
  247. }
  248. // Add table from hooks
  249. $parameters = array();
  250. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  251. $sql .= $hookmanager->resPrint;
  252. if ($object->ismultientitymanaged == 1) {
  253. $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
  254. } else {
  255. $sql .= " WHERE 1 = 1";
  256. }
  257. if (!empty($projectstatic->id)) {
  258. $sql .= " AND t.fk_project=".((int) $projectstatic->id);
  259. }
  260. foreach ($search as $key => $val) {
  261. if (array_key_exists($key, $object->fields)) {
  262. if ($key == 'status' && $search[$key] == -1) {
  263. continue;
  264. }
  265. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  266. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  267. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  268. $search[$key] = '';
  269. }
  270. $mode_search = 2;
  271. }
  272. if ($search[$key] != '') {
  273. $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
  274. }
  275. } else {
  276. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  277. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  278. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  279. if (preg_match('/_dtstart$/', $key)) {
  280. $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'";
  281. }
  282. if (preg_match('/_dtend$/', $key)) {
  283. $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
  284. }
  285. }
  286. }
  287. }
  288. }
  289. if ($search_all) {
  290. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  291. }
  292. //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
  293. // Add where from extra fields
  294. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  295. // Add where from hooks
  296. $parameters = array();
  297. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  298. $sql .= $hookmanager->resPrint;
  299. $sql .= $db->order($sortfield, $sortorder);
  300. // Count total nb of records
  301. $nbtotalofrecords = '';
  302. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  303. $resql = $db->query($sql);
  304. $nbtotalofrecords = $db->num_rows($resql);
  305. if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
  306. $page = 0;
  307. $offset = 0;
  308. }
  309. }
  310. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
  311. if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
  312. $num = $nbtotalofrecords;
  313. } else {
  314. if ($limit) {
  315. $sql .= $db->plimit($limit + 1, $offset);
  316. }
  317. $resql = $db->query($sql);
  318. if (!$resql) {
  319. dol_print_error($db);
  320. exit;
  321. }
  322. $num = $db->num_rows($resql);
  323. }
  324. // Direct jump if only one record found
  325. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  326. $obj = $db->fetch_object($resql);
  327. $id = $obj->rowid;
  328. header("Location: ".dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$id);
  329. exit;
  330. }
  331. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  332. if ($projectstatic->id > 0 || $confOrBooth > 0) {
  333. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
  334. $projectstatic->fetchComments();
  335. }
  336. if (!empty($projectstatic->socid)) {
  337. $projectstatic->fetch_thirdparty();
  338. }
  339. $withProjectUrl='';
  340. $object->project = clone $projectstatic;
  341. if (!empty($withproject)) {
  342. // Tabs for project
  343. $tab = 'eventorganisation';
  344. $withProjectUrl = "&withproject=1";
  345. $head = project_prepare_head($projectstatic);
  346. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
  347. $param = ($mode == 'mine' ? '&mode=mine' : '');
  348. // Project card
  349. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  350. $morehtmlref = '<div class="refidno">';
  351. // Title
  352. $morehtmlref .= $projectstatic->title;
  353. // Thirdparty
  354. if ($projectstatic->thirdparty->id > 0) {
  355. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  356. }
  357. $morehtmlref .= '</div>';
  358. // Define a complementary filter for search of next/prev ref.
  359. if (empty($user->rights->projet->all->lire)) {
  360. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  361. $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  362. }
  363. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  364. print '<div class="fichecenter">';
  365. print '<div class="fichehalfleft">';
  366. print '<div class="underbanner clearboth"></div>';
  367. print '<table class="border tableforfield centpercent">';
  368. // Usage
  369. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
  370. print '<tr><td class="tdtop">';
  371. print $langs->trans("Usage");
  372. print '</td>';
  373. print '<td>';
  374. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  375. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  376. $htmltext = $langs->trans("ProjectFollowOpportunity");
  377. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  378. print '<br>';
  379. }
  380. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  381. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  382. $htmltext = $langs->trans("ProjectFollowTasks");
  383. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  384. print '<br>';
  385. }
  386. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  387. 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"' : '')).'"> ';
  388. $htmltext = $langs->trans("ProjectBillTimeDescription");
  389. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  390. print '<br>';
  391. }
  392. if (isModEnabled('eventorganization')) {
  393. 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"' : '')).'"> ';
  394. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  395. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  396. }
  397. print '</td></tr>';
  398. }
  399. // Visibility
  400. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  401. if ($projectstatic->public == 0) {
  402. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  403. print $langs->trans("PrivateProject");
  404. } else {
  405. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  406. print $langs->trans("SharedProject");
  407. }
  408. print '</td></tr>';
  409. // Budget
  410. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  411. if (strcmp($projectstatic->budget_amount, '')) {
  412. print '<span class="amount">'.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
  413. }
  414. print '</td></tr>';
  415. // Date start - end project
  416. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Project").')</td><td>';
  417. $start = dol_print_date($projectstatic->date_start, 'day');
  418. print ($start ? $start : '?');
  419. $end = dol_print_date($projectstatic->date_end, 'day');
  420. print ' - ';
  421. print ($end ? $end : '?');
  422. if ($projectstatic->hasDelay()) {
  423. print img_warning("Late");
  424. }
  425. print '</td></tr>';
  426. // Date start - end of event
  427. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Event").')</td><td>';
  428. $start = dol_print_date($projectstatic->date_start_event, 'day');
  429. print ($start ? $start : '?');
  430. $end = dol_print_date($projectstatic->date_end_event, 'day');
  431. print ' - ';
  432. print ($end ? $end : '?');
  433. if ($projectstatic->hasDelay()) {
  434. print img_warning("Late");
  435. }
  436. print '</td></tr>';
  437. // Location event
  438. print '<tr><td>'.$langs->trans("Location").'</td><td>';
  439. print $projectstatic->location;
  440. print '</td></tr>';
  441. // Other attributes
  442. $cols = 2;
  443. $objectconf = $object;
  444. $object = $projectstatic;
  445. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  446. $object = $objectconf;
  447. print '</table>';
  448. print '</div>';
  449. print '<div class="fichehalfright">';
  450. print '<div class="underbanner clearboth"></div>';
  451. print '<table class="border tableforfield centpercent">';
  452. // Description
  453. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  454. print nl2br($projectstatic->description);
  455. print '</td></tr>';
  456. // Categories
  457. if (isModEnabled('categorie')) {
  458. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  459. print $form->showCategories($projectstatic->id, 'project', 1);
  460. print "</td></tr>";
  461. }
  462. print '<tr><td class="nowrap">';
  463. $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : '');
  464. $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp");
  465. print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  466. print '</td><td>';
  467. print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  468. print "</td></tr>";
  469. print '<tr><td>';
  470. $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : '');
  471. $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp");
  472. print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  473. print '</td><td>';
  474. print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  475. print "</td></tr>";
  476. print '<tr><td>';
  477. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  478. print '</td><td>';
  479. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  480. print "</td></tr>";
  481. print '<tr><td>';
  482. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  483. print '</td><td>';
  484. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  485. print "</td></tr>";
  486. print '<tr><td class="titlefield">';
  487. print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $projectstatic, $permissiontoadd, 'integer:3', '&withproject=1', 0, 0, 'projectid');
  488. print '</td><td class="valuefield">';
  489. print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $projectstatic->max_attendees, $projectstatic, $permissiontoadd, 'integer:3', '', 0, 0, '&withproject=1', 0, '', 'projectid');
  490. print "</td></tr>";
  491. print '<tr><td valign="middle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
  492. // Define $urlwithroot
  493. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  494. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
  495. // Show message
  496. $message = '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : "");
  497. $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...');
  498. $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').'</a>';
  499. print $message;
  500. print "</td></tr>";
  501. // Link to the submit vote/register page
  502. print '<tr><td>';
  503. //print '<span class="opacitymedium">';
  504. print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
  505. //print '</span>';
  506. print '</td><td>';
  507. $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$projectstatic->id;
  508. $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 'md5');
  509. $linksuggest .= '&securekey='.urlencode($encodedsecurekey);
  510. //print '<div class="urllink">';
  511. //print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  512. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'" class="quatrevingtpercent">'.$linksuggest.'</a></div>';
  513. print '<a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'">'.img_picto('', 'globe').'</a>';
  514. //print '</div>';
  515. //print ajax_autoselect("linkregister");
  516. print '</td></tr>';
  517. // Link to the subscribe
  518. print '<tr><td>';
  519. //print '<span class="opacitymedium">';
  520. print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
  521. //print '</span>';
  522. print '</td><td>';
  523. $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.$projectstatic->id.'&type=global';
  524. $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 'md5');
  525. $link_subscription .= '&securekey='.urlencode($encodedsecurekey);
  526. //print '<div class="urllink">';
  527. //print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  528. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$link_subscription.'" class="quatrevingtpercent">'.$link_subscription.'</a></div>';
  529. print '<a target="_blank" rel="noopener noreferrer" href="'.$link_subscription.'">'.img_picto('', 'globe').'</a>';
  530. //print '</div>';
  531. //print ajax_autoselect("linkregister");
  532. print '</td></tr>';
  533. print '</table>';
  534. print '</div>';
  535. print '</div>';
  536. print '<div class="clearboth"></div>';
  537. print dol_get_fiche_end();
  538. if (empty($confOrBooth->id)) {
  539. $head = conferenceorboothProjectPrepareHead($projectstatic);
  540. $tab = 'attendees';
  541. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project'), 0, '', 'reposition');
  542. }
  543. }
  544. if ($confOrBooth->id > 0) {
  545. $head = conferenceorboothPrepareHead($confOrBooth, $withproject);
  546. print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
  547. $object_evt = $object;
  548. $object = $confOrBooth;
  549. dol_banner_tab($object, 'ref', '', 0);
  550. print '<div class="fichecenter">';
  551. print '<div class="fichehalfleft">';
  552. print '<div class="underbanner clearboth"></div>';
  553. print '<table class="border centpercent tableforfield">' . "\n";
  554. include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
  555. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  556. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  557. $object = $object_evt;
  558. print '</table>';
  559. print '</div>';
  560. print '</div>';
  561. print '<div class="clearboth"></div>';
  562. print dol_get_fiche_end();
  563. }
  564. }
  565. $arrayofselected = is_array($toselect) ? $toselect : array();
  566. $param = '';
  567. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  568. $param .= '&contextpage='.urlencode($contextpage);
  569. }
  570. if ($limit > 0 && $limit != $conf->liste_limit) {
  571. $param .= '&limit='.urlencode($limit);
  572. }
  573. foreach ($search as $key => $val) {
  574. if (is_array($search[$key]) && count($search[$key])) {
  575. foreach ($search[$key] as $skey) {
  576. if ($skey != '') {
  577. $param .= '&search_'.$key.'[]='.urlencode($skey);
  578. }
  579. }
  580. } elseif ($search[$key] != '') {
  581. $param .= '&search_'.$key.'='.urlencode($search[$key]);
  582. }
  583. }
  584. if ($confOrBooth->id > 0) {
  585. $param .= '&conforboothid='.urlencode($confOrBooth->id);
  586. }
  587. if ($projectstatic->id > 0) {
  588. $param .= '&fk_project='.urlencode($projectstatic->id);
  589. }
  590. $param .= $withProjectUrl;
  591. if ($optioncss != '') {
  592. $param .= '&optioncss='.urlencode($optioncss);
  593. }
  594. // Add $param from extra fields
  595. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  596. // Add $param from hooks
  597. $parameters = array();
  598. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  599. $param .= $hookmanager->resPrint;
  600. // List of mass actions available
  601. $arrayofmassactions = array(
  602. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  603. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  604. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  605. 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  606. );
  607. if ($permissiontodelete) {
  608. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  609. }
  610. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  611. $arrayofmassactions = array();
  612. }
  613. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  614. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].(!empty($conf_or_booth_id)?'?conforboothid='.$conf_or_booth_id:'').'">'."\n";
  615. if ($optioncss != '') {
  616. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  617. }
  618. print '<input type="hidden" name="token" value="'.newToken().'">';
  619. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  620. print '<input type="hidden" name="action" value="list">';
  621. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  622. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  623. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  624. print '<input type="hidden" name="withproject" value="'.$withproject.'">';
  625. print '<input type="hidden" name="fk_project" value="'.$fk_project.'">';
  626. print '<input type="hidden" name="page_y" value="">';
  627. $params = array('morecss'=>'reposition');
  628. $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);
  629. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  630. // Add code for pre mass action (confirmation or email presend form)
  631. $topicmail = $projectstatic->title;
  632. $modelmail = "conferenceorbooth";
  633. $objecttmp = new ConferenceOrBoothAttendee($db);
  634. $trackid = 'conferenceorbooth_'.$object->id;
  635. $withmaindocfilemail = 0;
  636. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  637. if ($search_all) {
  638. foreach ($fieldstosearchall as $key => $val) {
  639. $fieldstosearchall[$key] = $langs->trans($val);
  640. }
  641. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  642. }
  643. $moreforfilter = '';
  644. /*$moreforfilter.='<div class="divsearchfield">';
  645. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  646. $moreforfilter.= '</div>';*/
  647. $parameters = array();
  648. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  649. if (empty($reshook)) {
  650. $moreforfilter .= $hookmanager->resPrint;
  651. } else {
  652. $moreforfilter = $hookmanager->resPrint;
  653. }
  654. if (!empty($moreforfilter)) {
  655. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  656. print $moreforfilter;
  657. print '</div>';
  658. }
  659. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  660. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  661. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  662. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  663. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  664. // Fields title search
  665. // --------------------------------------------------------------------
  666. print '<tr class="liste_titre">';
  667. foreach ($object->fields as $key => $val) {
  668. $cssforfield = (empty($val['css']) ? '' : $val['css']);
  669. if ($key == 'status') {
  670. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  671. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  672. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  673. } elseif (in_array($val['type'], array('timestamp'))) {
  674. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  675. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') {
  676. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  677. }
  678. if (!empty($arrayfields['t.'.$key]['checked'])) {
  679. print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
  680. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  681. print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
  682. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) {
  683. print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
  684. } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  685. print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
  686. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  687. print '<div class="nowrap">';
  688. print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  689. print '</div>';
  690. print '<div class="nowrap">';
  691. print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  692. print '</div>';
  693. }
  694. print '</td>';
  695. }
  696. }
  697. // Extra fields
  698. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  699. // Fields from hook
  700. $parameters = array('arrayfields'=>$arrayfields);
  701. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  702. print $hookmanager->resPrint;
  703. // Action column
  704. print '<td class="liste_titre maxwidthsearch">';
  705. $searchpicto = $form->showFilterButtons();
  706. print $searchpicto;
  707. print '</td>';
  708. print '</tr>'."\n";
  709. // Fields title label
  710. // --------------------------------------------------------------------
  711. print '<tr class="liste_titre">';
  712. foreach ($object->fields as $key => $val) {
  713. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  714. if ($key == 'status') {
  715. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  716. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  717. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  718. } elseif (in_array($val['type'], array('timestamp'))) {
  719. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  720. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') {
  721. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  722. }
  723. if (!empty($arrayfields['t.'.$key]['checked'])) {
  724. print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
  725. }
  726. }
  727. // Extra fields
  728. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  729. // Hook fields
  730. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  731. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  732. print $hookmanager->resPrint;
  733. // Action column
  734. print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
  735. print '</tr>'."\n";
  736. // Detect if we need a fetch on each output line
  737. $needToFetchEachLine = 0;
  738. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  739. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  740. if (preg_match('/\$object/', $val)) {
  741. $needToFetchEachLine++; // There is at least one compute field that use $object
  742. }
  743. }
  744. }
  745. // Loop on record
  746. // --------------------------------------------------------------------
  747. $i = 0;
  748. $totalarray = array();
  749. while ($i < ($limit ? min($num, $limit) : $num)) {
  750. $obj = $db->fetch_object($resql);
  751. if (empty($obj)) {
  752. break; // Should not happen
  753. }
  754. // Store properties in $object
  755. $object->setVarsFromFetchObj($obj);
  756. // Show here line of result
  757. print '<tr class="oddeven">';
  758. foreach ($object->fields as $key => $val) {
  759. $cssforfield = (empty($val['css']) ? '' : $val['css']);
  760. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  761. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  762. } elseif ($key == 'status') {
  763. $cssforfield .= ($cssforfield ? ' ' : '').'center';
  764. }
  765. if (in_array($val['type'], array('timestamp'))) {
  766. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap left';
  767. } elseif ($key == 'ref') {
  768. $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
  769. }
  770. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status'))) {
  771. $cssforfield .= ($cssforfield ? ' ' : '').'right';
  772. }
  773. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  774. if (!empty($arrayfields['t.'.$key]['checked'])) {
  775. print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
  776. if ($key == 'status') {
  777. print $object->getLibStatut(5);
  778. } elseif ($key == 'ref') {
  779. $optionLink = (!empty($withproject)?'conforboothidproject':'conforboothid');
  780. if (empty($confOrBooth->id)) {
  781. $optionLink='projectid';
  782. }
  783. print $object->getNomUrl(1, $optionLink);
  784. } else {
  785. print $object->showOutputField($val, $key, $object->$key, '');
  786. }
  787. print '</td>';
  788. if (!$i) {
  789. $totalarray['nbfield']++;
  790. }
  791. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  792. if (!$i) {
  793. $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
  794. }
  795. if (!isset($totalarray['val'])) {
  796. $totalarray['val'] = array();
  797. }
  798. if (!isset($totalarray['val']['t.'.$key])) {
  799. $totalarray['val']['t.'.$key] = 0;
  800. }
  801. $totalarray['val']['t.'.$key] += $object->$key;
  802. }
  803. }
  804. }
  805. // Extra fields
  806. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  807. // Fields from hook
  808. $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  809. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  810. print $hookmanager->resPrint;
  811. // Action column
  812. print '<td class="nowrap center">';
  813. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  814. $selected = 0;
  815. if (in_array($object->id, $arrayofselected)) {
  816. $selected = 1;
  817. }
  818. print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
  819. }
  820. print '</td>';
  821. if (!$i) {
  822. $totalarray['nbfield']++;
  823. }
  824. print '</tr>'."\n";
  825. $i++;
  826. }
  827. // Show total line
  828. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  829. // If no record found
  830. if ($num == 0) {
  831. $colspan = 1;
  832. foreach ($arrayfields as $key => $val) {
  833. if (!empty($val['checked'])) {
  834. $colspan++;
  835. }
  836. }
  837. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  838. }
  839. $db->free($resql);
  840. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  841. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  842. print $hookmanager->resPrint;
  843. print '</table>'."\n";
  844. print '</div>'."\n";
  845. print '</form>'."\n";
  846. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  847. $hidegeneratedfilelistifempty = 1;
  848. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  849. $hidegeneratedfilelistifempty = 0;
  850. }
  851. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  852. $formfile = new FormFile($db);
  853. // Show list of available documents
  854. $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
  855. $urlsource .= str_replace('&amp;', '&', $param);
  856. $filedir = $diroutputmassaction;
  857. $genallowed = $permissiontoread;
  858. $delallowed = $permissiontoadd;
  859. print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  860. }
  861. // End of page
  862. llxFooter();
  863. $db->close();