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