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