1<?php 2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> 3 * Copyright (C) ---Put here your own copyright and developer email--- 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 19/** 20 * \file recruitmentcandidature_document.php 21 * \ingroup recruitment 22 * \brief Tab for documents linked to RecruitmentCandidature 23 */ 24 25// Load Dolibarr environment 26$res = 0; 27// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { 29 $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 30} 31// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 32$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 33while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { 34 $i--; $j--; 35} 36if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { 37 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 38} 39if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { 40 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 41} 42// Try main.inc.php using relative path 43if (!$res && file_exists("../main.inc.php")) { 44 $res = @include "../main.inc.php"; 45} 46if (!$res && file_exists("../../main.inc.php")) { 47 $res = @include "../../main.inc.php"; 48} 49if (!$res && file_exists("../../../main.inc.php")) { 50 $res = @include "../../../main.inc.php"; 51} 52if (!$res) { 53 die("Include of main fails"); 54} 55 56require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 57require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 58require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; 59require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 60dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); 61dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); 62 63// Load translation files required by the page 64$langs->loadLangs(array("recruitment", "companies", "other", "mails")); 65 66 67$action = GETPOST('action', 'aZ09'); 68$confirm = GETPOST('confirm'); 69$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); 70$ref = GETPOST('ref', 'alpha'); 71 72// Get parameters 73$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; 74$sortfield = GETPOST("sortfield", 'alpha'); 75$sortorder = GETPOST("sortorder", 'alpha'); 76$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 77if (empty($page) || $page == -1) { 78 $page = 0; 79} // If $page is not defined, or '' or -1 80$offset = $liste_limit * $page; 81$pageprev = $page - 1; 82$pagenext = $page + 1; 83if (!$sortorder) { 84 $sortorder = "ASC"; 85} 86if (!$sortfield) { 87 $sortfield = "name"; 88} 89//if (! $sortfield) $sortfield="position_name"; 90 91// Initialize technical objects 92$object = new RecruitmentCandidature($db); 93$extrafields = new ExtraFields($db); 94$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id; 95$hookmanager->initHooks(array('recruitmentcandidaturedocument', 'globalcard')); // Note that conf->hooks_modules contains array 96// Fetch optionals attributes and labels 97$extrafields->fetch_name_optionals_label($object->table_element); 98 99// Load object 100include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 101 102if ($id > 0 || !empty($ref)) { 103 $upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentcandidature/".get_exdir(0, 0, 0, 1, $object); 104} 105 106// Security check - Protection if external user 107//if ($user->socid > 0) accessforbidden(); 108//if ($user->socid > 0) $socid = $user->socid; 109$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); 110$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft); 111 112$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php 113 114 115 116/* 117 * Actions 118 */ 119 120include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; 121 122 123/* 124 * View 125 */ 126 127$form = new Form($db); 128 129$title = $langs->trans("RecruitmentJobPosition").' - '.$langs->trans("Files"); 130$help_url = ''; 131//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 132llxHeader('', $title, $help_url); 133 134if ($object->id) { 135 /* 136 * Show tabs 137 */ 138 $head = recruitmentCandidaturePrepareHead($object); 139 140 print dol_get_fiche_head($head, 'document', $langs->trans("RecruitmentCandidature"), -1, $object->picto); 141 142 143 // Build file list 144 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); 145 $totalsize = 0; 146 foreach ($filearray as $key => $file) { 147 $totalsize += $file['size']; 148 } 149 150 // Object card 151 // ------------------------------------------------------------ 152 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentcandidature_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; 153 154 $morehtmlref = '<div class="refidno">'; 155 /* 156 // Ref customer 157 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 158 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 159 // Thirdparty 160 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 161 */ 162 // Project 163 /*if (! empty($conf->projet->enabled)) 164 { 165 $langs->load("projects"); 166 $morehtmlref .= $langs->trans('Project') . ' '; 167 if ($permissiontoadd) 168 { 169 if ($action != 'classify') 170 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; 171 $morehtmlref .=' : '; 172 if ($action == 'classify') { 173 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 174 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; 175 $morehtmlref .= '<input type="hidden" name="action" value="classin">'; 176 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; 177 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 178 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; 179 $morehtmlref .= '</form>'; 180 } else { 181 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 182 } 183 } else { 184 if (! empty($object->fk_project)) { 185 $proj = new Project($db); 186 $proj->fetch($object->fk_project); 187 $morehtmlref .= ': '.$proj->getNomUrl(); 188 } else { 189 $morehtmlref .= ''; 190 } 191 } 192 }*/ 193 $morehtmlref .= '</div>'; 194 195 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 196 197 print '<div class="fichecenter">'; 198 199 print '<div class="underbanner clearboth"></div>'; 200 print '<table class="border centpercent tableforfield">'; 201 202 // Number of files 203 print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; 204 205 // Total size 206 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; 207 208 print '</table>'; 209 210 print '</div>'; 211 212 print dol_get_fiche_end(); 213 214 $modulepart = 'recruitment'; 215 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; 216 $permtoedit = $user->rights->recruitment->recruitmentjobposition->write; 217 $param = '&id='.$object->id; 218 219 $relativepathwithnofile = 'recruitmentcandidature/'.dol_sanitizeFileName($object->ref).'/'; 220 221 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; 222} else { 223 accessforbidden('', 0, 1); 224} 225 226// End of page 227llxFooter(); 228$db->close(); 229