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