recruitmentjobposition_card.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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 recruitmentjobposition_card.php
  19. * \ingroup recruitment
  20. * \brief Page to create/edit/view recruitmentjobposition
  21. */
  22. // Load Dolibarr environment
  23. require_once '../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.'/projet/class/project.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("recruitment", "other"));
  32. // Get parameters
  33. $id = GETPOST('id', 'int');
  34. $ref = GETPOST('ref', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. $confirm = GETPOST('confirm', 'alpha');
  37. $cancel = GETPOST('cancel', 'aZ09');
  38. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
  39. $backtopage = GETPOST('backtopage', 'alpha');
  40. $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
  41. $lineid = GETPOST('lineid', 'int');
  42. // Initialize technical objects
  43. $object = new RecruitmentJobPosition($db);
  44. $extrafields = new ExtraFields($db);
  45. $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
  46. $hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
  47. // Fetch optionals attributes and labels
  48. $extrafields->fetch_name_optionals_label($object->table_element);
  49. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  50. // Initialize array of search criterias
  51. $search_all = GETPOST("search_all", 'alpha');
  52. $search = array();
  53. foreach ($object->fields as $key => $val) {
  54. if (GETPOST('search_'.$key, 'alpha')) {
  55. $search[$key] = GETPOST('search_'.$key, 'alpha');
  56. }
  57. }
  58. if (empty($action) && empty($id) && empty($ref)) {
  59. $action = 'create';
  60. }
  61. // Load object
  62. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
  63. $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
  64. $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  65. $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  66. $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
  67. $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
  68. $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
  69. $usercanclose = $permissiontoadd;
  70. // Security check - Protection if external user
  71. //if ($user->socid > 0) accessforbidden();
  72. //if ($user->socid > 0) $socid = $user->socid;
  73. $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  74. $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
  75. /*
  76. * Actions
  77. */
  78. $parameters = array();
  79. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  80. if ($reshook < 0) {
  81. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  82. }
  83. if (empty($reshook)) {
  84. $error = 0;
  85. $backurlforlist = dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1);
  86. if (empty($backtopage) || ($cancel && empty($id))) {
  87. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  88. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  89. $backtopage = $backurlforlist;
  90. } else {
  91. $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
  92. }
  93. }
  94. }
  95. $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
  96. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  97. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  98. // Actions when linking object each other
  99. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
  100. // Actions when printing a doc from card
  101. include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
  102. // Action to move up and down lines of object
  103. //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
  104. // Action to build doc
  105. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  106. if ($action == 'set_thirdparty' && $permissiontoadd) {
  107. $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
  108. }
  109. if ($action == 'classin' && $permissiontoadd) {
  110. $object->setProject(GETPOST('projectid', 'int'));
  111. }
  112. if ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) {
  113. if (!(GETPOST('status', 'int') > 0)) {
  114. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
  115. $action = 'closeas';
  116. } else {
  117. // prevent browser refresh from closing proposal several times
  118. if ($object->status == $object::STATUS_VALIDATED) {
  119. $db->begin();
  120. $result = $object->cloture($user, GETPOST('status', 'int'), GETPOST('note_private', 'restricthtml'));
  121. if ($result < 0) {
  122. setEventMessages($object->error, $object->errors, 'errors');
  123. $error++;
  124. }
  125. if (!$error) {
  126. $db->commit();
  127. } else {
  128. $db->rollback();
  129. }
  130. }
  131. }
  132. }
  133. // Actions to send emails
  134. $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
  135. $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
  136. $trackid = 'recruitmentjobposition'.$object->id;
  137. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  138. }
  139. /*
  140. * View
  141. */
  142. $form = new Form($db);
  143. $formfile = new FormFile($db);
  144. $formproject = new FormProjets($db);
  145. $title = $object->ref." - ".$langs->trans('Card');
  146. $help_url = '';
  147. llxHeader('', $title, $help_url);
  148. // Part to create
  149. if ($action == 'create') {
  150. print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
  151. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  152. print '<input type="hidden" name="token" value="'.newToken().'">';
  153. print '<input type="hidden" name="action" value="add">';
  154. if ($backtopage) {
  155. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  156. }
  157. if ($backtopageforcancel) {
  158. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  159. }
  160. // Set some default values
  161. if (!GETPOSTISSET('fk_user_recruiter')) {
  162. $_POST['fk_user_recruiter'] = $user->id;
  163. }
  164. print dol_get_fiche_head(array(), '');
  165. print '<table class="border centpercent tableforfieldcreate">'."\n";
  166. // Common attributes
  167. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
  168. // Other attributes
  169. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  170. print '</table>'."\n";
  171. print dol_get_fiche_end();
  172. print $form->buttonsSaveCancel("Create");
  173. print '</form>';
  174. //dol_set_focus('input[name="ref"]');
  175. }
  176. // Part to edit record
  177. if (($id || $ref) && $action == 'edit') {
  178. print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto);
  179. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  180. print '<input type="hidden" name="token" value="'.newToken().'">';
  181. print '<input type="hidden" name="action" value="update">';
  182. print '<input type="hidden" name="id" value="'.$object->id.'">';
  183. if ($backtopage) {
  184. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  185. }
  186. if ($backtopageforcancel) {
  187. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  188. }
  189. print dol_get_fiche_head();
  190. print '<table class="border centpercent tableforfieldedit">'."\n";
  191. // Common attributes
  192. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
  193. // Other attributes
  194. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
  195. print '</table>';
  196. print dol_get_fiche_end();
  197. print $form->buttonsSaveCancel();
  198. print '</form>';
  199. }
  200. // Part to show record
  201. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  202. $head = recruitmentjobpositionPrepareHead($object);
  203. print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentJobPosition"), -1, $object->picto);
  204. $formconfirm = '';
  205. // Confirmation to delete
  206. if ($action == 'delete') {
  207. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  208. }
  209. // Confirmation to delete line
  210. if ($action == 'deleteline') {
  211. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
  212. }
  213. // Clone confirmation
  214. if ($action == 'clone') {
  215. // Create an array for form
  216. $formquestion = array();
  217. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
  218. }
  219. if ($action == 'closeas') {
  220. $text = "";
  221. //Form to close proposal (signed or not)
  222. $formquestion = array(
  223. array('type' => 'select', 'name' => 'status', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array(3=>$object->LibStatut($object::STATUS_RECRUITED), 9=>$object->LibStatut($object::STATUS_CANCELED))),
  224. array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
  225. );
  226. /*if (isModEnabled('notification'))
  227. {
  228. require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
  229. $notify = new Notify($db);
  230. $formquestion = array_merge($formquestion, array(
  231. array('type' => 'onecolumn', 'value' => $notify->confirmMessage('RECRUITMENTJOBPOSITION_CLOSE_SIGNED', $object->socid, $object)),
  232. ));
  233. }*/
  234. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
  235. }
  236. // Call Hook formConfirm
  237. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  238. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  239. if (empty($reshook)) {
  240. $formconfirm .= $hookmanager->resPrint;
  241. } elseif ($reshook > 0) {
  242. $formconfirm = $hookmanager->resPrint;
  243. }
  244. // Print form confirm
  245. print $formconfirm;
  246. // Object card
  247. // ------------------------------------------------------------
  248. $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  249. $morehtmlref = '<div class="refidno">';
  250. /*
  251. // Ref customer
  252. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  253. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  254. // Thirdparty
  255. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  256. */
  257. // Project
  258. if (isModEnabled('project')) {
  259. $langs->load("projects");
  260. $morehtmlref .= $langs->trans('Project').' ';
  261. if ($permissiontoadd) {
  262. if ($action != 'classify') {
  263. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
  264. }
  265. $morehtmlref .= ' : ';
  266. if ($action == 'classify') {
  267. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  268. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  269. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  270. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  271. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  272. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  273. $morehtmlref .= '</form>';
  274. } else {
  275. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
  276. }
  277. } else {
  278. if (!empty($object->fk_project)) {
  279. $proj = new Project($db);
  280. $proj->fetch($object->fk_project);
  281. $morehtmlref .= ': '.$proj->getNomUrl();
  282. } else {
  283. $morehtmlref .= '';
  284. }
  285. }
  286. }
  287. $morehtmlref .= '</div>';
  288. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  289. print '<div class="fichecenter">';
  290. print '<div class="fichehalfleft">';
  291. print '<div class="underbanner clearboth"></div>';
  292. print '<table class="border centpercent tableforfield">'."\n";
  293. // Common attributes
  294. $keyforbreak = 'description'; // We change column just after this field
  295. unset($object->fields['fk_project']); // Hide field already shown in banner
  296. //unset($object->fields['fk_soc']); // Hide field already shown in banner
  297. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  298. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  299. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  300. print '</table>';
  301. print '</div>';
  302. print '</div>';
  303. print '<div class="clearboth"></div>';
  304. print dol_get_fiche_end();
  305. // Buttons for actions
  306. if ($action != 'presend' && $action != 'editline') {
  307. print '<div class="tabsAction">'."\n";
  308. $parameters = array();
  309. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  310. if ($reshook < 0) {
  311. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  312. }
  313. if (empty($reshook)) {
  314. // Send
  315. if (empty($user->socid)) {
  316. print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
  317. }
  318. // Back to draft
  319. if ($object->status == $object::STATUS_VALIDATED) {
  320. if ($permissiontoadd) {
  321. print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
  322. }
  323. }
  324. // Modify
  325. print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
  326. // Validate
  327. if ($object->status == $object::STATUS_DRAFT) {
  328. if ($permissiontoadd) {
  329. if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
  330. print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
  331. } else {
  332. $langs->load("errors");
  333. print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
  334. }
  335. }
  336. }
  337. // Close as recruited/canceled
  338. if ($object->status == $object::STATUS_VALIDATED) {
  339. if ($usercanclose) {
  340. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=closeas&token='.newToken().(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
  341. print '>'.$langs->trans('Close').'</a>';
  342. } else {
  343. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Close').'</a>';
  344. }
  345. }
  346. // Clone
  347. if ($permissiontoadd) {
  348. print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=recruitmentjobposition', 'clone', $permissiontoadd);
  349. }
  350. /*
  351. if ($permissiontoadd) {
  352. if ($object->status == $object::STATUS_ENABLED) {
  353. print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
  354. } else {
  355. print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
  356. }
  357. }
  358. }*/
  359. if ($permissiontoadd) {
  360. if ($object->status == $object::STATUS_CANCELED) {
  361. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
  362. }
  363. }
  364. // Delete
  365. $params = array();
  366. print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params);
  367. }
  368. print '</div>'."\n";
  369. }
  370. // Select mail models is same action as presend
  371. if (GETPOST('modelselected')) {
  372. $action = 'presend';
  373. }
  374. if ($action != 'presend') {
  375. print '<div class="fichecenter"><div class="fichehalfleft">';
  376. print '<a name="builddoc"></a>'; // ancre
  377. $includedocgeneration = 1;
  378. // Documents
  379. if ($includedocgeneration) {
  380. $objref = dol_sanitizeFileName($object->ref);
  381. $relativepath = $objref.'/'.$objref.'.pdf';
  382. $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
  383. $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
  384. $genallowed = $user->rights->recruitment->recruitmentjobposition->read; // If you can read, you can build the PDF to read content
  385. $delallowed = $user->rights->recruitment->recruitmentjobposition->write; // If you can create/edit, you can remove a file on card
  386. print $formfile->showdocuments('recruitment:RecruitmentJobPosition', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
  387. }
  388. // Show links to link elements
  389. $linktoelem = $form->showLinkToObjectBlock($object, null, array('recruitmentjobposition'));
  390. $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
  391. // Show link to public job page
  392. if ($object->status != RecruitmentJobPosition::STATUS_DRAFT) {
  393. print '<br><!-- Link to go on public job page -->'."\n";
  394. // Load translation files required by the page
  395. $langs->loadLangs(array('recruitment'));
  396. $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("PublicUrl").'</span><br>';
  397. $url = getPublicJobPositionUrl(0, $object->ref);
  398. $out .= '<div class="urllink"><input type="text" id="recruitmentjobpositionurl" class="quatrevingtpercent" value="'.$url.'">';
  399. $out .= '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe').'</a></div>';
  400. $out .= ajax_autoselect("recruitmentjobpositionurl", 0);
  401. print $out;
  402. }
  403. print '</div><div class="fichehalfright">';
  404. $MAXEVENT = 10;
  405. $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/recruitment/recruitmentjobposition_agenda.php?id='.$object->id);
  406. // List of actions on element
  407. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  408. $formactions = new FormActions($db);
  409. $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
  410. print '</div></div>';
  411. }
  412. //Select mail models is same action as presend
  413. if (GETPOST('modelselected')) {
  414. $action = 'presend';
  415. }
  416. // Presend form
  417. $modelmail = 'recruitmentjobposition';
  418. $defaulttopic = 'InformationMessage';
  419. $diroutput = $conf->recruitment->dir_output;
  420. $trackid = 'recruitmentjobposition'.$object->id;
  421. include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
  422. }
  423. // End of page
  424. llxFooter();
  425. $db->close();