dolibarr  13.0.2
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 $res = 0;
46 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
47 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
48 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
49 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
50 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
51 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
52 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
53 // Try main.inc.php using relative path
54 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
55 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
56 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
57 if (!$res) die("Include of main fails");
58 
59 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
61 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
62 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
63 dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
64 dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
65 
66 // Load translation files required by the page
67 $langs->loadLangs(array("recruitment", "other"));
68 
69 // Get parameters
70 $id = GETPOST('id', 'int');
71 $ref = GETPOST('ref', 'alpha');
72 $action = GETPOST('action', 'aZ09');
73 $confirm = GETPOST('confirm', 'alpha');
74 $cancel = GETPOST('cancel', 'aZ09');
75 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
76 $backtopage = GETPOST('backtopage', 'alpha');
77 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
78 //$lineid = GETPOST('lineid', 'int');
79 
80 // Initialize technical objects
81 $object = new RecruitmentJobPosition($db);
82 $extrafields = new ExtraFields($db);
83 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
84 $hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
85 
86 // Fetch optionals attributes and labels
87 $extrafields->fetch_name_optionals_label($object->table_element);
88 
89 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
90 
91 // Initialize array of search criterias
92 $search_all = GETPOST("search_all", 'alpha');
93 $search = array();
94 foreach ($object->fields as $key => $val)
95 {
96  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
97 }
98 
99 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
100 
101 // Load object
102 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
103 
104 
105 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
106 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
107 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
108 $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
109 $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
110 $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
111 
112 $usercanclose = $permissiontoadd;
113 
114 // Security check - Protection if external user
115 //if ($user->socid > 0) accessforbidden();
116 //if ($user->socid > 0) $socid = $user->socid;
117 //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
118 //$result = restrictedArea($user, 'recruitment', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
119 
120 //if (!$permissiontoread) accessforbidden();
121 
122 
123 /*
124  * Actions
125  */
126 
127 $parameters = array();
128 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
129 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
130 
131 if (empty($reshook))
132 {
133  $error = 0;
134 
135  $backurlforlist = dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1);
136 
137  if (empty($backtopage) || ($cancel && empty($id))) {
138  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
139  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
140  else $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
141  }
142  }
143  $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
144 
145  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
146  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
147 
148  // Actions when linking object each other
149  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
150 
151  // Actions when printing a doc from card
152  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
153 
154  // Action to move up and down lines of object
155  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
156 
157  // Action to build doc
158  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
159 
160  if ($action == 'set_thirdparty' && $permissiontoadd)
161  {
162  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
163  }
164  if ($action == 'classin' && $permissiontoadd)
165  {
166  $object->setProject(GETPOST('projectid', 'int'));
167  }
168  if ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) {
169  if (!(GETPOST('status', 'int') > 0)) {
170  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
171  $action = 'closeas';
172  } else {
173  // prevent browser refresh from closing proposal several times
174  if ($object->status == $object::STATUS_VALIDATED)
175  {
176  $db->begin();
177 
178  $result = $object->cloture($user, GETPOST('status', 'int'), GETPOST('note_private', 'restricthtml'));
179  if ($result < 0)
180  {
181  setEventMessages($object->error, $object->errors, 'errors');
182  $error++;
183  }
184 
185  if (!$error)
186  {
187  $db->commit();
188  } else {
189  $db->rollback();
190  }
191  }
192  }
193  }
194 
195  // Actions to send emails
196  $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
197  $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
198  $trackid = 'recruitmentjobposition'.$object->id;
199  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
200 }
201 
202 
203 
204 
205 /*
206  * View
207  *
208  * Put here all code to build page
209  */
210 
211 $form = new Form($db);
212 $formfile = new FormFile($db);
213 $formproject = new FormProjets($db);
214 
215 $title = $langs->trans("PositionToBeFilled");
216 $help_url = '';
217 llxHeader('', $title, $help_url);
218 
219 // Part to create
220 if ($action == 'create')
221 {
222  print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
223 
224  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
225  print '<input type="hidden" name="token" value="'.newToken().'">';
226  print '<input type="hidden" name="action" value="add">';
227  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
228  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
229 
230  // Set some default values
231  if (!GETPOSTISSET('fk_user_recruiter')) $_POST['fk_user_recruiter'] = $user->id;
232 
233  print dol_get_fiche_head(array(), '');
234 
235  print '<table class="border centpercent tableforfieldcreate">'."\n";
236 
237  // Common attributes
238  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
239 
240  // Other attributes
241  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
242 
243  print '</table>'."\n";
244 
246 
247  print '<div class="center">';
248  print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
249  print '&nbsp; ';
250  print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
251  print '</div>';
252 
253  print '</form>';
254 
255  //dol_set_focus('input[name="ref"]');
256 }
257 
258 // Part to edit record
259 if (($id || $ref) && $action == 'edit')
260 {
261  print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto);
262 
263  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
264  print '<input type="hidden" name="token" value="'.newToken().'">';
265  print '<input type="hidden" name="action" value="update">';
266  print '<input type="hidden" name="id" value="'.$object->id.'">';
267  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
268  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
269 
271 
272  print '<table class="border centpercent tableforfieldedit">'."\n";
273 
274  // Common attributes
275  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
276 
277  // Other attributes
278  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
279 
280  print '</table>';
281 
283 
284  print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
285  print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
286  print '</div>';
287 
288  print '</form>';
289 }
290 
291 // Part to show record
292 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
293 {
294  $res = $object->fetch_optionals();
295 
296  $head = recruitmentjobpositionPrepareHead($object);
297  print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentJobPosition"), -1, $object->picto);
298 
299  $formconfirm = '';
300 
301  // Confirmation to delete
302  if ($action == 'delete')
303  {
304  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
305  }
306  // Confirmation to delete line
307  if ($action == 'deleteline')
308  {
309  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
310  }
311  // Clone confirmation
312  if ($action == 'clone') {
313  // Create an array for form
314  $formquestion = array();
315  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
316  }
317  if ($action == 'closeas')
318  {
319  //Form to close proposal (signed or not)
320  $formquestion = array(
321  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))),
322  array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
323  );
324 
325  /*if (!empty($conf->notification->enabled))
326  {
327  require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
328  $notify = new Notify($db);
329  $formquestion = array_merge($formquestion, array(
330  array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)),
331  ));
332  }*/
333 
334  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
335  }
336 
337  // Call Hook formConfirm
338  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
339  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
340  if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
341  elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
342 
343  // Print form confirm
344  print $formconfirm;
345 
346 
347  // Object card
348  // ------------------------------------------------------------
349  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
350 
351  $morehtmlref = '<div class="refidno">';
352  /*
353  // Ref customer
354  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
355  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
356  // Thirdparty
357  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
358  */
359  // Project
360  if (!empty($conf->projet->enabled))
361  {
362  $langs->load("projects");
363  $morehtmlref .= $langs->trans('Project').' ';
364  if ($permissiontoadd)
365  {
366  if ($action != 'classify') $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
367  $morehtmlref .= ' : ';
368  if ($action == 'classify') {
369  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
370  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
371  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
372  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
373  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
374  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
375  $morehtmlref .= '</form>';
376  } else {
377  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
378  }
379  } else {
380  if (!empty($object->fk_project)) {
381  $proj = new Project($db);
382  $proj->fetch($object->fk_project);
383  $morehtmlref .= ': '.$proj->getNomUrl();
384  } else {
385  $morehtmlref .= '';
386  }
387  }
388  }
389  $morehtmlref .= '</div>';
390 
391 
392  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
393 
394 
395  print '<div class="fichecenter">';
396  print '<div class="fichehalfleft">';
397  print '<div class="underbanner clearboth"></div>';
398  print '<table class="border centpercent tableforfield">'."\n";
399 
400  // Common attributes
401  $keyforbreak = 'description'; // We change column just after this field
402  unset($object->fields['fk_project']); // Hide field already shown in banner
403  //unset($object->fields['fk_soc']); // Hide field already shown in banner
404  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
405 
406  // Other attributes. Fields from hook formObjectOptions and Extrafields.
407  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
408 
409  print '</table>';
410  print '</div>';
411  print '</div>';
412 
413  print '<div class="clearboth"></div>';
414 
416 
417 
418  /*
419  * Lines
420  */
421 
422  if (!empty($object->table_element_line))
423  {
424  // Show object lines
425  $result = $object->getLinesArray();
426 
427  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
428  <input type="hidden" name="token" value="' . newToken().'">
429  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
430  <input type="hidden" name="mode" value="">
431  <input type="hidden" name="id" value="' . $object->id.'">
432  ';
433 
434  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
435  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
436  }
437 
438  print '<div class="div-table-responsive-no-min">';
439  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
440  {
441  print '<table id="tablelines" class="noborder noshadow" width="100%">';
442  }
443 
444  if (!empty($object->lines))
445  {
446  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
447  }
448 
449  // Form to add new line
450  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
451  {
452  if ($action != 'editline')
453  {
454  // Add products/services form
455  $object->formAddObjectLine(1, $mysoc, $soc);
456 
457  $parameters = array();
458  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
459  }
460  }
461 
462  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
463  {
464  print '</table>';
465  }
466  print '</div>';
467 
468  print "</form>\n";
469  }
470 
471 
472  // Buttons for actions
473 
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) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
479 
480  if (empty($reshook))
481  {
482  // Send
483  if (empty($user->socid)) {
484  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
485  }
486 
487  // Back to draft
488  if ($object->status == $object::STATUS_VALIDATED) {
489  if ($permissiontoadd)
490  {
491  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
492  }
493  }
494 
495  // Modify
496  if ($permissiontoadd) {
497  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
498  } else {
499  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
500  }
501 
502  // Validate
503  if ($object->status == $object::STATUS_DRAFT) {
504  if ($permissiontoadd) {
505  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
506  {
507  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>';
508  } else {
509  $langs->load("errors");
510  print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
511  }
512  }
513  }
514 
515  // Close as recruited/canceled
516  if ($object->status == $object::STATUS_VALIDATED) {
517  if ($usercanclose) {
518  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=closeas'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
519  print '>'.$langs->trans('Close').'</a>';
520  } else {
521  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Close').'</a>';
522  }
523  }
524 
525  // Clone
526  if ($permissiontoadd) {
527  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentjobposition">'.$langs->trans("ToClone").'</a>'."\n";
528  }
529 
530  /*
531  if ($permissiontoadd) {
532  if ($object->status == $object::STATUS_ENABLED) {
533  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a>'."\n";
534  } else {
535  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a>'."\n";
536  }
537  }*/
538  if ($permissiontoadd)
539  {
540  if ($object->status == $object::STATUS_CANCELED) {
541  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
542  }
543  }
544 
545  // Delete (need delete permission, or if draft, just need create/modify permission)
546  if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) {
547  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
548  } else {
549  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
550  }
551  }
552  print '</div>'."\n";
553  }
554 
555 
556  // Select mail models is same action as presend
557  if (GETPOST('modelselected')) {
558  $action = 'presend';
559  }
560 
561  if ($action != 'presend')
562  {
563  print '<div class="fichecenter"><div class="fichehalfleft">';
564  print '<a name="builddoc"></a>'; // ancre
565 
566  $includedocgeneration = 1;
567 
568  // Documents
569  if ($includedocgeneration) {
570  $objref = dol_sanitizeFileName($object->ref);
571  $relativepath = $objref.'/'.$objref.'.pdf';
572  $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
573  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
574  $genallowed = $user->rights->recruitment->recruitmentjobposition->read; // If you can read, you can build the PDF to read content
575  $delallowed = $user->rights->recruitment->recruitmentjobposition->write; // If you can create/edit, you can remove a file on card
576  print $formfile->showdocuments('recruitment:RecruitmentJobPosition', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
577  }
578 
579  // Show links to link elements
580  $linktoelem = $form->showLinkToObjectBlock($object, null, array('recruitmentjobposition'));
581  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
582 
583  // Show link to public job page
584  if ($object->status != RecruitmentJobPosition::STATUS_DRAFT)
585  {
586  print '<br><!-- Link to go on public job page -->'."\n";
587  // Load translation files required by the page
588  $langs->loadLangs(array('recruitment'));
589 
590  $out = img_picto('', 'globe').' '.$langs->trans("PublicUrl").'<br>';
591 
592  $url = getPublicJobPositionUrl(0, $object->ref);
593  $out .= '<input type="text" id="recruitmentjobpositionurl" class="quatrevingtpercent" value="'.$url.'">';
594  $out .= '<a href="'.$url.'" target="_blank">'.img_picto('', 'globe').'</a>';
595  $out .= ajax_autoselect("recruitmentjobpositionurl", 0);
596 
597  print $out;
598  }
599 
600  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
601 
602  $MAXEVENT = 10;
603 
604  $morehtmlright = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_agenda.php', 1).'?id='.$object->id.'">';
605  $morehtmlright .= $langs->trans("SeeAll");
606  $morehtmlright .= '</a>';
607 
608  // List of actions on element
609  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
610  $formactions = new FormActions($db);
611  $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
612 
613  print '</div></div></div>';
614  }
615 
616  //Select mail models is same action as presend
617  if (GETPOST('modelselected')) $action = 'presend';
618 
619  // Presend form
620  $modelmail = 'recruitmentjobposition';
621  $defaulttopic = 'InformationMessage';
622  $diroutput = $conf->recruitment->dir_output;
623  $trackid = 'recruitmentjobposition'.$object->id;
624 
625  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
626 }
627 
628 // End of page
629 llxFooter();
630 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
Class to manage building of HTML components.
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class for RecruitmentJobPosition.
Class to offer components to list and upload files.
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getPublicJobPositionUrl($mode, $ref= '', $localorexternal=0)
Return string with full Url.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...