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