dolibarr  16.0.1
recruitmentcandidature_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2020 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.'/core/lib/functions2.lib.php';
50 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
52 require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php';
53 
54 // Load translation files required by the page
55 $langs->loadLangs(array("recruitment", "other", "users"));
56 
57 // Get parameters
58 $id = GETPOST('id', 'int');
59 $ref = GETPOST('ref', 'alpha');
60 $action = GETPOST('action', 'aZ09');
61 $confirm = GETPOST('confirm', 'alpha');
62 $cancel = GETPOST('cancel', 'aZ09');
63 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search
64 $backtopage = GETPOST('backtopage', 'alpha');
65 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
66 //$lineid = GETPOST('lineid', 'int');
67 
68 // Initialize technical objects
69 $object = new RecruitmentCandidature($db);
70 $extrafields = new ExtraFields($db);
71 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
72 $hookmanager->initHooks(array('recruitmentcandidaturecard', 'globalcard')); // Note that conf->hooks_modules contains array
73 
74 // Fetch optionals attributes and labels
75 $extrafields->fetch_name_optionals_label($object->table_element);
76 
77 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
78 
79 // Initialize array of search criterias
80 $search_all = GETPOST("search_all", 'alpha');
81 $search = array();
82 foreach ($object->fields as $key => $val) {
83  if (GETPOST('search_'.$key, 'alpha')) {
84  $search[$key] = GETPOST('search_'.$key, 'alpha');
85  }
86 }
87 
88 if (empty($action) && empty($id) && empty($ref)) {
89  $action = 'view';
90 }
91 
92 // Load object
93 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
94 
95 
96 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
97 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
98 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
99 $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
100 $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
101 $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
102 
103 // Security check - Protection if external user
104 //if ($user->socid > 0) accessforbidden();
105 //if ($user->socid > 0) $socid = $user->socid;
106 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
107 $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft);
108 
109 
110 /*
111  * Actions
112  */
113 
114 $parameters = array();
115 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
116 if ($reshook < 0) {
117  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
118 }
119 
120 if (empty($reshook)) {
121  $error = 0;
122 
123  $backurlforlist = dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1);
124 
125  if (empty($backtopage) || ($cancel && empty($id))) {
126  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
127  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
128  $backtopage = $backurlforlist;
129  } else {
130  $backtopage = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
131  }
132  }
133  }
134  $triggermodname = 'RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record
135 
136  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
137  $object->email_fields_no_propagate_in_actioncomm = 1;
138  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
139  $object->email_fields_no_propagate_in_actioncomm = 0;
140 
141  // Actions when linking object each other
142  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
143 
144  // Actions when printing a doc from card
145  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
146 
147  // Action to move up and down lines of object
148  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
149 
150  // Action to build doc
151  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
152 
153  if ($action == 'classin' && $permissiontoadd) {
154  $object->setProject(GETPOST('projectid', 'int'));
155  }
156  if ($action == 'confirm_decline' && $confirm == 'yes' && $permissiontoadd) {
157  $result = $object->setStatut($object::STATUS_REFUSED, null, '', $triggermodname);
158  if ($result < 0) {
159  setEventMessages($object->error, $object->errors, 'errors');
160  }
161  }
162 
163  if ($action == 'confirm_makeofferordecline' && $permissiontoadd && !GETPOST('cancel', 'alpha')) {
164  if (!(GETPOST('status', 'int') > 0)) {
165  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
166  $action = 'makeofferordecline';
167  } else {
168  // prevent browser refresh from closing proposal several times
169  if ($object->status == $object::STATUS_VALIDATED) {
170  $db->begin();
171 
172  if (GETPOST('status', 'int') == $object::STATUS_REFUSED) {
173  $result = $object->setStatut($object::STATUS_REFUSED, null, '', $triggermodname);
174  if ($result < 0) {
175  setEventMessages($object->error, $object->errors, 'errors');
176  }
177  } else {
178  $result = $object->setStatut($object::STATUS_CONTRACT_PROPOSED, null, '', $triggermodname);
179  if ($result < 0) {
180  setEventMessages($object->error, $object->errors, 'errors');
181  }
182  }
183 
184  if (!$error) {
185  $db->commit();
186  } else {
187  $db->rollback();
188  }
189  }
190  }
191  }
192 
193  if ($action == 'confirm_closeas' && $permissiontoadd && !GETPOST('cancel', 'alpha')) {
194  if (!(GETPOST('status', 'int') > 0)) {
195  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
196  $action = 'makeofferordecline';
197  } else {
198  // prevent browser refresh from closing proposal several times
199  if ($object->status == $object::STATUS_CONTRACT_PROPOSED) {
200  $db->begin();
201 
202  if (GETPOST('status', 'int') == $object::STATUS_CONTRACT_REFUSED) {
203  $result = $object->setStatut($object::STATUS_CONTRACT_REFUSED, null, '', $triggermodname);
204  if ($result < 0) {
205  setEventMessages($object->error, $object->errors, 'errors');
206  }
207  } else {
208  $result = $object->setStatut($object::STATUS_CONTRACT_SIGNED, null, '', $triggermodname);
209  if ($result < 0) {
210  setEventMessages($object->error, $object->errors, 'errors');
211  }
212  }
213 
214  if (!$error) {
215  $db->commit();
216  } else {
217  $db->rollback();
218  }
219  }
220  }
221  }
222 
223  // Create user from a member
224  if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
225  if ($result > 0) {
226  $jobposition = new RecruitmentJobPosition($db);
227  $jobposition->fetch($object->fk_recruitmentjobposition);
228 
229  // Creation user
230  $nuser = new User($db);
231  $nuser->login = GETPOST('login', 'alphanohtml');
232  $nuser->fk_soc = 0;
233  $nuser->employee = 1;
234  $nuser->firstname = $object->firstname;
235  $nuser->lastname = $object->lastname;
236  $nuser->email = '';
237  $nuser->personal_email = $object->email;
238  $nuser->personal_mobile = $object->phone;
239  $nuser->birth = $object->date_birth;
240  $nuser->salary = $object->remuneration_proposed;
241  $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor
242  $nuser->email = $object->email;
243 
244  $result = $nuser->create($user);
245 
246  if ($result < 0) {
247  $langs->load("errors");
248  setEventMessages($langs->trans($nuser->error), null, 'errors');
249  $action = 'create_user';
250  } else {
251  setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
252  $action = '';
253  }
254  } else {
255  setEventMessages($object->error, $object->errors, 'errors');
256  $action = 'create_user';
257  }
258  }
259 
260  // Actions to send emails
261  $triggersendname = 'RECRUITMENTCANDIDATURE_SENTBYMAIL';
262  $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTCANDIDATURE_TO';
263  $trackid = 'recruitmentcandidature'.$object->id;
264  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
265 }
266 
267 
268 
269 
270 /*
271  * View
272  *
273  * Put here all code to build page
274  */
275 
276 $form = new Form($db);
277 $formfile = new FormFile($db);
278 $formproject = new FormProjets($db);
279 
280 $title = $langs->trans("RecruitmentCandidature");
281 $help_url = '';
282 llxHeader('', $title, $help_url);
283 
284 
285 // Part to create
286 if ($action == 'create') {
287  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("RecruitmentCandidature")), '', 'object_'.$object->picto);
288 
289  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
290  print '<input type="hidden" name="token" value="'.newToken().'">';
291  print '<input type="hidden" name="action" value="add">';
292  if ($backtopage) {
293  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
294  }
295  if ($backtopageforcancel) {
296  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
297  }
298 
299  print dol_get_fiche_head(array(), '');
300 
301  print '<table class="border centpercent tableforfieldcreate">'."\n";
302 
303  // Common attributes
304  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
305 
306  // Other attributes
307  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
308 
309  print '</table>'."\n";
310 
311  print dol_get_fiche_end();
312 
313  print $form->buttonsSaveCancel("Create");
314 
315  print '</form>';
316 
317  //dol_set_focus('input[name="ref"]');
318 }
319 
320 // Part to edit record
321 if (($id || $ref) && $action == 'edit') {
322  print load_fiche_titre($langs->trans("RecruitmentCandidature"), '', 'object_'.$object->picto);
323 
324  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
325  print '<input type="hidden" name="token" value="'.newToken().'">';
326  print '<input type="hidden" name="action" value="update">';
327  print '<input type="hidden" name="id" value="'.$object->id.'">';
328  if ($backtopage) {
329  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
330  }
331  if ($backtopageforcancel) {
332  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
333  }
334 
335  print dol_get_fiche_head();
336 
337  print '<table class="border centpercent tableforfieldedit">'."\n";
338 
339  // Common attributes
340  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
341 
342  // Other attributes
343  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
344 
345  print '</table>';
346 
347  print dol_get_fiche_end();
348 
349  print $form->buttonsSaveCancel();
350 
351  print '</form>';
352 }
353 
354 // Part to show record
355 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
356  $res = $object->fetch_optionals();
357 
358  $head = recruitmentcandidaturePrepareHead($object);
359  print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentCandidature"), -1, $object->picto);
360 
361  $formconfirm = '';
362 
363  // Confirmation to delete
364  if ($action == 'delete') {
365  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentCandidature'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
366  }
367  // Confirmation to delete line
368  if ($action == 'deleteline') {
369  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
370  }
371  // Clone confirmation
372  if ($action == 'clone') {
373  // Create an array for form
374  $formquestion = array();
375  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
376  }
377 
378  if ($action == 'makeofferordecline') {
379  $langs->load("propal");
380 
381  //Form to close proposal (signed or not)
382  $formquestion = array(
383  array('type' => 'select', 'name' => 'status', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array($object::STATUS_CONTRACT_PROPOSED => $object->LibStatut($object::STATUS_CONTRACT_PROPOSED), $object::STATUS_REFUSED => $object->LibStatut($object::STATUS_REFUSED))),
384  array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
385  );
386 
387  $text = '';
388 
389  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_makeofferordecline', $formquestion, '', 1, 250);
390  }
391 
392  if ($action == 'closeas') {
393  $langs->load("propal");
394 
395  //Form to close proposal (signed or not)
396  $formquestion = array(
397  array('type' => 'select', 'name' => 'status', 'label' => '<span class="fieldrequired">'.$langs->trans("CloseAs").'</span>', 'values' => array($object::STATUS_CONTRACT_SIGNED => $object->LibStatut($object::STATUS_CONTRACT_SIGNED), $object::STATUS_CONTRACT_REFUSED => $object->LibStatut($object::STATUS_CONTRACT_REFUSED))),
398  array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
399  );
400 
401  $text = '';
402 
403  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
404  }
405 
406  // Confirm create user
407  if ($action == 'create_user') {
408  $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
409  if (empty($login)) {
410  // Full firstname and name separated with a dot : firstname.name
411  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
412  $login = dol_buildlogin($object->lastname, $object->firstname);
413  }
414  if (empty($login)) {
415  $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
416  }
417 
418  // Create a form array
419  $formquestion = array(
420  array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
421  );
422  $text .= $langs->trans("ConfirmCreateLogin");
423  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
424  }
425 
426  // Call Hook formConfirm
427  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
428  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
429  if (empty($reshook)) {
430  $formconfirm .= $hookmanager->resPrint;
431  } elseif ($reshook > 0) {
432  $formconfirm = $hookmanager->resPrint;
433  }
434 
435  // Print form confirm
436  print $formconfirm;
437 
438 
439  // Object card
440  // ------------------------------------------------------------
441  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
442 
443  $morehtmlref = '<div class="refidno">';
444  /*
445  // Ref customer
446  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
447  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
448  // Thirdparty
449  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
450  // Project
451  if (! empty($conf->project->enabled))
452  {
453  $langs->load("projects");
454  $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
455  if ($permissiontoadd)
456  {
457  //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
458  $morehtmlref .= ' : ';
459  if ($action == 'classify') {
460  //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
461  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
462  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
463  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
464  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
465  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
466  $morehtmlref .= '</form>';
467  } else {
468  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
469  }
470  } else {
471  if (! empty($object->fk_project)) {
472  $proj = new Project($db);
473  $proj->fetch($object->fk_project);
474  $morehtmlref .= ': '.$proj->getNomUrl();
475  } else {
476  $morehtmlref .= '';
477  }
478  }
479  }*/
480  // Author
481  if (!empty($object->email_msgid)) {
482  $morehtmlref .= $langs->trans("CreatedBy").' : ';
483 
484  if ($object->fk_user_creat > 0) {
485  $fuser = new User($db);
486  $fuser->fetch($object->fk_user_creat);
487  $morehtmlref .= $fuser->getNomUrl(-1);
488  }
489  if (!empty($object->email_msgid)) {
490  $morehtmlref .= ' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
491  }
492  } /* elseif (!empty($object->origin_email)) {
493  $morehtmlref .= $langs->trans("CreatedBy").' : ';
494  $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
495  $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
496  } */
497  $morehtmlref .= '</div>';
498 
499 
500  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
501 
502 
503  print '<div class="fichecenter">';
504  print '<div class="fichehalfleft">';
505  print '<div class="underbanner clearboth"></div>';
506  print '<table class="border centpercent tableforfield">'."\n";
507 
508  // Common attributes
509  $keyforbreak = 'description'; // We change column just before this field
510  unset($object->fields['email']); // Hide field already shown in banner
511  //unset($object->fields['fk_soc']); // Hide field already shown in banner
512  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
513 
514  // Other attributes. Fields from hook formObjectOptions and Extrafields.
515  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
516 
517  print '</table>';
518  print '</div>';
519  print '</div>';
520 
521  print '<div class="clearboth"></div>';
522 
523  print dol_get_fiche_end();
524 
525  // Buttons for actions
526 
527  if ($action != 'presend' && $action != 'editline') {
528  print '<div class="tabsAction">'."\n";
529  $parameters = array();
530  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
531  if ($reshook < 0) {
532  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
533  }
534 
535  if (empty($reshook)) {
536  // Send
537  if (empty($user->socid)) {
538  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&sendto='.urlencode($object->email).'#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
539  }
540 
541  // Back to draft
542  if ($object->status == $object::STATUS_VALIDATED) {
543  if ($permissiontoadd) {
544  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
545  }
546  }
547 
548  // Modify
549  if ($permissiontoadd) {
550  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'."\n";
551  } else {
552  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
553  }
554 
555  // Validate
556  if ($object->status == $object::STATUS_DRAFT) {
557  if ($permissiontoadd) {
558  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
559  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes">'.$langs->trans("Validate").'</a>';
560  } else {
561  $langs->load("errors");
562  print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
563  }
564  }
565  }
566 
567  // Make offer - Refuse - Decline
568  if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CONTRACT_PROPOSED) {
569  if ($permissiontoadd) {
570  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=makeofferordecline">'.$langs->trans("MakeOffer").' / '.$langs->trans("Decline").'</a>';
571  }
572  }
573 
574  // Contract refused / accepted
575  if ($object->status == $object::STATUS_CONTRACT_PROPOSED) {
576  if ($permissiontoadd) {
577  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=closeas&token='.newToken().'">'.$langs->trans("Accept").' / '.$langs->trans("Decline").'</a>';
578  }
579  }
580 
581  // Clone
582  if ($permissiontoadd) {
583  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature">'.$langs->trans("ToClone").'</a>'."\n";
584  }
585 
586  // Button to convert into a user
587  if ($object->status == $object::STATUS_CONTRACT_SIGNED) {
588  if ($user->rights->user->user->creer) {
589  // TODO Check if a user already exists
590  $useralreadyexists = 0;
591  if (empty($useralreadyexists)) {
592  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
593  } else {
594  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
595  }
596  } else {
597  print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</span></div>";
598  }
599  }
600 
601  // Cancel
602  if ($permissiontoadd) {
603  if ($object->status == $object::STATUS_VALIDATED) {
604  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("Cancel").'</a>'."\n";
605  } elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED) {
606  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
607  }
608  }
609 
610  // Delete (need delete permission, or if draft, just need create/modify permission)
611  if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) {
612  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
613  } else {
614  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
615  }
616  }
617  print '</div>'."\n";
618  }
619 
620 
621  // Select mail models is same action as presend
622  if (GETPOST('modelselected')) {
623  $action = 'presend';
624  }
625 
626  if ($action != 'presend') {
627  print '<div class="fichecenter"><div class="fichehalfleft">';
628  print '<a name="builddoc"></a>'; // ancre
629 
630  $includedocgeneration = 1;
631 
632  // Documents
633  if ($includedocgeneration) {
634  $objref = dol_sanitizeFileName($object->ref);
635  $relativepath = $objref.'/'.$objref.'.pdf';
636  $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
637  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
638  $genallowed = $user->rights->recruitment->recruitmentjobposition->read; // If you can read, you can build the PDF to read content
639  $delallowed = $user->rights->recruitment->recruitmentjobposition->write; // If you can create/edit, you can remove a file on card
640  print $formfile->showdocuments('recruitment:RecruitmentCandidature', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
641  }
642 
643  // Show links to link elements
644  $linktoelem = $form->showLinkToObjectBlock($object, null, array('recruitmentcandidature'));
645  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
646 
647 
648  print '</div><div class="fichehalfright">';
649 
650  $MAXEVENT = 10;
651 
652  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/recruitment/recruitmentcandidature_agenda.php?id='.$object->id);
653 
654  // List of actions on element
655  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
656  $formactions = new FormActions($db);
657  $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
658 
659  print '</div></div>';
660  }
661 
662  //Select mail models is same action as presend
663  if (GETPOST('modelselected')) {
664  $action = 'presend';
665  }
666 
667  // Presend form
668  $modelmail = 'recruitmentcandidature_send';
669  $defaulttopic = 'InformationMessage';
670  $diroutput = $conf->recruitment->dir_output;
671  $trackid = 'recruitmentcandidature'.$object->id;
672 
673  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
674 }
675 
676 // End of page
677 llxFooter();
678 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
Class to manage building of HTML components.
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.
Class to manage Dolibarr users.
Definition: user.class.php:44
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
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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
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 from a POST of a form...
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
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.
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.
Class for RecruitmentCandidature.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.
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:73
$formconfirm
if ($action == &#39;delbookkeepingyear&#39;) {