dolibarr 24.0.0-beta
hrm_skillrank.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
3 * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
4 * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
5 * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
36{
37 global $db, $langs, $conf;
38
39 $langs->load("hrm");
40
41 $h = 0;
42 $head = array();
43
44 $head[$h][0] = dol_buildpath("/hrm/skillrank_card.php", 1).'?id='.$object->id;
45 $head[$h][1] = $langs->trans("Card");
46 $head[$h][2] = 'card';
47 $h++;
48
49 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
50 $nbNote = 0;
51 if (!empty($object->note_private)) {
52 $nbNote++;
53 }
54 if (!empty($object->note_public)) {
55 $nbNote++;
56 }
57 $head[$h][0] = dol_buildpath('/hrm/skillrank_note.php', 1).'?id='.$object->id;
58 $head[$h][1] = $langs->trans('Notes');
59 if ($nbNote > 0) {
60 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
61 }
62 $head[$h][2] = 'note';
63 $h++;
64 }
65
66 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
67 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
68 $upload_dir = $conf->hrm->dir_output."/skillrank/".dol_sanitizeFileName($object->ref);
69 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
70 $nbLinks = Link::count($db, $object->element, $object->id);
71 $head[$h][0] = dol_buildpath("/hrm/skillrank_document.php", 1).'?id='.$object->id;
72 $head[$h][1] = $langs->trans('Documents');
73 if (($nbFiles + $nbLinks) > 0) {
74 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
75 }
76 $head[$h][2] = 'document';
77 $h++;
78
79 $head[$h][0] = dol_buildpath("/hrm/skillrank_agenda.php", 1).'?id='.$object->id;
80 $head[$h][1] = $langs->trans("Events");
81 $head[$h][2] = 'agenda';
82 $h++;
83
84 // Show more tabs from modules
85 // Entries must be declared in modules descriptor with line
86 //$this->tabs = array(
87 // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
88 //); // to add new tab
89 //$this->tabs = array(
90 // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
91 //); // to remove a tab
92 complete_head_from_modules($conf, $langs, $object, $head, $h, 'skillrank@hrm');
93
94 complete_head_from_modules($conf, $langs, $object, $head, $h, 'skillrank@hrm', 'remove');
95
96 return $head;
97}
98
109function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode = 'view')
110{
111 global $db, $conf, $langs;
112
113 require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php';
114 require_once DOL_DOCUMENT_ROOT . '/hrm/class/skilldet.class.php';
115
116 // Load the different possible ratings for skill $fk_skill
117 $skilldet = new Skilldet($db);
118 $Lines = $skilldet->fetchAll('ASC', 'rankorder', 0, 0, '(fk_skill:=:'.((int) $fk_skill).')');
119
120 if (!is_array($Lines) && $Lines < 0) {
121 setEventMessages($skilldet->error, $skilldet->errors, 'errors');
122 }
123 if (empty($Lines)) {
124 return $langs->trans('SkillHasNoLines');
125 }
126
127 $ret = '<!-- field jquery --><span title="'.$langs->trans('NA').'" class="radio_js_bloc_number '.$inputname.'_'.$fk_skill.($selected_rank == "-1" ? ' selected' : '').'">';
128 $ret .= $langs->trans('NA');
129 $ret .= '</span>';
130 if (is_array($Lines) && !empty($Lines)) {
131 foreach ($Lines as $line) {
132 $MaxNumberSkill = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL);
133 if ($line->rankorder > $MaxNumberSkill) {
134 continue;
135 }
136
137 $ret .= '<span title="' . $line->description . '" class="radio_js_bloc_number ' . $inputname . '_' . $line->fk_skill;
138 $ret .= $line->rankorder == $selected_rank ? ' selected' : '';
139 $ret .= '">' . $line->rankorder . '</span>';
140 }
141
142 if ($mode == 'edit') {
143 $ret .= '
144 <input type="hidden" id="' . $inputname . '_' . $fk_skill . '" name="' . $inputname . '[' . $fk_skill . ']" value="' . $selected_rank . '">
145 <script type="text/javascript">
146 $(document).ready(function(){
147 $(".radio_js_bloc_number").tooltip();
148 var error,same;
149 $(".' . $inputname . '_' . $fk_skill . '").on("click",function(){
150 same=false;
151 val = $(this).html();
152 if($(this).hasClass("selected"))same=true;
153 $(".' . $inputname . '_' . $fk_skill . '").removeClass("selected");
154 if(same)
155 {
156 $("#' . $inputname . '_' . $fk_skill . '").val("");
157 }else {
158 $(this).addClass("selected");
159 $("#' . $inputname . '_' . $fk_skill . '").val(val);
160 }
161 });
162
163 });
164 </script>';
165 }
166 }
167
168 return $ret;
169}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class for Skilldet.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
skillrankPrepareHead($object)
Prepare array of tabs for SkillRank.
displayRankInfos($selected_rank, $fk_skill, $inputname='TNote', $mode='view')
Used to print ranks of a skill into several case, view or edit pour js necessary to select a rank.