conferenceorboothattendee_list.php 42 KB

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