dolibarr 21.0.0-alpha
hrm_job.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_URL_ROOT."/hrm/job_card.php?id=".$object->id;
44 $head[$h][1] = $langs->trans("JobProfile");
45 $head[$h][2] = 'job_card';
46 $h++;
47
48 $head[$h][0] = DOL_URL_ROOT."/hrm/skill_tab.php?id=".$object->id.'&objecttype=job';
49 $head[$h][1] = $langs->trans("RequiredSkills");
50 $nbResources = 0;
51 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_skillrank WHERE objecttype = 'job' AND fk_object = ".((int) $object->id);
52 $resql = $db->query($sql);
53 if ($resql) {
54 $obj = $db->fetch_object($resql);
55 if ($obj) {
56 $nbResources = $obj->nb;
57 }
58 }
59 if ($nbResources > 0) {
60 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.($nbResources).'</span>' : '');
61 }
62 $head[$h][2] = 'skill_tab';
63 $h++;
64
65 $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?id=".$object->id;
66 $head[$h][1] = $langs->trans("PositionsWithThisProfile");
67 $nbResources = 0;
68 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_job_user WHERE fk_job = ".((int) $object->id);
69 $resql = $db->query($sql);
70 if ($resql) {
71 $obj = $db->fetch_object($resql);
72 if ($obj) {
73 $nbResources = $obj->nb;
74 }
75 }
76 if ($nbResources > 0) {
77 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.($nbResources).'</span>' : '');
78 }
79 $head[$h][2] = 'position';
80 $h++;
81
82
83 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
84 $nbNote = 0;
85 if (!empty($object->note_private)) {
86 $nbNote++;
87 }
88 if (!empty($object->note_public)) {
89 $nbNote++;
90 }
91 $head[$h][0] = dol_buildpath('/hrm/job_note.php', 1).'?id='.$object->id;
92 $head[$h][1] = $langs->trans('Notes');
93 if ($nbNote > 0) {
94 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
95 }
96 $head[$h][2] = 'note';
97 $h++;
98 }
99
100 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
101 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
102 $upload_dir = $conf->hrm->dir_output."/job/".dol_sanitizeFileName($object->label);
103 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
104 $nbLinks = Link::count($db, $object->element, $object->id);
105 $head[$h][0] = dol_buildpath("/hrm/job_document.php", 1).'?id='.$object->id;
106 $head[$h][1] = $langs->trans('Documents');
107 if (($nbFiles + $nbLinks) > 0) {
108 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
109 }
110 $head[$h][2] = 'document';
111 $h++;
112
113 $head[$h][0] = dol_buildpath("/hrm/job_agenda.php", 1).'?id='.$object->id;
114 $head[$h][1] = $langs->trans("Events");
115 $head[$h][2] = 'agenda';
116 $h++;
117
118 // Show more tabs from modules
119 // Entries must be declared in modules descriptor with line
120 //$this->tabs = array(
121 // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
122 //); // to add new tab
123 //$this->tabs = array(
124 // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
125 //); // to remove a tab
126 complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm');
127
128 complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm', 'remove');
129
130 return $head;
131}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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
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.
jobPrepareHead($object)
Prepare array of tabs for Job.