conferenceorbooth_list.php 45 KB

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