35require_once
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions.lib.php';
37require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
38require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skill.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/hrm/class/evaluation.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/hrm/class/position.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm.lib.php';
51$permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read;
55if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd))
accessforbidden();
62$css = array(
'/hrm/css/style.css');
64llxHeader(
'', $langs->trans(
'SkillComparison'),
'',
'', 0, 0,
'', $css);
69$head[$h][0] = $_SERVER[
"PHP_SELF"];
70$head[$h][1] = $langs->trans(
"SkillComparison");
71$head[$h][2] =
'compare';
76 <script
type=
"text/javascript">
78 $(document).ready(
function () {
80 $(
"li[fk_user]").click(
function () {
82 if ($(
this).hasClass(
'disabled')) {
83 $(
this).removeClass(
'disabled');
85 $(
this).addClass(
'disabled');
89 var $userl = $(
this).closest(
'ul');
90 var listname = $userl.attr(
'name');
94 $userl.find(
'li').each(
function (i, item) {
96 if ($(item).hasClass(
'disabled')) {
97 TId.push($(item).attr(
'fk_user'));
102 $(
'#' + listname +
'_excluded_id').val(TId.join(
','));
115$fk_job = (int)
GETPOST(
'fk_job');
116if ($fk_job <= 0) $fk_usergroup2 =
GETPOST(
'fk_usergroup2');
118$fk_usergroup1 =
GETPOST(
'fk_usergroup1');
123 <div
class=
"fichecenter">
124 <form action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
126 <div
class=
"tabBar tabBarWithBottom">
127 <div
class=
"fichehalfleft">
128 <table
class=
"border tableforfield" width=
"100%">
131 print $langs->trans(
'group1ToCompare').
'</td><td>';
132 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
133 print $form->select_dolgroups($fk_usergroup1,
'fk_usergroup1', 1);
136 <tr><td> </td></tr>
139 print $langs->trans(
'group2ToCompare').
'</td><td>';
140 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
141 print $form->select_dolgroups($fk_usergroup2,
'fk_usergroup2', 1);
145 <td><STRONG><?php print $langs->trans(
'or'); ?></STRONG></td>
149 echo $langs->trans(
'OrJobToCompare') .
'</td><td>';
151 $jobs = $j->fetchAll();
154 foreach ($jobs as &$j) {
155 $TJobs[$j->id] = $j->label;
158 print
img_picto(
'',
'jobprofile',
'class="pictofixedwidth"').$form->selectarray(
'fk_job', $TJobs, $fk_job, 1);
164 <div style=
"background:#eee;border-radius:5px 0;margin:0px 0 10px;font-style:italic;padding:5px;" class=
"fichehalfright">
165 <!--<h4><?php echo $langs->trans(
'legend'); ?></h4>-->
166 <table
class=
"border" width=
"100%">
168 <td><span style=
"vertical-align:middle" class=
"toohappy diffnote little"></span>
169 <?php echo $langs->trans(
'CompetenceAcquiredByOneOrMore'); ?></td>
172 <td><span style=
"vertical-align:middle" class=
"veryhappy diffnote little"></span>
173 <?php echo $langs->trans(
'MaxlevelGreaterThan'); ?></td>
176 <td><span style=
"vertical-align:middle" class=
"happy diffnote little"></span>
177 <?php echo $langs->trans(
'MaxLevelEqualTo'); ?></td>
180 <td><span style=
"vertical-align:middle" class=
"sad diffnote little"></span>
181 <?php echo $langs->trans(
'MaxLevelLowerThan'); ?></td>
184 <td><span style=
"vertical-align:middle" class=
"toosad diffnote little"></span>
185 <?php echo $langs->trans(
'SkillNotAcquired'); ?></td>
191 <div
class=
"clearboth"></div>
197 <input
class=
"button" type=
"SUBMIT" name=
"bt1" VALUE=
"<?php print $langs->trans('Refresh'); ?>">
201 <div
id=
"compare" width=
"100%" style=
"position:relative;">
203 <?php
if ($fk_usergroup1 > 0 || $fk_usergroup2 > 0 || $fk_job > 0) { ?>
207 <th><?php print $langs->trans(
'skill'); ?></th>
208 <th><?php print $langs->trans(
'rank'); ?></th>
209 <th><?php print $langs->trans(
'difference'); ?></th>
210 <th><?php print $langs->trans(
'rank'); ?></th>
215 echo
'<tr><td id="list-user-left" style="width:30%" valign="top">';
217 $TUser1 = $TUser2 = array();
219 $userlist1 = displayUsersListWithPicto($TUser1, $fk_usergroup1,
'list1');
222 $skill =
new Skill($db);
223 $TSkill1 = getSkillForUsers($TUser1);
226 $TSkill2 = getSkillForJob($fk_job);
229 $job->fetch($fk_job);
232 <h3>' . $job->label .
'</h3>
233 <p>' . $job->description .
'</p>
237 $userlist2 = displayUsersListWithPicto($TUser2, $fk_usergroup2,
'list2');
238 $TSkill2 = getSkillForUsers($TUser2);
241 $TMergedSkills = mergeSkills($TSkill1, $TSkill2);
247 echo
'<td id="" style="width:20%" valign="top">' . skillList($TMergedSkills) .
'</td>';
248 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate1') .
'</td>';
249 echo
'<td id="" style="width:10%" valign="top">' . diff($TMergedSkills) .
'</td>';
250 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate2') .
'</td>';
252 echo
'<td id="list-user-right" style="width:30%" valign="top">';
285function diff(&$TMergedSkills)
288 $out =
'<ul class="diff">';
290 foreach ($TMergedSkills as $id => &$sk) {
293 if (empty($sk->rate2)) $class .=
' toohappy';
294 elseif (empty($sk->rate1)) $class .= ' toosad';
295 elseif ($sk->rate1 == $sk->rate2) $class .= ' happy';
296 elseif ($sk->rate2 < $sk->rate1) $class .= ' veryhappy';
297 elseif ($sk->rate2 > $sk->rate1) $class .= ' sad';
299 $out .= '<li fk_skill="' . $id . '" class="' . $class . '" style="text-align:center;">
300 <span class="' . $class . '"> </span>
315function rate(&$TMergedSkills, $field)
317 global $langs, $fk_job;
319 $out =
'<ul class="competence">';
321 foreach ($TMergedSkills as $id => &$sk) {
324 if (empty($sk->$field)) {
329 $how_many = ($field ===
'rate1') ? $sk->how_many_max1 : $sk->how_many_max2;
332 if ($field ===
'rate2' && $fk_job > 0) $trad = $langs->trans(
'RequiredRank');
333 else $trad = $langs->trans(
'HighestRank');
335 $out .=
'<li fk_skill="' . $id .
'" style="text-align:center;">
336 <p><span class="' . $class .
' classfortooltip" title="' . $trad .
'">' . $note .
'</span>' . ($how_many > 0 ?
'<span class="bubble classfortooltip" title="' . $langs->trans(
'HowManyUserWithThisMaxNote') .
'">' . $how_many .
'</span>' :
'') .
'</p>
351function skillList(&$TMergedSkills)
354 $out =
'<ul class="competence">';
356 foreach ($TMergedSkills as $id => &$sk) {
357 $out .=
'<li fk_skill="' . $id .
'">
358 <h3>' . $sk->label .
'</h3>
359 <p>' . $sk->description .
'</p>
375function mergeSkills($TSkill1, $TSkill2)
380 foreach ($TSkill1 as &$sk) {
381 if (empty($Tab[$sk->fk_skill])) $Tab[$sk->fk_skill] =
new stdClass;
383 $Tab[$sk->fk_skill]->rate1 = $sk->rankorder;
384 $Tab[$sk->fk_skill]->how_many_max1 = $sk->how_many_max;
385 $Tab[$sk->fk_skill]->label = $sk->label;
386 $Tab[$sk->fk_skill]->description = $sk->description;
389 foreach ($TSkill2 as &$sk) {
390 if (empty($Tab[$sk->fk_skill])) $Tab[$sk->fk_skill] =
new stdClass;
391 $Tab[$sk->fk_skill]->rate2 = $sk->rankorder;
392 $Tab[$sk->fk_skill]->label = $sk->label;
393 $Tab[$sk->fk_skill]->description = $sk->description;
394 $Tab[$sk->fk_skill]->how_many_max2 = $sk->how_many_max;
408function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist =
'list-user')
410 global $db, $langs, $conf, $form;
413 if ($fk_usergroup > 0) {
414 $list = $namelist .
'_excluded_id';
416 $excludedIdsList =
GETPOST($list);
418 $sql =
"SELECT u.rowid FROM " . MAIN_DB_PREFIX .
"user u
419 LEFT JOIN " . MAIN_DB_PREFIX .
"usergroup_user as ugu ON (u.rowid = ugu.fk_user)
420 WHERE u.statut > 0 AND ugu.entity = ".((int) $conf->entity);
421 $sql .=
" AND ugu.fk_usergroup=" . ((int) $fk_usergroup);
423 $res = $db->query($sql);
424 $out .=
'<ul name="' . $namelist .
'">';
426 $TExcludedId = explode(
',', $excludedIdsList);
428 $out .=
'<input id="'.$list.
'" type="hidden" name="'.$list.
'" value="'.$excludedIdsList.
'"> ';
432 while ($obj = $db->fetch_object($res)) {
435 $user =
new User($db);
436 $user->fetch($obj->rowid);
438 $name = $user->getFullName($langs);
439 if (empty($name)) $name = $user->login;
441 if (in_array($user->id, $TExcludedId)) {
442 $class .=
' disabled';
444 if (!in_array($user->id, $TUser)) $TUser[] = $user->id;
449 $jobstring = $job->getLastJobForUser($user->id);
453 $evaluation = $static_eval->getLastEvaluationForUser($user->id);
455 if (!empty($evaluation) && !empty($evaluation->date_eval)) {
456 $desc .= $langs->trans(
'DateLastEval') .
' : ' .
dol_print_date($evaluation->date_eval);
458 $desc .= $langs->trans(
'NoEval');
461 if (!empty($user->array_options[
'options_DDA'])) $desc .=
'<br>' . $langs->trans(
'Anciennete') .
' : ' .
dol_print_date(strtotime($user->array_options[
'options_DDA']));
463 $out .=
'<li fk_user="' . $user->id .
'" class="' . $class .
'">
464 ' . $form->showphoto(
'userphoto', $user, 0, 0, 0,
'photoref',
'small', 1, 0, 1) .
'
465 <h3>' . $name .
'</h3>
484function getSkillForUsers($TUser)
489 if (empty($TUser))
return array();
491 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill, ';
492 $sql.=
' MAX(sr.rankorder) as rankorder';
493 $sql.=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill sk';
494 $sql.=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
495 $sql.=
" WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
496 $sql.=
' AND sr.fk_object IN ('.$db->sanitize(implode(
',', $TUser)).
')';
497 $sql.=
" GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill ";
499 $resql = $db->query($sql);
505 while ($obj = $db->fetch_object($resql) ) {
506 $sql1 =
"SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX.
"hrm_skillrank as sr";
507 $sql1.=
" WHERE sr.rankorder = ".((int) $obj->rankorder);
508 $sql1.=
" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
509 $sql1.=
" AND sr.fk_skill = ".((int) $obj->fk_skill);
510 $sql1.=
" AND sr.fk_object IN (".$db->sanitize(implode(
',', $TUser)).
")";
511 $resql1 = $db->query($sql1);
513 $objMax = $db->fetch_object($resql1);
515 $Tab[$num] =
new stdClass();
516 $Tab[$num]->fk_skill = $obj->fk_skill;
517 $Tab[$num]->label = $obj->label;
518 $Tab[$num]->description = $obj->description;
519 $Tab[$num]->skill_type = $obj->skill_type;
520 $Tab[$num]->fk_object = $obj->fk_object;
521 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_USER;
522 $Tab[$num]->rankorder = $obj->rankorder;
523 $Tab[$num]->how_many_max = $objMax->how_many_max;
540function getSkillForJob($fk_job)
544 if (empty($fk_job))
return array();
546 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
547 $sql.=
" MAX(sr.rankorder) as rankorder";
548 $sql.=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill as sk';
549 $sql.=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
550 $sql.=
" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB.
"'";
551 $sql.=
' AND sr.fk_object = '.((int) $fk_job);
552 $sql.=
' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill';
554 $resql = $db->query($sql);
559 while ($obj = $db->fetch_object($resql) ) {
560 $Tab[$num] =
new stdClass();
561 $Tab[$num]->fk_skill = $obj->fk_skill;
562 $Tab[$num]->label = $obj->label;
563 $Tab[$num]->description = $obj->description;
564 $Tab[$num]->skill_type = $obj->skill_type;
567 $Tab[$num]->fk_object = $obj->fk_object;
568 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_JOB;
569 $Tab[$num]->rankorder = $obj->rankorder;
570 $Tab[$num]->how_many_max = $obj->how_many_max;
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage Dolibarr users.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.