conferenceorbooth_card.php 27 KB

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