conferenceorboothattendee_card.php 27 KB

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