conferenceorbooth_list.php 36 KB

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