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