dolibarr 21.0.0-alpha
recruitmentjobposition_applications.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require_once '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
32require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
33
34// Load translation files required by the page
35$langs->loadLangs(array("recruitment", "other"));
36
37// Get parameters
38$id = GETPOSTINT('id');
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') : 'recruitmentjobpositioncard'; // To manage different context of search
44$backtopage = GETPOST('backtopage', 'alpha');
45$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
46//$lineid = GETPOST('lineid', 'int');
47
48// Initialize a technical objects
50$extrafields = new ExtraFields($db);
51$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
52$hookmanager->initHooks(array('recruitmentjobpositioncard', '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 criteria
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 = 'view';
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_recruitmentjobposition', '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_URL_ROOT.'/recruitment/recruitmentjobposition_list.php';
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_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.($id > 0 ? $id : '__ID__');
111 }
112 }
113 }
114 $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_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 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
118
119 // Actions when linking object each other
120 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
121
122 // Actions when printing a doc from card
123 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
124
125 // Action to move up and down lines of object
126 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
127
128 // Action to build doc
129 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
130
131 if ($action == 'set_thirdparty' && $permissiontoadd) {
132 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
133 }
134 if ($action == 'classin' && $permissiontoadd) {
135 $object->setProject(GETPOSTINT('projectid'));
136 }
137
138 // Actions to send emails
139 $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
140 $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
141 $trackid = 'recruitmentjobposition'.$object->id;
142 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
143}
144
145
146
147
148/*
149 * View
150 */
151
152$form = new Form($db);
153$formfile = new FormFile($db);
154$formproject = new FormProjets($db);
155
156$title = $langs->trans("JobPositionApplications");
157$help_url = '';
158llxHeader('', $title, $help_url);
159
160// Part to show record
161if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
162 $res = $object->fetch_optionals();
163
164 $head = recruitmentjobpositionPrepareHead($object);
165 print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto);
166
167 $formconfirm = '';
168
169 // Confirmation to delete
170 if ($action == 'delete') {
171 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
172 }
173 // Confirmation to delete line
174 if ($action == 'deleteline') {
175 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
176 }
177 // Clone confirmation
178 if ($action == 'clone') {
179 // Create an array for form
180 $formquestion = array();
181 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
182 }
183
184 // Confirmation of action xxxx
185 if ($action == 'xxx') {
186 $formquestion = array();
187 /*
188 $forcecombo=0;
189 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
190 $formquestion = array(
191 // 'text' => $langs->trans("ConfirmClone"),
192 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
193 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
194 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
195 );
196 */
197 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
198 }
199
200 // Call Hook formConfirm
201 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
202 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
203 if (empty($reshook)) {
204 $formconfirm .= $hookmanager->resPrint;
205 } elseif ($reshook > 0) {
206 $formconfirm = $hookmanager->resPrint;
207 }
208
209 // Print form confirm
210 print $formconfirm;
211
212
213 // Object card
214 // ------------------------------------------------------------
215 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
216
217 $morehtmlref = '<div class="refidno">';
218 /*
219 // Ref customer
220 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
221 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
222 // Thirdparty
223 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
224 */
225 // Project
226 if (isModEnabled('project')) {
227 $langs->load("projects");
228 $morehtmlref .= $langs->trans('Project').' ';
229 if ($permissiontoadd) {
230 if ($action != 'classify') {
231 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
232 }
233 $morehtmlref .= ' : ';
234 if ($action == 'classify') {
235 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
236 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
237 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
238 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
239 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
240 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
241 $morehtmlref .= '</form>';
242 } else {
243 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
244 }
245 } else {
246 if (!empty($object->fk_project)) {
247 $proj = new Project($db);
248 $proj->fetch($object->fk_project);
249 $morehtmlref .= ': '.$proj->getNomUrl();
250 } else {
251 $morehtmlref .= '';
252 }
253 }
254 }
255 $morehtmlref .= '</div>';
256
257
258 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
259
260
261 print '<div class="fichecenter">';
262 print '<div class="fichehalfleft">';
263 print '<div class="underbanner clearboth"></div>';
264 print '<table class="border centpercent tableforfield">'."\n";
265
266 // Common attributes
267 $keyforbreak = 'description'; // We change column just after this field
268 unset($object->fields['fk_project']); // Hide field already shown in banner
269 //unset($object->fields['fk_soc']); // Hide field already shown in banner
270 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
271
272 // Other attributes. Fields from hook formObjectOptions and Extrafields.
273 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
274
275 print '</table>';
276 print '</div>';
277 print '</div>';
278
279 print '<div class="clearboth"></div>';
280
281 print dol_get_fiche_end();
282
283 print '<br>'.$langs->trans("FeatureNotYetAvailable");
284}
285
286// End of page
287llxFooter();
288$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
Class to manage standard extra fields.
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 to manage projects.
Class for RecruitmentJobPosition.
llxFooter()
Footer empty.
Definition document.php:107
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.
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'.
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 edit/modify fiche.
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
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.