30 require 
'../main.inc.php';
 
   32 require_once DOL_DOCUMENT_ROOT . 
'/core/class/html.formcompany.class.php';
 
   33 require_once DOL_DOCUMENT_ROOT . 
'/core/class/html.formfile.class.php';
 
   34 require_once DOL_DOCUMENT_ROOT . 
'/core/class/html.formprojet.class.php';
 
   35 require_once DOL_DOCUMENT_ROOT . 
'/user/class/user.class.php';
 
   36 require_once DOL_DOCUMENT_ROOT . 
'/hrm/class/skill.class.php';
 
   37 require_once DOL_DOCUMENT_ROOT . 
'/hrm/class/skillrank.class.php';
 
   38 require_once DOL_DOCUMENT_ROOT . 
'/hrm/lib/hrm_skill.lib.php';
 
   41 $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);
 
   71 $hookmanager->initHooks(array(
'skilltab', 
'globalcard')); 
 
   74 include DOL_DOCUMENT_ROOT . 
'/core/actions_fetchobject.inc.php'; 
 
   77 $permissiontoread = $user->hasRight(
'hrm', 
'all', 
'read');
 
   78 $permissiontoadd  = $user->hasRight(
'hrm', 
'all', 
'write'); 
 
   90 $parameters = array();
 
   91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
   96 if (empty($reshook)) {
 
   99   $backurlforlist = DOL_URL_ROOT.
'/hrm/skill_list.php';
 
  101   if (empty($backtopage) || ($cancel && empty($id))) {
 
  102     if (empty($backtopage) || ($cancel && strpos($backtopage, 
'__ID__'))) {
 
  103       if (empty($id) && (($action != 
'add' && $action != 
'create') || $cancel)) {
 
  104         $backtopage = $backurlforlist;
 
  106         $backtopage = DOL_URL_ROOT.
'/hrm/skill_list.php?id=' . ($id > 0 ? $id : 
'__ID__');
 
  111   if ($action == 
'addSkill') {
 
  114     if (empty($TSkillsToAdd)) {
 
  120       foreach ($TSkillsToAdd as $k=>$v) {
 
  122         $skillAdded->fk_skill = $v;
 
  123         $skillAdded->fk_object = $id;
 
  124         $skillAdded->objecttype = $objecttype;
 
  125         $ret = $skillAdded->create($user);
 
  131   } elseif ($action == 
'saveSkill') {
 
  132     if (!empty($TNote)) {
 
  133       foreach ($TNote as $skillId => $rank) {
 
  134         $TSkills = $skill->fetchAll(
'ASC', 
't.rowid', 0, 0, array(
'customsql' => 
'fk_object=' . ((
int) $id) . 
" AND objecttype='" . $db->escape($objecttype) . 
"' AND fk_skill = " . ((
int) $skillId)));
 
  135         if (is_array($TSkills) && !empty($TSkills)) {
 
  136           foreach ($TSkills as $tmpObj) {
 
  137             $tmpObj->rankorder = $rank;
 
  138             $tmpObj->update($user);
 
  143       header(
"Location: " . DOL_URL_ROOT.
'/hrm/skill_tab.php?id=' . $id. 
'&objecttype=job');
 
  146   } elseif ($action == 
'confirm_deleteskill' && $confirm == 
'yes') {
 
  148     $ret = $skillToDelete->fetch($lineid);
 
  151       $skillToDelete->delete($user);
 
  164 $title = $langs->trans(
"RequiredSkills");
 
  169 if ($object->id > 0 && (empty($action) || ($action != 
'edit' && $action != 
'create'))) {
 
  170   $res = $object->fetch_optionals();
 
  173   if ($objecttype == 
'job') {
 
  174     require_once DOL_DOCUMENT_ROOT . 
'/hrm/lib/hrm_job.lib.php';
 
  177   } elseif ($objecttype == 
"user") {
 
  178     require_once DOL_DOCUMENT_ROOT . 
"/core/lib/usergroups.lib.php";
 
  179     $object->getRights();
 
  184   print 
dol_get_fiche_head($head, 
'skill_tab', $langs->trans(
"Workstation"), -1, $object->picto);
 
  193   if ($action == 
'ask_deleteskill') {
 
  194     $formconfirm = 
$form->formconfirm($_SERVER[
"PHP_SELF"] . 
'?id=' . $object->id . 
'&objecttype=' . $objecttype . 
'&lineid=' . $lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'), 
'confirm_deleteskill', 
'', 0, 1);
 
  204   $parameters = array(
'formConfirm' => 
$formconfirm, 
'lineid' => $lineid);
 
  205   $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action); 
 
  206   if (empty($reshook)) {
 
  208   } elseif ($reshook > 0) {
 
  218   $linkback = 
'<a href="' . $listLink . 
'?restore_lastsearch_values=1' . (!empty($socid) ? 
'&socid=' . $socid : 
'') . 
'">' . $langs->trans(
"BackToList") . 
'</a>';
 
  220   $morehtmlref = 
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'" class="refid">';
 
  221   $morehtmlref .= 
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"), 
'vcard.png', 
'class="valignmiddle marginleftonly paddingrightonly"');
 
  222   $morehtmlref .= 
'</a>';
 
  224   dol_banner_tab($object, 
'id', $linkback, 1, 
'rowid', 
'rowid', $morehtmlref, 
'&objecttype='.$objecttype);
 
  228   $static_skill = 
new Skill($db);
 
  229   $TAllSkills = $static_skill->fetchAll();
 
  232   $TAllSkillsFormatted=array();
 
  233   if (!empty($TAllSkills)) {
 
  234     foreach ($TAllSkills as $k=>$v) {
 
  235       $TAllSkillsFormatted[$k] = $v->label;
 
  240   $TSkillsJob = $skill->fetchAll(
'ASC', 
't.rowid', 0, 0, array(
'customsql' => 
'fk_object=' . ((
int) $id) . 
" AND objecttype='" . $db->escape($objecttype) . 
"'"));
 
  242   $TAlreadyUsedSkill = array();
 
  243   if (is_array($TSkillsJob) && !empty($TSkillsJob)) {
 
  244     foreach ($TSkillsJob as $skillElement) {
 
  245       $TAlreadyUsedSkill[$skillElement->fk_skill] = $skillElement->fk_skill;
 
  249   print 
'<div class="fichecenter">';
 
  250   print 
'<div class="fichehalfleft">';
 
  252   print 
'<div class="underbanner clearboth"></div>';
 
  253   print 
'<table class="border centpercent tableforfield">';
 
  256   print 
'<tr><td class="titlefield">'.$langs->trans(
"Login").
'</td>';
 
  257   if (!empty($object->ldap_sid) && $object->statut == 0) {
 
  258     print 
'<td class="error">';
 
  259     print $langs->trans(
"LoginAccountDisableInDolibarr");
 
  264     if (property_exists($object, 
'admin')) {
 
  265       if (
isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
 
  266         $addadmin .= 
img_picto($langs->trans(
"SuperAdministratorDesc"), 
"redstar", 
'class="paddingleft"');
 
  267       } elseif (!empty($object->admin)) {
 
  268         $addadmin .= 
img_picto($langs->trans(
"AdministratorDesc"), 
"star", 
'class="paddingleft"');
 
  276   $object->fields[
'label'][
'visible']=0; 
 
  277   $object->fields[
'firstname'][
'visible']=0; 
 
  278   $object->fields[
'lastname'][
'visible']=0; 
 
  282   print 
'<tr><td class="titlefield">'.$langs->trans(
"RefEmployee").
'</td>';
 
  283   print 
'<td class="error">';
 
  289   print 
'<tr><td class="titlefield">'.$langs->trans(
"NationalRegistrationNumber").
'</td>';
 
  290   print 
'<td class="error">';
 
  313   print 
'<div class="clearboth"></div><br>';
 
  315   if ($objecttype != 
'user' && $permissiontoadd) {
 
  317     print 
'<form name="addSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] . 
'">';
 
  318     print 
'<input type="hidden" name="objecttype" value="' . $objecttype . 
'">';
 
  319     print 
'<input type="hidden" name="id" value="' . $id . 
'">';
 
  320     print 
'<input type="hidden" name="action" value="addSkill">';
 
  321     print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  322     print 
'<div class="div-table-responsive-no-min">';
 
  323     print 
'<table id="tablelines" class="noborder noshadow" width="100%">';
 
  324     print 
'<tr><td style="width:90%">' . $langs->trans(
'AddSkill') . 
'</td><td style="width:10%"></td></tr>';
 
  326     print 
'<td>' . 
$form->multiselectarray(
'fk_skill', array_diff_key($TAllSkillsFormatted, $TAlreadyUsedSkill), array(), 0, 0, 
'', 0, 
'100%') . 
'</td>';
 
  327     print 
'<td><input class="button reposition" type="submit" value="' . $langs->trans(
'Add') . 
'"></td>';
 
  335   print 
'<div class="clearboth"></div>';
 
  337   if ($objecttype != 
'user' && $permissiontoadd) {
 
  338     print 
'<form name="saveSkill" method="post" action="' . $_SERVER[
'PHP_SELF'] . 
'">';
 
  339     print 
'<input type="hidden" name="objecttype" value="' . $objecttype . 
'">';
 
  340     print 
'<input type="hidden" name="id" value="' . $id . 
'">';
 
  341     print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  342     print 
'<input type="hidden" name="action" value="saveSkill">';
 
  344   print 
'<div class="div-table-responsive-no-min">';
 
  345   print 
'<table id="tablelines" class="noborder centpercent" width="100%">';
 
  346   print 
'<tr class="liste_titre">';
 
  347   print 
'<th>'.$langs->trans(
'SkillType').
'</th>';
 
  348   print 
'<th>'.$langs->trans(
'Label').
'</th>';
 
  349   print 
'<th>'.$langs->trans(
'Description').
'</th>';
 
  350   print 
'<th>'.$langs->trans($objecttype === 
'job' ? 
'RequiredRank' : 
'EmployeeRank').
'</th>';
 
  351   if ($objecttype === 
'job') {
 
  352     print 
'<th class="linecoledit"></th>';
 
  353     print 
'<th class="linecoldelete"></th>';
 
  356   if (!is_array($TSkillsJob) || empty($TSkillsJob)) {
 
  357     print 
'<tr><td><span class="opacitymedium">' . $langs->trans(
"NoRecordFound") . 
'</span></td></tr>';
 
  359     $sk = 
new Skill($db);
 
  360     foreach ($TSkillsJob as $skillElement) {
 
  361       $sk->fetch($skillElement->fk_skill);
 
  365       print 
'</td><td class="linecolfk_skill">';
 
  366       print $sk->getNomUrl(1);
 
  369       print $sk->description;
 
  370       print 
'</td><td class="linecolrank">';
 
  371       print 
displayRankInfos($skillElement->rankorder, $skillElement->fk_skill, 
'TNote', $objecttype == 
'job' && $permissiontoadd ? 
'edit' : 
'view');
 
  373       if ($objecttype != 
'user' && $permissiontoadd) {
 
  374         print 
'<td class="linecoledit"></td>';
 
  375         print 
'<td class="linecoldelete">';
 
  376         print 
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] . 
'?id=' . $skillElement->fk_object . 
'&objecttype=' . $objecttype . 
'&action=ask_deleteskill&lineid=' . $skillElement->id . 
'">';
 
  386   if ($objecttype != 
'user' && $permissiontoadd) print 
'<td><input class="button pull-right" type="submit" value="' . $langs->trans(
'SaveRank') . 
'"></td>';
 
  388   if ($objecttype != 
'user' && $permissiontoadd) print 
'</form>';
 
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
 
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.
 
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
 
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='')
Show tabs of a record.
 
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_end($notab=0)
Return tab footer of a card.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
 
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
 
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
 
isModEnabled($module)
Is Dolibarr module enabled.
 
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.
 
$formconfirm
if ($action == 'delbookkeepingyear') {
 
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.