本文整理汇总了PHP中getUserContext函数的典型用法代码示例。如果您正苦于以下问题:PHP getUserContext函数的具体用法?PHP getUserContext怎么用?PHP getUserContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getUserContext函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Display a page with this order of priority (based on the provided page name) :
* 1. Does the page exist into local/pages/{lang}/ (this allows you to overwrite default pages)?
* 2. Does the page exist into the views available in views/pages/ folder?
* Pages are not public and we take into account the language of the connected user.
* If the page name contains the keyword export, then we don't output the default template.
* @param string $page Name of the view (and of the corresponding PHP file)
* @author Benjamin BALET <[email protected]>
*/
public function view($page = 'home')
{
$data = getUserContext($this);
$trans = array("-" => " ", "_" => " ", "." => " ");
$data['title'] = ucfirst(strtr($page, $trans));
// Capitalize the first letter
//The page containing export in their name are returning another MIMETYPE
if (strpos($page, 'export') === FALSE) {
//Don't include header and menu
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
}
$view = 'pages/' . $this->language_code . '/' . $page . '.php';
$pathCI = APPPATH . 'views/';
$pathLocal = FCPATH . 'local/';
//Check if we have a user-defined view
if (file_exists($pathLocal . $view)) {
$this->load->customView($pathLocal, $view, $data);
} else {
//Load the page from the default location (CI views folder)
if (!file_exists($pathCI . $view)) {
redirect('notfound');
}
$this->load->view($view, $data);
}
if (strpos($page, 'export') === FALSE) {
$this->load->view('templates/footer', $data);
}
}
开发者ID:ishawge,项目名称:jorani,代码行数:38,代码来源:pages.php
示例2: counters
/**
* Display the details of leaves taken/entitled for a given employee
* This page can be displayed only if the connected user is the manager of the employee
* @param string $refTmp Timestamp (reference date)
* @author Benjamin BALET <[email protected]>
*/
public function counters($id, $refTmp = NULL)
{
$data = getUserContext($this);
$this->lang->load('datatable', $this->language);
$this->lang->load('entitleddays', $this->language);
$this->lang->load('hr', $this->language);
$this->load->model('users_model');
$employee = $this->users_model->get_users($id);
if ($this->user_id != $employee['manager'] && $this->is_hr == false) {
log_message('error', 'User #' . $this->user_id . ' illegally tried to access to leave counter of employee #' . $id);
$this->session->set_flashdata('msg', lang('requests_summary_flash_msg_forbidden'));
redirect('requests/collaborators');
} else {
$refDate = date("Y-m-d");
if ($refTmp != NULL) {
$refDate = date("Y-m-d", $refTmp);
$data['isDefault'] = 0;
} else {
$data['isDefault'] = 1;
}
$data['refDate'] = $refDate;
$data['summary'] = $this->leaves_model->get_user_leaves_summary($id, FALSE, $refDate);
if (!is_null($data['summary'])) {
$this->load->model('entitleddays_model');
$this->load->model('types_model');
$data['types'] = $this->types_model->get_types();
$this->load->model('users_model');
$data['employee_name'] = $this->users_model->get_label($id);
$user = $this->users_model->get_users($id);
$this->load->model('contracts_model');
$contract = $this->contracts_model->get_contracts($user['contract']);
$data['contract_name'] = $contract['name'];
$data['contract_start'] = $contract['startentdate'];
$data['contract_end'] = $contract['endentdate'];
$data['employee_id'] = $id;
$data['contract_id'] = $user['contract'];
$data['entitleddayscontract'] = $this->entitleddays_model->get_entitleddays_contract($user['contract']);
$data['entitleddaysemployee'] = $this->entitleddays_model->get_entitleddays_employee($id);
expires_now();
$data['title'] = lang('requests_summary_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_leave_balance_collaborators');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('requests/counters', $data);
$this->load->view('templates/footer');
} else {
$this->session->set_flashdata('msg', lang('requests_summary_flash_msg_error'));
redirect('requests/collaborators');
}
}
}
开发者ID:roidelapluie,项目名称:jorani,代码行数:57,代码来源:requests.php
示例3: settings
/**
* Display the settings of the system (extract of config.php)
* @author Benjamin BALET <[email protected]>
*/
public function settings()
{
$this->auth->checkIfOperationIsAllowed('list_settings');
$data = getUserContext($this);
$data['title'] = 'application/config/config.php';
$data['help'] = $this->help->create_help_link('global_link_doc_page_settings');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('admin/settings', $data);
$this->load->view('templates/footer');
}
开发者ID:shawnyeh,项目名称:jorani,代码行数:15,代码来源:admin.php
示例4: balance
/**
* Landing page of the shipped-in balance report
* @author Benjamin BALET <[email protected]>
*/
public function balance($refTmp = NULL)
{
$this->auth->checkIfOperationIsAllowed('native_report_balance');
$data = getUserContext($this);
$refDate = date("Y-m-d");
if ($refTmp != NULL) {
$refDate = date("Y-m-d", $refTmp);
}
$data['refDate'] = $refDate;
$data['title'] = lang('reports_balance_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_leave_balance_report');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('reports/balance/index', $data);
$this->load->view('templates/footer');
}
开发者ID:GIP-RECIA,项目名称:jorani,代码行数:20,代码来源:reports.php
示例5: view
/**
* Display a static web page. We try to find if a filename matches with the
* views available in views/pages/ folder
* @param type $page
* @author Benjamin BALET <[email protected]>
*/
public function view($page = 'home')
{
$data = getUserContext($this);
$path = 'pages/' . $this->session->userdata('language_code') . '/' . $page . '.php';
if (!file_exists('application/views/' . $path)) {
$path = 'pages/en/' . $page . '.php';
if (!file_exists('application/views/' . $path)) {
//fallback on default language
show_404();
}
}
$data['title'] = ucfirst($page);
// Capitalize the first letter
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view($path, $data);
$this->load->view('templates/footer', $data);
}
开发者ID:roidelapluie,项目名称:jorani,代码行数:24,代码来源:pages.php
示例6: edit
/**
* Display a form that allows editing a leave type
* @param int $id Identitier of the leave type
* @author Benjamin BALET <[email protected]>
*/
public function edit($id)
{
$this->auth->checkIfOperationIsAllowed('leavetypes_edit');
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = lang('leavetypes_popup_update_title');
$data['id'] = $id;
$data['type_name'] = $this->types_model->getName($id);
$this->form_validation->set_rules('name', lang('leavetypes_popup_update_field_name'), 'required|xss_clean|strip_tags');
if ($this->form_validation->run() === FALSE) {
$this->load->view('leavetypes/edit', $data);
} else {
$this->types_model->updateTypes($id, $this->input->post('name'));
$this->session->set_flashdata('msg', lang('leavetypes_popup_update_flash_msg'));
redirect('leavetypes');
}
}
开发者ID:bodun,项目名称:jorani,代码行数:23,代码来源:leavetypes.php
示例7: edit
/**
* Display a form that allows editing a leave type
* @author Benjamin BALET <[email protected]>
*/
public function edit($id)
{
$this->auth->check_is_granted('leavetypes_edit');
expires_now();
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = lang('leavetypes_popup_update_title');
$data['id'] = $id;
$data['type_name'] = $this->types_model->get_label($id);
$this->form_validation->set_rules('name', lang('leavetypes_popup_update_field_name'), 'required|xss_clean');
if ($this->form_validation->run() === FALSE) {
$this->load->view('leavetypes/edit', $data);
} else {
$this->types_model->update_types();
$this->session->set_flashdata('msg', lang('leavetypes_popup_update_flash_msg'));
redirect('leavetypes');
}
}
开发者ID:sksree,项目名称:Jorani_new,代码行数:23,代码来源:leavetypes.php
示例8: index
public function index($filter = 'requested')
{
$this->auth->checkIfOperationIsAllowed('list_overtime');
if ($filter == 'all') {
$showAll = TRUE;
} else {
$showAll = FALSE;
}
$data = getUserContext($this);
$this->lang->load('datatable', $this->language);
$data['filter'] = $filter;
$data['title'] = lang('overtime_index_title');
$data['requests'] = $this->overtime_model->requests($this->user_id, $showAll);
$data['flash_partial_view'] = $this->load->view('templates/flash', $data, TRUE);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('overtime/index', $data);
$this->load->view('templates/footer');
}
开发者ID:HarkiratGhotra,项目名称:application,代码行数:19,代码来源:overtime.php
示例9: select
/**
* Pop-up showing the tree of the organization and allowing a
* user to choose an entity (filter of a report or a calendar)
* @author Benjamin BALET <[email protected]>
*/
public function select()
{
if ($this->config->item('public_calendar') == TRUE && !$this->session->userdata('logged_in')) {
$this->load->library('polyglot');
$data['language'] = $this->config->item('language');
$data['language_code'] = $this->polyglot->language2code($data['language']);
$this->lang->load('organization', $data['language']);
$this->lang->load('treeview', $data['language']);
$data['help'] = '';
$data['logged_in'] = FALSE;
$this->load->view('organization/select', $data);
} else {
setUserContext($this);
$this->auth->checkIfOperationIsAllowed('organization_select');
$data = getUserContext($this);
$this->lang->load('organization', $this->language);
$this->lang->load('treeview', $this->language);
$this->load->view('organization/select', $data);
}
}
开发者ID:GIP-RECIA,项目名称:jorani,代码行数:25,代码来源:organization.php
示例10: contract
/**
* Display an ajax-based form that list entitled days of a contract
* and allow updating the list by adding or removing one item
* @param int $id contract identifier
* @author Benjamin BALET <[email protected]>
*/
public function contract($id)
{
$this->auth->check_is_granted('entitleddays_contract');
$data = getUserContext($this);
$data['id'] = $id;
$data['entitleddays'] = $this->entitleddays_model->get_entitleddays_contract($id);
$this->load->model('types_model');
$data['types'] = $this->types_model->get_types();
$this->load->model('contracts_model');
$contract = $this->contracts_model->get_contracts($id);
$data['contract_name'] = $contract['name'];
$data['contract_start_month'] = intval(substr($contract['startentdate'], 0, 2));
$data['contract_start_day'] = intval(substr($contract['startentdate'], 3));
$data['contract_end_month'] = intval(substr($contract['endentdate'], 0, 2));
$data['contract_end_day'] = intval(substr($contract['endentdate'], 3));
$data['title'] = lang('entitleddays_contract_index_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_entitleddays_contract');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('entitleddays/contract', $data);
$this->load->view('templates/footer');
}
开发者ID:sksree,项目名称:Jorani_new,代码行数:28,代码来源:entitleddays.php
示例11: index
/**
* Display the list of all overtime requests submitted to you
* Status is submitted
* @author Benjamin BALET <[email protected]>
*/
public function index($filter = 'requested')
{
$this->auth->check_is_granted('list_overtime');
expires_now();
if ($filter == 'all') {
$showAll = true;
} else {
$showAll = false;
}
$data = getUserContext($this);
$data['filter'] = $filter;
$data['title'] = lang('overtime_index_title');
$data['requests'] = $this->overtime_model->requests($this->user_id, $showAll);
$this->load->model('status_model');
for ($i = 0; $i < count($data['requests']); ++$i) {
$data['requests'][$i]['status_label'] = $this->status_model->get_label($data['requests'][$i]['status']);
}
$data['flash_partial_view'] = $this->load->view('templates/flash', $data, true);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('overtime/index', $data);
$this->load->view('templates/footer');
}
开发者ID:sksree,项目名称:Jorani_new,代码行数:28,代码来源:overtime.php
示例12: view
public function view($page = 'home')
{
$data = getUserContext($this);
$trans = array("-" => " ", "_" => " ", "." => " ");
$data['title'] = ucfirst(strtr($page, $trans));
if (strpos($page, 'export') === FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
}
$view = 'pages/' . $this->language_code . '/' . $page . '.php';
$pathCI = APPPATH . 'views/';
$pathLocal = FCPATH . 'local/';
if (file_exists($pathLocal . $view)) {
$this->load->customView($pathLocal, $view, $data);
} else {
if (!file_exists($pathCI . $view)) {
redirect('notfound');
}
$this->load->view($view, $data);
}
if (strpos($page, 'export') === FALSE) {
$this->load->view('templates/footer', $data);
}
}
开发者ID:HarkiratGhotra,项目名称:application,代码行数:24,代码来源:pages.php
示例13: edit
public function edit($id)
{
$this->auth->checkIfOperationIsAllowed('edit_positions');
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = lang('positions_edit_title');
$data['position'] = $this->positions_model->getPositions($id);
if (empty($data['position'])) {
redirect('notfound');
}
$this->form_validation->set_rules('name', lang('positions_edit_field_name'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('description', lang('positions_edit_field_description'), 'xss_clean|strip_tags');
if ($this->form_validation->run() === FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('positions/edit', $data);
$this->load->view('templates/footer');
} else {
$this->positions_model->updatePositions($id, $this->input->post('name'), $this->input->post('description'));
$this->session->set_flashdata('msg', lang('positions_edit_flash_msg'));
redirect('positions');
}
}
开发者ID:HarkiratGhotra,项目名称:application,代码行数:24,代码来源:positions.php
示例14: create
/**
* Display the form / action Create a new user
* @author Benjamin BALET <[email protected]>
*/
public function create()
{
$this->auth->check_is_granted('create_user');
expires_now();
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('polyglot');
$data['title'] = lang('users_create_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_create_user');
$this->load->model('roles_model');
$data['roles'] = $this->roles_model->get_roles();
$this->load->model('contracts_model');
$data['contracts'] = $this->contracts_model->get_contracts();
$data['public_key'] = file_get_contents('./assets/keys/public.pem', true);
$this->form_validation->set_rules('firstname', lang('users_create_field_firstname'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('lastname', lang('users_create_field_lastname'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('login', lang('users_create_field_login'), 'required|callback_login_check|xss_clean|strip_tags');
$this->form_validation->set_rules('email', lang('users_create_field_email'), 'required|xss_clean|strip_tags');
if (!$this->config->item('ldap_enabled')) {
$this->form_validation->set_rules('CipheredValue', lang('users_create_field_password'), 'required');
}
$this->form_validation->set_rules('role[]', lang('users_create_field_role'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('manager', lang('users_create_field_manager'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('contract', lang('users_create_field_contract'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('position', lang('users_create_field_position'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('entity', lang('users_create_field_entity'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('datehired', lang('users_create_field_hired'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('identifier', lang('users_create_field_identifier'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('language', lang('users_create_field_language'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('timezone', lang('users_create_field_timezone'), 'xss_clean|strip_tags');
if ($this->config->item('ldap_basedn_db')) {
$this->form_validation->set_rules('ldap_path', lang('users_create_field_ldap_path'), 'xss_clean|strip_tags');
}
if ($this->form_validation->run() === FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('users/create', $data);
$this->load->view('templates/footer');
} else {
$password = $this->users_model->set_users();
log_message('info', 'User ' . $this->input->post('login') . ' has been created by user #' . $this->session->userdata('id'));
//Send an e-mail to the user so as to inform that its account has been created
$this->load->library('email');
$usr_lang = $this->polyglot->code2language($this->input->post('language'));
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_user_create_title'), 'BaseURL' => base_url(), 'Firstname' => $this->input->post('firstname'), 'Lastname' => $this->input->post('lastname'), 'Login' => $this->input->post('login'), 'Password' => $password);
$message = $this->parser->parse('emails/' . $this->input->post('language') . '/new_user', $data, TRUE);
if ($this->email->mailer_engine == 'phpmailer') {
$this->email->phpmailer->Encoding = 'quoted-printable';
}
if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
$this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
} else {
$this->email->from('[email protected]', 'LMS');
}
$this->email->to($this->input->post('email'));
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
$this->email->subject($subject . $lang_mail->line('email_user_create_subject'));
$this->email->message($message);
$this->email->send();
$this->session->set_flashdata('msg', lang('users_create_flash_msg_success'));
redirect('users');
}
}
开发者ID:autohausnielsen,项目名称:jorani,代码行数:76,代码来源:users.php
示例15: calendar
/**
* Display an interactive calendar that allows to dynamically set the days
* off, bank holidays, etc. for a given contract
* @param type $id contract identifier
* @param type $year optional year number (4 digits), current year if empty
* @author Benjamin BALET <[email protected]>
*/
public function calendar($id, $year = 0)
{
$this->auth->check_is_granted('calendar_contract');
$data = getUserContext($this);
$data['title'] = lang('contract_calendar_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_contracts_calendar');
if ($year != 0) {
$data['year'] = $year;
} else {
$data['year'] = date("Y");
}
$contract = $this->contracts_model->get_contracts($id);
$data['contract_id'] = $id;
$data['contract_name'] = $contract['name'];
$data['contract_start_month'] = intval(substr($contract['startentdate'], 0, 2));
$data['contract_start_day'] = intval(substr($contract['startentdate'], 3));
$data['contract_end_month'] = intval(substr($contract['endentdate'], 0, 2));
$data['contract_end_day'] = intval(substr($contract['endentdate'], 3));
$this->load->model('dayoffs_model');
$data['dayoffs'] = $this->dayoffs_model->get_dayoffs($id, $data['year']);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('contracts/calendar', $data);
$this->load->view('templates/footer');
}
开发者ID:sksree,项目名称:Jorani_new,代码行数:32,代码来源:contracts.php
示例16: edit
/**
* Edit a leave request
* @author Benjamin BALET <[email protected]>
*/
public function edit($id)
{
$this->auth->check_is_granted('edit_extra');
$data = getUserContext($this);
$data['extra'] = $this->overtime_model->get_extra($id);
//Check if exists
if (empty($data['extra'])) {
show_404();
}
//If the user is not its own manager and if the leave is
//already requested, the employee can't modify it
if (!$this->is_hr) {
if ($this->session->userdata('manager') != $this->user_id && $data['extra']['status'] != 1) {
log_message('error', 'User #' . $this->user_id . ' illegally tried to edit overtime request #' . $id);
$this->session->set_flashdata('msg', lang('extra_edit_msg_error'));
redirect('extra');
}
}
//Admin
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('date', lang('extra_edit_field_date'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('duration', lang('extra_edit_field_duration'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('cause', lang('extra_edit_field_cause'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('status', lang('extra_edit_field_status'), 'required|xss_clean|strip_tags');
if ($this->form_validation->run() === FALSE) {
$data['title'] = lang('extra_edit_hmtl_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_create_overtime');
$data['id'] = $id;
$this->load->model('users_model');
$data['name'] = $this->users_model->get_label($data['extra']['employee']);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('extra/edit', $data);
$this->load->view('templates/footer');
} else {
$extra_id = $this->overtime_model->update_extra($id);
$this->session->set_flashdata('msg', lang('extra_edit_msg_success'));
//If the status is requested, send an email to the manager
if ($this->input->post('status') == 2) {
$this->sendMail($id);
}
if (isset($_GET['source'])) {
redirect($_GET['source']);
} else {
redirect('extra');
}
}
}
开发者ID:autohausnielsen,项目名称:jorani,代码行数:53,代码来源:extra.php
示例17: calendar
/**
* Display an interactive calendar that allows to dynamically set the days
* off, bank holidays, etc. for a given contract
* @param int $id contract identifier
* @param int $year optional year number (4 digits), current year if empty
* @author Benjamin BALET <[email protected]>
*/
public function calendar($id, $year = 0)
{
$this->auth->checkIfOperationIsAllowed('calendar_contract');
$data = getUserContext($this);
$this->lang->load('calendar', $this->language);
$data['title'] = lang('contract_calendar_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_contracts_calendar');
if ($year != 0) {
$data['year'] = $year;
} else {
$data['year'] = date("Y");
}
//Load the list of contracts (select destination contract / copy dayoff feature)
$data['contracts'] = $this->contracts_model->getContracts();
//Remove the contract being displayed (source)
foreach ($data['contracts'] as $key => $value) {
if ($value['id'] == $id) {
unset($data['contracts'][$key]);
break;
}
}
$contract = $this->contracts_model->getContracts($id);
$data['contract_id'] = $id;
$data['contract_name'] = $contract['name'];
$data['contract_start_month'] = intval(substr($contract['startentdate'], 0, 2));
$data['contract_start_day'] = intval(substr($contract['startentdate'], 3));
$data['contract_end_month'] = intval(substr($contract['endentdate'], 0, 2));
$data['contract_end_day'] = intval(substr($contract['endentdate'], 3));
$this->load->model('dayoffs_model');
$data['dayoffs'] = $this->dayoffs_model->getDaysOffForCivilYear($id, $data['year']);
$data['flash_partial_view'] = $this->load->view('templates/flash', $data, TRUE);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('contracts/calendar', $data);
$this->load->view('templates/footer');
}
开发者ID:bodun,项目名称:jorani,代码行数:43,代码来源:contracts.php
示例18: presence
/**
* Display presence details for a given employee
* @param int $id employee id
* @author Benjamin BALET <[email protected]>
*/
public function presence($id, $month = 0, $year = 0)
{
$this->auth->check_is_granted('list_employees');
$data = getUserContext($this);
$this->lang->load('datatable', $this->language);
$this->lang->load('calendar', $this->language);
$data['title'] = lang('hr_presence_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_presence_report');
$data['user_id'] = $id;
$this->load->model('leaves_model');
$this->load->model('users_model');
$this->load->model('dayoffs_model');
$this->load->model('contracts_model');
//Details about the employee
$employee = $this->users_model->get_users($id);
$data['employee_name'] = $employee['firstname'] . ' ' . $employee['lastname'];
$contract = $this->contracts_model->get_contracts($employee['contract']);
if (!empty($contract)) {
$data['contract_id'] = $contract['id'];
$data['contract_name'] = $contract['name'];
} else {
$data['contract_id'] = '';
$data['contract_name'] = '';
}
//Compute facts about dates and the selected month
if ($month == 0) {
$month = date('m', strtotime('last month'));
}
if ($year == 0) {
$year = date('Y', strtotime('last month'));
}
$total_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$start = sprintf('%d-%02d-01', $year, $month);
$lastDay = date("t", strtotime($start));
//last day of selected month
$end = sprintf('%d-%02d-%02d', $year, $month, $lastDay);
//Number of non working days during the selected month
$non_working_days = $this->dayoffs_model->sumdayoffs($employee['contract'], $start, $end);
$opened_days = $total_days - $non_working_days;
$data['month'] = $month;
$data['month_name'] = date('F', strtotime($start));
$data['year'] = $year;
$data['default_date'] = $start;
$data['total_days'] = $total_days;
$data['opened_days'] = $opened_days;
$data['non_working_days'] = $non_working_days;
//tabular view of the leaves
$data['linear'] = $this->leaves_model->linear($id, $month, $year, FALSE, FALSE, TRUE, FALSE);
$data['leave_duration'] = $this->leaves_model->monthly_leaves_duration($data['linear']);
$data['work_duration'] = $opened_days - $data['leave_duration'];
$data['leaves_detail'] = $this->leaves_model->monthly_leaves_by_type($data['linear']);
//List of accepted leave requests
$data['leaves'] = $this->leaves_model->get_accepted_leaves_in_dates($id, $start, $end);
//Leave balance of the employee
$data['employee_id'] = $id;
$refDate = new DateTime($end);
$data['refDate'] = $refDate->format(lang('global_date_format'));
$data['summary'] = $this->leaves_model->get_user_leaves_summary($id, FALSE, $end);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('hr/presence', $data);
$this->load->view('templates/footer');
}
开发者ID:john-mobivate,项目名称:jorani,代码行数:68,代码来源:hr.php
示例19: tabular
/**
* Display a global tabular calendar
* @param int $id identifier of the entity
* @param int $month Month number
* @param int $year Year number
* @param bool $children If TRUE, includes children entity, FALSE otherwise
* @author Benjamin BALET <[email protected]>
*/
public function tabular($id = -1, $month = 0, $year = 0, $children = TRUE)
{
if ($this->config->item('public_calendar') == TRUE && !$this->session->userdata('logged_in')) {
$this->load->library('polyglot');
$data['language'] = $this->config->item('language');
$data['language_code'] = $this->polyglot->language2code($data['language']);
$this->load->model('leaves_model');
$this->load->model('organization_model');
$data['tabular'] = $this->leaves_model->tabular($id, $month, $year, $children);
$data['entity'] = $id;
$data['month'] = $month;
$data['year'] = $year;
$data['children'] = $children;
$data['department'] = $this->organization_model->getName($id);
$data['title'] = lang('calendar_tabular_title');
$data['help'] = '';
$this->load->view('templates/header', $data);
$this->load->view('calendar/tabular', $data);
$this->load->view('templates/footer_simple');
} else {
setUserContext($this);
$this->lang->load('calendar', $this->language);
$this->auth->checkIfOperationIsAllowed('organization_calendar');
$data = getUserContext($this);
$this->load->model('leaves_model');
$this->load->model('organization_model');
$data['tabular'] = $this->leaves_model->tabular($id, $month, $year, $children);
$data['entity'] = $id;
$data['month'] = $month;
$data['year'] = $year;
$data['children'] = $children;
$data['department'] = $this->organization_model->getName($id);
$data['title'] = lang('calendar_tabular_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_calendar_tabular');
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('calendar/tabular', $data);
$this->load->view('templates/footer');
}
}
开发者ID:GIP-RECIA,项目名称:jorani,代码行数:48,代码来源:calendar.php
示例20: edit
/**
* Edit a leave request
* @param int $id Identifier of the leave request
* @author Benjamin BALET <[email protected]>
*/
public function edit($id)
{
$this->auth->checkIfOperationIsAllowed('edit_leaves');
$data = getUserContext($this);
$data['leave'] = $this->leaves_model->getLeaves($id);
//Check if exists
if (empty($data['leave'])) {
redirect('notfound');
}
//If the user is not its own manager and if the leave is
//already requested, the employee can't modify it
if (!$this->is_hr) {
if ($this->session->userdata('manager') != $this->user_id && $data['leave']['status'] != 1) {
if ($this->config->item('edit_rejected_requests') == FALSE || $data['leave']['status'] != 4) {
//Configuration switch that allows editing the rejected leave requests
log_message('error', 'User #' . $this->user_id . ' illegally tried to edit leave #' . $id);
$this->session->set_flashdata('msg', lang('leaves_edit_flash_msg_error'));
redirect('leaves');
}
}
}
//Admin
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = lang('leaves_edit_html_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_request_leave');
$data['id'] = $id;
$data['credit'] = 0;
$data['types'] = $this->types_model->getTypes();
foreach ($data['types'] as $type) {
if ($type['id'] == $data['leave']['type']) {
$data['credit'] = $this->leaves_model->getLeavesTypeBalanceForEmployee($data['leave']['employee'], $type['name']);
break;
}
}
$this->form_validation->set_rules('startdate', lang('leaves_edit_field_start'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('startdatetype', 'Start Date type', 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('enddate', lang('leaves_edit_field_end'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('enddatetype', 'End Date type', 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('duration', lang('leaves_edit_field_duration'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('type', lang('leaves_edit_field_type'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('cause', lang('leaves_edit_field_cause'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('status', lang('leaves_edit_field_status'), 'required|xss_clean|strip_tags');
if ($this->form_validation->run() === FALSE) {
$this->load->model('users_model');
$data['name'] = $this->users_model->getName($data['leave']['employee']);
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('leaves/edit', $data);
$this->load->view('templates/footer');
} else {
$this->leaves_model->updateLeaves($id);
//We don't use the return value
$this->session->set_flashdata('msg', lang('leaves_edit_flash_msg_success'));
//If the status is requested, send an email to the manager
if ($this->input->post('status') == 2) {
$this->sendMail($id);
}
if (isset($_GET['source'])) {
redire
|
请发表评论