dolibarr  16.0.5
recruitmentjobposition_card.php
Go to the documentation of this file.
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 
24 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db
25 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user
26 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc
27 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs
28 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters
29 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters
30 //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
31 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
32 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
33 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
35 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
36 //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
37 //if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
38 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value
39 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler
40 //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
41 //if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies
42 
43 
44 // Load Dolibarr environment
45 require_once '../main.inc.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
50 dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
51 dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
52 
53 // Load translation files required by the page
54 $langs->loadLangs(array("recruitment", "other"));
55 
56 // Get parameters
57 $id = GETPOST('id', 'int');
58 $ref = GETPOST('ref', 'alpha');
59 $action = GETPOST('action', 'aZ09');
60 $confirm = GETPOST('confirm', 'alpha');
61 $cancel = GETPOST('cancel', 'aZ09');
62 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
63 $backtopage = GETPOST('backtopage', 'alpha');
64 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
65 //$lineid = GETPOST('lineid', 'int');
66 
67 // Initialize technical objects
68 $object = new RecruitmentJobPosition($db);
69 $extrafields = new ExtraFields($db);
70 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
71 $hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
72 
73 // Fetch optionals attributes and labels
74 $extrafields->fetch_name_optionals_label($object->table_element);
75 
76 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
77 
78 // Initialize array of search criterias
79 $search_all = GETPOST("search_all", 'alpha');
80 $search = array();
81 foreach ($object->fields as $key => $val) {
82  if (GETPOST('search_'.$key, 'alpha')) {
83  $search[$key] = GETPOST('search_'.$key, 'alpha');
84  }
85 }
86 
87 if (empty($action) && empty($id) && empty($ref)) {
88  $action = 'view';
89 }
90 
91 // Load object
92 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
93 
94 
95 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
96 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
97 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
98 $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
99 $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
100 $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
101 
102 $usercanclose = $permissiontoadd;
103 
104 // Security check - Protection if external user
105 //if ($user->socid > 0) accessforbidden();
106 //if ($user->socid > 0) $socid = $user->socid;
107 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
108 $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
109 
110 
111 /*
112  * Actions
113  */
114 
115 $parameters = array();
116 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
117 if ($reshook < 0) {
118  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
119 }
120 
121 if (empty($reshook)) {
122  $error = 0;
123 
124  $backurlforlist = dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1);
125 
126  if (empty($backtopage) || ($cancel && empty($id))) {
127  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
128  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
129  $backtopage = $backurlforlist;
130  } else {
131  $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
132  }
133  }
134  }
135  $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
136 
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 
140  // Actions when linking object each other
141  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
142 
143  // Actions when printing a doc from card
144  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
145 
146  // Action to move up and down lines of object
147  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
148 
149  // Action to build doc
150  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
151 
152  if ($action == 'set_thirdparty' && $permissiontoadd) {
153  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
154  }
155  if ($action == 'classin' && $permissiontoadd) {
156  $object->setProject(GETPOST('projectid', 'int'));
157  }
158  if ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) {
159  if (!(GETPOST('status', 'int') > 0)) {
160  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
161  $action = 'closeas';
162  } else {
163  // prevent browser refresh from closing proposal several times
164  if ($object->status == $object::STATUS_VALIDATED) {
165  $db->begin();
166 
167  $result = $object->cloture($user, GETPOST('status', 'int'), GETPOST('note_private', 'restricthtml'));
168  if ($result < 0) {
169  setEventMessages($object->error, $object->errors, 'errors');
170  $error++;
171  }
172 
173  if (!$error) {
174  $db->commit();
175  } else {
176  $db->rollback();
177  }
178  }
179  }
180  }
181 
182  // Actions to send emails
183  $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
184  $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
185  $trackid = 'recruitmentjobposition'.$object->id;
186  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
187 }
188 
189 
190 
191 
192 /*
193  * View
194  */
195 
196 $form = new Form($db);
197 $formfile = new FormFile($db);
198 $formproject = new FormProjets($db);
199 
200 $title = $langs->trans("PositionToBeFilled");
201 $help_url = '';
202 llxHeader('', $title, $help_url);
203 
204 // Part to create
205 if ($action == 'create') {
206  print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
207 
208  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
209  print '<input type="hidden" name="token" value="'.newToken().'">';
210  print '<input type="hidden" name="action" value="add">';
211  if ($backtopage) {
212  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
213  }
214  if ($backtopageforcancel) {
215  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
216  }
217 
218  // Set some default values
219  if (!GETPOSTISSET('fk_user_recruiter')) {
220  $_POST['fk_user_recruiter'] = $user->id;
221  }
222 
223  print dol_get_fiche_head(array(), '');
224 
225  print '<table class="border centpercent tableforfieldcreate">'."\n";
226 
227  // Common attributes
228  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
229 
230  // Other attributes
231  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
232 
233  print '</table>'."\n";
234 
235  print dol_get_fiche_end();
236 
237  print $form->buttonsSaveCancel("Create");
238 
239  print '</form>';
240 
241  //dol_set_focus('input[name="ref"]');
242 }
243 
244 // Part to edit record
245 if (($id || $ref) && $action == 'edit') {
246  print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto);
247 
248  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
249  print '<input type="hidden" name="token" value="'.newToken().'">';
250  print '<input type="hidden" name="action" value="update">';
251  print '<input type="hidden" name="id" value="'.$object->id.'">';
252  if ($backtopage) {
253  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
254  }
255  if ($backtopageforcancel) {
256  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
257  }
258 
259  print dol_get_fiche_head();
260 
261  print '<table class="border centpercent tableforfieldedit">'."\n";
262 
263  // Common attributes
264  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
265 
266  // Other attributes
267  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
268 
269  print '</table>';
270 
271  print dol_get_fiche_end();
272 
273  print $form->buttonsSaveCancel();
274 
275  print '</form>';
276 }
277 
278 // Part to show record
279 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
280  $res = $object->fetch_optionals();
281 
282  $head = recruitmentjobpositionPrepareHead($object);
283  print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentJobPosition"), -1, $object->picto);
284 
285  $formconfirm = '';
286 
287  // Confirmation to delete
288  if ($action == 'delete') {
289  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
290  }
291  // Confirmation to delete line
292  if ($action == 'deleteline') {
293  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
294  }
295  // Clone confirmation
296  if ($action == 'clone') {
297  // Create an array for form
298  $formquestion = array();
299  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
300  }
301  if ($action == 'closeas') {
302  //Form to close proposal (signed or not)
303  $formquestion = array(
304  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))),
305  array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
306  );
307 
308  /*if (!empty($conf->notification->enabled))
309  {
310  require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
311  $notify = new Notify($db);
312  $formquestion = array_merge($formquestion, array(
313  array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)),
314  ));
315  }*/
316 
317  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
318  }
319 
320  // Call Hook formConfirm
321  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
322  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
323  if (empty($reshook)) {
324  $formconfirm .= $hookmanager->resPrint;
325  } elseif ($reshook > 0) {
326  $formconfirm = $hookmanager->resPrint;
327  }
328 
329  // Print form confirm
330  print $formconfirm;
331 
332 
333  // Object card
334  // ------------------------------------------------------------
335  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
336 
337  $morehtmlref = '<div class="refidno">';
338  /*
339  // Ref customer
340  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
341  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
342  // Thirdparty
343  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
344  */
345  // Project
346  if (!empty($conf->project->enabled)) {
347  $langs->load("projects");
348  $morehtmlref .= $langs->trans('Project').' ';
349  if ($permissiontoadd) {
350  if ($action != 'classify') {
351  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
352  }
353  $morehtmlref .= ' : ';
354  if ($action == 'classify') {
355  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
356  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
357  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
358  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
359  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
360  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
361  $morehtmlref .= '</form>';
362  } else {
363  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
364  }
365  } else {
366  if (!empty($object->fk_project)) {
367  $proj = new Project($db);
368  $proj->fetch($object->fk_project);
369  $morehtmlref .= ': '.$proj->getNomUrl();
370  } else {
371  $morehtmlref .= '';
372  }
373  }
374  }
375  $morehtmlref .= '</div>';
376 
377 
378  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
379 
380 
381  print '<div class="fichecenter">';
382  print '<div class="fichehalfleft">';
383  print '<div class="underbanner clearboth"></div>';
384  print '<table class="border centpercent tableforfield">'."\n";
385 
386  // Common attributes
387  $keyforbreak = 'description'; // We change column just after this field
388  unset($object->fields['fk_project']); // Hide field already shown in banner
389  //unset($object->fields['fk_soc']); // Hide field already shown in banner
390  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
391 
392  // Other attributes. Fields from hook formObjectOptions and Extrafields.
393  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
394 
395  print '</table>';
396  print '</div>';
397  print '</div>';
398 
399  print '<div class="clearboth"></div>';
400 
401  print dol_get_fiche_end();
402 
403 
404  // Buttons for actions
405 
406  if ($action != 'presend' && $action != 'editline') {
407  print '<div class="tabsAction">'."\n";
408  $parameters = array();
409  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
410  if ($reshook < 0) {
411  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
412  }
413 
414  if (empty($reshook)) {
415  // Send
416  if (empty($user->socid)) {
417  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
418  }
419 
420  // Back to draft
421  if ($object->status == $object::STATUS_VALIDATED) {
422  if ($permissiontoadd) {
423  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
424  }
425  }
426 
427  // Modify
428  if ($permissiontoadd) {
429  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'."\n";
430  } else {
431  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
432  }
433 
434  // Validate
435  if ($object->status == $object::STATUS_DRAFT) {
436  if ($permissiontoadd) {
437  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
438  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes">'.$langs->trans("Validate").'</a>';
439  } else {
440  $langs->load("errors");
441  print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
442  }
443  }
444  }
445 
446  // Close as recruited/canceled
447  if ($object->status == $object::STATUS_VALIDATED) {
448  if ($usercanclose) {
449  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=closeas&token='.newToken().(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
450  print '>'.$langs->trans('Close').'</a>';
451  } else {
452  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Close').'</a>';
453  }
454  }
455 
456  // Clone
457  if ($permissiontoadd) {
458  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentjobposition">'.$langs->trans("ToClone").'</a>'."\n";
459  }
460 
461  /*
462  if ($permissiontoadd) {
463  if ($object->status == $object::STATUS_ENABLED) {
464  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("Disable").'</a>'."\n";
465  } else {
466  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Enable").'</a>'."\n";
467  }
468  }*/
469  if ($permissiontoadd) {
470  if ($object->status == $object::STATUS_CANCELED) {
471  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
472  }
473  }
474 
475  // Delete (need delete permission, or if draft, just need create/modify permission)
476  if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) {
477  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
478  } else {
479  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
480  }
481  }
482  print '</div>'."\n";
483  }
484 
485 
486  // Select mail models is same action as presend
487  if (GETPOST('modelselected')) {
488  $action = 'presend';
489  }
490 
491  if ($action != 'presend') {
492  print '<div class="fichecenter"><div class="fichehalfleft">';
493  print '<a name="builddoc"></a>'; // ancre
494 
495  $includedocgeneration = 1;
496 
497  // Documents
498  if ($includedocgeneration) {
499  $objref = dol_sanitizeFileName($object->ref);
500  $relativepath = $objref.'/'.$objref.'.pdf';
501  $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
502  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
503  $genallowed = $user->rights->recruitment->recruitmentjobposition->read; // If you can read, you can build the PDF to read content
504  $delallowed = $user->rights->recruitment->recruitmentjobposition->write; // If you can create/edit, you can remove a file on card
505  print $formfile->showdocuments('recruitment:RecruitmentJobPosition', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
506  }
507 
508  // Show links to link elements
509  $linktoelem = $form->showLinkToObjectBlock($object, null, array('recruitmentjobposition'));
510  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
511 
512  // Show link to public job page
513  if ($object->status != RecruitmentJobPosition::STATUS_DRAFT) {
514  print '<br><!-- Link to go on public job page -->'."\n";
515  // Load translation files required by the page
516  $langs->loadLangs(array('recruitment'));
517 
518  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("PublicUrl").'</span><br>';
519 
520  $url = getPublicJobPositionUrl(0, $object->ref);
521  $out .= '<div class="urllink"><input type="text" id="recruitmentjobpositionurl" class="quatrevingtpercent" value="'.$url.'">';
522  $out .= '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe').'</a></div>';
523  $out .= ajax_autoselect("recruitmentjobpositionurl", 0);
524 
525  print $out;
526  }
527 
528  print '</div><div class="fichehalfright">';
529 
530  $MAXEVENT = 10;
531 
532  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/recruitment/recruitmentjobposition_agenda.php?id='.$object->id);
533 
534  // List of actions on element
535  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
536  $formactions = new FormActions($db);
537  $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
538 
539  print '</div></div>';
540  }
541 
542  //Select mail models is same action as presend
543  if (GETPOST('modelselected')) {
544  $action = 'presend';
545  }
546 
547  // Presend form
548  $modelmail = 'recruitmentjobposition';
549  $defaulttopic = 'InformationMessage';
550  $diroutput = $conf->recruitment->dir_output;
551  $trackid = 'recruitmentjobposition'.$object->id;
552 
553  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
554 }
555 
556 // End of page
557 llxFooter();
558 $db->close();
recruitmentjobpositionPrepareHead
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
Definition: recruitment_recruitmentjobposition.lib.php:30
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1033
getPublicJobPositionUrl
getPublicJobPositionUrl($mode, $ref='', $localorexternal=0)
Return string with full Url.
Definition: recruitment_recruitmentjobposition.lib.php:121
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
RecruitmentJobPosition
Class for RecruitmentJobPosition.
Definition: recruitmentjobposition.class.php:32
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:178
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9681
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59