dolibarr 20.0.2
recruitment_recruitmentjobposition.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Put here your own copyright and developer email---
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
32{
33 global $db, $langs, $conf;
34
35 $langs->load("recruitment");
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = DOL_URL_ROOT . '/recruitment/recruitmentjobposition_card.php?id=' . $object->id;
41 $head[$h][1] = $langs->trans("PositionToBeFilled");
42 $head[$h][2] = 'card';
43 $h++;
44
45 $head[$h][0] = DOL_URL_ROOT . '/recruitment/recruitmentcandidature_list.php?id=' . $object->id;
46 $head[$h][1] = $langs->trans("RecruitmentCandidatures");
47 $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "recruitment_recruitmentcandidature WHERE fk_recruitmentjobposition = " . ((int) $object->id);
48 $resql = $db->query($sql);
49 if ($resql) {
50 $obj = $db->fetch_object($resql);
51 if ($obj) {
52 $nCandidature = $obj->nb;
53 if ($nCandidature > 0) {
54 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nCandidature . '</span>';
55 }
56 }
57 } else {
58 dol_print_error($db);
59 }
60 $head[$h][2] = 'candidatures';
61 $h++;
62
63 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
64 $nbNote = 0;
65 if (!empty($object->note_private)) {
66 $nbNote++;
67 }
68 if (!empty($object->note_public)) {
69 $nbNote++;
70 }
71 $head[$h][0] = DOL_URL_ROOT . '/recruitment/recruitmentjobposition_note.php?id=' . $object->id;
72 $head[$h][1] = $langs->trans('Notes');
73 if ($nbNote > 0) {
74 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbNote . '</span>';
75 }
76 $head[$h][2] = 'note';
77 $h++;
78 }
79
80 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
81 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
82 $upload_dir = $conf->recruitment->dir_output . "/recruitmentjobposition/" . dol_sanitizeFileName($object->ref);
83 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
84 $nbLinks = Link::count($db, $object->element, $object->id);
85 $head[$h][0] = DOL_URL_ROOT . '/recruitment/recruitmentjobposition_document.php?id=' . $object->id;
86 $head[$h][1] = $langs->trans('Documents');
87 if (($nbFiles + $nbLinks) > 0) {
88 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
89 }
90 $head[$h][2] = 'document';
91 $h++;
92
93 $head[$h][0] = DOL_URL_ROOT . '/recruitment/recruitmentjobposition_agenda.php?id=' . $object->id;
94 $head[$h][1] = $langs->trans("Events");
95 $head[$h][2] = 'agenda';
96 $h++;
97
98 // Show more tabs from modules
99 // Entries must be declared in modules descriptor with line
100 //$this->tabs = array(
101 // 'entity:+tabname:Title:@recruitment:/recruitment/mypage.php?id=__ID__'
102 //); // to add new tab
103 //$this->tabs = array(
104 // 'entity:-tabname:Title:@recruitment:/recruitment/mypage.php?id=__ID__'
105 //); // to remove a tab
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'recruitmentjobposition');
107
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'recruitmentjobposition', 'remove');
109
110 return $head;
111}
112
113
122function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0)
123{
124 global $conf, $dolibarr_main_url_root;
125
126 $ref = str_replace(' ', '', $ref);
127 $out = '';
128
129 // Define $urlwithroot
130 $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
131 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file
132 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
133
134 $urltouse = DOL_MAIN_URL_ROOT;
135 if ($localorexternal) {
136 $urltouse = $urlwithroot;
137 }
138
139 $out = $urltouse . '/public/recruitment/view.php?ref=' . ($mode ? '<span style="color: #666666">' : '') . $ref . ($mode ? '</span>' : '');
140 /*if (!empty($conf->global->RECRUITMENT_SECURITY_TOKEN))
141 {
142 if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.urlencode($conf->global->RECRUITMENT_SECURITY_TOKEN);
143 else $out .= '&securekey='.urlencode(dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2));
144 }*/
145
146 // For multicompany
147 if (!empty($out) && isModEnabled('multicompany')) {
148 $out .= "&entity=" . $conf->entity; // Check the entity because we may have the same reference in several entities
149 }
150
151 return $out;
152}
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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).
getPublicJobPositionUrl($mode, $ref='', $localorexternal=0)
Return string with full Url.
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.