1<?php 2/* Copyright (C) 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 recruitmentjobposition_agenda.php 21 * \ingroup recruitment 22 * \brief Page of RecruitmentJobPosition events 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"])) $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; 31while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33if (!$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 35if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 36if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38if (!$res) die("Include of main fails"); 39 40require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; 41require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 42require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 43dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); 44dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); 45 46 47// Load translation files required by the page 48$langs->loadLangs(array("recruitment", "other")); 49 50// Get parameters 51$id = GETPOST('id', 'int'); 52$ref = GETPOST('ref', 'alpha'); 53$action = GETPOST('action', 'aZ09'); 54$cancel = GETPOST('cancel', 'aZ09'); 55$backtopage = GETPOST('backtopage', 'alpha'); 56 57if (GETPOST('actioncode', 'array')) { 58 $actioncode = GETPOST('actioncode', 'array', 3); 59 if (!count($actioncode)) $actioncode = '0'; 60} else { 61 $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); 62} 63$search_agenda_label = GETPOST('search_agenda_label'); 64 65$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; 66$sortfield = GETPOST("sortfield", 'alpha'); 67$sortorder = GETPOST("sortorder", 'alpha'); 68$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 69if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 70$offset = $limit * $page; 71$pageprev = $page - 1; 72$pagenext = $page + 1; 73if (!$sortfield) $sortfield = 'a.datep,a.id'; 74if (!$sortorder) $sortorder = 'DESC,DESC'; 75 76// Initialize technical objects 77$object = new RecruitmentJobPosition($db); 78$extrafields = new ExtraFields($db); 79$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id; 80$hookmanager->initHooks(array('recruitmentjobpositionagenda', 'globalcard')); // Note that conf->hooks_modules contains array 81// Fetch optionals attributes and labels 82$extrafields->fetch_name_optionals_label($object->table_element); 83 84// Load object 85include 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 86if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; 87 88// Security check - Protection if external user 89//if ($user->socid > 0) accessforbidden(); 90//if ($user->socid > 0) $socid = $user->socid; 91//$result = restrictedArea($user, 'recruitment', $object->id); 92 93$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php 94 95 96/* 97 * Actions 98 */ 99 100$parameters = array('id'=>$id); 101$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 102if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 103 104if (empty($reshook)) 105{ 106 // Cancel 107 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) 108 { 109 header("Location: ".$backtopage); 110 exit; 111 } 112 113 // Purge search criteria 114 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers 115 { 116 $actioncode = ''; 117 $search_agenda_label = ''; 118 } 119} 120 121 122 123/* 124 * View 125 */ 126 127$form = new Form($db); 128 129if ($object->id > 0) 130{ 131 $title = $langs->trans("Agenda"); 132 //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; 133 $help_url = ''; 134 llxHeader('', $title, $help_url); 135 136 if (!empty($conf->notification->enabled)) $langs->load("mails"); 137 $head = recruitmentjobpositionPrepareHead($object); 138 139 140 print dol_get_fiche_head($head, 'agenda', $langs->trans("RecruitmentJobPosition"), -1, $object->picto); 141 142 // Object card 143 // ------------------------------------------------------------ 144 $linkback = '<a href="'.dol_buildpath('/recruitment/recruitmentjobposition_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; 145 146 $morehtmlref = '<div class="refidno">'; 147 /* 148 // Ref customer 149 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 150 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 151 // Thirdparty 152 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 153 */ 154 // Project 155 if (!empty($conf->projet->enabled)) 156 { 157 $langs->load("projects"); 158 $morehtmlref .= $langs->trans('Project').' '; 159 if ($permissiontoadd) 160 { 161 if ($action != 'classify') 162 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; 163 $morehtmlref .= ' : '; 164 if ($action == 'classify') { 165 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 166 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; 167 $morehtmlref .= '<input type="hidden" name="action" value="classin">'; 168 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; 169 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 170 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; 171 $morehtmlref .= '</form>'; 172 } else { 173 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 174 } 175 } else { 176 if (!empty($object->fk_project)) { 177 $proj = new Project($db); 178 $proj->fetch($object->fk_project); 179 $morehtmlref .= ': '.$proj->getNomUrl(); 180 } else { 181 $morehtmlref .= ''; 182 } 183 } 184 } 185 $morehtmlref .= '</div>'; 186 187 188 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 189 190 print '<div class="fichecenter">'; 191 print '<div class="underbanner clearboth"></div>'; 192 193 $object->info($object->id); 194 dol_print_object_info($object, 1); 195 196 print '</div>'; 197 198 print dol_get_fiche_end(); 199 200 201 202 // Actions buttons 203 204 $objthirdparty = $object; 205 $objcon = new stdClass(); 206 207 $out = '&origin='.$object->element.'@recruitment&originid='.$object->id; 208 $permok = $user->rights->agenda->myactions->create; 209 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) 210 { 211 //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; 212 if (get_class($objthirdparty) == 'Societe') $out .= '&socid='.$objthirdparty->id; 213 $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; 214 //$out.=$langs->trans("AddAnAction").' '; 215 //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); 216 //$out.="</a>"; 217 } 218 219 220 print '<div class="tabsAction">'; 221 222 if (!empty($conf->agenda->enabled)) 223 { 224 if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) 225 { 226 print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>'; 227 } else { 228 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>'; 229 } 230 } 231 232 print '</div>'; 233 234 if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) 235 { 236 $param = '&id='.$object->id.'&socid='.$socid; 237 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); 238 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); 239 240 241 //print load_fiche_titre($langs->trans("ActionsOnRecruitmentJobPosition"), '', ''); 242 243 // List of all actions 244 $filters = array(); 245 $filters['search_agenda_label'] = $search_agenda_label; 246 247 // TODO Replace this with same code than into list.php 248 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, 'recruitment'); 249 } 250} 251 252// End of page 253llxFooter(); 254$db->close(); 255