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