conferenceorboothattendee_card.php 28 KB

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