conferenceorbooth_card.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <?php
  2. /* Copyright (C) 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 htdocs/eventorganization/conferenceorbooth_card.php
  20. * \ingroup eventorganization
  21. * \brief Page to create/edit/view conferenceorbooth
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.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.'/projet/class/project.class.php';
  33. global $dolibarr_main_url_root;
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('eventorganization', 'projects'));
  36. // Get parameters
  37. $action = GETPOST('action', 'aZ09');
  38. $confirm = GETPOST('confirm', 'alpha');
  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. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  44. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  45. $id = GETPOST('id', 'int');
  46. $ref = GETPOST('ref', 'alpha');
  47. $withproject = GETPOST('withproject', 'int');
  48. // Initialize technical objects
  49. $object = new ConferenceOrBooth($db);
  50. $extrafields = new ExtraFields($db);
  51. $projectstatic = new Project($db);
  52. $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
  53. $hookmanager->initHooks(array($contextpage, 'globalcard')); // Note that conf->hooks_modules contains array
  54. // Fetch optionals attributes and labels
  55. $extrafields->fetch_name_optionals_label($object->table_element);
  56. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  57. // Initialize array of search criterias
  58. $search_all = GETPOST("search_all", 'alpha');
  59. $search = array();
  60. foreach ($object->fields as $key => $val) {
  61. if (GETPOST('search_'.$key, 'alpha') !== '') {
  62. $search[$key] = GETPOST('search_'.$key, 'alpha');
  63. }
  64. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  65. $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
  66. $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
  67. }
  68. }
  69. if (empty($action) && empty($id) && empty($ref)) {
  70. $action = 'view';
  71. }
  72. // Load object
  73. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  74. // Permissions
  75. $permissiontoread = $user->rights->eventorganization->read;
  76. $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  77. $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  78. $permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php
  79. $permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php
  80. $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1];
  81. // Security check
  82. if ($user->socid > 0) {
  83. accessforbidden();
  84. }
  85. $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0);
  86. $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'id', $isdraft);
  87. if (!$permissiontoread) {
  88. accessforbidden();
  89. }
  90. /*
  91. * Actions
  92. */
  93. $parameters = array();
  94. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  95. if ($reshook < 0) {
  96. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  97. }
  98. if (empty($reshook)) {
  99. $error = 0;
  100. $backurlforlist = dol_buildpath('/eventorganization/conferenceorbooth_list.php', 1);
  101. if (empty($backtopage) || ($cancel && empty($id))) {
  102. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  103. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  104. $backtopage = $backurlforlist;
  105. } else {
  106. $backtopage = dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?id='.($id > 0 ? $id : '__ID__').($withproject ? '&withproject=1' : '');
  107. }
  108. }
  109. }
  110. $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTH_MODIFY'; // Name of trigger action code to execute when we modify record
  111. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  112. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  113. // Actions when linking object each other
  114. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
  115. // Actions when printing a doc from card
  116. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  117. // Action to move up and down lines of object
  118. //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
  119. // Action to build doc
  120. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  121. if ($action == 'set_thirdparty' && $permissiontoadd) {
  122. $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
  123. }
  124. if ($action == 'classin' && $permissiontoadd) {
  125. $object->setProject(GETPOST('projectid', 'int'));
  126. }
  127. // Actions to send emails
  128. $triggersendname = 'EVENTORGANIZATION_CONFERENCEORBOOTH_SENTBYMAIL';
  129. $autocopy = 'MAIN_MAIL_AUTOCOPY_CONFERENCEORBOOTH_TO';
  130. $trackid = 'conferenceorbooth'.$object->id;
  131. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  132. }
  133. /*
  134. * View
  135. */
  136. $form = new Form($db);
  137. $formfile = new FormFile($db);
  138. $formproject = new FormProjets($db);
  139. $title = $langs->trans("ConferenceOrBooth");
  140. $help_url = '';
  141. llxHeader('', $title, $help_url);
  142. if ($action == 'create') {
  143. $result = $projectstatic->fetch(GETPOST('fk_project'));
  144. } else {
  145. $result = $projectstatic->fetch($object->fk_project);
  146. }
  147. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
  148. $projectstatic->fetchComments();
  149. }
  150. if (!empty($projectstatic->socid)) {
  151. $projectstatic->fetch_thirdparty();
  152. }
  153. $withProjectUrl='';
  154. $object->project = clone $projectstatic;
  155. if (!empty($withproject)) {
  156. // Tabs for project
  157. $tab = 'eventorganisation';
  158. $withProjectUrl = "&withproject=1";
  159. $head = project_prepare_head($projectstatic);
  160. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
  161. $param = ($mode == 'mine' ? '&mode=mine' : '');
  162. // Project card
  163. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  164. $morehtmlref = '<div class="refidno">';
  165. // Title
  166. $morehtmlref .= $projectstatic->title;
  167. // Thirdparty
  168. if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
  169. $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
  170. }
  171. $morehtmlref .= '</div>';
  172. // Define a complementary filter for search of next/prev ref.
  173. if (empty($user->rights->project->all->lire)) {
  174. $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
  175. $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  176. }
  177. dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  178. print '<div class="fichecenter">';
  179. print '<div class="fichehalfleft">';
  180. print '<div class="underbanner clearboth"></div>';
  181. print '<table class="border tableforfield centpercent">';
  182. // Usage
  183. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
  184. print '<tr><td class="tdtop">';
  185. print $langs->trans("Usage");
  186. print '</td>';
  187. print '<td>';
  188. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  189. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  190. $htmltext = $langs->trans("ProjectFollowOpportunity");
  191. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  192. print '<br>';
  193. }
  194. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  195. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
  196. $htmltext = $langs->trans("ProjectFollowTasks");
  197. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  198. print '<br>';
  199. }
  200. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  201. 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"' : '')).'"> ';
  202. $htmltext = $langs->trans("ProjectBillTimeDescription");
  203. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  204. print '<br>';
  205. }
  206. if (isModEnabled('eventorganization')) {
  207. 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"' : '')).'"> ';
  208. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  209. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  210. }
  211. print '</td></tr>';
  212. }
  213. // Visibility
  214. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  215. if ($projectstatic->public == 0) {
  216. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  217. print $langs->trans("PrivateProject");
  218. } else {
  219. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  220. print $langs->trans("SharedProject");
  221. }
  222. print '</td></tr>';
  223. // Budget
  224. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  225. if (strcmp($projectstatic->budget_amount, '')) {
  226. print '<span class="amount">'.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
  227. }
  228. print '</td></tr>';
  229. // Date start - end project
  230. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Project").')</td><td>';
  231. $start = dol_print_date($projectstatic->date_start, 'day');
  232. print ($start ? $start : '?');
  233. $end = dol_print_date($projectstatic->date_end, 'day');
  234. print ' - ';
  235. print ($end ? $end : '?');
  236. if ($object->hasDelay()) {
  237. print img_warning("Late");
  238. }
  239. print '</td></tr>';
  240. // Date start - end of event
  241. print '<tr><td>'.$langs->trans("Dates").' ('.$langs->trans("Event").')</td><td>';
  242. $start = dol_print_date($projectstatic->date_start_event, 'day');
  243. print ($start ? $start : '?');
  244. $end = dol_print_date($projectstatic->date_end_event, 'day');
  245. print ' - ';
  246. print ($end ? $end : '?');
  247. if ($object->hasDelay()) {
  248. print img_warning("Late");
  249. }
  250. print '</td></tr>';
  251. // Location event
  252. print '<tr><td>'.$langs->trans("Location").'</td><td>';
  253. print $projectstatic->location;
  254. print '</td></tr>';
  255. // Other attributes
  256. $cols = 2;
  257. $objectconf = $object;
  258. $object = $projectstatic;
  259. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  260. $object = $objectconf;
  261. print '</table>';
  262. print '</div>';
  263. print '<div class="fichehalfright">';
  264. print '<div class="underbanner clearboth"></div>';
  265. print '<table class="border tableforfield centpercent">';
  266. // Description
  267. print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td class="valuefield">';
  268. print dol_htmlentitiesbr($projectstatic->description);
  269. print '</td></tr>';
  270. // Categories
  271. if (isModEnabled('categorie')) {
  272. print '<tr><td class="titlefield valignmiddle">'.$langs->trans("Categories").'</td><td class="valuefield">';
  273. print $form->showCategories($projectstatic->id, Categorie::TYPE_PROJECT, 1);
  274. print "</td></tr>";
  275. }
  276. print '<tr><td class="titlefield nowrap">';
  277. $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : '');
  278. $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp");
  279. print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  280. print '</td><td class="valuefield">';
  281. print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  282. print "</td></tr>";
  283. print '<tr><td class="valuefield">';
  284. $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : '');
  285. $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp");
  286. print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext);
  287. print '</td><td class="valuefield">';
  288. print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
  289. print "</td></tr>";
  290. print '<tr><td class="valuefield">';
  291. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  292. print '</td><td class="valuefield">';
  293. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  294. print "</td></tr>";
  295. print '<tr><td class="valuefield">';
  296. print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid');
  297. print '</td><td class="valuefield">';
  298. print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid');
  299. print "</td></tr>";
  300. print '<tr><td class="titlefield">';
  301. print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $project, $permissiontoadd, 'integer:3', '', 0, 0, 'projectid');
  302. print '</td><td class="valuefield">';
  303. print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid');
  304. print "</td></tr>";
  305. print '<tr><td class="titlefield valignmiddle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
  306. // Define $urlwithroot
  307. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  308. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
  309. // Show message
  310. $message = '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : "");
  311. $message .= '&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...'));
  312. $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').'</a>';
  313. print $message;
  314. print "</td></tr>";
  315. // Link to the submit vote/register page
  316. print '<tr><td>';
  317. //print '<span class="opacitymedium">';
  318. print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
  319. //print '</span>';
  320. print '</td><td>';
  321. $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $projectstatic->id);
  322. $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5');
  323. $linksuggest .= '&securekey='.urlencode($encodedsecurekey);
  324. //print '<div class="urllink">';
  325. //print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  326. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$linksuggest.'" class="quatrevingtpercent">'.$linksuggest.'</a></div>';
  327. print '<a target="_blank" rel="noopener noreferrer" href="'.$linksuggest.'">'.img_picto('', 'globe').'</a>';
  328. //print '</div>';
  329. //print ajax_autoselect("linkregister");
  330. print '</td></tr>';
  331. // Link to the subscribe
  332. print '<tr><td>';
  333. //print '<span class="opacitymedium">';
  334. print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
  335. //print '</span>';
  336. print '</td><td>';
  337. $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $projectstatic->id).'&type=global';
  338. $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5');
  339. $link_subscription .= '&securekey='.urlencode($encodedsecurekey);
  340. //print '<div class="urllink">';
  341. //print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
  342. print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$link_subscription.'" class="quatrevingtpercent">'.$link_subscription.'</a></div>';
  343. print '<a target="_blank" rel="noopener noreferrer" rel="noopener noreferrer" href="'.$link_subscription.'">'.img_picto('', 'globe').'</a>';
  344. //print '</div>';
  345. //print ajax_autoselect("linkregister");
  346. print '</td></tr>';
  347. print '</table>';
  348. print '</div>';
  349. print '</div>';
  350. print '<div class="clearboth"></div>';
  351. print dol_get_fiche_end();
  352. print '<br>';
  353. }
  354. // Part to create
  355. if ($action == 'create') {
  356. print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto);
  357. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  358. print '<input type="hidden" name="token" value="'.newToken().'">';
  359. print '<input type="hidden" name="action" value="add">';
  360. if ($withproject) {
  361. print '<input type="hidden" name="withproject" value="'.$withproject.'">';
  362. print '<input type="hidden" name="fk_project" value="'.GETPOST('fk_project', 'int').'">';
  363. }
  364. if ($backtopage) {
  365. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  366. }
  367. if ($backtopageforcancel) {
  368. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  369. }
  370. print dol_get_fiche_head(array(), '');
  371. print '<table class="border centpercent tableforfieldcreate">'."\n";
  372. // Common attributes
  373. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
  374. // Other attributes
  375. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  376. print '</table>'."\n";
  377. print dol_get_fiche_end();
  378. print $form->buttonsSaveCancel("Create");
  379. print '</form>';
  380. //dol_set_focus('input[name="ref"]');
  381. }
  382. // Part to edit record
  383. if (($id || $ref) && $action == 'edit') {
  384. print load_fiche_titre($langs->trans("ConferenceOrBooth"), '', 'object_'.$object->picto);
  385. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  386. print '<input type="hidden" name="token" value="'.newToken().'">';
  387. if (!empty($withProjectUrl)) {
  388. print '<input type="hidden" name="withproject" value="1">';
  389. }
  390. print '<input type="hidden" name="action" value="update">';
  391. print '<input type="hidden" name="id" value="'.$object->id.'">';
  392. if ($backtopage) {
  393. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  394. }
  395. if ($backtopageforcancel) {
  396. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  397. }
  398. print dol_get_fiche_head();
  399. print '<table class="border centpercent tableforfieldedit">'."\n";
  400. // Common attributes
  401. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
  402. // Other attributes
  403. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
  404. print '</table>';
  405. print dol_get_fiche_end();
  406. print $form->buttonsSaveCancel();
  407. print '</form>';
  408. }
  409. // Part to show record
  410. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  411. $res = $object->fetch_optionals();
  412. $head = conferenceorboothPrepareHead($object, $withproject);
  413. print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
  414. $formconfirm = '';
  415. // Confirmation to delete
  416. if ($action == 'delete') {
  417. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  418. }
  419. // Clone confirmation
  420. if ($action == 'clone') {
  421. // Create an array for form
  422. $formquestion = array();
  423. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  424. }
  425. // Confirmation of action xxxx
  426. //TODO Send mass email
  427. if ($action == 'xxx') {
  428. $formquestion = array();
  429. /*
  430. $forcecombo=0;
  431. if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
  432. $formquestion = array(
  433. // 'text' => $langs->trans("ConfirmClone"),
  434. // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
  435. // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
  436. // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
  437. );
  438. */
  439. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
  440. }
  441. // Call Hook formConfirm
  442. $parameters = array('formConfirm' => $formconfirm);
  443. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  444. if (empty($reshook)) {
  445. $formconfirm .= $hookmanager->resPrint;
  446. } elseif ($reshook > 0) {
  447. $formconfirm = $hookmanager->resPrint;
  448. }
  449. // Print form confirm
  450. print $formconfirm;
  451. // Object card
  452. // ------------------------------------------------------------
  453. $linkback = '<a href="'.dol_buildpath('/eventorganization/conferenceorbooth_list.php', 1).'?projectid='.$object->fk_project.$withProjectUrl.'">'.$langs->trans("BackToList").'</a>';
  454. $morehtmlref = '<div class="refidno">';
  455. $morehtmlref .= '</div>';
  456. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  457. print '<div class="fichecenter">';
  458. print '<div class="fichehalfleft">';
  459. print '<div class="underbanner clearboth"></div>';
  460. print '<table class="border centpercent tableforfield">'."\n";
  461. // Common attributes
  462. //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
  463. //unset($object->fields['fk_project']); // Hide field already shown in banner
  464. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  465. $keyforbreak='num_vote';
  466. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  467. //var_dump($object);
  468. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  469. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  470. print '</table>';
  471. print '</div>';
  472. print '</div>';
  473. print '<div class="clearboth"></div>';
  474. print dol_get_fiche_end();
  475. // Buttons for actions
  476. if ($action != 'presend' && $action != 'editline') {
  477. print '<div class="tabsAction">'."\n";
  478. $parameters = array();
  479. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  480. if ($reshook < 0) {
  481. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  482. }
  483. if (empty($reshook)) {
  484. // Send
  485. if (empty($user->socid)) {
  486. print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
  487. }
  488. print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken(), '', $permissiontoadd);
  489. // Clone
  490. print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd);
  491. // Delete (need delete permission, or if draft, just need create/modify permission)
  492. print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
  493. }
  494. print '</div>'."\n";
  495. }
  496. // Select mail models is same action as presend
  497. if (GETPOST('modelselected')) {
  498. $action = 'presend';
  499. }
  500. if ($action != 'presend') {
  501. print '<div class="fichecenter"><div class="fichehalfleft">';
  502. print '<a name="builddoc"></a>'; // ancre
  503. $includedocgeneration = 1;
  504. // Documents
  505. if ($includedocgeneration) {
  506. $objref = dol_sanitizeFileName($object->ref);
  507. $relativepath = $objref.'/'.$objref.'.pdf';
  508. $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref;
  509. $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
  510. $genallowed = $user->rights->eventorganization->read; // If you can read, you can build the PDF to read content
  511. $delallowed = $user->rights->eventorganization->write; // If you can create/edit, you can remove a file on card
  512. print $formfile->showdocuments('eventorganization', $object->element.'/'.$objref, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
  513. }
  514. // Show links to link elements
  515. //$linktoelem = $form->showLinkToObjectBlock($object, null, array('conferenceorbooth'));
  516. //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
  517. $object->fetchObjectLinked();
  518. if (is_array($object->linkedObjects) && count($object->linkedObjects)>0 && array_key_exists("facture", $object->linkedObjects)) {
  519. foreach ($object->linkedObjects["facture"] as $fac) {
  520. if (empty($fac->paye)) {
  521. $key = 'paymentlink_'.$fac->id;
  522. print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $langs->transnoentitiesnoconv('Online')) . ' '. $fac->ref.'</span><br>';
  523. $sourcetouse = 'boothlocation';
  524. $reftouse = $fac->id;
  525. $url = getOnlinePaymentUrl(0, $sourcetouse, $reftouse);
  526. $url .= '&booth='.$object->id;
  527. print '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">';
  528. print '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a></div>';
  529. }
  530. }
  531. }
  532. print '</div><div class="fichehalfright">';
  533. print '</div></div>';
  534. }
  535. //Select mail models is same action as presend
  536. if (GETPOST('modelselected')) {
  537. $action = 'presend';
  538. }
  539. // Presend form
  540. $modelmail = 'conferenceorbooth';
  541. $defaulttopic = 'InformationMessage';
  542. $diroutput = $conf->eventorganization->dir_output;
  543. $trackid = 'conferenceorbooth'.$object->id;
  544. include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
  545. }
  546. // End of page
  547. llxFooter();
  548. $db->close();