30require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
35require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
36require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skill.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skillrank.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm_skill.lib.php';
42$langs->loadLangs(array(
'hrm',
'other'));
45$action =
GETPOST(
'action',
'aZ09');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$cancel =
GETPOST(
'cancel',
'aZ09');
48$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'skillcard';
49$backtopage =
GETPOST(
'backtopage',
'alpha');
50$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
53$TSkillsToAdd =
GETPOST(
'fk_skill',
'array');
54$objecttype =
GETPOST(
'objecttype',
'alpha');
55$TNote =
GETPOST(
'TNote',
'array');
56$lineid =
GETPOST(
'lineid',
'int');
58if (empty($objecttype)) {
62$TAuthorizedObjects = array(
'job',
'user');
66if (in_array($objecttype, $TAuthorizedObjects)) {
67 if ($objecttype ==
'job') {
68 $object =
new Job($db);
69 } elseif ($objecttype ==
"user") {
70 $object =
new User($db);
76$hookmanager->initHooks(array(
'skilltab',
'globalcard'));
79include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
82$permissiontoread = $user->hasRight(
'hrm',
'all',
'read');
83$permissiontoadd = $user->hasRight(
'hrm',
'all',
'write');
96$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101if (empty($reshook)) {
104 $backurlforlist = DOL_URL_ROOT.
'/hrm/skill_list.php';
106 if (empty($backtopage) || ($cancel && empty($id))) {
107 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
108 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
109 $backtopage = $backurlforlist;
111 $backtopage = DOL_URL_ROOT.
'/hrm/skill_list.php?id=' . ($id > 0 ? $id :
'__ID__');
116 if ($action ==
'addSkill') {
119 if (empty($TSkillsToAdd)) {
125 foreach ($TSkillsToAdd as $k=>$v) {
127 $skillAdded->fk_skill = $v;
128 $skillAdded->fk_object = $id;
129 $skillAdded->objecttype = $objecttype;
130 $ret = $skillAdded->create($user);
136 } elseif ($action ==
'saveSkill') {
137 if (!empty($TNote)) {
138 foreach ($TNote as $skillId => $rank) {
139 $TSkills = $skill->fetchAll(
'ASC',
't.rowid', 0, 0, array(
'customsql' =>
'fk_object=' . ((
int) $id) .
" AND objecttype='" . $db->escape($objecttype) .
"' AND fk_skill = " . ((
int) $skillId)));
140 if (is_array($TSkills) && !empty($TSkills)) {
141 foreach ($TSkills as $tmpObj) {
142 $tmpObj->rankorder = $rank;
143 $tmpObj->update($user);
148 header(
"Location: " . DOL_URL_ROOT.
'/hrm/skill_tab.php?id=' . $id.
'&objecttype=job');
151 } elseif ($action ==
'confirm_deleteskill' && $confirm ==
'yes') {
153 $ret = $skillToDelete->fetch($lineid);
156 $skillToDelete->delete($user);
165$form =
new Form($db);
169$title = $langs->trans(
"RequiredSkills");
174if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
175 $res = $object->fetch_optionals();
178 if ($objecttype ==
'job') {
179 require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm_job.lib.php';
182 } elseif ($objecttype ==
"user") {
183 require_once DOL_DOCUMENT_ROOT .
"/core/lib/usergroups.lib.php";
184 $object->getRights();
189 print
dol_get_fiche_head($head,
'skill_tab', $langs->trans(
"Workstation"), -1, $object->picto);
198 if ($action ==
'ask_deleteskill') {
199 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&objecttype=' . $objecttype .
'&lineid=' . $lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteskill',
'', 0, 1);
209 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
210 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
211 if (empty($reshook)) {
212 $formconfirm .= $hookmanager->resPrint;
213 } elseif ($reshook > 0) {
214 $formconfirm = $hookmanager->resPrint;
223 if ($objecttype ==
'job') {
224 $linkback =
'<a href="' .
dol_buildpath(
'/hrm/job_list.php', 1) .
'?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
226 $morehtmlref =
'<div class="refid">';
227 $morehtmlref.= $object->label;
228 $morehtmlref .=
'</div>';
230 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
232 $linkback =
'<a href="' . $listLink .
'?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
234 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'&output=file&file='.urlencode(
dol_sanitizeFileName($object->getFullName($langs).
'.vcf')).
'" class="refid" rel="noopener">';
235 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
236 $morehtmlref .=
'</a>';
238 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $object->id);
239 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->trans(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
241 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref,
'&objecttype='.$objecttype);
245 $static_skill =
new Skill($db);
246 $TAllSkills = $static_skill->fetchAll();
249 $TAllSkillsFormatted=array();
250 if (!empty($TAllSkills)) {
251 foreach ($TAllSkills as $k=>$v) {
252 $TAllSkillsFormatted[$k] = $v->label;
257 $TSkillsJob = $skill->fetchAll(
'ASC',
't.rowid', 0, 0, array(
'customsql' =>
'fk_object=' . ((
int) $id) .
" AND objecttype='" . $db->escape($objecttype) .
"'"));
259 $TAlreadyUsedSkill = array();
260 if (is_array($TSkillsJob) && !empty($TSkillsJob)) {
261 foreach ($TSkillsJob as $skillElement) {
262 $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill;
266 print
'<div class="fichecenter">';
267 print
'<div class="fichehalfleft">';
269 print
'<div class="underbanner clearboth"></div>';
270 print
'<table class="border centpercent tableforfield">'.
"\n";
272 if ($objecttype ==
'job') {
277 $object->fields[
'label'][
'visible']=0;
278 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_view.tpl.php';
281 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
284 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
285 if (!empty($object->ldap_sid) && $object->statut == 0) {
286 print
'<td class="error">';
287 print $langs->trans(
"LoginAccountDisableInDolibarr");
292 if (property_exists($object,
'admin')) {
293 if (isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
294 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
295 } elseif (!empty($object->admin)) {
296 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
304 $object->fields[
'label'][
'visible']=0;
305 $object->fields[
'firstname'][
'visible']=0;
306 $object->fields[
'lastname'][
'visible']=0;
310 print
'<tr><td class="titlefield">'.$langs->trans(
"RefEmployee").
'</td>';
311 print
'<td class="error">';
317 print
'<tr><td class="titlefield">'.$langs->trans(
"NationalRegistrationNumber").
'</td>';
318 print
'<td class="error">';
330 print
'<div class="clearboth"></div><br>';
332 if ($objecttype !=
'user' && $permissiontoadd) {
334 print
'<form name="addSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] .
'">';
335 print
'<input type="hidden" name="objecttype" value="' . $objecttype .
'">';
336 print
'<input type="hidden" name="id" value="' . $id .
'">';
337 print
'<input type="hidden" name="action" value="addSkill">';
338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
339 print
'<div class="div-table-responsive-no-min">';
340 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
341 print
'<tr><td style="width:90%">' . $langs->trans(
'AddSkill') .
'</td><td style="width:10%"></td></tr>';
344 print
img_picto(
'',
'shapes',
'class="pictofixedwidth"');
345 print $form->multiselectarray(
'fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0,
'widthcentpercentminusx') .
'</td>';
346 print
'<td><input class="button reposition" type="submit" value="' . $langs->trans(
'Add') .
'"></td>';
354 print
'<div class="clearboth"></div>';
356 if ($objecttype !=
'user' && $permissiontoadd) {
357 print
'<form name="saveSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] .
'">';
358 print
'<input type="hidden" name="objecttype" value="' . $objecttype .
'">';
359 print
'<input type="hidden" name="id" value="' . $id .
'">';
360 print
'<input type="hidden" name="token" value="'.newToken().
'">';
361 print
'<input type="hidden" name="action" value="saveSkill">';
363 print
'<div class="div-table-responsive-no-min">';
364 print
'<table id="tablelines" class="noborder centpercent" width="100%">';
365 print
'<tr class="liste_titre">';
366 print
'<th>'.$langs->trans(
'SkillType').
'</th>';
367 print
'<th>'.$langs->trans(
'Label').
'</th>';
368 print
'<th>'.$langs->trans(
'Description').
'</th>';
369 print
'<th>'.$langs->trans($objecttype ===
'job' ?
'RequiredRank' :
'EmployeeRank').
'</th>';
370 if ($objecttype ===
'job') {
371 print
'<th class="linecoledit"></th>';
372 print
'<th class="linecoldelete"></th>';
375 if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
376 print
'<tr><td><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") .
'</span></td></tr>';
378 $sk =
new Skill($db);
379 foreach ($TSkillsJob as $skillElement) {
380 $sk->fetch($skillElement->fk_skill);
384 print
'</td><td class="linecolfk_skill">';
385 print $sk->getNomUrl(1);
388 print $sk->description;
389 print
'</td><td class="linecolrank">';
390 print
displayRankInfos($skillElement->rankorder, $skillElement->fk_skill,
'TNote', $objecttype ==
'job' && $permissiontoadd ?
'edit' :
'view');
392 if ($objecttype !=
'user' && $permissiontoadd) {
393 print
'<td class="linecoledit"></td>';
394 print
'<td class="linecoldelete">';
395 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $skillElement->fk_object .
'&objecttype=' . $objecttype .
'&action=ask_deleteskill&lineid=' . $skillElement->id .
'">';
405 if ($objecttype !=
'user' && $permissiontoadd) print
'<td><input class="button pull-right" type="submit" value="' . $langs->trans(
'SaveRank') .
'"></td>';
407 if ($objecttype !=
'user' && $permissiontoadd) print
'</form>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static typeCodeToLabel($code)
Class to manage Dolibarr users.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
jobPrepareHead($object)
Prepare array of tabs for Job.
displayRankInfos($selected_rank, $fk_skill, $inputname='TNote', $mode='view')
Used to print ranks of a skill into several case, view or edit pour js necessary to select a rank.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.