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';
54$permissiontoread = $user->hasRight(
'hrm',
'evaluation',
'read') || $user->hasRight(
'hrm',
'compare_advance',
'read');
57if (empty($conf->hrm->enabled)) {
60if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
69$css = array(
'/hrm/css/style.css');
71llxHeader(
'', $langs->trans(
'SkillComparison'),
'',
'', 0, 0,
'', $css);
76$head[$h][0] = $_SERVER[
"PHP_SELF"];
77$head[$h][1] = $langs->trans(
"SkillComparison");
78$head[$h][2] =
'compare';
83 <script
type=
"text/javascript">
85 $(document).ready(
function () {
87 $(
"li[fk_user]").click(
function () {
89 if ($(
this).hasClass(
'disabled')) {
90 $(
this).removeClass(
'disabled');
92 $(
this).addClass(
'disabled');
96 var $userl = $(
this).closest(
'ul');
97 var listname = $userl.attr(
'name');
101 $userl.find(
'li').each(
function (i, item) {
103 if ($(item).hasClass(
'disabled')) {
104 TId.push($(item).attr(
'fk_user'));
109 $(
'#' + listname +
'_excluded_id').val(TId.join(
','));
122$fk_job = (int)
GETPOST(
'fk_job');
124 $fk_usergroup2 =
GETPOST(
'fk_usergroup2');
127$fk_usergroup1 =
GETPOST(
'fk_usergroup1');
132 <div
class=
"fichecenter">
133 <form action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
135 <div
class=
"tabBar tabBarWithBottom">
136 <div
class=
"fichehalfleft">
137 <
table class=
"border tableforfield" width=
"100%">
140 print $langs->trans(
'group1ToCompare').
'</td><td>';
141 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
142 print $form->select_dolgroups($fk_usergroup1,
'fk_usergroup1', 1);
145 <tr><td> </td></tr>
148 print $langs->trans(
'group2ToCompare').
'</td><td>';
149 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
150 print $form->select_dolgroups($fk_usergroup2,
'fk_usergroup2', 1);
154 <td><STRONG><?php print $langs->trans(
'or'); ?></STRONG></td>
158 echo $langs->trans(
'OrJobToCompare') .
'</td><td>';
160 $jobs = $j->fetchAll();
163 foreach ($jobs as &$j) {
164 $TJobs[$j->id] = $j->label;
167 print
img_picto(
'',
'jobprofile',
'class="pictofixedwidth"').$form->selectarray(
'fk_job', $TJobs, $fk_job, 1);
173 <div style=
"background:#eee;border-radius:5px 0;margin:0px 0 10px;font-style:italic;padding:5px;" class=
"fichehalfright">
174 <!--<h4><?php echo $langs->trans(
'legend'); ?></h4>-->
175 <
table class=
"border" width=
"100%">
177 <td><span style=
"vertical-align:middle" class=
"toohappy diffnote little"></span>
178 <?php echo $langs->trans(
'CompetenceAcquiredByOneOrMore'); ?></td>
181 <td><span style=
"vertical-align:middle" class=
"veryhappy diffnote little"></span>
182 <?php echo $langs->trans(
'MaxlevelGreaterThan'); ?></td>
185 <td><span style=
"vertical-align:middle" class=
"happy diffnote little"></span>
186 <?php echo $langs->trans(
'MaxLevelEqualTo'); ?></td>
189 <td><span style=
"vertical-align:middle" class=
"sad diffnote little"></span>
190 <?php echo $langs->trans(
'MaxLevelLowerThan'); ?></td>
193 <td><span style=
"vertical-align:middle" class=
"toosad diffnote little"></span>
194 <?php echo $langs->trans(
'SkillNotAcquired'); ?></td>
200 <div
class=
"clearboth"></div>
206 <input
class=
"button" type=
"SUBMIT" name=
"bt1" VALUE=
"<?php print $langs->trans('Refresh'); ?>">
210 <div
id=
"compare" width=
"100%" style=
"position:relative;">
212 <?php
if ($fk_usergroup1 > 0 || $fk_usergroup2 > 0 || $fk_job > 0) { ?>
216 <th><?php print $langs->trans(
'skill'); ?></th>
217 <th><?php print $langs->trans(
'rank'); ?></th>
218 <th><?php print $langs->trans(
'difference'); ?></th>
219 <th><?php print $langs->trans(
'rank'); ?></th>
224 echo
'<tr><td id="list-user-left" style="width:30%" valign="top">';
226 $TUser1 = $TUser2 = array();
228 $userlist1 = displayUsersListWithPicto($TUser1, $fk_usergroup1,
'list1');
231 $skill =
new Skill($db);
232 $TSkill1 = getSkillForUsers($TUser1);
235 $TSkill2 = getSkillForJob($fk_job);
238 $job->fetch($fk_job);
241 <h3>' . $job->label .
'</h3>
242 <p>' . $job->description .
'</p>
246 $userlist2 = displayUsersListWithPicto($TUser2, $fk_usergroup2,
'list2');
247 $TSkill2 = getSkillForUsers($TUser2);
250 $TMergedSkills = mergeSkills($TSkill1, $TSkill2);
256 echo
'<td id="" style="width:20%" valign="top">' . skillList($TMergedSkills) .
'</td>';
257 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate1') .
'</td>';
258 echo
'<td id="" style="width:10%" valign="top">' . diff($TMergedSkills) .
'</td>';
259 echo
'<td id="" style="width:5%" valign="top">' . rate($TMergedSkills,
'rate2') .
'</td>';
261 echo
'<td id="list-user-right" style="width:30%" valign="top">';
295function diff(&$TMergedSkills)
297 $out =
'<ul class="diff">';
299 foreach ($TMergedSkills as $id => &$sk) {
302 if (empty($sk->rate2)) {
303 $class .=
' toohappy';
304 } elseif (empty($sk->rate1)) {
306 } elseif ($sk->rate1 == $sk->rate2) {
308 } elseif ($sk->rate2 < $sk->rate1) {
309 $class .=
' veryhappy';
310 } elseif ($sk->rate2 > $sk->rate1) {
314 $out .=
'<li fk_skill="' . $id .
'" class="' . $class .
'" style="text-align:center;">
315 <span class="' . $class .
'"> </span>
330function rate(&$TMergedSkills, $field)
332 global $langs, $fk_job;
334 $out =
'<ul class="competence">';
336 foreach ($TMergedSkills as $id => &$sk) {
339 if (empty($sk->$field)) {
344 $how_many = ($field ===
'rate1') ? $sk->how_many_max1 : $sk->how_many_max2;
347 if ($field ===
'rate2' && $fk_job > 0) {
348 $trad = $langs->trans(
'RequiredRank');
350 $trad = $langs->trans(
'HighestRank');
353 $out .=
'<li fk_skill="' . $id .
'" style="text-align:center;">
354 <p><span class="' . $class .
' classfortooltip" title="' . $trad .
'">' . $note .
'</span>' . ($how_many > 0 ?
'<span class="bubble classfortooltip" title="' . $langs->trans(
'HowManyUserWithThisMaxNote') .
'">' . $how_many .
'</span>' :
'') .
'</p>
369function skillList(&$TMergedSkills)
371 $out =
'<ul class="competence">';
373 foreach ($TMergedSkills as $id => &$sk) {
374 $out .=
'<li fk_skill="' . $id .
'">
375 <h3>' . $sk->label .
'</h3>
376 <p>' . $sk->description .
'</p>
392function mergeSkills($TSkill1, $TSkill2)
396 foreach ($TSkill1 as &$sk) {
397 if (empty($Tab[$sk->fk_skill])) {
398 $Tab[$sk->fk_skill] =
new stdClass();
401 $Tab[$sk->fk_skill]->rate1 = $sk->rankorder;
402 $Tab[$sk->fk_skill]->how_many_max1 = $sk->how_many_max;
403 $Tab[$sk->fk_skill]->label = $sk->label;
404 $Tab[$sk->fk_skill]->description = $sk->description;
407 foreach ($TSkill2 as &$sk) {
408 if (empty($Tab[$sk->fk_skill])) {
409 $Tab[$sk->fk_skill] =
new stdClass();
411 $Tab[$sk->fk_skill]->rate2 = $sk->rankorder;
412 $Tab[$sk->fk_skill]->label = $sk->label;
413 $Tab[$sk->fk_skill]->description = $sk->description;
414 $Tab[$sk->fk_skill]->how_many_max2 = $sk->how_many_max;
428function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist =
'list-user')
430 global $db, $langs, $conf, $form;
433 if ($fk_usergroup > 0) {
434 $list = $namelist .
'_excluded_id';
436 $excludedIdsList =
GETPOST($list);
438 $sql =
"SELECT u.rowid FROM " . MAIN_DB_PREFIX .
"user u
439 LEFT JOIN " . MAIN_DB_PREFIX .
"usergroup_user as ugu ON (u.rowid = ugu.fk_user)
440 WHERE u.statut > 0 AND ugu.entity = ".((int) $conf->entity);
441 $sql .=
" AND ugu.fk_usergroup=" . ((int) $fk_usergroup);
443 $res = $db->query($sql);
444 $out .=
'<ul name="' . $namelist .
'">';
446 $TExcludedId = explode(
',', $excludedIdsList);
448 $out .=
'<input id="'.$list.
'" type="hidden" name="'.$list.
'" value="'.$excludedIdsList.
'"> ';
452 while ($obj = $db->fetch_object($res)) {
455 $user =
new User($db);
456 $user->fetch($obj->rowid);
458 $name = $user->getFullName($langs);
460 $name = $user->login;
463 if (in_array($user->id, $TExcludedId)) {
464 $class .=
' disabled';
466 if (!in_array($user->id, $TUser)) {
467 $TUser[] = $user->id;
473 $jobstring = $job->getLastJobForUser($user->id);
477 $evaluation = $static_eval->getLastEvaluationForUser($user->id);
479 if (!empty($evaluation) && !empty($evaluation->date_eval)) {
480 $desc .= $langs->trans(
'DateLastEval') .
' : ' .
dol_print_date($evaluation->date_eval);
482 $desc .= $langs->trans(
'NoEval');
485 if (!empty($user->array_options[
'options_DDA'])) {
486 $desc .=
'<br>' . $langs->trans(
'Anciennete') .
' : ' .
dol_print_date(strtotime($user->array_options[
'options_DDA']));
489 $out .=
'<li fk_user="' . $user->id .
'" class="' . $class .
'">
490 ' . $form->showphoto(
'userphoto', $user, 0, 0, 0,
'photoref',
'small', 1, 0, 1) .
'
491 <h3>' . $name .
'</h3>
510function getSkillForUsers($TUser)
519 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill, ';
520 $sql .=
' MAX(sr.rankorder) as rankorder';
521 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill sk';
522 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
523 $sql .=
" WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
524 $sql .=
' AND sr.fk_object IN ('.$db->sanitize(implode(
',', $TUser)).
')';
525 $sql .=
" GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill ";
527 $resql = $db->query($sql);
533 while ($obj = $db->fetch_object($resql)) {
534 $sql1 =
"SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX.
"hrm_skillrank as sr";
535 $sql1 .=
" WHERE sr.rankorder = ".((int) $obj->rankorder);
536 $sql1 .=
" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
537 $sql1 .=
" AND sr.fk_skill = ".((int) $obj->fk_skill);
538 $sql1 .=
" AND sr.fk_object IN (".$db->sanitize(implode(
',', $TUser)).
")";
539 $resql1 = $db->query($sql1);
541 $objMax = $db->fetch_object($resql1);
544 $Tab[$num]->fk_skill = $obj->fk_skill;
545 $Tab[$num]->label = $obj->label;
546 $Tab[$num]->description = $obj->description;
547 $Tab[$num]->skill_type = $obj->skill_type;
548 $Tab[$num]->fk_object = $obj->fk_object;
549 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_USER;
550 $Tab[$num]->rankorder = $obj->rankorder;
551 $Tab[$num]->how_many_max = $objMax->how_many_max;
568function getSkillForJob($fk_job)
572 if (empty($fk_job)) {
576 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
577 $sql .=
" MAX(sr.rankorder) as rankorder";
578 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill as sk';
579 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
580 $sql .=
" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB.
"'";
581 $sql .=
' AND sr.fk_object = '.((int) $fk_job);
582 $sql .=
' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill';
584 $resql = $db->query($sql);
589 while ($obj = $db->fetch_object($resql)) {
591 $Tab[$num]->fk_skill = $obj->fk_skill;
592 $Tab[$num]->label = $obj->label;
593 $Tab[$num]->description = $obj->description;
594 $Tab[$num]->skill_type = $obj->skill_type;
597 $Tab[$num]->fk_object = $obj->fk_object;
598 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_JOB;
599 $Tab[$num]->rankorder = $obj->rankorder;
600 $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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.