dolibarr 25.0.0-alpha
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-2026 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 $resultupdate = $object->update($user);
257 if ($resultupdate < 0) {
258 $error++;
259 setEventMessages($object->error, $object->errors, 'errors');
260 }
261 }
262
263 if (!$error) {
264 $db->commit();
265
266 setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
267 $action = '';
268 } else {
269 $db->rollback();
270 }
271 }
272
273 // Actions to send emails
274 $triggersendname = 'RECRUITMENTCANDIDATURE_SENTBYMAIL';
275 $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTCANDIDATURE_TO';
276 $trackid = 'recruitmentcandidature'.$object->id;
277 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
278}
279
280
281
282
283/*
284 * View
285 *
286 * Put here all code to build page
287 */
288
289$form = new Form($db);
290$formfile = new FormFile($db);
291$formproject = new FormProjets($db);
292$text = '';
293
294if ($action == 'create') {
295 $title = $langs->trans('NewCandidature');
296 $help_url = '';
297} else {
298 $title = $object->ref." - ".$langs->trans('Card');
299 $help_url = '';
300}
301
302llxHeader('', $title, $help_url);
303
304// Part to create
305if ($action == 'create') {
306 print load_fiche_titre($title, '', 'object_'.$object->picto);
307
308 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
309 print '<input type="hidden" name="token" value="'.newToken().'">';
310 print '<input type="hidden" name="action" value="add">';
311 if ($backtopage) {
312 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
313 }
314 if ($backtopageforcancel) {
315 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
316 }
317
318 print dol_get_fiche_head([], '');
319
320 print '<table class="border centpercent tableforfieldcreate">'."\n";
321
322 // Common attributes
323 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
324
325 // Other attributes
326 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
327
328 print '</table>'."\n";
329
330 print dol_get_fiche_end();
331
332 print $form->buttonsSaveCancel("Create");
333
334 print '</form>';
335
336 //dol_set_focus('input[name="ref"]');
337}
338
339// Part to edit record
340if (($id || $ref) && $action == 'edit') {
341 print load_fiche_titre($langs->trans("RecruitmentCandidature"), '', 'object_'.$object->picto);
342
343 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
344 print '<input type="hidden" name="token" value="'.newToken().'">';
345 print '<input type="hidden" name="action" value="update">';
346 print '<input type="hidden" name="id" value="'.$object->id.'">';
347 if ($backtopage) {
348 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
349 }
350 if ($backtopageforcancel) {
351 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
352 }
353
354 print dol_get_fiche_head();
355
356 print '<table class="border centpercent tableforfieldedit">'."\n";
357
358 // Common attributes
359 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
360
361 // Other attributes
362 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
363
364 print '</table>';
365
366 print dol_get_fiche_end();
367
368 print $form->buttonsSaveCancel();
369
370 print '</form>';
371}
372
373// Part to show record
374if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
375 $res = $object->fetch_optionals();
376
377 $head = recruitmentCandidaturePrepareHead($object);
378 print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentCandidature"), -1, $object->picto, 0, '', '', 0, '', 1);
379
380 $formconfirm = '';
381
382 // Confirmation to delete
383 if ($action == 'delete') {
384 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentCandidature'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
385 }
386 // Confirmation to delete line
387 if ($action == 'deleteline') {
388 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
389 }
390 // Clone confirmation
391 if ($action == 'clone') {
392 // Create an array for form
393 $formquestion = array();
394 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
395 }
396
397 if ($action == 'makeofferordecline') {
398 $langs->load("propal");
399
400 //Form to close proposal (signed or not)
401 $formquestion = array(
402 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))),
403 array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
404 );
405
406 $text = '';
407
408 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_makeofferordecline', $formquestion, '', 1, 250);
409 }
410
411 if ($action == 'closeas') {
412 $langs->load("propal");
413
414 //Form to close proposal (signed or not)
415 $formquestion = array(
416 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))),
417 array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
418 );
419
420 $text = '';
421
422 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
423 }
424
425 if ($action == 'close') {
426 $langs->load("propal");
427 $formquestion = array();
428 //Form to close proposal (signed or not)
429 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ConfirmClose'), $langs->trans('ConfirmCloseAsk'), 'confirm_close', $formquestion, '', 1, 250);
430 }
431
432 // Confirm create user
433 if ($action == 'create_user') {
434 $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
435 if (empty($login)) {
436 // Full firstname and name separated with a dot : firstname.name
437 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
438 $login = dol_buildlogin($object->lastname, $object->firstname);
439 }
440 if (empty($login)) {
441 $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
442 }
443
444 // Create a form array
445 $formquestion = array(
446 array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
447 );
448 $text .= $langs->trans("ConfirmCreateLogin");
449 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
450 }
451
452 // Call Hook formConfirm
453 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
454 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
455 if (empty($reshook)) {
456 $formconfirm .= $hookmanager->resPrint;
457 } elseif ($reshook > 0) {
458 $formconfirm = $hookmanager->resPrint;
459 }
460
461 // Print form confirm
462 print $formconfirm;
463
464
465 // Object card
466 // ------------------------------------------------------------
467 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
468
469 $morehtmlref = '<div class="refidno">';
470 $morehtmlref .= $object->getFullName(null, 1);
471 /*
472 // Ref customer
473 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
474 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
475 // Thirdparty
476 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
477 // Project
478 if (isModEnabled('project'))
479 {
480 $langs->load("projects");
481 $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
482 if ($permissiontoadd)
483 {
484 //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
485 $morehtmlref .= ' : ';
486 if ($action == 'classify') {
487 //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
488 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
489 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
490 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
491 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
492 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
493 $morehtmlref .= '</form>';
494 } else {
495 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
496 }
497 } else {
498 if (!empty($object->fk_project)) {
499 $proj = new Project($db);
500 $proj->fetch($object->fk_project);
501 $morehtmlref .= ': '.$proj->getNomUrl();
502 } else {
503 $morehtmlref .= '';
504 }
505 }
506 }*/
507 // Author
508 if (!empty($object->email_msgid)) {
509 $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' ';
510
511 if ($object->fk_user_creat > 0) {
512 $fuser = new User($db);
513 $fuser->fetch($object->fk_user_creat);
514 $morehtmlref .= $fuser->getNomUrl(-1);
515 }
516 $morehtmlref .= ' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
517 } /* elseif (!empty($object->origin_email)) {
518 $morehtmlref .= $langs->trans("CreatedBy").' : ';
519 $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
520 $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
521 } */
522 $morehtmlref .= '</div>';
523
524
525 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
526
527
528 print '<div class="fichecenter">';
529 print '<div class="fichehalfleft">';
530 print '<div class="underbanner clearboth"></div>';
531 print '<table class="border centpercent tableforfield">'."\n";
532
533 // Common attributes
534 $keyforbreak = 'description'; // We change column just before this field
535 unset($object->fields['email']); // Hide field already shown in banner
536 //unset($object->fields['fk_soc']); // Hide field already shown in banner
537 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
538
539 // Other attributes. Fields from hook formObjectOptions and Extrafields.
540 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
541
542 print '</table>';
543 print '</div>';
544 print '</div>';
545
546 print '<div class="clearboth"></div>';
547
548 print dol_get_fiche_end();
549
550 // Buttons for actions
551
552 if ($action != 'presend' && $action != 'editline') {
553 print '<div class="tabsAction">'."\n";
554 $parameters = array();
555 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
556 if ($reshook < 0) {
557 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
558 }
559
560 if (empty($reshook)) {
561 // Send
562 if (empty($user->socid)) {
563 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'presend', 'mode' => 'init'], true).'#formmailbeforetitle', '');
564 }
565
566 // Back to draft
567 if ($object->status == $object::STATUS_VALIDATED) {
568 if ($permissiontoadd) {
569 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&token='.newToken().'&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
570 }
571 }
572
573 // Modify
574 if ($permissiontoadd) {
575 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'."\n";
576 } else {
577 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
578 }
579
580 // Validate
581 if ($object->status == $object::STATUS_DRAFT) {
582 if ($permissiontoadd) {
583 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
584 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes">'.$langs->trans("Validate").'</a>';
585 } else {
586 $langs->load("errors");
587 print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
588 }
589 }
590 }
591
592 // Make offer - Refuse - Decline
593 if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CONTRACT_PROPOSED) {
594 if ($permissiontoadd) {
595 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=makeofferordecline&token='.newToken().'">'.$langs->trans("MakeOffer").' / '.$langs->trans("Decline").'</a>';
596 }
597 }
598
599 // Contract refused / accepted
600 if ($object->status == $object::STATUS_CONTRACT_PROPOSED) {
601 if ($permissiontoadd) {
602 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=closeas&token='.newToken().'">'.$langs->trans("Accept").' / '.$langs->trans("Decline").'</a>';
603 }
604 }
605
606 // Clone
607 if ($permissiontoadd) {
608 print dolGetButtonAction($langs->trans("ToClone"), $langs->trans("ToClone"), 'clone', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&object=recruitmentcandidature', 'clone', $permissiontoadd, array('attr' => array('class' => 'reposition')))."\n";
609 }
610
611 // Button to convert into a user
612 if ($object->status == $object::STATUS_CONTRACT_SIGNED) {
613 if ($user->hasRight('user', 'user', 'creer')) {
614 $useralreadyexists = $object->fk_user;
615 if (empty($useralreadyexists)) {
616 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>';
617 } else {
618 print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
619 }
620 } else {
621 print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</span></div>";
622 }
623 }
624
625 // Cancel
626 if ($permissiontoadd) {
627 if ($object->status == $object::STATUS_VALIDATED) {
628 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("Cancel").'</a>'."\n";
629 } elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED) {
630 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
631 }
632 }
633
634 // Delete
635 print dolGetButtonAction($langs->trans("Delete"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, array('attr' => array('class' => 'reposition')))."\n";
636 }
637 print '</div>'."\n";
638 }
639
640
641 // Select mail models is same action as presend
642 if (GETPOST('modelselected')) {
643 $action = 'presend';
644 }
645
646 if ($action != 'presend') {
647 print '<div class="fichecenter"><div class="fichehalfleft">';
648 print '<a name="builddoc"></a>'; // ancre
649
650 $includedocgeneration = 1;
651
652 // Documents
653 if ($includedocgeneration) {
654 $objref = dol_sanitizeFileName($object->ref);
655 $relativepath = $objref.'/'.$objref.'.pdf';
656 $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
657 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
658 $genallowed = $user->hasRight('recruitment', 'recruitmentjobposition', 'read'); // If you can read, you can build the PDF to read content
659 $delallowed = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // If you can create/edit, you can remove a file on card
660 print $formfile->showdocuments('recruitment:RecruitmentCandidature', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
661 }
662
663 // Show links to link elements
664 $tmparray = $form->showLinkToObjectBlock($object, array(), array('recruitmentcanidature'), 1);
665 $linktoelem = $tmparray['linktoelem'];
666 $htmltoenteralink = $tmparray['htmltoenteralink'];
667 print $htmltoenteralink;
668
669 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
670
671
672 print '</div><div class="fichehalfright">';
673
674 $MAXEVENT = 10;
675
676 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/recruitment/recruitmentcandidature_agenda.php?id='.$object->id);
677
678 // List of actions on element
679 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
680 $formactions = new FormActions($db);
681 $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
682
683 print '</div></div>';
684 }
685
686 //Select mail models is same action as presend
687 if (GETPOST('modelselected')) {
688 $action = 'presend';
689 }
690
691 // Presend form
692 $modelmail = 'recruitmentcandidature_send';
693 $defaulttopic = 'InformationMessage';
694 $diroutput = $conf->recruitment->dir_output;
695 $trackid = 'recruitmentcandidature'.$object->id;
696 $inreplyto = $object->email_msgid;
697
698 $job = new RecruitmentJobPosition($db);
699 $job->fetch($object->fk_recruitmentjobposition);
700
701 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
702 $recruiter = new User($db);
703 $recruiter->fetch($job->fk_user_recruiter);
704
705 $recruitername = $recruiter->getFullName($langs);
706 $recruitermail = (!empty($job->email_recruiter) ? $job->email_recruiter : $recruiter->email);
707
708 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
709}
710
711// End of page
712llxFooter();
713$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:
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
Definition html.lib.php:540
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.
Definition html.lib.php:738
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, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.