31 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
34 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
36 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
37 require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skill.class.php';
38 require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skillrank.class.php';
39 require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm_skill.lib.php';
42 $langs->loadLangs(array(
"hrm",
"other"));
45 $TSkillsToAdd =
GETPOST(
'fk_skill',
'array');
46 $objecttype =
GETPOST(
'objecttype',
'alpha');
47 $TNote =
GETPOST(
'TNote',
'array');
48 $lineid =
GETPOST(
'lineid',
'int');
49 $action =
GETPOST(
'action',
'aZ09');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $cancel =
GETPOST(
'cancel',
'aZ09');
52 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'skillcard';
53 $backtopage =
GETPOST(
'backtopage',
'alpha');
54 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
56 $TAuthorizedObjects = array(
'job',
'user');
60 if (in_array($objecttype, $TAuthorizedObjects)) {
61 if ($objecttype ==
'job') {
62 require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
63 $object =
new Job($db);
64 } elseif ($objecttype ==
"user") {
65 $object =
new User($db);
69 $hookmanager->initHooks(array(
'skilltab',
'globalcard'));
72 include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
74 $permissiontoread = $user->rights->hrm->all->read;
75 $permissiontoadd = $user->rights->hrm->all->write;
87 $parameters = array();
88 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
93 if (empty($reshook)) {
96 $backurlforlist = DOL_URL_ROOT.
'/hrm/skill_list.php';
98 if (empty($backtopage) || ($cancel && empty($id))) {
99 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
100 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
101 $backtopage = $backurlforlist;
103 $backtopage = DOL_URL_ROOT.
'/hrm/skill_list.php?id=' . ($id > 0 ? $id :
'__ID__');
108 if ($action ==
'addSkill') {
111 if (empty($TSkillsToAdd)) {
117 foreach ($TSkillsToAdd as $k=>$v) {
119 $skillAdded->fk_skill = $v;
120 $skillAdded->fk_object = $id;
121 $skillAdded->objecttype = $objecttype;
122 $ret = $skillAdded->create($user);
128 } elseif ($action ==
'saveSkill') {
129 if (!empty($TNote)) {
130 foreach ($TNote as $skillId => $rank) {
131 $TSkills = $skill->fetchAll(
'ASC',
't.rowid', 0, 0, array(
'customsql' =>
'fk_object=' . ((
int) $id) .
" AND objecttype='" . $db->escape($objecttype) .
"' AND fk_skill = " . ((
int) $skillId)));
132 if (is_array($TSkills) && !empty($TSkills)) {
133 foreach ($TSkills as $tmpObj) {
134 $tmpObj->rankorder = $rank;
135 $tmpObj->update($user);
140 header(
"Location: " . DOL_URL_ROOT.
'/hrm/skill_tab.php?id=' . $id.
'&objecttype=job');
143 } elseif ($action ==
'confirm_deleteskill' && $confirm ==
'yes') {
145 $ret = $skillToDelete->fetch($lineid);
148 $skillToDelete->delete($user);
161 $title = $langs->trans(
"RequiredSkills");
166 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
167 $res = $object->fetch_optionals();
170 if ($objecttype ==
'job') {
171 require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm_job.lib.php';
174 } elseif ($objecttype ==
"user") {
175 require_once DOL_DOCUMENT_ROOT .
"/core/lib/usergroups.lib.php";
176 $object->getRights();
181 print
dol_get_fiche_head($head,
'skill_tab', $langs->trans(
"Workstation"), -1, $object->picto);
190 if ($action ==
'ask_deleteskill') {
191 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&objecttype=' . $objecttype .
'&lineid=' . $lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteskill',
'', 0, 1);
201 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
202 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
203 if (empty($reshook)) {
205 } elseif ($reshook > 0) {
215 $linkback =
'<a href="' . $listLink .
'?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
217 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'" class="refid">';
218 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
219 $morehtmlref .=
'</a>';
221 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref,
'&objecttype='.$objecttype);
225 $static_skill =
new Skill($db);
226 $TAllSkills = $static_skill->fetchAll();
229 $TAllSkillsFormatted=array();
230 if (!empty($TAllSkills)) {
231 foreach ($TAllSkills as $k=>$v) {
232 $TAllSkillsFormatted[$k] = $v->label;
237 $TSkillsJob = $skill->fetchAll(
'ASC',
't.rowid', 0, 0, array(
'customsql' =>
'fk_object=' . ((
int) $id) .
" AND objecttype='" . $db->escape($objecttype) .
"'"));
239 $TAlreadyUsedSkill = array();
240 if (is_array($TSkillsJob) && !empty($TSkillsJob)) {
241 foreach ($TSkillsJob as $skillElement) {
242 $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill;
246 print
'<div class="fichecenter">';
247 print
'<div class="fichehalfleft">';
249 print
'<div class="underbanner clearboth"></div>';
250 print
'<table class="border centpercent tableforfield">';
253 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
254 if (!empty($object->ldap_sid) && $object->statut == 0) {
255 print
'<td class="error">';
256 print $langs->trans(
"LoginAccountDisableInDolibarr");
261 if (property_exists($object,
'admin')) {
262 if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
263 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
264 } elseif (!empty($object->admin)) {
265 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
273 $object->fields[
'label'][
'visible']=0;
274 $object->fields[
'firstname'][
'visible']=0;
275 $object->fields[
'lastname'][
'visible']=0;
279 print
'<tr><td class="titlefield">'.$langs->trans(
"RefEmployee").
'</td>';
280 print
'<td class="error">';
286 print
'<tr><td class="titlefield">'.$langs->trans(
"NationalRegistrationNumber").
'</td>';
287 print
'<td class="error">';
310 print
'<div class="clearboth"></div><br>';
312 if ($objecttype !=
'user' && $permissiontoadd) {
314 print
'<form name="addSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] .
'">';
315 print
'<input type="hidden" name="objecttype" value="' . $objecttype .
'">';
316 print
'<input type="hidden" name="id" value="' . $id .
'">';
317 print
'<input type="hidden" name="action" value="addSkill">';
318 print
'<input type="hidden" name="token" value="'.newToken().
'">';
319 print
'<div class="div-table-responsive-no-min">';
320 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
321 print
'<tr><td style="width:90%">' . $langs->trans(
'AddSkill') .
'</td><td style="width:10%"></td></tr>';
323 print
'<td>' .
$form->multiselectarray(
'fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0,
'', 0,
'100%') .
'</td>';
324 print
'<td><input class="button reposition" type="submit" value="' . $langs->trans(
'Add') .
'"></td>';
332 print
'<div class="clearboth"></div>';
334 if ($objecttype !=
'user' && $permissiontoadd) {
335 print
'<form name="saveSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] .
'">';
336 print
'<input type="hidden" name="objecttype" value="' . $objecttype .
'">';
337 print
'<input type="hidden" name="id" value="' . $id .
'">';
338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
339 print
'<input type="hidden" name="action" value="saveSkill">';
341 print
'<div class="div-table-responsive-no-min">';
342 print
'<table id="tablelines" class="noborder centpercent" width="100%">';
343 print
'<tr class="liste_titre">';
344 print
'<th>'.$langs->trans(
'SkillType').
'</th>';
345 print
'<th>'.$langs->trans(
'Label').
'</th>';
346 print
'<th>'.$langs->trans(
'Description').
'</th>';
347 print
'<th>'.$langs->trans($objecttype ===
'job' ?
'RequiredRank' :
'EmployeeRank').
'</th>';
348 if ($objecttype ===
'job') {
349 print
'<th class="linecoledit"></th>';
350 print
'<th class="linecoldelete"></th>';
353 if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
354 print
'<tr><td><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
356 $sk =
new Skill($db);
357 foreach ($TSkillsJob as $skillElement) {
358 $sk->fetch($skillElement->fk_skill);
362 print
'</td><td class="linecolfk_skill">';
363 print $sk->getNomUrl(1);
366 print $sk->description;
367 print
'</td><td class="linecolrank">';
368 print
displayRankInfos($skillElement->rankorder, $skillElement->fk_skill,
'TNote', $objecttype ==
'job' && $permissiontoadd ?
'edit' :
'view');
370 if ($objecttype !=
'user' && $permissiontoadd) {
371 print
'<td class="linecoledit"></td>';
372 print
'<td class="linecoldelete">';
373 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $skillElement->fk_object .
'&objecttype=' . $objecttype .
'&action=ask_deleteskill&lineid=' . $skillElement->id .
'">';
383 if ($objecttype !=
'user' && $permissiontoadd) print
'<td><input class="button pull-right" type="submit" value="' . $langs->trans(
'SaveRank') .
'"></td>';
385 if ($objecttype !=
'user' && $permissiontoadd) print
'</form>';