conferenceorboothattendee_card.php 27 KB

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