dolibarr 22.0.5
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-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require_once '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
31require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
32require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
33require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array("recruitment", "other"));
45
46// Get parameters
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$action = GETPOST('action', 'aZ09');
50$confirm = GETPOST('confirm', 'alpha');
51$cancel = GETPOST('cancel');
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'recruitmentjobpositioncard'; // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha');
54$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
55//$lineid = GETPOST('lineid', 'int');
56
57// Initialize a technical objects
59$extrafields = new ExtraFields($db);
60$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
61$hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
62
63// Fetch optionals attributes and labels
64$extrafields->fetch_name_optionals_label($object->table_element);
65
66$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
67
68// Initialize array of search criteria
69$search_all = GETPOST("search_all", 'alpha');
70$search = array();
71foreach ($object->fields as $key => $val) {
72 if (GETPOST('search_'.$key, 'alpha')) {
73 $search[$key] = GETPOST('search_'.$key, 'alpha');
74 }
75}
76
77if (empty($action) && empty($id) && empty($ref)) {
78 $action = 'view';
79}
80
81// Load object
82include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
83
84
85$permissiontoread = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
86$permissiontoadd = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
87$permissiontodelete = $user->hasRight('recruitment', 'recruitmentjobposition', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
88$permissionnote = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_setnotes.inc.php
89$permissiondellink = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_dellink.inc.php
90$upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
91
92// Security check - Protection if external user
93//if ($user->socid > 0) accessforbidden();
94//if ($user->socid > 0) $socid = $user->socid;
95$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
96$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
97
98
99/*
100 * Actions
101 */
102
103$parameters = array();
104$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
105if ($reshook < 0) {
106 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
107}
108
109if (empty($reshook)) {
110 $error = 0;
111
112 $backurlforlist = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php';
113
114 if (empty($backtopage) || ($cancel && empty($id))) {
115 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
116 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
117 $backtopage = $backurlforlist;
118 } else {
119 $backtopage = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.($id > 0 ? $id : '__ID__');
120 }
121 }
122 }
123 $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
124
125 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
126 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
127
128 // Actions when linking object each other
129 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
130
131 // Actions when printing a doc from card
132 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
133
134 // Action to move up and down lines of object
135 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
136
137 // Action to build doc
138 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
139
140 if ($action == 'set_thirdparty' && $permissiontoadd) {
141 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
142 }
143 if ($action == 'classin' && $permissiontoadd) {
144 $object->setProject(GETPOSTINT('projectid'));
145 }
146
147 // Actions to send emails
148 $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
149 $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
150 $trackid = 'recruitmentjobposition'.$object->id;
151 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
152}
153
154
155
156
157/*
158 * View
159 */
160
161$form = new Form($db);
162$formfile = new FormFile($db);
163$formproject = new FormProjets($db);
164
165$title = $langs->trans("JobPositionApplications");
166$help_url = '';
167llxHeader('', $title, $help_url);
168
169// Part to show record
170if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
171 $res = $object->fetch_optionals();
172
173 $head = recruitmentjobpositionPrepareHead($object);
174 print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto);
175
176 $formconfirm = '';
177
178 // Confirmation to delete
179 if ($action == 'delete') {
180 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
181 }
182 // Confirmation to delete line
183 if ($action == 'deleteline') {
184 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
185 }
186 // Clone confirmation
187 if ($action == 'clone') {
188 // Create an array for form
189 $formquestion = array();
190 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
191 }
192
193 // Call Hook formConfirm
194 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
195 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
196 if (empty($reshook)) {
197 $formconfirm .= $hookmanager->resPrint;
198 } elseif ($reshook > 0) {
199 $formconfirm = $hookmanager->resPrint;
200 }
201
202 // Print form confirm
203 print $formconfirm;
204
205
206 // Object card
207 // ------------------------------------------------------------
208 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
209
210 $morehtmlref = '<div class="refidno">';
211 /*
212 // Ref customer
213 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
214 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
215 // Thirdparty
216 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
217 */
218 // Project
219 if (isModEnabled('project')) {
220 $langs->load("projects");
221 $morehtmlref .= $langs->trans('Project').' ';
222 if ($permissiontoadd) {
223 if ($action != 'classify') {
224 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
225 }
226 $morehtmlref .= ' : ';
227 if ($action == 'classify') {
228 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
229 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
230 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
231 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
232 $morehtmlref .= $formproject->select_projects($object->socid, (string) $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
233 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
234 $morehtmlref .= '</form>';
235 } else {
236 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
237 }
238 } else {
239 if (!empty($object->fk_project)) {
240 $proj = new Project($db);
241 $proj->fetch($object->fk_project);
242 $morehtmlref .= ': '.$proj->getNomUrl();
243 } else {
244 $morehtmlref .= '';
245 }
246 }
247 }
248 $morehtmlref .= '</div>';
249
250
251 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
252
253
254 print '<div class="fichecenter">';
255 print '<div class="fichehalfleft">';
256 print '<div class="underbanner clearboth"></div>';
257 print '<table class="border centpercent tableforfield">'."\n";
258
259 // Common attributes
260 $keyforbreak = 'description'; // We change column just after this field
261 unset($object->fields['fk_project']); // Hide field already shown in banner
262 //unset($object->fields['fk_soc']); // Hide field already shown in banner
263 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
264
265 // Other attributes. Fields from hook formObjectOptions and Extrafields.
266 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
267
268 print '</table>';
269 print '</div>';
270 print '</div>';
271
272 print '<div class="clearboth"></div>';
273
274 print dol_get_fiche_end();
275
276 print '<br>'.$langs->trans("FeatureNotYetAvailable");
277}
278
279// End of page
280llxFooter();
281$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
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.
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, $morecssdiv='')
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.