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