dolibarr  13.0.2
recruitmentjobposition_document.php
Go to the documentation of this file.
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 
25 // Load Dolibarr environment
26 $res = 0;
27 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
28 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
29 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
30 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
31 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
32 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
33 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
34 // Try main.inc.php using relative path
35 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
36 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
37 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
38 if (!$res) die("Include of main fails");
39 
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44 dol_include_once('/recruitment/class/recruitmentjobposition.class.php');
45 dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php');
46 
47 // Load translation files required by the page
48 $langs->loadLangs(array("recruitment", "companies", "other", "mails"));
49 
50 
51 $action = GETPOST('action', 'aZ09');
52 $confirm = GETPOST('confirm');
53 $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
54 $ref = GETPOST('ref', 'alpha');
55 
56 // Get parameters
57 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
58 $sortfield = GETPOST("sortfield", 'alpha');
59 $sortorder = GETPOST("sortorder", 'alpha');
60 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
61 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
62 $offset = $liste_limit * $page;
63 $pageprev = $page - 1;
64 $pagenext = $page + 1;
65 if (!$sortorder) $sortorder = "ASC";
66 if (!$sortfield) $sortfield = "name";
67 //if (! $sortfield) $sortfield="position_name";
68 
69 // Initialize technical objects
70 $object = new RecruitmentJobPosition($db);
71 $extrafields = new ExtraFields($db);
72 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
73 $hookmanager->initHooks(array('recruitmentjobpositiondocument', 'globalcard')); // Note that conf->hooks_modules contains array
74 // Fetch optionals attributes and labels
75 $extrafields->fetch_name_optionals_label($object->table_element);
76 
77 // Load object
78 include 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
79 
80 if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity ? $object->entity : $conf->entity]."/recruitmentjobposition/".get_exdir(0, 0, 0, 1, $object);
81 
82 // Security check - Protection if external user
83 //if ($user->socid > 0) accessforbidden();
84 //if ($user->socid > 0) $socid = $user->socid;
85 //$result = restrictedArea($user, 'recruitment', $object->id);
86 
87 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php
88 
89 
90 
91 /*
92  * Actions
93  */
94 
95 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
96 
97 
98 /*
99  * View
100  */
101 
102 $form = new Form($db);
103 
104 $title = $langs->trans("RecruitmentJobPosition").' - '.$langs->trans("Files");
105 $help_url = '';
106 //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
107 llxHeader('', $title, $help_url);
108 
109 if ($object->id)
110 {
111  /*
112  * Show tabs
113  */
114  $head = recruitmentjobpositionPrepareHead($object);
115 
116  print dol_get_fiche_head($head, 'document', $langs->trans("RecruitmentJobPosition"), -1, $object->picto);
117 
118 
119  // Build file list
120  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
121  $totalsize = 0;
122  foreach ($filearray as $key => $file)
123  {
124  $totalsize += $file['size'];
125  }
126 
127  // Object card
128  // ------------------------------------------------------------
129  $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
130 
131  $morehtmlref = '<div class="refidno">';
132  /*
133  // Ref customer
134  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
135  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
136  // Thirdparty
137  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
138  */
139  // Project
140  if (!empty($conf->projet->enabled))
141  {
142  $langs->load("projects");
143  $morehtmlref .= $langs->trans('Project').' ';
144  if ($permissiontoadd)
145  {
146  if ($action != 'classify')
147  //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
148  $morehtmlref .= ' : ';
149  if ($action == 'classify') {
150  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
151  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
152  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
153  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
154  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
155  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
156  $morehtmlref .= '</form>';
157  } else {
158  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
159  }
160  } else {
161  if (!empty($object->fk_project)) {
162  $proj = new Project($db);
163  $proj->fetch($object->fk_project);
164  $morehtmlref .= ': '.$proj->getNomUrl();
165  } else {
166  $morehtmlref .= '';
167  }
168  }
169  }
170  $morehtmlref .= '</div>';
171 
172  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
173 
174  print '<div class="fichecenter">';
175 
176  print '<div class="underbanner clearboth"></div>';
177  print '<table class="border centpercent tableforfield">';
178 
179  // Number of files
180  print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
181 
182  // Total size
183  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
184 
185  print '</table>';
186 
187  print '</div>';
188 
190 
191  $modulepart = 'recruitment';
192  $permission = $user->rights->recruitment->recruitmentjobposition->write;
193  $permtoedit = $user->rights->recruitment->recruitmentjobposition->write;
194  $param = '&id='.$object->id;
195 
196  //$relativepathwithnofile='recruitmentjobposition/' . dol_sanitizeFileName($object->id).'/';
197  $relativepathwithnofile = 'recruitmentjobposition/'.dol_sanitizeFileName($object->ref).'/';
198 
199  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
200 } else {
201  accessforbidden('', 0, 1);
202 }
203 
204 // End of page
205 llxFooter();
206 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
recruitmentjobpositionPrepareHead($object)
Prepare array of tabs for RecruitmentJobPosition.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage projects.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
Class for RecruitmentJobPosition.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59