dolibarr  16.0.1
recruitmentjobposition_applications.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 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"])) {
48  $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
49 }
50 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
51 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
52 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
53  $i--; $j--;
54 }
55 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
56  $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
57 }
58 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
59  $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
60 }
61 // Try main.inc.php using relative path
62 if (!$res && file_exists("../main.inc.php")) {
63  $res = @include "../main.inc.php";
64 }
65 if (!$res && file_exists("../../main.inc.php")) {
66  $res = @include "../../main.inc.php";
67 }
68 if (!$res && file_exists("../../../main.inc.php")) {
69  $res = @include "../../../main.inc.php";
70 }
71 if (!$res) {
72  die("Include of main fails");
73 }
74 
75 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
76 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
77 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
78 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
79 dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
80 dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
81 
82 // Load translation files required by the page
83 $langs->loadLangs(array("recruitment", "other"));
84 
85 // Get parameters
86 $id = GETPOST('id', 'int');
87 $ref = GETPOST('ref', 'alpha');
88 $action = GETPOST('action', 'aZ09');
89 $confirm = GETPOST('confirm', 'alpha');
90 $cancel = GETPOST('cancel', 'aZ09');
91 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
92 $backtopage = GETPOST('backtopage', 'alpha');
93 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
94 //$lineid = GETPOST('lineid', 'int');
95 
96 // Initialize technical objects
97 $object = new RecruitmentJobPosition($db);
98 $extrafields = new ExtraFields($db);
99 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
100 $hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
101 
102 // Fetch optionals attributes and labels
103 $extrafields->fetch_name_optionals_label($object->table_element);
104 
105 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
106 
107 // Initialize array of search criterias
108 $search_all = GETPOST("search_all", 'alpha');
109 $search = array();
110 foreach ($object->fields as $key => $val) {
111  if (GETPOST('search_'.$key, 'alpha')) {
112  $search[$key] = GETPOST('search_'.$key, 'alpha');
113  }
114 }
115 
116 if (empty($action) && empty($id) && empty($ref)) {
117  $action = 'view';
118 }
119 
120 // Load object
121 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
122 
123 
124 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
125 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
126 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
127 $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php
128 $permissiondellink = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_dellink.inc.php
129 $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
130 
131 // Security check - Protection if external user
132 //if ($user->socid > 0) accessforbidden();
133 //if ($user->socid > 0) $socid = $user->socid;
134 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
135 $result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
136 
137 
138 /*
139  * Actions
140  */
141 
142 $parameters = array();
143 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
144 if ($reshook < 0) {
145  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
146 }
147 
148 if (empty($reshook)) {
149  $error = 0;
150 
151  $backurlforlist = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php';
152 
153  if (empty($backtopage) || ($cancel && empty($id))) {
154  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
155  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
156  $backtopage = $backurlforlist;
157  } else {
158  $backtopage = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.($id > 0 ? $id : '__ID__');
159  }
160  }
161  }
162  $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
163 
164  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
165  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
166 
167  // Actions when linking object each other
168  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
169 
170  // Actions when printing a doc from card
171  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
172 
173  // Action to move up and down lines of object
174  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
175 
176  // Action to build doc
177  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
178 
179  if ($action == 'set_thirdparty' && $permissiontoadd) {
180  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
181  }
182  if ($action == 'classin' && $permissiontoadd) {
183  $object->setProject(GETPOST('projectid', 'int'));
184  }
185 
186  // Actions to send emails
187  $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
188  $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
189  $trackid = 'recruitmentjobposition'.$object->id;
190  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
191 }
192 
193 
194 
195 
196 /*
197  * View
198  */
199 
200 $form = new Form($db);
201 $formfile = new FormFile($db);
202 $formproject = new FormProjets($db);
203 
204 $title = $langs->trans("JobPositionApplications");
205 $help_url = '';
206 llxHeader('', $title, $help_url);
207 
208 // Part to show record
209 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
210  $res = $object->fetch_optionals();
211 
212  $head = recruitmentjobpositionPrepareHead($object);
213  print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto);
214 
215  $formconfirm = '';
216 
217  // Confirmation to delete
218  if ($action == 'delete') {
219  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
220  }
221  // Confirmation to delete line
222  if ($action == 'deleteline') {
223  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
224  }
225  // Clone confirmation
226  if ($action == 'clone') {
227  // Create an array for form
228  $formquestion = array();
229  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
230  }
231 
232  // Confirmation of action xxxx
233  if ($action == 'xxx') {
234  $formquestion = array();
235  /*
236  $forcecombo=0;
237  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
238  $formquestion = array(
239  // 'text' => $langs->trans("ConfirmClone"),
240  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
241  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
242  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
243  );
244  */
245  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
246  }
247 
248  // Call Hook formConfirm
249  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
250  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
251  if (empty($reshook)) {
252  $formconfirm .= $hookmanager->resPrint;
253  } elseif ($reshook > 0) {
254  $formconfirm = $hookmanager->resPrint;
255  }
256 
257  // Print form confirm
258  print $formconfirm;
259 
260 
261  // Object card
262  // ------------------------------------------------------------
263  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
264 
265  $morehtmlref = '<div class="refidno">';
266  /*
267  // Ref customer
268  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
269  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
270  // Thirdparty
271  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
272  */
273  // Project
274  if (!empty($conf->project->enabled)) {
275  $langs->load("projects");
276  $morehtmlref .= $langs->trans('Project').' ';
277  if ($permissiontoadd) {
278  if ($action != 'classify') {
279  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
280  }
281  $morehtmlref .= ' : ';
282  if ($action == 'classify') {
283  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
284  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
285  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
286  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
287  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
288  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
289  $morehtmlref .= '</form>';
290  } else {
291  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
292  }
293  } else {
294  if (!empty($object->fk_project)) {
295  $proj = new Project($db);
296  $proj->fetch($object->fk_project);
297  $morehtmlref .= ': '.$proj->getNomUrl();
298  } else {
299  $morehtmlref .= '';
300  }
301  }
302  }
303  $morehtmlref .= '</div>';
304 
305 
306  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
307 
308 
309  print '<div class="fichecenter">';
310  print '<div class="fichehalfleft">';
311  print '<div class="underbanner clearboth"></div>';
312  print '<table class="border centpercent tableforfield">'."\n";
313 
314  // Common attributes
315  $keyforbreak = 'description'; // We change column just after this field
316  unset($object->fields['fk_project']); // Hide field already shown in banner
317  //unset($object->fields['fk_soc']); // Hide field already shown in banner
318  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
319 
320  // Other attributes. Fields from hook formObjectOptions and Extrafields.
321  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
322 
323  print '</table>';
324  print '</div>';
325  print '</div>';
326 
327  print '<div class="clearboth"></div>';
328 
329  print dol_get_fiche_end();
330 
331  print '<br>'.$langs->trans("FeatureNotYetAvailable");
332 }
333 
334 // End of page
335 llxFooter();
336 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
Definition: agenda.php:116
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.
Class to manage projects.
Class to manage building of HTML components.
Class for RecruitmentJobPosition.
Class to offer components to list and upload files.
restrictedArea($user, $features, $objectid=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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.
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:73
$formconfirm
if ($action == &#39;delbookkeepingyear&#39;) {