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