dolibarr 24.0.0-beta
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-2026 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 = '';
56//$lineid = GETPOST('lineid', 'int');
57
58// Initialize a technical objects
60$extrafields = new ExtraFields($db);
61$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
62$hookmanager->initHooks(array('recruitmentjobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
63
64// Fetch optionals attributes and labels
65$extrafields->fetch_name_optionals_label($object->table_element);
66
67$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
68
69// Initialize array of search criteria
70$search_all = GETPOST("search_all", 'alpha');
71$search = array();
72foreach ($object->fields as $key => $val) {
73 if (GETPOST('search_'.$key, 'alpha')) {
74 $search[$key] = GETPOST('search_'.$key, 'alpha');
75 }
76}
77
78if (empty($action) && empty($id) && empty($ref)) {
79 $action = 'view';
80}
81
82// Load object
83include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
84
85
86$permissiontoread = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
87$permissiontoadd = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
88$permissiontodelete = $user->hasRight('recruitment', 'recruitmentjobposition', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
89$permissionnote = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_setnotes.inc.php
90$permissiondellink = $user->hasRight('recruitment', 'recruitmentjobposition', 'write'); // Used by the include of actions_dellink.inc.php
91$upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $object->entity : 1];
92
93// Security check - Protection if external user
94//if ($user->socid > 0) accessforbidden();
95//if ($user->socid > 0) $socid = $user->socid;
96$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
97$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft);
98
99
100/*
101 * Actions
102 */
103
104$parameters = array();
105$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
106if ($reshook < 0) {
107 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
108}
109
110if (empty($reshook)) {
111 $error = 0;
112
113 $backurlforlist = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_list.php';
114
115 if (empty($backtopage) || ($cancel && empty($id))) {
116 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
117 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
118 $backtopage = $backurlforlist;
119 } else {
120 $backtopage = DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.($id > 0 ? $id : '__ID__');
121 }
122 }
123 }
124 $triggermodname = 'RECRUITMENT_RECRUITMENTJOBPOSITION_MODIFY'; // Name of trigger action code to execute when we modify record
125
126 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
127 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
128
129 // Actions when linking object each other
130 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
131
132 // Actions when printing a doc from card
133 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
134
135 // Action to move up and down lines of object
136 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
137
138 // Action to build doc
139 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
140
141 if ($action == 'set_thirdparty' && $permissiontoadd) {
142 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY');
143 }
144 if ($action == 'classin' && $permissiontoadd) {
145 $object->setProject(GETPOSTINT('projectid'));
146 }
147
148 // Actions to send emails
149 $triggersendname = 'RECRUITMENTJOBPOSITION_SENTBYMAIL';
150 $autocopy = 'MAIN_MAIL_AUTOCOPY_RECRUITMENTJOBPOSITION_TO';
151 $trackid = 'recruitmentjobposition'.$object->id;
152 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
153}
154
155
156
157
158/*
159 * View
160 */
161
162$form = new Form($db);
163$formfile = new FormFile($db);
164$formproject = new FormProjets($db);
165
166$title = $langs->trans("JobPositionApplications");
167$help_url = '';
168llxHeader('', $title, $help_url);
169
170// Part to show record
171if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
172 $res = $object->fetch_optionals();
173
174 $head = recruitmentjobpositionPrepareHead($object);
175 print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto);
176
177 $formconfirm = '';
178
179 // Confirmation to delete
180 if ($action == 'delete') {
181 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
182 }
183 // Confirmation to delete line
184 if ($action == 'deleteline') {
185 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
186 }
187 // Clone confirmation
188 if ($action == 'clone') {
189 // Create an array for form
190 $formquestion = array();
191 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
192 }
193
194 // Call Hook formConfirm
195 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
196 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
197 if (empty($reshook)) {
198 $formconfirm .= $hookmanager->resPrint;
199 } elseif ($reshook > 0) {
200 $formconfirm = $hookmanager->resPrint;
201 }
202
203 // Print form confirm
204 print $formconfirm;
205
206
207 // Object card
208 // ------------------------------------------------------------
209 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
210
211 $morehtmlref = '<div class="refidno">';
212 /*
213 // Ref customer
214 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
215 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
216 // Thirdparty
217 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
218 */
219 // Project
220 if (isModEnabled('project')) {
221 $langs->load("projects");
222 $morehtmlref .= $langs->trans('Project').' ';
223 if ($permissiontoadd) {
224 if ($action != 'classify') {
225 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
226 }
227 $morehtmlref .= ' : ';
228 if ($action == 'classify') {
229 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
230 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
231 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
232 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
233 $morehtmlref .= $formproject->select_projects($object->socid, (string) $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
234 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
235 $morehtmlref .= '</form>';
236 } else {
237 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
238 }
239 } else {
240 if (!empty($object->fk_project)) {
241 $proj = new Project($db);
242 $proj->fetch($object->fk_project);
243 $morehtmlref .= ': '.$proj->getNomUrl();
244 } else {
245 $morehtmlref .= '';
246 }
247 }
248 }
249 $morehtmlref .= '</div>';
250
251
252 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
253
254
255 print '<div class="fichecenter">';
256 print '<div class="fichehalfleft">';
257 print '<div class="underbanner clearboth"></div>';
258 print '<table class="border centpercent tableforfield">'."\n";
259
260 // Common attributes
261 $keyforbreak = 'description'; // We change column just after this field
262 unset($object->fields['fk_project']); // Hide field already shown in banner
263 //unset($object->fields['fk_soc']); // Hide field already shown in banner
264 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
265
266 // Other attributes. Fields from hook formObjectOptions and Extrafields.
267 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
268
269 print '</table>';
270 print '</div>';
271 print '</div>';
272
273 print '<div class="clearboth"></div>';
274
275 print dol_get_fiche_end();
276
277 print '<br>'.$langs->trans("FeatureNotYetAvailable");
278}
279
280// End of page
281llxFooter();
282$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
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.