dolibarr 19.0.3
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 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
33function jobPrepareHead($object)
34{
35 global $db, $langs, $conf;
36
37 $langs->load("hrm");
38
39 $h = 0;
40 $head = array();
41
42 $head[$h][0] = DOL_URL_ROOT."/hrm/job_card.php?id=".$object->id;
43 $head[$h][1] = $langs->trans("JobProfile");
44 $head[$h][2] = 'job_card';
45 $h++;
46
47 $head[$h][0] = DOL_URL_ROOT."/hrm/skill_tab.php?id=".$object->id.'&objecttype=job';
48 $head[$h][1] = $langs->trans("RequiredSkills");
49 $nbResources = 0;
50 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_skillrank WHERE objecttype = 'job' AND fk_object = ".((int) $object->id);
51 $resql = $db->query($sql);
52 if ($resql) {
53 $obj = $db->fetch_object($resql);
54 if ($obj) {
55 $nbResources = $obj->nb;
56 }
57 }
58 if ($nbResources > 0) {
59 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.($nbResources).'</span>' : '');
60 }
61 $head[$h][2] = 'skill_tab';
62 $h++;
63
64 $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?id=".$object->id;
65 $head[$h][1] = $langs->trans("PositionsWithThisProfile");
66 $nbResources = 0;
67 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_job_user WHERE fk_job = ".((int) $object->id);
68 $resql = $db->query($sql);
69 if ($resql) {
70 $obj = $db->fetch_object($resql);
71 if ($obj) {
72 $nbResources = $obj->nb;
73 }
74 }
75 if ($nbResources > 0) {
76 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.($nbResources).'</span>' : '');
77 }
78 $head[$h][2] = 'position';
79 $h++;
80
81
82 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
83 $nbNote = 0;
84 if (!empty($object->note_private)) {
85 $nbNote++;
86 }
87 if (!empty($object->note_public)) {
88 $nbNote++;
89 }
90 $head[$h][0] = dol_buildpath('/hrm/job_note.php', 1).'?id='.$object->id;
91 $head[$h][1] = $langs->trans('Notes');
92 if ($nbNote > 0) {
93 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
94 }
95 $head[$h][2] = 'note';
96 $h++;
97 }
98
99 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
100 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
101 $upload_dir = $conf->hrm->dir_output."/job/".dol_sanitizeFileName($object->label);
102 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
103 $nbLinks = Link::count($db, $object->element, $object->id);
104 $head[$h][0] = dol_buildpath("/hrm/job_document.php", 1).'?id='.$object->id;
105 $head[$h][1] = $langs->trans('Documents');
106 if (($nbFiles + $nbLinks) > 0) {
107 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
108 }
109 $head[$h][2] = 'document';
110 $h++;
111
112 $head[$h][0] = dol_buildpath("/hrm/job_agenda.php", 1).'?id='.$object->id;
113 $head[$h][1] = $langs->trans("Events");
114 $head[$h][2] = 'agenda';
115 $h++;
116
117 // Show more tabs from modules
118 // Entries must be declared in modules descriptor with line
119 //$this->tabs = array(
120 // 'entity:+tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
121 //); // to add new tab
122 //$this->tabs = array(
123 // 'entity:-tabname:Title:@hrm:/hrm/mypage.php?id=__ID__'
124 //); // to remove a tab
125 complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm');
126
127 complete_head_from_modules($conf, $langs, $object, $head, $h, 'job@hrm', 'remove');
128
129 return $head;
130}
dol_dir_list($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:62
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 dolibarr global constant string value.
jobPrepareHead($object)
Prepare array of tabs for Job.