dolibarr  13.0.2
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 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db
25 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user
26 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc
27 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs
28 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters
29 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters
30 //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
31 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
32 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
33 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
35 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
36 //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
37 //if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
38 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value
39 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler
40 //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
41 //if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies
42 
43 
44 // Load Dolibarr environment
45 $res = 0;
46 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
47 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
48 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
49 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
50 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
51 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
52 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
53 // Try main.inc.php using relative path
54 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
55 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
56 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
57 if (!$res) die("Include of main fails");
58 
59 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
61 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
62 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
64 require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
65 require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentcandidature.lib.php';
66 
67 // Load translation files required by the page
68 $langs->loadLangs(array("recruitment", "other", "users"));
69 
70 // Get parameters
71 $id = GETPOST('id', 'int');
72 $ref = GETPOST('ref', 'alpha');
73 $action = GETPOST('action', 'aZ09');
74 $confirm = GETPOST('confirm', 'alpha');
75 $cancel = GETPOST('cancel', 'aZ09');
76 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturecard'; // To manage different context of search
77 $backtopage = GETPOST('backtopage', 'alpha');
78 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
79 //$lineid = GETPOST('lineid', 'int');
80 
81 // Initialize technical objects
82 $object = new RecruitmentCandidature($db);
83 $extrafields = new ExtraFields($db);
84 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
85 $hookmanager->initHooks(array('recruitmentcandidaturecard', 'globalcard')); // Note that conf->hooks_modules contains array
86 
87 // Fetch optionals attributes and labels
88 $extrafields->fetch_name_optionals_label($object->table_element);
89 
90 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
91 
92 // Initialize array of search criterias
93 $search_all = GETPOST("search_all", 'alpha');
94 $search = array();
95 foreach ($object->fields as $key => $val)
96 {
97  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
98 }
99 
100 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
101 
102 // Load object
103 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
104 
105 
106 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
107 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
108 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
109 $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
110 $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
111 $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
112 
113 // Security check - Protection if external user
114 //if ($user->socid > 0) accessforbidden();
115 //if ($user->socid > 0) $socid = $user->socid;
116 //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
117 //$result = restrictedArea($user, 'recruitment', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
118 
119 //if (!$permissiontoread) accessforbidden();
120 
121 
122 /*
123  * Actions
124  */
125 
126 $parameters = array();
127 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
128 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
129 
130 if (empty($reshook))
131 {
132  $error = 0;
133 
134  $backurlforlist = dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1);
135 
136  if (empty($backtopage) || ($cancel && empty($id))) {
137  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
138  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
139  else $backtopage = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
140  }
141  }
142  $triggermodname = 'RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record
143 
144  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
145  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
146 
147  // Actions when linking object each other
148  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
149 
150  // Actions when printing a doc from card
151  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
152 
153  // Action to move up and down lines of object
154  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
155 
156  // Action to build doc
157  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
158 
159  if ($action == 'classin' && $permissiontoadd)
160  {
161  $object->setProject(GETPOST('projectid', 'int'));
162  }
163  if ($action == 'confirm_decline' && $confirm == 'yes' && $permissiontoadd) {
164  $result = $object->setStatut($object::STATUS_REFUSED, null, '', $triggermodname);
165  if ($result < 0) {
166  setEventMessages($object->error, $object->errors, 'errors');
167  }
168  }
169 
170  if ($action == 'confirm_makeofferordecline' && $permissiontoadd && !GETPOST('cancel', 'alpha')) {
171  if (!(GETPOST('status', 'int') > 0)) {
172  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
173  $action = 'makeofferordecline';
174  } else {
175  // prevent browser refresh from closing proposal several times
176  if ($object->status == $object::STATUS_VALIDATED)
177  {
178  $db->begin();
179 
180  if (GETPOST('status', 'int') == $object::STATUS_REFUSED) {
181  $result = $object->setStatut($object::STATUS_REFUSED, null, '', $triggermodname);
182  if ($result < 0) {
183  setEventMessages($object->error, $object->errors, 'errors');
184  }
185  } else {
186  $result = $object->setStatut($object::STATUS_CONTRACT_PROPOSED, null, '', $triggermodname);
187  if ($result < 0) {
188  setEventMessages($object->error, $object->errors, 'errors');
189  }
190  }
191 
192  if (!$error)
193  {
194  $db->commit();
195  } else {
196  $db->rollback();
197  }
198  }
199  }
200  }
201 
202  if ($action == 'confirm_closeas' && $permissiontoadd && !GETPOST('cancel', 'alpha')) {
203  if (!(GETPOST('status', 'int') > 0)) {
204  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors');
205  $action = 'makeofferordecline';
206  } else {
207  // prevent browser refresh from closing proposal several times
208  if ($object->status == $object::STATUS_CONTRACT_PROPOSED)
209  {
210  $db->begin();
211 
212  if (GETPOST('status', 'int') == $object::STATUS_CONTRACT_REFUSED) {
213  $result = $object->setStatut($object::STATUS_CONTRACT_REFUSED, null, '', $triggermodname);
214  if ($result < 0) {
215  setEventMessages($object->error, $object->errors, 'errors');
216  }
217  } else {
218  $result = $object->setStatut($object::STATUS_CONTRACT_SIGNED, null, '', $triggermodname);
219  if ($result < 0) {
220  setEventMessages($object->error, $object->errors, 'errors');
221  }
222  }
223 
224  if (!$error)
225  {
226  $db->commit();
227  } else {
228  $db->rollback();
229  }
230  }
231  }
232  }
233 
234  // Create user from a member
235  if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
236  if ($result > 0) {
237  $jobposition = new RecruitmentJobPosition($db);
238  $jobposition->fetch($object->fk_recruitmentjobposition);
239 
240  // Creation user
241  $nuser = new User($db);
242  $nuser->login = GETPOST('login', 'alphanohtml');
243  $nuser->fk_soc = 0;
244  $nuser->employee = 1;
245  $nuser->firstname = $object->firstname;
246  $nuser->lastname = $object->lastname;
247  $nuser->personal_mobile = $object->phone;
248  $nuser->birth = $object->date_birth;
249  $nuser->salary = $object->remuneration_proposed;
250  $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor
251 
252  $result = $nuser->create($user);
253 
254  if ($result < 0) {
255  $langs->load("errors");
256  setEventMessages($langs->trans($nuser->error), null, 'errors');
257  $action = 'create_user';
258  } else {
259  setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
260  $action = '';
261  }
262  } else {
263  setEventMessages($object->error, $object->errors, 'errors');
264  $action = 'create_user';
265  }
266  }
267 
268  // Actions to send emails
269  $triggersendname = 'RECRUITMENTCANDIDATURE_SENTBYMAIL';
270  $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTCANDIDATURE_TO';
271  $trackid = 'recruitmentcandidature'.$object->id;
272  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
273 }
274 
275 
276 
277 
278 /*
279  * View
280  *
281  * Put here all code to build page
282  */
283 
284 $form = new Form($db);
285 $formfile = new FormFile($db);
286 $formproject = new FormProjets($db);
287 
288 $title = $langs->trans("RecruitmentCandidature");
289 $help_url = '';
290 llxHeader('', $title, $help_url);
291 
292 // Example : Adding jquery code
293 print '<script type="text/javascript" language="javascript">
294 jQuery(document).ready(function() {
295  function init_myfunc()
296  {
297  jQuery("#myid").removeAttr(\'disabled\');
298  jQuery("#myid").attr(\'disabled\',\'disabled\');
299  }
300  init_myfunc();
301  jQuery("#mybutton").click(function() {
302  init_myfunc();
303  });
304 });
305 </script>';
306 
307 
308 // Part to create
309 if ($action == 'create')
310 {
311  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("RecruitmentCandidature")), '', 'object_'.$object->picto);
312 
313  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
314  print '<input type="hidden" name="token" value="'.newToken().'">';
315  print '<input type="hidden" name="action" value="add">';
316  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
317  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
318 
319  print dol_get_fiche_head(array(), '');
320 
321  // Set some default values
322  //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
323 
324  print '<table class="border centpercent tableforfieldcreate">'."\n";
325 
326  // Common attributes
327  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
328 
329  // Other attributes
330  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
331 
332  print '</table>'."\n";
333 
335 
336  print '<div class="center">';
337  print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
338  print '&nbsp; ';
339  print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
340  print '</div>';
341 
342  print '</form>';
343 
344  //dol_set_focus('input[name="ref"]');
345 }
346 
347 // Part to edit record
348 if (($id || $ref) && $action == 'edit')
349 {
350  print load_fiche_titre($langs->trans("RecruitmentCandidature"), '', 'object_'.$object->picto);
351 
352  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
353  print '<input type="hidden" name="token" value="'.newToken().'">';
354  print '<input type="hidden" name="action" value="update">';
355  print '<input type="hidden" name="id" value="'.$object->id.'">';
356  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
357  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
358 
360 
361  print '<table class="border centpercent tableforfieldedit">'."\n";
362 
363  // Common attributes
364  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
365 
366  // Other attributes
367  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
368 
369  print '</table>';
370 
372 
373  print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
374  print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
375  print '</div>';
376 
377  print '</form>';
378 }
379 
380 // Part to show record
381 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
382 {
383  $res = $object->fetch_optionals();
384 
385  $head = recruitmentcandidaturePrepareHead($object);
386  print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentCandidature"), -1, $object->picto);
387 
388  $formconfirm = '';
389 
390  // Confirmation to delete
391  if ($action == 'delete') {
392  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentCandidature'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
393  }
394  // Confirmation to delete line
395  if ($action == 'deleteline') {
396  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
397  }
398  // Clone confirmation
399  if ($action == 'clone') {
400  // Create an array for form
401  $formquestion = array();
402  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
403  }
404 
405  if ($action == 'makeofferordecline')
406  {
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_PROPOSED => $object->LibStatut($object::STATUS_CONTRACT_PROPOSED), $object::STATUS_REFUSED => $object->LibStatut($object::STATUS_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_makeofferordecline', $formquestion, '', 1, 250);
418  }
419 
420  if ($action == 'closeas')
421  {
422  $langs->load("propal");
423 
424  //Form to close proposal (signed or not)
425  $formquestion = array(
426  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))),
427  array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
428  );
429 
430  $text = '';
431 
432  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250);
433  }
434 
435  // Confirm create user
436  if ($action == 'create_user') {
437  $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
438  if (empty($login)) {
439  // Full firstname and name separated with a dot : firstname.name
440  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
441  $login = dol_buildlogin($object->lastname, $object->firstname);
442  }
443  if (empty($login)) $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
444 
445  // Create a form array
446  $formquestion = array(
447  array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
448  );
449  $text .= $langs->trans("ConfirmCreateLogin");
450  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
451  }
452 
453  // Call Hook formConfirm
454  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
455  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
456  if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
457  elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
458 
459  // Print form confirm
460  print $formconfirm;
461 
462 
463  // Object card
464  // ------------------------------------------------------------
465  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
466 
467  $morehtmlref = '<div class="refidno">';
468  /*
469  // Ref customer
470  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
471  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
472  // Thirdparty
473  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
474  // Project
475  if (! empty($conf->projet->enabled))
476  {
477  $langs->load("projects");
478  $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
479  if ($permissiontoadd)
480  {
481  //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
482  $morehtmlref .= ' : ';
483  if ($action == 'classify') {
484  //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
485  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
486  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
487  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
488  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
489  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
490  $morehtmlref .= '</form>';
491  } else {
492  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
493  }
494  } else {
495  if (! empty($object->fk_project)) {
496  $proj = new Project($db);
497  $proj->fetch($object->fk_project);
498  $morehtmlref .= ': '.$proj->getNomUrl();
499  } else {
500  $morehtmlref .= '';
501  }
502  }
503  }*/
504  $morehtmlref .= '</div>';
505 
506 
507  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
508 
509 
510  print '<div class="fichecenter">';
511  print '<div class="fichehalfleft">';
512  print '<div class="underbanner clearboth"></div>';
513  print '<table class="border centpercent tableforfield">'."\n";
514 
515  // Common attributes
516  $keyforbreak = 'description'; // We change column just before this field
517  unset($object->fields['email']); // Hide field already shown in banner
518  //unset($object->fields['fk_soc']); // Hide field already shown in banner
519  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
520 
521  // Other attributes. Fields from hook formObjectOptions and Extrafields.
522  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
523 
524  print '</table>';
525  print '</div>';
526  print '</div>';
527 
528  print '<div class="clearboth"></div>';
529 
531 
532 
533  /*
534  * Lines
535  */
536 
537  if (!empty($object->table_element_line))
538  {
539  // Show object lines
540  $result = $object->getLinesArray();
541 
542  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
543  <input type="hidden" name="token" value="' . newToken().'">
544  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
545  <input type="hidden" name="mode" value="">
546  <input type="hidden" name="id" value="' . $object->id.'">
547  ';
548 
549  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
550  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
551  }
552 
553  print '<div class="div-table-responsive-no-min">';
554  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
555  {
556  print '<table id="tablelines" class="noborder noshadow" width="100%">';
557  }
558 
559  if (!empty($object->lines))
560  {
561  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
562  }
563 
564  // Form to add new line
565  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
566  {
567  if ($action != 'editline')
568  {
569  // Add products/services form
570  $object->formAddObjectLine(1, $mysoc, $soc);
571 
572  $parameters = array();
573  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
574  }
575  }
576 
577  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
578  {
579  print '</table>';
580  }
581  print '</div>';
582 
583  print "</form>\n";
584  }
585 
586 
587  // Buttons for actions
588 
589  if ($action != 'presend' && $action != 'editline') {
590  print '<div class="tabsAction">'."\n";
591  $parameters = array();
592  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
593  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
594 
595  if (empty($reshook))
596  {
597  // Send
598  if (empty($user->socid)) {
599  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";
600  }
601 
602  // Back to draft
603  if ($object->status == $object::STATUS_VALIDATED)
604  {
605  if ($permissiontoadd)
606  {
607  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
608  }
609  }
610 
611  // Modify
612  if ($permissiontoadd)
613  {
614  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
615  } else {
616  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
617  }
618 
619  // Validate
620  if ($object->status == $object::STATUS_DRAFT)
621  {
622  if ($permissiontoadd)
623  {
624  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
625  {
626  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>';
627  } else {
628  $langs->load("errors");
629  print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
630  }
631  }
632  }
633 
634  // Make offer - Refuse - Decline
635  if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CONTRACT_PROPOSED)
636  {
637  if ($permissiontoadd)
638  {
639  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=makeofferordecline">'.$langs->trans("MakeOffer").' / '.$langs->trans("Decline").'</a>';
640  }
641  }
642 
643  // Contract refused / accepted
644  if ($object->status == $object::STATUS_CONTRACT_PROPOSED)
645  {
646  if ($permissiontoadd)
647  {
648  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=closeas">'.$langs->trans("Accept").' / '.$langs->trans("Decline").'</a>';
649  }
650  }
651 
652  // Clone
653  if ($permissiontoadd)
654  {
655  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=recruitmentcandidature">'.$langs->trans("ToClone").'</a>'."\n";
656  }
657 
658  // Button to convert into a user
659  if ($object->status == $object::STATUS_CONTRACT_SIGNED)
660  {
661  if ($user->rights->user->user->creer) {
662  // TODO Check if a user already exists
663  $useralreadyexists = 0;
664  if (empty($useralreadyexists)) {
665  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>';
666  } else {
667  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
668  }
669  } else {
670  print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
671  }
672  }
673 
674  // Cancel
675  if ($permissiontoadd)
676  {
677  if ($object->status == $object::STATUS_VALIDATED)
678  {
679  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close">'.$langs->trans("Cancel").'</a>'."\n";
680  }
681  elseif ($object->status == $object::STATUS_REFUSED || $object->status == $object::STATUS_CANCELED || $object->status == $object::STATUS_CONTRACT_REFUSED)
682  {
683  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
684  }
685  }
686 
687  // Delete (need delete permission, or if draft, just need create/modify permission)
688  if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd))
689  {
690  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
691  } else {
692  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
693  }
694  }
695  print '</div>'."\n";
696  }
697 
698 
699  // Select mail models is same action as presend
700  if (GETPOST('modelselected')) {
701  $action = 'presend';
702  }
703 
704  if ($action != 'presend')
705  {
706  print '<div class="fichecenter"><div class="fichehalfleft">';
707  print '<a name="builddoc"></a>'; // ancre
708 
709  $includedocgeneration = 1;
710 
711  // Documents
712  if ($includedocgeneration) {
713  $objref = dol_sanitizeFileName($object->ref);
714  $relativepath = $objref.'/'.$objref.'.pdf';
715  $filedir = $conf->recruitment->dir_output.'/'.$object->element.'/'.$objref;
716  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
717  $genallowed = $user->rights->recruitment->recruitmentjobposition->read; // If you can read, you can build the PDF to read content
718  $delallowed = $user->rights->recruitment->recruitmentjobposition->write; // If you can create/edit, you can remove a file on card
719  print $formfile->showdocuments('recruitment:RecruitmentCandidature', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
720  }
721 
722  // Show links to link elements
723  $linktoelem = $form->showLinkToObjectBlock($object, null, array('recruitmentcandidature'));
724  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
725 
726 
727  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
728 
729  $MAXEVENT = 10;
730 
731  $morehtmlright = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_agenda.php', 1).'?id='.$object->id.'">';
732  $morehtmlright .= $langs->trans("SeeAll");
733  $morehtmlright .= '</a>';
734 
735  // List of actions on element
736  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
737  $formactions = new FormActions($db);
738  $somethingshown = $formactions->showactions($object, $object->element.'@recruitment', (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
739 
740  print '</div></div></div>';
741  }
742 
743  //Select mail models is same action as presend
744  if (GETPOST('modelselected')) $action = 'presend';
745 
746  // Presend form
747  $modelmail = 'recruitmentcandidature_send';
748  $defaulttopic = 'InformationMessage';
749  $diroutput = $conf->recruitment->dir_output;
750  $trackid = 'recruitmentcandidature'.$object->id;
751 
752  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
753 }
754 
755 // End of page
756 llxFooter();
757 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
Class to manage building of HTML components.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class for RecruitmentJobPosition.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
Class for RecruitmentCandidature.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...