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