conferenceorbooth_list.php 45 KB

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