dolibarr 21.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 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
35{
36 global $db, $langs, $conf;
37
38 $langs->load("hrm");
39
40 $h = 0;
41 $head = array();
42
43 $head[$h][0] = dol_buildpath("/hrm/skillrank_card.php", 1).'?id='.$object->id;
44 $head[$h][1] = $langs->trans("Card");
45 $head[$h][2] = 'card';
46 $h++;
47
48 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
49 $nbNote = 0;
50 if (!empty($object->note_private)) {
51 $nbNote++;
52 }
53 if (!empty($object->note_public)) {
54 $nbNote++;
55 }
56 $head[$h][0] = dol_buildpath('/hrm/skillrank_note.php', 1).'?id='.$object->id;
57 $head[$h][1] = $langs->trans('Notes');
58 if ($nbNote > 0) {
59 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
60 }
61 $head[$h][2] = 'note';
62 $h++;
63 }
64
65 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
66 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
67 $upload_dir = $conf->hrm->dir_output."/skillrank/".dol_sanitizeFileName($object->ref);
68 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
69 $nbLinks = Link::count($db, $object->element, $object->id);
70 $head[$h][0] = dol_buildpath("/hrm/skillrank_document.php", 1).'?id='.$object->id;
71 $head[$h][1] = $langs->trans('Documents');
72 if (($nbFiles + $nbLinks) > 0) {
73 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
74 }
75 $head[$h][2] = 'document';
76 $h++;
77
78 $head[$h][0] = dol_buildpath("/hrm/skillrank_agenda.php", 1).'?id='.$object->id;
79 $head[$h][1] = $langs->trans("Events");
80 $head[$h][2] = 'agenda';
81 $h++;
82
83 // Show more tabs from modules
84 // Entries must be declared in modules descriptor with line
85 //$this->tabs = array(
86 // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
87 //); // to add new tab
88 //$this->tabs = array(
89 // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
90 //); // to remove a tab
91 complete_head_from_modules($conf, $langs, $object, $head, $h, 'skillrank@hrm');
92
93 complete_head_from_modules($conf, $langs, $object, $head, $h, 'skillrank@hrm', 'remove');
94
95 return $head;
96}
97
108function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode = 'view')
109{
110 global $db, $conf, $langs;
111
112 require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php';
113 require_once DOL_DOCUMENT_ROOT . '/hrm/class/skilldet.class.php';
114
115 // On charge les différentes notes possibles pour la compétence $fk_skill
116 $skilldet = new Skilldet($db);
117 $Lines = $skilldet->fetchAll('ASC', 'rankorder', 0, 0, '(fk_skill:=:'.((int) $fk_skill).')');
118
119 if (!is_array($Lines) && $Lines < 0) {
120 setEventMessages($skilldet->error, $skilldet->errors, 'errors');
121 }
122 if (empty($Lines)) {
123 return $langs->trans('SkillHasNoLines');
124 }
125
126 $ret = '<!-- field jquery --><span title="'.$langs->trans('NA').'" class="radio_js_bloc_number '.$inputname.'_'.$fk_skill.($selected_rank == "-1" ? ' selected' : '').'">';
127 $ret .= $langs->trans('NA');
128 $ret .= '</span>';
129 if (is_array($Lines) && !empty($Lines)) {
130 foreach ($Lines as $line) {
131 $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
132 if ($line->rankorder > $MaxNumberSkill) {
133 continue;
134 }
135
136 $ret .= '<span title="' . $line->description . '" class="radio_js_bloc_number ' . $inputname . '_' . $line->fk_skill;
137 $ret .= $line->rankorder == $selected_rank ? ' selected' : '';
138 $ret .= '">' . $line->rankorder . '</span>';
139 }
140
141 if ($mode == 'edit') {
142 $ret .= '
143 <input type="hidden" id="' . $inputname . '_' . $fk_skill . '" name="' . $inputname . '[' . $fk_skill . ']" value="' . $selected_rank . '">
144 <script type="text/javascript">
145 $(document).ready(function(){
146 $(".radio_js_bloc_number").tooltip();
147 var error,same;
148 $(".' . $inputname . '_' . $fk_skill . '").on("click",function(){
149 same=false;
150 val = $(this).html();
151 if($(this).hasClass("selected"))same=true;
152 $(".' . $inputname . '_' . $fk_skill . '").removeClass("selected");
153 if(same)
154 {
155 $("#' . $inputname . '_' . $fk_skill . '").val("");
156 }else {
157 $(this).addClass("selected");
158 $("#' . $inputname . '_' . $fk_skill . '").val(val);
159 }
160 });
161
162 });
163 </script>';
164 }
165 }
166
167 return $ret;
168}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class for Skilldet.
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:63
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79