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;
54if (empty($conf->hrm->enabled)) {
57if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
66$css = array(
'/hrm/css/style.css');
68llxHeader(
'', $langs->trans(
'SkillComparison'),
'',
'', 0, 0,
'', $css);
73$head[$h][0] = $_SERVER[
"PHP_SELF"];
74$head[$h][1] = $langs->trans(
"SkillComparison");
75$head[$h][2] =
'compare';
80 <script
type=
"text/javascript">
82 $(document).ready(
function () {
84 $(
"li[fk_user]").click(
function () {
86 if ($(
this).hasClass(
'disabled')) {
87 $(
this).removeClass(
'disabled');
89 $(
this).addClass(
'disabled');
93 var $userl = $(
this).closest(
'ul');
94 var listname = $userl.attr(
'name');
98 $userl.find(
'li').each(
function (i, item) {
100 if ($(item).hasClass(
'disabled')) {
101 TId.push($(item).attr(
'fk_user'));
106 $(
'#' + listname +
'_excluded_id').val(TId.join(
','));
119$fk_job = (int)
GETPOST(
'fk_job');
121 $fk_usergroup2 =
GETPOST(
'fk_usergroup2');
124$fk_usergroup1 =
GETPOST(
'fk_usergroup1');
129 <div
class=
"fichecenter">
130 <form action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
132 <div
class=
"tabBar tabBarWithBottom">
133 <div
class=
"fichehalfleft">
134 <table
class=
"border tableforfield" width=
"100%">
137 print $langs->trans(
'group1ToCompare').
'</td><td>';
138 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
139 print $form->select_dolgroups($fk_usergroup1,
'fk_usergroup1', 1);
142 <tr><td> </td></tr>
145 print $langs->trans(
'group2ToCompare').
'</td><td>';
146 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
147 print $form->select_dolgroups($fk_usergroup2,
'fk_usergroup2', 1);
151 <td><STRONG><?php print $langs->trans(
'or'); ?></STRONG></td>
155 echo $langs->trans(
'OrJobToCompare') .
'</td><td>';
157 $jobs = $j->fetchAll();
160 foreach ($jobs as &$j) {
161 $TJobs[$j->id] = $j->label;
164 print
img_picto(
'',
'jobprofile',
'class="pictofixedwidth"').$form->selectarray(
'fk_job', $TJobs, $fk_job, 1);
170 <div style=
"background:#eee;border-radius:5px 0;margin:0px 0 10px;font-style:italic;padding:5px;" class=
"fichehalfright">
171 <!--<h4><?php echo $langs->trans(
'legend'); ?></h4>-->
172 <table
class=
"border" width=
"100%">
174 <td><span style=
"vertical-align:middle" class=
"toohappy diffnote little"></span>
175 <?php echo $langs->trans(
'CompetenceAcquiredByOneOrMore'); ?></td>
178 <td><span style=
"vertical-align:middle" class=
"veryhappy diffnote little"></span>
179 <?php echo $langs->trans(
'MaxlevelGreaterThan'); ?></td>
182 <td><span style=
"vertical-align:middle" class=
"happy diffnote little"></span>
183 <?php echo $langs->trans(
'MaxLevelEqualTo'); ?></td>
186 <td><span style=
"vertical-align:middle" class=
"sad diffnote little"></span>
187 <?php echo $langs->trans(
'MaxLevelLowerThan'); ?></td>
190 <td><span style=
"vertical-align:middle" class=
"toosad diffnote little"></span>
191 <?php echo $langs->trans(
'SkillNotAcquired'); ?></td>
197 <div
class=
"clearboth"></div>
203 <input
class=
"button" type=
"SUBMIT" name=
"bt1" VALUE=
"<?php print $langs->trans('Refresh'); ?>">
207 <div
id=
"compare" width=
"100%" style=
"position:relative;">
209 <?php
if ($fk_usergroup1 > 0 || $fk_usergroup2 > 0 || $fk_job > 0) { ?>
213 <th><?php print $langs->trans(
'skill'); ?></th>
214 <th><?php print $langs->trans(
'rank'); ?></th>
215 <th><?php print $langs->trans(
'difference'); ?></th>
216 <th><?php print $langs->trans(
'rank'); ?></th>
221 echo
'<tr><td id="list-user-left" style="width:30%" valign="top">';
223 $TUser1 = $TUser2 = array();
225 $userlist1 = displayUsersListWithPicto($TUser1, $fk_usergroup1,
'list1');
228 $skill =
new Skill($db);
229 $TSkill1 = getSkillForUsers($TUser1);
232 $TSkill2 = getSkillForJob($fk_job);
235 $job->fetch($fk_job);
238 <h3>' . $job->label .
'</h3>
239 <p>' . $job->description .
'</p>
243 $userlist2 = displayUsersListWithPicto($TUser2, $fk_usergroup2,
'list2');
244 $TSkill2 = getSkillForUsers($TUser2);
247 $TMergedSkills = mergeSkills($TSkill1, $TSkill2);
253 echo
'<td id="" style="width:20%" valign="top">' . skillList($TMergedSkills) .
'</td>';
254 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate1') .
'</td>';
255 echo
'<td id="" style="width:10%" valign="top">' . diff($TMergedSkills) .
'</td>';
256 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate2') .
'</td>';
258 echo
'<td id="list-user-right" style="width:30%" valign="top">';
291function diff(&$TMergedSkills)
293 $out =
'<ul class="diff">';
295 foreach ($TMergedSkills as $id => &$sk) {
298 if (empty($sk->rate2)) {
299 $class .=
' toohappy';
300 } elseif (empty($sk->rate1)) {
302 } elseif ($sk->rate1 == $sk->rate2) {
304 } elseif ($sk->rate2 < $sk->rate1) {
305 $class .=
' veryhappy';
306 } elseif ($sk->rate2 > $sk->rate1) {
310 $out .=
'<li fk_skill="' . $id .
'" class="' . $class .
'" style="text-align:center;">
311 <span class="' . $class .
'"> </span>
326function rate(&$TMergedSkills, $field)
328 global $langs, $fk_job;
330 $out =
'<ul class="competence">';
332 foreach ($TMergedSkills as $id => &$sk) {
335 if (empty($sk->$field)) {
340 $how_many = ($field ===
'rate1') ? $sk->how_many_max1 : $sk->how_many_max2;
343 if ($field ===
'rate2' && $fk_job > 0) {
344 $trad = $langs->trans(
'RequiredRank');
346 $trad = $langs->trans(
'HighestRank');
349 $out .=
'<li fk_skill="' . $id .
'" style="text-align:center;">
350 <p><span class="' . $class .
' classfortooltip" title="' . $trad .
'">' . $note .
'</span>' . ($how_many > 0 ?
'<span class="bubble classfortooltip" title="' . $langs->trans(
'HowManyUserWithThisMaxNote') .
'">' . $how_many .
'</span>' :
'') .
'</p>
365function skillList(&$TMergedSkills)
367 $out =
'<ul class="competence">';
369 foreach ($TMergedSkills as $id => &$sk) {
370 $out .=
'<li fk_skill="' . $id .
'">
371 <h3>' . $sk->label .
'</h3>
372 <p>' . $sk->description .
'</p>
388function mergeSkills($TSkill1, $TSkill2)
392 foreach ($TSkill1 as &$sk) {
393 if (empty($Tab[$sk->fk_skill])) {
394 $Tab[$sk->fk_skill] =
new stdClass();
397 $Tab[$sk->fk_skill]->rate1 = $sk->rankorder;
398 $Tab[$sk->fk_skill]->how_many_max1 = $sk->how_many_max;
399 $Tab[$sk->fk_skill]->label = $sk->label;
400 $Tab[$sk->fk_skill]->description = $sk->description;
403 foreach ($TSkill2 as &$sk) {
404 if (empty($Tab[$sk->fk_skill])) {
405 $Tab[$sk->fk_skill] =
new stdClass();
407 $Tab[$sk->fk_skill]->rate2 = $sk->rankorder;
408 $Tab[$sk->fk_skill]->label = $sk->label;
409 $Tab[$sk->fk_skill]->description = $sk->description;
410 $Tab[$sk->fk_skill]->how_many_max2 = $sk->how_many_max;
424function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist =
'list-user')
426 global $db, $langs, $conf, $form;
429 if ($fk_usergroup > 0) {
430 $list = $namelist .
'_excluded_id';
432 $excludedIdsList =
GETPOST($list);
434 $sql =
"SELECT u.rowid FROM " . MAIN_DB_PREFIX .
"user u
435 LEFT JOIN " . MAIN_DB_PREFIX .
"usergroup_user as ugu ON (u.rowid = ugu.fk_user)
436 WHERE u.statut > 0 AND ugu.entity = ".((int) $conf->entity);
437 $sql .=
" AND ugu.fk_usergroup=" . ((int) $fk_usergroup);
439 $res = $db->query($sql);
440 $out .=
'<ul name="' . $namelist .
'">';
442 $TExcludedId = explode(
',', $excludedIdsList);
444 $out .=
'<input id="'.$list.
'" type="hidden" name="'.$list.
'" value="'.$excludedIdsList.
'"> ';
448 while ($obj = $db->fetch_object($res)) {
451 $user =
new User($db);
452 $user->fetch($obj->rowid);
454 $name = $user->getFullName($langs);
456 $name = $user->login;
459 if (in_array($user->id, $TExcludedId)) {
460 $class .=
' disabled';
462 if (!in_array($user->id, $TUser)) {
463 $TUser[] = $user->id;
469 $jobstring = $job->getLastJobForUser($user->id);
473 $evaluation = $static_eval->getLastEvaluationForUser($user->id);
475 if (!empty($evaluation) && !empty($evaluation->date_eval)) {
476 $desc .= $langs->trans(
'DateLastEval') .
' : ' .
dol_print_date($evaluation->date_eval);
478 $desc .= $langs->trans(
'NoEval');
481 if (!empty($user->array_options[
'options_DDA'])) {
482 $desc .=
'<br>' . $langs->trans(
'Anciennete') .
' : ' .
dol_print_date(strtotime($user->array_options[
'options_DDA']));
485 $out .=
'<li fk_user="' . $user->id .
'" class="' . $class .
'">
486 ' . $form->showphoto(
'userphoto', $user, 0, 0, 0,
'photoref',
'small', 1, 0, 1) .
'
487 <h3>' . $name .
'</h3>
506function getSkillForUsers($TUser)
515 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill, ';
516 $sql.=
' MAX(sr.rankorder) as rankorder';
517 $sql.=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill sk';
518 $sql.=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
519 $sql.=
" WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
520 $sql.=
' AND sr.fk_object IN ('.$db->sanitize(implode(
',', $TUser)).
')';
521 $sql.=
" GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill ";
523 $resql = $db->query($sql);
529 while ($obj = $db->fetch_object($resql)) {
530 $sql1 =
"SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX.
"hrm_skillrank as sr";
531 $sql1.=
" WHERE sr.rankorder = ".((int) $obj->rankorder);
532 $sql1.=
" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
533 $sql1.=
" AND sr.fk_skill = ".((int) $obj->fk_skill);
534 $sql1.=
" AND sr.fk_object IN (".$db->sanitize(implode(
',', $TUser)).
")";
535 $resql1 = $db->query($sql1);
537 $objMax = $db->fetch_object($resql1);
540 $Tab[$num]->fk_skill = $obj->fk_skill;
541 $Tab[$num]->label = $obj->label;
542 $Tab[$num]->description = $obj->description;
543 $Tab[$num]->skill_type = $obj->skill_type;
544 $Tab[$num]->fk_object = $obj->fk_object;
545 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_USER;
546 $Tab[$num]->rankorder = $obj->rankorder;
547 $Tab[$num]->how_many_max = $objMax->how_many_max;
564function getSkillForJob($fk_job)
568 if (empty($fk_job)) {
572 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
573 $sql.=
" MAX(sr.rankorder) as rankorder";
574 $sql.=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill as sk';
575 $sql.=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
576 $sql.=
" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB.
"'";
577 $sql.=
' AND sr.fk_object = '.((int) $fk_job);
578 $sql.=
' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill';
580 $resql = $db->query($sql);
585 while ($obj = $db->fetch_object($resql)) {
587 $Tab[$num]->fk_skill = $obj->fk_skill;
588 $Tab[$num]->label = $obj->label;
589 $Tab[$num]->description = $obj->description;
590 $Tab[$num]->skill_type = $obj->skill_type;
593 $Tab[$num]->fk_object = $obj->fk_object;
594 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_JOB;
595 $Tab[$num]->rankorder = $obj->rankorder;
596 $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.