conferenceorbooth_list.php 40 KB

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