conferenceorbooth_document.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file conferenceorbooth_document.php
  20. * \ingroup eventorganization
  21. * \brief Tab for documents linked to ConferenceOrBooth
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.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/lib/eventorganization_conferenceorbooth.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("eventorganization", "projects", "companies", "other", "mails"));
  36. // Get Parameters
  37. $action = GETPOST('action', 'aZ09');
  38. $confirm = GETPOST('confirm');
  39. $cancel = GETPOST('cancel', 'aZ09');
  40. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothcard'; // To manage different context of search
  41. $backtopage = GETPOST('backtopage', 'alpha');
  42. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  43. $id = GETPOST('id', 'int');
  44. $ref = GETPOST('ref', 'alpha');
  45. $withproject = GETPOST('withproject', 'int');
  46. $project_ref = GETPOST('project_ref', 'alpha');
  47. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  48. $sortfield = GETPOST('sortfield', 'aZ09comma');
  49. $sortorder = GETPOST('sortorder', 'aZ09comma');
  50. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  51. if (empty($page) || $page == -1) {
  52. $page = 0;
  53. } // If $page is not defined, or '' or -1
  54. $offset = $limit * $page;
  55. $pageprev = $page - 1;
  56. $pagenext = $page + 1;
  57. if (!$sortorder) {
  58. $sortorder = "ASC";
  59. }
  60. if (!$sortfield) {
  61. $sortfield = "name";
  62. }
  63. //if (! $sortfield) $sortfield="position_name";
  64. // Initialize technical objects
  65. $object = new ConferenceOrBooth($db);
  66. $extrafields = new ExtraFields($db);
  67. $projectstatic = new Project($db);
  68. $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
  69. $hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array
  70. // Fetch optionals attributes and labels
  71. $extrafields->fetch_name_optionals_label($object->table_element);
  72. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  73. // Load object
  74. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  75. if ($id > 0 || !empty($ref)) {
  76. $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object);
  77. }
  78. // Permissions
  79. $permissiontoread = $user->rights->eventorganization->read;
  80. $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  81. $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  82. $permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php
  83. $permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php
  84. $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1];
  85. // Security check
  86. if ($user->socid > 0) {
  87. accessforbidden();
  88. }
  89. $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0);
  90. $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'id', $isdraft);
  91. if (!$permissiontoread) {
  92. accessforbidden();
  93. }
  94. /*
  95. * Actions
  96. */
  97. $parameters = array();
  98. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  99. if ($reshook < 0) {
  100. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  101. }
  102. include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
  103. /*
  104. * View
  105. */
  106. $form = new Form($db);
  107. $title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files");
  108. $help_url = '';
  109. llxHeader('', $title, $help_url);
  110. $result = $projectstatic->fetch($object->fk_project);
  111. if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
  112. $projectstatic->fetchComments();
  113. }
  114. if (!empty($projectstatic->socid)) {
  115. $projectstatic->fetch_thirdparty();
  116. }
  117. $withProjectUrl='';
  118. $object->project = clone $projectstatic;
  119. if (!empty($withproject)) {
  120. // Tabs for project
  121. $tab = 'eventorganisation';
  122. $withProjectUrl = "&withproject=1";
  123. $head = project_prepare_head($projectstatic);
  124. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
  125. // Project card
  126. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  127. $morehtmlref = '<div class="refidno">';
  128. // Title
  129. $morehtmlref .= $projectstatic->title;
  130. // Thirdparty
  131. if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
  132. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  133. }
  134. $morehtmlref .= '</div>';
  135. // Define a complementary filter for search of next/prev ref.
  136. if (!$user->hasRight('project', 'all', 'lire')) {
  137. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  138. $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
  139. }
  140. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  141. print '<div class="fichecenter">';
  142. print '<div class="fichehalfleft">';
  143. print '<div class="underbanner clearboth"></div>';
  144. print '<table class="border tableforfield centpercent">';
  145. // Usage
  146. if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
  147. print '<tr><td class="tdtop">';
  148. print $langs->trans("Usage");
  149. print '</td>';
  150. print '<td>';
  151. if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
  152. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  153. $htmltext = $langs->trans("ProjectFollowOpportunity");
  154. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  155. print '<br>';
  156. }
  157. if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
  158. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  159. $htmltext = $langs->trans("ProjectFollowTasks");
  160. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  161. print '<br>';
  162. }
  163. if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
  164. print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
  165. $htmltext = $langs->trans("ProjectBillTimeDescription");
  166. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  167. print '<br>';
  168. }
  169. if (isModEnabled('eventorganization')) {
  170. print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> ';
  171. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  172. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  173. }
  174. print '</td></tr>';
  175. }
  176. // Visibility
  177. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  178. if ($projectstatic->public) {
  179. print $langs->trans('SharedProject');
  180. } else {
  181. print $langs->trans('PrivateProject');
  182. }
  183. print '</td></tr>';
  184. // Date start - end
  185. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  186. $start = dol_print_date($projectstatic->date_start, 'day');
  187. print($start ? $start : '?');
  188. $end = dol_print_date($projectstatic->date_end, 'day');
  189. print ' - ';
  190. print($end ? $end : '?');
  191. if ($projectstatic->hasDelay()) {
  192. print img_warning("Late");
  193. }
  194. print '</td></tr>';
  195. // Budget
  196. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  197. if (strcmp($projectstatic->budget_amount, '')) {
  198. print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  199. }
  200. print '</td></tr>';
  201. // Other attributes
  202. $cols = 2;
  203. $objectconf = $object;
  204. $object = $projectstatic;
  205. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  206. $object = $objectconf;
  207. print '</table>';
  208. print '</div>';
  209. print '<div class="fichehalfright">';
  210. print '<div class="underbanner clearboth"></div>';
  211. print '<table class="border tableforfield centpercent">';
  212. // Description
  213. print '<td class="tdtop">'.$langs->trans("Description").'</td><td>';
  214. print nl2br($projectstatic->description);
  215. print '</td></tr>';
  216. // Categories
  217. if (isModEnabled('categorie')) {
  218. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  219. print $form->showCategories($projectstatic->id, Categorie::TYPE_PROJECT, 1);
  220. print "</td></tr>";
  221. }
  222. print '<tr><td>';
  223. $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : '');
  224. $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp");
  225. print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  226. print '</td><td>';
  227. print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  228. print "</td></tr>";
  229. print '<tr><td>';
  230. $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : '');
  231. $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp");
  232. print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  233. print '</td><td>';
  234. print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  235. print "</td></tr>";
  236. print '<tr><td>';
  237. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  238. print '</td><td>';
  239. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  240. print "</td></tr>";
  241. print '<tr><td>';
  242. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  243. print '</td><td>';
  244. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  245. print "</td></tr>";
  246. print '<tr><td valign="middle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
  247. // Define $urlwithroot
  248. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  249. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
  250. // Show message
  251. $message = '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : "");
  252. $message .= '&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...'));
  253. $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').'</a>';
  254. print $message;
  255. print "</td></tr>";
  256. // Link to the submit vote/register page
  257. print '<tr><td>';
  258. //print '<span class="opacitymedium">';
  259. print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
  260. //print '</span>';
  261. print '</td><td>';
  262. $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $projectstatic->id);
  263. $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5');
  264. $linksuggest .= '&securekey='.urlencode($encodedsecurekey);
  265. //print '<div class="urllink">';
  266. //print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  267. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$linksuggest.'" class="quatrevingtpercent">'.$linksuggest.'</a></div>';
  268. print '<a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'">'.img_picto('', 'globe').'</a>';
  269. //print '</div>';
  270. //print ajax_autoselect("linkregister");
  271. print '</td></tr>';
  272. // Link to the subscribe
  273. print '<tr><td>';
  274. //print '<span class="opacitymedium">';
  275. print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
  276. //print '</span>';
  277. print '</td><td>';
  278. $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $projectstatic->id).'&type=global';
  279. $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5');
  280. $link_subscription .= '&securekey='.urlencode($encodedsecurekey);
  281. //print '<div class="urllink">';
  282. //print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  283. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$link_subscription.'" class="quatrevingtpercent">'.$link_subscription.'</a></div>';
  284. print '<a target="_blank" rel="noopener noreferrer" rel="noopener noreferrer" href="'.$link_subscription.'">'.img_picto('', 'globe').'</a>';
  285. //print '</div>';
  286. //print ajax_autoselect("linkregister");
  287. print '</td></tr>';
  288. print '</table>';
  289. print '</div>';
  290. print '</div>';
  291. print '<div class="clearboth"></div>';
  292. print dol_get_fiche_end();
  293. print '<br>';
  294. }
  295. if ($object->id) {
  296. /*
  297. * Show tabs
  298. */
  299. $head = conferenceorboothPrepareHead($object, $withproject);
  300. print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
  301. // Build file list
  302. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
  303. $totalsize = 0;
  304. foreach ($filearray as $key => $file) {
  305. $totalsize += $file['size'];
  306. }
  307. // Object card
  308. //-----------------------------------------------
  309. $linkback = '<a href="'.dol_buildpath('/eventorganization/conferenceorbooth_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  310. $morehtmlref = '<div class="refidno">';
  311. $morehtmlref .= '</div>';
  312. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  313. print '<div class="fichecenter">';
  314. print '<div class="underbanner clearboth"></div>';
  315. print '<table class="border centpercent tableforfield">';
  316. // Number of files
  317. print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
  318. // Total size
  319. print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
  320. print '</table>';
  321. print '</div>';
  322. print dol_get_fiche_end();
  323. $modulepart = 'eventorganization';
  324. //$permission = $user->rights->eventorganization->conferenceorbooth->write;
  325. $permission = 1;
  326. //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write;
  327. $permtoedit = 1;
  328. $param = '&id='.$object->id;
  329. //$param = '';
  330. if ($withproject) {
  331. $param .= '&withproject=1';
  332. }
  333. //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/';
  334. $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/';
  335. include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
  336. } else {
  337. accessforbidden('', 0, 1);
  338. }
  339. // End of page
  340. llxFooter();
  341. $db->close();