38require_once
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions.lib.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
41require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skill.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/hrm/class/evaluation.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/hrm/class/position.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm.lib.php';
63$permissiontoread = $user->hasRight(
'hrm',
'evaluation',
'read') || $user->hasRight(
'hrm',
'compare_advance',
'read');
66if (empty(
$conf->hrm->enabled)) {
69if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
78$css = array(
'/hrm/css/style.css');
80llxHeader(
'', $langs->trans(
'SkillComparison'),
'',
'', 0, 0,
'', $css);
85$head[$h][0] = $_SERVER[
"PHP_SELF"];
86$head[$h][1] = $langs->trans(
"SkillComparison");
87$head[$h][2] =
'compare';
92 <script
type=
"text/javascript">
94 $(document).ready(
function () {
96 $(
"li[fk_user]").click(
function () {
98 if ($(
this).hasClass(
'disabled')) {
99 $(
this).removeClass(
'disabled');
101 $(
this).addClass(
'disabled');
105 var $userl = $(
this).closest(
'ul');
106 var listname = $userl.attr(
'name');
110 $userl.find(
'li').each(
function (i, item) {
112 if ($(item).hasClass(
'disabled')) {
113 TId.push($(item).attr(
'fk_user'));
118 $(
'#' + listname +
'_excluded_id').val(TId.join(
','));
131$fk_job = (int)
GETPOST(
'fk_job');
141 <div
class=
"fichecenter">
142 <form action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
144 <div
class=
"tabBar tabBarWithBottom">
145 <div
class=
"fichehalfleft">
146 <
table class=
"border tableforfield" width=
"100%">
149 print $langs->trans(
'group1ToCompare').
'</td><td>';
150 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
151 print $form->select_dolgroups($fk_usergroup1,
'fk_usergroup1', 1);
154 <tr><td> </td></tr>
157 print $langs->trans(
'group2ToCompare').
'</td><td>';
158 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
159 print $form->select_dolgroups($fk_usergroup2,
'fk_usergroup2', 1);
163 <td><STRONG><?php print $langs->trans(
'or'); ?></STRONG></td>
167 echo $langs->trans(
'OrJobToCompare') .
'</td><td>';
169 $jobs = $j->fetchAll();
172 foreach ($jobs as &$j) {
173 $TJobs[$j->id] = $j->label;
176 print
img_picto(
'',
'jobprofile',
'class="pictofixedwidth"').$form->selectarray(
'fk_job', $TJobs, $fk_job, 1);
182 <div style=
"background:#eee;border-radius:5px 0;margin:0px 0 10px;font-style:italic;padding:5px;" class=
"fichehalfright">
183 <!--<h4><?php echo $langs->trans(
'legend'); ?></h4>-->
184 <
table class=
"border" width=
"100%">
186 <td><span style=
"vertical-align:middle" class=
"toohappy diffnote little"></span>
187 <?php echo $langs->trans(
'CompetenceAcquiredByOneOrMore'); ?></td>
190 <td><span style=
"vertical-align:middle" class=
"veryhappy diffnote little"></span>
191 <?php echo $langs->trans(
'MaxlevelGreaterThan'); ?></td>
194 <td><span style=
"vertical-align:middle" class=
"happy diffnote little"></span>
195 <?php echo $langs->trans(
'MaxLevelEqualTo'); ?></td>
198 <td><span style=
"vertical-align:middle" class=
"sad diffnote little"></span>
199 <?php echo $langs->trans(
'MaxLevelLowerThan'); ?></td>
202 <td><span style=
"vertical-align:middle" class=
"toosad diffnote little"></span>
203 <?php echo $langs->trans(
'SkillNotAcquired'); ?></td>
209 <div
class=
"clearboth"></div>
215 <input
class=
"button" type=
"SUBMIT" name=
"bt1" VALUE=
"<?php print $langs->trans('Refresh'); ?>">
219 <div
id=
"compare" width=
"100%" style=
"position:relative;">
221 <?php
if ($fk_usergroup1 > 0 || $fk_usergroup2 > 0 || $fk_job > 0) { ?>
225 <th><?php print $langs->trans(
'skill'); ?></th>
226 <th><?php print $langs->trans(
'rank'); ?></th>
227 <th><?php print $langs->trans(
'difference'); ?></th>
228 <th><?php print $langs->trans(
'rank'); ?></th>
233 echo
'<tr><td id="list-user-left" style="width:30%" valign="top">';
235 $TUser1 = $TUser2 = array();
237 $userlist1 = displayUsersListWithPicto($TUser1, $fk_usergroup1,
'list1');
240 $skill =
new Skill($db);
241 $TSkill1 = getSkillForUsers($TUser1);
244 $TSkill2 = getSkillForJob($fk_job);
247 $job->fetch($fk_job);
250 <h3>' . $job->label .
'</h3>
251 <p>' . $job->description .
'</p>
255 $userlist2 = displayUsersListWithPicto($TUser2, $fk_usergroup2,
'list2');
256 $TSkill2 = getSkillForUsers($TUser2);
259 $TMergedSkills = mergeSkills($TSkill1, $TSkill2);
265 echo
'<td id="" style="width:20%" valign="top">' . skillList($TMergedSkills) .
'</td>';
266 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate1') .
'</td>';
267 echo
'<td id="" style="width:10%" valign="top">' . diff($TMergedSkills) .
'</td>';
268 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate2') .
'</td>';
270 echo
'<td id="list-user-right" style="width:30%" valign="top">';
304function diff(&$TMergedSkills)
306 $out =
'<ul class="diff">';
308 foreach ($TMergedSkills as
$id => &$sk) {
311 if (empty($sk->rate2)) {
312 $class .=
' toohappy';
313 } elseif (empty($sk->rate1)) {
315 } elseif ($sk->rate1 == $sk->rate2) {
317 } elseif ($sk->rate2 < $sk->rate1) {
318 $class .=
' veryhappy';
319 } elseif ($sk->rate2 > $sk->rate1) {
323 $out .=
'<li fk_skill="' .
$id .
'" class="' . $class .
'" style="text-align:center;">
324 <span class="' . $class .
'"> </span>
339function rate(&$TMergedSkills, $field)
341 global $langs, $fk_job;
343 $out =
'<ul class="competence">';
345 foreach ($TMergedSkills as
$id => &$sk) {
348 if (empty($sk->$field)) {
353 $how_many = ($field ===
'rate1') ? $sk->how_many_max1 : $sk->how_many_max2;
356 if ($field ===
'rate2' && $fk_job > 0) {
357 $trad = $langs->trans(
'RequiredRank');
359 $trad = $langs->trans(
'HighestRank');
362 $out .=
'<li fk_skill="' .
$id .
'" style="text-align:center;">
363 <p><span class="' . $class .
' classfortooltip" title="' . $trad .
'">' . $note .
'</span>' . ($how_many > 0 ?
'<span class="bubble classfortooltip" title="' . $langs->trans(
'HowManyUserWithThisMaxNote') .
'">' . $how_many .
'</span>' :
'') .
'</p>
378function skillList(&$TMergedSkills)
380 $out =
'<ul class="competence">';
382 foreach ($TMergedSkills as
$id => &$sk) {
383 $out .=
'<li fk_skill="' .
$id .
'">
384 <h3>' . $sk->label .
'</h3>
385 <p>' . $sk->description .
'</p>
401function mergeSkills($TSkill1, $TSkill2)
405 foreach ($TSkill1 as &$sk) {
406 if (empty($Tab[$sk->fk_skill])) {
407 $Tab[$sk->fk_skill] =
new stdClass();
410 $Tab[$sk->fk_skill]->rate1 = $sk->rankorder;
411 $Tab[$sk->fk_skill]->how_many_max1 = $sk->how_many_max;
412 $Tab[$sk->fk_skill]->label = $sk->label;
413 $Tab[$sk->fk_skill]->description = $sk->description;
416 foreach ($TSkill2 as &$sk) {
417 if (empty($Tab[$sk->fk_skill])) {
418 $Tab[$sk->fk_skill] =
new stdClass();
420 $Tab[$sk->fk_skill]->rate2 = $sk->rankorder;
421 $Tab[$sk->fk_skill]->label = $sk->label;
422 $Tab[$sk->fk_skill]->description = $sk->description;
423 $Tab[$sk->fk_skill]->how_many_max2 = $sk->how_many_max;
437function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist =
'list-user')
439 global $db, $langs,
$conf, $form;
442 if ($fk_usergroup > 0) {
443 $list = $namelist .
'_excluded_id';
445 $excludedIdsList =
GETPOST($list);
447 $sql =
"SELECT u.rowid FROM " . MAIN_DB_PREFIX .
"user u
448 LEFT JOIN " . MAIN_DB_PREFIX .
"usergroup_user as ugu ON (u.rowid = ugu.fk_user)
449 WHERE u.statut > 0 AND ugu.entity = ".((int)
$conf->entity);
450 $sql .=
" AND ugu.fk_usergroup=" . ((int) $fk_usergroup);
452 $res = $db->query($sql);
453 $out .=
'<ul name="' . $namelist .
'">';
455 $TExcludedId = explode(
',', $excludedIdsList);
457 $out .=
'<input id="'.$list.
'" type="hidden" name="'.$list.
'" value="'.$excludedIdsList.
'"> ';
461 while ($obj = $db->fetch_object($res)) {
464 $user =
new User($db);
465 $user->fetch($obj->rowid);
467 $name = $user->getFullName($langs);
469 $name = $user->login;
472 if (in_array($user->id, $TExcludedId)) {
473 $class .=
' disabled';
475 if (!in_array($user->id, $TUser)) {
476 $TUser[] = $user->id;
482 $jobstring = $job->getLastJobForUser($user->id);
486 $evaluation = $static_eval->getLastEvaluationForUser($user->id);
488 if (!empty($evaluation) && !empty($evaluation->date_eval)) {
489 $desc .= $langs->trans(
'DateLastEval') .
' : ' .
dol_print_date($evaluation->date_eval);
491 $desc .= $langs->trans(
'NoEval');
494 if (!empty($user->array_options[
'options_DDA'])) {
495 $desc .=
'<br>' . $langs->trans(
'Anciennete') .
' : ' .
dol_print_date(strtotime($user->array_options[
'options_DDA']));
498 $out .=
'<li fk_user="' . $user->id .
'" class="' . $class .
'">
499 ' . $form->showphoto(
'userphoto', $user, 0, 0, 0,
'photoref',
'small', 1, 0, 1) .
'
500 <h3>' . $name .
'</h3>
519function getSkillForUsers($TUser)
528 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill, ';
529 $sql .=
' MAX(sr.rankorder) as rankorder';
530 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill sk';
531 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
532 $sql .=
" WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
533 $sql .=
' AND sr.fk_object IN ('.$db->sanitize(implode(
',', $TUser)).
')';
534 $sql .=
" GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill ";
536 $resql = $db->query($sql);
542 while ($obj = $db->fetch_object($resql)) {
543 $sql1 =
"SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX.
"hrm_skillrank as sr";
544 $sql1 .=
" WHERE sr.rankorder = ".((int) $obj->rankorder);
545 $sql1 .=
" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
546 $sql1 .=
" AND sr.fk_skill = ".((int) $obj->fk_skill);
547 $sql1 .=
" AND sr.fk_object IN (".$db->sanitize(implode(
',', $TUser)).
")";
548 $resql1 = $db->query($sql1);
550 $objMax = $db->fetch_object($resql1);
553 $Tab[$num]->fk_skill = $obj->fk_skill;
554 $Tab[$num]->label = $obj->label;
555 $Tab[$num]->description = $obj->description;
556 $Tab[$num]->skill_type = $obj->skill_type;
557 $Tab[$num]->fk_object = $obj->fk_object;
558 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_USER;
559 $Tab[$num]->rankorder = $obj->rankorder;
560 $Tab[$num]->how_many_max = $objMax->how_many_max;
577function getSkillForJob($fk_job)
581 if (empty($fk_job)) {
585 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
586 $sql .=
" MAX(sr.rankorder) as rankorder";
587 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill as sk';
588 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
589 $sql .=
" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB.
"'";
590 $sql .=
' AND sr.fk_object = '.((int) $fk_job);
591 $sql .=
' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill';
593 $resql = $db->query($sql);
598 while ($obj = $db->fetch_object($resql)) {
600 $Tab[$num]->fk_skill = $obj->fk_skill;
601 $Tab[$num]->label = $obj->label;
602 $Tab[$num]->description = $obj->description;
603 $Tab[$num]->skill_type = $obj->skill_type;
606 $Tab[$num]->fk_object = $obj->fk_object;
607 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_JOB;
608 $Tab[$num]->rankorder = $obj->rankorder;
609 $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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Dolibarr users.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
treeview li table
No Email.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.