38require_once
'../main.inc.php';
47require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
48require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skill.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/hrm/class/job.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/hrm/class/evaluation.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/hrm/class/position.class.php';
52require_once DOL_DOCUMENT_ROOT .
'/hrm/lib/hrm.lib.php';
62$permissiontoread = $user->hasRight(
'hrm',
'evaluation',
'read') || $user->hasRight(
'hrm',
'compare_advance',
'read');
68if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
77$css = array(
'/hrm/css/style.css');
79llxHeader(
'', $langs->trans(
'SkillComparison'),
'',
'', 0, 0,
'', $css);
84$head[$h][0] = DOL_URL_ROOT.
'/hrm/compare.php';
85$head[$h][1] = $langs->trans(
"SkillComparison");
86$head[$h][2] =
'compare';
91 <script
type=
"text/javascript">
93 $(document).ready(
function () {
95 $(
"li[fk_user]").click(
function () {
97 if ($(
this).hasClass(
'disabled')) {
98 $(
this).removeClass(
'disabled');
100 $(
this).addClass(
'disabled');
104 var $userl = $(
this).closest(
'ul');
105 var listname = $userl.attr(
'name');
109 $userl.find(
'li').each(
function (i, item) {
111 if ($(item).hasClass(
'disabled')) {
112 TId.push($(item).attr(
'fk_user'));
117 $(
'#' + listname +
'_excluded_id').val(TId.join(
','));
130$fk_job = (int)
GETPOST(
'fk_job');
140 <div
class=
"fichecenter">
141 <form action=
"<?php echo $_SERVER['PHP_SELF'] ?>">
143 <div
class=
"tabBar tabBarWithBottom">
144 <div
class=
"fichehalfleft">
145 <
table class=
"border tableforfield" width=
"100%">
148 print $langs->trans(
'group1ToCompare').
'</td><td>';
149 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
150 print $form->select_dolgroups($fk_usergroup1,
'fk_usergroup1', 1);
153 <tr><td></td><td></td></tr>
156 print $langs->trans(
'group2ToCompare').
'</td><td>';
157 print
img_picto(
'',
'group',
'class="pictofixedwidth"');
158 print $form->select_dolgroups($fk_usergroup2,
'fk_usergroup2', 1);
162 <td><b><?php print $langs->trans(
'or'); ?></b></td><td></td>
166 echo $langs->trans(
'OrJobToCompare') .
'</td><td>';
168 $jobs = $j->fetchAll();
171 foreach ($jobs as &$j) {
172 $TJobs[$j->id] = $j->label;
175 print
img_picto(
'',
'jobprofile',
'class="pictofixedwidth"').$form->selectarray(
'fk_job', $TJobs, $fk_job, 1);
181 <div style=
"background:#eee;border-radius:5px 0;margin:0px 0 10px;font-style:italic;padding:5px;" class=
"fichehalfright">
182 <!--<h4><?php echo $langs->trans(
'legend'); ?></h4>-->
183 <
table class=
"border" width=
"100%">
185 <td><span style=
"vertical-align:middle" class=
"toohappy diffnote little"></span>
186 <?php echo $langs->trans(
'CompetenceAcquiredByOneOrMore'); ?></td>
189 <td><span style=
"vertical-align:middle" class=
"veryhappy diffnote little"></span>
190 <?php echo $langs->trans(
'MaxlevelGreaterThan'); ?></td>
193 <td><span style=
"vertical-align:middle" class=
"happy diffnote little"></span>
194 <?php echo $langs->trans(
'MaxLevelEqualTo'); ?></td>
197 <td><span style=
"vertical-align:middle" class=
"sad diffnote little"></span>
198 <?php echo $langs->trans(
'MaxLevelLowerThan'); ?></td>
201 <td><span style=
"vertical-align:middle" class=
"toosad diffnote little"></span>
202 <?php echo $langs->trans(
'SkillNotAcquired'); ?></td>
208 <div
class=
"clearboth"></div>
214 <input
class=
"button" type=
"SUBMIT" name=
"bt1" VALUE=
"<?php print $langs->trans('Refresh'); ?>">
218 <div
id=
"compare" class=
"centpercent" style=
"position:relative;">
220 <?php
if ($fk_usergroup1 > 0 || $fk_usergroup2 > 0 || $fk_job > 0) {
221 $TUser1 = $TUser2 = array();
223 $userlist1 = displayUsersListWithPicto($TUser1, $fk_usergroup1,
'list1');
225 $TSkill1 = getSkillForUsers($TUser1);
228 $TSkill2 = getSkillForJob($fk_job);
231 $job->fetch($fk_job);
234 <h3>' . $job->label .
'</h3>
235 <p>' . $job->description .
'</p>
239 $userlist2 = displayUsersListWithPicto($TUser2, $fk_usergroup2,
'list2');
240 $TSkill2 = getSkillForUsers($TUser2);
243 $TMergedSkills = mergeSkills($TSkill1, $TSkill2);
245 <
table class=
"centpercent">
247 <th
class=
"left"><?php print $langs->trans(
'Employees'); ?></th>
248 <th
class=
"left" style=
"padding-left: 10px;"><?php print $langs->trans(
'Skill'); ?></th>
249 <th><?php print $langs->trans(
'HighestRank'); ?></th>
250 <th><?php print $langs->trans(
'difference'); ?></th>
251 <th><?php print $langs->trans($fk_job > 0 ?
'ExpectedRank' :
'HighestRank'); ?></th>
258 echo
'<td id="list-user-left" style="width:25%; padding-right: 10px; border-right: 1px solid #ccc" class="valigntop">';
262 echo
'<td id="" style="width:20%; padding-left: 10px;" valign="top">' . skillList($TMergedSkills) .
'</td>';
264 echo
'<td id="" style="width:10%" valign="top">' . rate($TMergedSkills,
'rate1') .
'</td>';
266 echo
'<td id="" style="width:10%" valign="top">' . diff($TMergedSkills) .
'</td>';
268 echo
'<td id="" style="width:10%; padding-right: 10px;" valign="top">' . rate($TMergedSkills,
'rate2') .
'</td>';
270 echo
'<td id="list-user-right" style="width:25%; padding-left: 10px; border-left: 1px solid #ccc;" class="valigntop">';
303function diff(&$TMergedSkills)
305 $out =
'<ul class="diff">';
307 foreach ($TMergedSkills as
$id => &$sk) {
310 if (empty($sk->rate2)) {
311 $class .=
' toohappy';
312 } elseif (empty($sk->rate1)) {
314 } elseif ($sk->rate1 == $sk->rate2) {
316 } elseif ($sk->rate2 < $sk->rate1) {
317 $class .=
' veryhappy';
318 } elseif ($sk->rate2 > $sk->rate1) {
322 $out .=
'<li fk_skill="' .
$id .
'" class="' . $class .
'" style="text-align:center;">
323 <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)) {
352 $note = $sk->$field < 0 ? $langs->trans(
"NA") : $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 .
'" class="center">
363 <p class="nowraponall"><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;
413 $Tab[$sk->fk_skill]->label = $sk->label;
414 $Tab[$sk->fk_skill]->description = $sk->description;
417 foreach ($TSkill2 as &$sk) {
418 if (empty($Tab[$sk->fk_skill])) {
419 $Tab[$sk->fk_skill] =
new stdClass();
421 $Tab[$sk->fk_skill]->rate2 = $sk->rankorder;
422 $Tab[$sk->fk_skill]->how_many_max2 = $sk->how_many_max;
424 $Tab[$sk->fk_skill]->label = $sk->label;
425 $Tab[$sk->fk_skill]->description = $sk->description;
439function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist =
'list-user')
444 if ($fk_usergroup > 0) {
445 $list = $namelist .
'_excluded_id';
447 $excludedIdsList =
GETPOST($list);
449 $sql =
"SELECT u.rowid FROM " . MAIN_DB_PREFIX .
"user u
450 LEFT JOIN " . MAIN_DB_PREFIX .
"usergroup_user as ugu ON (u.rowid = ugu.fk_user)
451 WHERE u.statut > 0 AND ugu.entity = ".((int)
$conf->entity);
452 $sql .=
" AND ugu.fk_usergroup=" . ((int) $fk_usergroup);
454 $res =
$db->query($sql);
455 $out .=
'<ul name="' . $namelist .
'">';
457 $TExcludedId = explode(
',', $excludedIdsList);
459 $out .=
'<input id="'.$list.
'" type="hidden" name="'.$list.
'" value="'.$excludedIdsList.
'"> ';
463 while ($obj =
$db->fetch_object($res)) {
467 $user->fetch($obj->rowid);
469 $name = $user->getFullName($langs);
471 $name = $user->login;
474 if (in_array($user->id, $TExcludedId)) {
475 $class .=
' disabled';
477 if (!in_array($user->id, $TUser)) {
478 $TUser[] = $user->id;
484 $jobstring = $job->getLastJobForUser($user->id);
488 $evaluation = $static_eval->getLastEvaluationForUser($user->id);
490 if (!empty($evaluation) && !empty($evaluation->date_eval)) {
491 $desc .= $langs->trans(
'DateLastEval') .
' : ' .
dol_print_date($evaluation->date_eval);
493 $desc .= $langs->trans(
'NoEval');
496 if (!empty($user->array_options[
'options_DDA'])) {
497 $desc .=
'<br>' . $langs->trans(
'Seniority') .
' : ' .
dol_print_date(strtotime($user->array_options[
'options_DDA']));
500 $out .=
'<li fk_user="' . $user->id .
'" class="' . $class .
'">
501 ' . $form->showphoto(
'userphoto', $user, 0, 0, 0,
'photoref',
'small', 1, 0,
'', 1) .
'
502 <h3>' . $name .
'</h3>
520function getSkillForUsers($TUser)
529 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type,';
530 $sql .=
' MAX(sr.rankorder) as rankorder';
531 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill sk';
532 $sql .=
' INNER JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank sr';
533 $sql .=
" WHERE sk.rowid = sr.fk_skill AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
534 $sql .=
' AND sr.fk_object IN ('.$db->sanitize(implode(
',', $TUser)).
')';
535 $sql .=
' AND rankorder >= 0';
536 $sql .=
" GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type";
537 $sql .=
" ORDER BY sk.rowid ASC";
539 $resql =
$db->query($sql);
545 while ($obj =
$db->fetch_object($resql)) {
548 $Tab[$num]->fk_skill = $obj->rowid;
549 $Tab[$num]->label = $obj->label;
550 $Tab[$num]->description = $obj->description;
551 $Tab[$num]->skill_type = $obj->skill_type;
553 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_USER;
555 $Tab[$num]->rankorder = $obj->rankorder;
558 $sql1 =
"SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX.
"hrm_skillrank as sr";
559 $sql1 .=
" WHERE sr.rankorder = ".((int) $obj->rankorder);
560 $sql1 .=
" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER).
"'";
561 $sql1 .=
" AND sr.fk_skill = ".((int) $obj->rowid);
562 $sql1 .=
" AND sr.fk_object IN (".$db->sanitize(implode(
',', $TUser)).
")";
563 $resql1 =
$db->query($sql1);
565 $objMax =
$db->fetch_object($resql1);
567 $Tab[$num]->how_many_max = $objMax->how_many_max;
586function getSkillForJob($fk_job)
590 if (empty($fk_job)) {
594 $sql =
'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
595 $sql .=
" MAX(sr.rankorder) as rankorder";
596 $sql .=
' FROM '.MAIN_DB_PREFIX.
'hrm_skill as sk';
597 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
598 $sql .=
" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB.
"'";
599 $sql .=
' AND sr.fk_object = '.((int) $fk_job);
600 $sql .=
' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill';
602 $resql =
$db->query($sql);
607 while ($obj =
$db->fetch_object($resql)) {
609 $Tab[$num]->fk_skill = $obj->fk_skill;
610 $Tab[$num]->label = $obj->label;
611 $Tab[$num]->description = $obj->description;
612 $Tab[$num]->skill_type = $obj->skill_type;
615 $Tab[$num]->fk_object = $obj->fk_object;
616 $Tab[$num]->objectType = SkillRank::SKILLRANK_TYPE_JOB;
617 $Tab[$num]->rankorder = $obj->rankorder;
618 $Tab[$num]->how_many_max = $obj->how_many_max;
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
treeview li table
No Email.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$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.