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