conferenceorbooth_document.php 18 KB

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