Exemple #1
2
 /**
  * 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 <*****@*****.**>
  */
 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);
     }
 }
Exemple #2
2
 /**
  * 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 <*****@*****.**>
  */
 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');
         }
     }
 }
Exemple #3
0
 /**
  * Display the settings of the system (extract of config.php)
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
 }
Exemple #4
0
 /**
  * Landing page of the shipped-in balance report
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
 }
Exemple #5
0
 /**
  * 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 <*****@*****.**>
  */
 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);
 }
Exemple #6
0
 /**
  * Display a form that allows editing a leave type
  * @param int $id Identitier of the leave type
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
     }
 }
Exemple #7
0
 /**
  * Display a form that allows editing a leave type
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
     }
 }
 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');
 }
Exemple #9
0
 /**
  * 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 <*****@*****.**>
  */
 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);
     }
 }
Exemple #10
0
 /**
  * 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 <*****@*****.**>
  */
 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');
 }
Exemple #11
0
 /**
  * Display the list of all overtime requests submitted to you
  * Status is submitted
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
 }
Exemple #12
0
 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);
     }
 }
 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');
     }
 }
Exemple #14
0
 /**
  * Display the form / action Create a new user
  * @author Benjamin BALET <*****@*****.**>
  */
 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('*****@*****.**', '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');
     }
 }
Exemple #15
0
 /**
  * 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 <*****@*****.**>
  */
 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');
 }
Exemple #16
0
 /**
  * Edit a leave request
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
         }
     }
 }
Exemple #17
0
 /**
  * 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 <*****@*****.**>
  */
 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');
 }
Exemple #18
0
 /**
  * Display presence details for a given employee
  * @param int $id employee id
  * @author Benjamin BALET <*****@*****.**>
  */
 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');
 }
Exemple #19
0
 /**
  * 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 <*****@*****.**>
  */
 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');
     }
 }
Exemple #20
0
 /**
  * Edit a leave request
  * @param int $id Identifier of the leave request
  * @author Benjamin BALET <*****@*****.**>
  */
 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'])) {
             redirect($_GET['source']);
         } else {
             redirect('leaves');
         }
     }
 }
 public function leaves()
 {
     $this->auth->checkIfOperationIsAllowed('native_report_leaves');
     $data = getUserContext($this);
     $data['title'] = lang('reports_leaves_title');
     $data['help'] = '';
     $this->load->view('templates/header', $data);
     $this->load->view('menu/index', $data);
     $this->load->view('reports/leaves/index', $data);
     $this->load->view('templates/footer');
 }
Exemple #22
0
 /**
  * Returns a JSON string describing the organization structure.
  * In a format expected by jsTree component.
  * @author Benjamin BALET <*****@*****.**>
  */
 public function root()
 {
     expires_now();
     header("Content-Type: application/json");
     $id = $this->input->get('id', TRUE);
     if ($id == "#") {
         unset($id);
     }
     $this->auth->check_is_granted('organization_select');
     $data = getUserContext($this);
     header("Content-Type: application/json");
     $entities = $this->organization_model->get_all_entities();
     $msg = '[';
     foreach ($entities->result() as $entity) {
         $msg .= '{"id":"' . $entity->id . '",';
         if ($entity->parent_id == -1) {
             $msg .= '"parent":"#",';
         } else {
             $msg .= '"parent":"' . $entity->parent_id . '",';
         }
         $msg .= '"text":"' . $entity->name . '"';
         $msg .= '},';
     }
     $msg = rtrim($msg, ",");
     $msg .= ']';
     echo $msg;
 }
Exemple #23
0
 /**
  * Export the balance report into Excel
  * @author Benjamin BALET <*****@*****.**>
  */
 public function balance_export()
 {
     $this->auth->check_is_granted('native_report_balance');
     $data = getUserContext($this);
     $this->load->library('excel');
     $this->excel->setActiveSheetIndex(0);
     $this->excel->getActiveSheet()->setTitle(lang('reports_export_balance_title'));
     $this->load->model('leaves_model');
     $this->load->model('types_model');
     $this->load->model('organization_model');
     $result = array();
     $summary = array();
     $types = $this->types_model->get_types();
     $refDate = date("Y-m-d");
     if (isset($_GET['refDate']) && $_GET['refDate'] != NULL) {
         $refDate = date("Y-m-d", $_GET['refDate']);
     }
     $include_children = filter_var($_GET['children'], FILTER_VALIDATE_BOOLEAN);
     $users = $this->organization_model->all_employees($_GET['entity'], $include_children);
     foreach ($users as $user) {
         $result[$user->id]['identifier'] = $user->identifier;
         $result[$user->id]['firstname'] = $user->firstname;
         $result[$user->id]['lastname'] = $user->lastname;
         $result[$user->id]['datehired'] = $user->datehired;
         $result[$user->id]['department'] = $user->department;
         $result[$user->id]['position'] = $user->position;
         $result[$user->id]['contract'] = $user->contract;
         //Init type columns
         foreach ($types as $type) {
             $result[$user->id][$type['name']] = '';
         }
         $summary = $this->leaves_model->get_user_leaves_summary($user->id, TRUE, $refDate);
         if (count($summary) > 0) {
             foreach ($summary as $key => $value) {
                 $result[$user->id][$key] = $value[1] - $value[0];
             }
         }
     }
     $max = 0;
     $line = 2;
     foreach ($result as $row) {
         $index = 1;
         foreach ($row as $key => $value) {
             if ($line == 2) {
                 $colidx = $this->excel->column_name($index) . '1';
                 if (lang($key) == '') {
                     $this->excel->getActiveSheet()->setCellValue($colidx, $key);
                 } else {
                     $this->excel->getActiveSheet()->setCellValue($colidx, lang($key));
                 }
                 $max++;
             }
             $colidx = $this->excel->column_name($index) . $line;
             $this->excel->getActiveSheet()->setCellValue($colidx, $value);
             $index++;
         }
         $line++;
     }
     $colidx = $this->excel->column_name($max) . '1';
     $this->excel->getActiveSheet()->getStyle('A1:' . $colidx)->getFont()->setBold(true);
     $this->excel->getActiveSheet()->getStyle('A1:' . $colidx)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $filename = 'leave_balance.xls';
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     $objWriter->save('php://output');
 }
Exemple #24
0
 /**
  * Create a leave request in behalf of a collaborator
  * @param int $id Identifier of the employee
  * @author Benjamin BALET <*****@*****.**>
  */
 public function createleave($id)
 {
     $this->lang->load('hr', $this->language);
     $this->load->model('users_model');
     $employee = $this->users_model->getUsers($id);
     if ($this->user_id != $employee['manager'] && $this->is_hr === FALSE) {
         log_message('error', 'User #' . $this->user_id . ' illegally tried to access to collaborators/leave/create  #' . $id);
         $this->session->set_flashdata('msg', lang('requests_summary_flash_msg_forbidden'));
         redirect('leaves');
     } else {
         $data = getUserContext($this);
         $this->load->helper('form');
         $this->load->library('form_validation');
         $data['title'] = lang('hr_leaves_create_title');
         $data['form_action'] = 'requests/createleave/' . $id;
         $data['source'] = 'requests/collaborators';
         $data['employee'] = $id;
         $this->form_validation->set_rules('startdate', lang('hr_leaves_create_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_create_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('hr_leaves_create_field_duration'), 'required|xss_clean|strip_tags');
         $this->form_validation->set_rules('type', lang('hr_leaves_create_field_type'), 'required|xss_clean|strip_tags');
         $this->form_validation->set_rules('cause', lang('hr_leaves_create_field_cause'), 'xss_clean|strip_tags');
         $this->form_validation->set_rules('status', lang('hr_leaves_create_field_status'), 'required|xss_clean|strip_tags');
         $data['credit'] = 0;
         if ($this->form_validation->run() === FALSE) {
             $this->load->model('types_model');
             $data['types'] = $this->types_model->getTypes();
             foreach ($data['types'] as $type) {
                 if ($type['id'] == 0) {
                     $data['credit'] = $this->leaves_model->getLeavesTypeBalanceForEmployee($id, $type['name']);
                     break;
                 }
             }
             $this->load->model('users_model');
             $data['name'] = $this->users_model->getName($id);
             $this->load->view('templates/header', $data);
             $this->load->view('menu/index', $data);
             $this->load->view('hr/createleave');
             $this->load->view('templates/footer');
         } else {
             $this->leaves_model->setLeaves($id);
             //We don't use the return value
             $this->session->set_flashdata('msg', lang('hr_leaves_create_flash_msg_success'));
             //No mail is sent, because the manager would set the leave status to accepted
             redirect('requests/collaborators');
         }
     }
 }
Exemple #25
0
 /**
  * Display presence details for a given employee
  * @param string $source page calling the report (employees, collaborators)
  * @param int $id employee id
  * @param int $month Month number or 0 for last month (default)
  * @param int $year Year number or 0 for current year (default)
  * @author Benjamin BALET <*****@*****.**>
  */
 public function presence($source, $id, $month = 0, $year = 0)
 {
     if ($source == 'collaborators') {
         $this->auth->checkIfOperationIsAllowed('list_collaborators');
     }
     if ($source == 'employees') {
         $this->auth->checkIfOperationIsAllowed('list_employees');
     }
     $data = getUserContext($this);
     if ($source == 'collaborators') {
         $data['source'] = 'collaborators';
     }
     if ($source == 'employees') {
         $data['source'] = 'employees';
     }
     $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->getUsers($id);
     if ($this->user_id != $employee['manager'] && $this->is_hr === FALSE) {
         log_message('error', 'User #' . $this->user_id . ' illegally tried to access to hr/presence  #' . $id);
         $this->session->set_flashdata('msg', sprintf(lang('global_msg_error_forbidden'), 'hr/presence'));
         redirect('leaves');
     }
     $data['employee_name'] = $employee['firstname'] . ' ' . $employee['lastname'];
     $contract = $this->contracts_model->getContracts($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->lengthDaysOffBetweenDates($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->monthlyLeavesDuration($data['linear']);
     $data['work_duration'] = $opened_days - $data['leave_duration'];
     $data['leaves_detail'] = $this->leaves_model->monthlyLeavesByType($data['linear']);
     //List of accepted leave requests
     $data['leaves'] = $this->leaves_model->getAcceptedLeavesBetweenDates($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->getLeaveBalanceForEmployee($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');
 }
Exemple #26
0
 /**
  * Ajax endpoint: Returns a JSON string describing the organization structure.
  * In a format expected by jsTree component.
  * @author Benjamin BALET <*****@*****.**>
  */
 public function root()
 {
     expires_now();
     header("Content-Type: application/json");
     if ($this->config->item('public_calendar') == TRUE && !$this->session->userdata('logged_in')) {
         //nop
     } else {
         setUserContext($this);
         $this->auth->check_is_granted('organization_select');
         $data = getUserContext($this);
     }
     $id = $this->input->get('id', TRUE);
     if ($id == "#") {
         unset($id);
     }
     $this->load->model('organization_model');
     $entities = $this->organization_model->get_all_entities();
     $msg = '[';
     foreach ($entities->result() as $entity) {
         $msg .= '{"id":"' . $entity->id . '",';
         if ($entity->parent_id == -1) {
             $msg .= '"parent":"#",';
         } else {
             $msg .= '"parent":"' . $entity->parent_id . '",';
         }
         $msg .= '"text":"' . $entity->name . '"';
         $msg .= '},';
     }
     $msg = rtrim($msg, ",");
     $msg .= ']';
     echo $msg;
 }
Exemple #27
0
 /**
  * Leave balance report limited to the subordinates of the connected manager
  * Status is submitted or accepted/rejected depending on the filter parameter.
  * @param int $dateTmp (Timestamp) date of report
  * @author Benjamin BALET <*****@*****.**>
  */
 public function balance($dateTmp = NULL)
 {
     $this->auth->checkIfOperationIsAllowed('list_requests');
     $data = getUserContext($this);
     $this->lang->load('datatable', $this->language);
     $data['title'] = lang('requests_balance_title');
     $data['help'] = $this->help->create_help_link('global_link_doc_page_leave_balance_report');
     if ($dateTmp === NULL) {
         $refDate = date("Y-m-d");
         $data['isDefault'] = 1;
     } else {
         $refDate = date("Y-m-d", $dateTmp);
         $data['isDefault'] = 0;
     }
     $data['refDate'] = $refDate;
     $this->load->model('types_model');
     $data['types'] = $this->types_model->getTypes();
     $result = array();
     $this->load->model('users_model');
     $users = $this->users_model->getCollaboratorsOfManager($this->user_id);
     foreach ($users as $user) {
         $result[$user['id']]['identifier'] = $user['identifier'];
         $result[$user['id']]['firstname'] = $user['firstname'];
         $result[$user['id']]['lastname'] = $user['lastname'];
         $date = new DateTime($user['datehired']);
         $result[$user['id']]['datehired'] = $date->format(lang('global_date_format'));
         $result[$user['id']]['position'] = $user['position'];
         foreach ($data['types'] as $type) {
             $result[$user['id']][$type['name']] = '';
         }
         $summary = $this->leaves_model->getLeaveBalanceForEmployee($user['id'], TRUE, $refDate);
         if (count($summary) > 0) {
             foreach ($summary as $key => $value) {
                 $result[$user['id']][$key] = round($value[1] - $value[0], 3, PHP_ROUND_HALF_DOWN);
             }
         }
     }
     $data['result'] = $result;
     $this->load->view('templates/header', $data);
     $this->load->view('menu/index', $data);
     $this->load->view('requests/balance', $data);
     $this->load->view('templates/footer');
 }
Exemple #28
0
 public function edit($id)
 {
     $this->auth->checkIfOperationIsAllowed('edit_extra');
     $data = getUserContext($this);
     $data['extra'] = $this->overtime_model->getExtras($id);
     if (empty($data['extra'])) {
         redirect('notfound');
     }
     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');
         }
     }
     $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->getName($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 {
         $this->overtime_model->updateExtra($id);
         $this->session->set_flashdata('msg', lang('extra_edit_msg_success'));
         if ($this->input->post('status') == 2) {
             $this->sendMail($id);
         }
         if (isset($_GET['source'])) {
             redirect($_GET['source']);
         } else {
             redirect('extra');
         }
     }
 }
Exemple #29
-1
 /**
  * Import a list of users (XLS, XLSX or CSV) file.
  * It can be used to mass edit the users
  * @author Benjamin BALET <*****@*****.**>
  */
 public function import()
 {
     $this->auth->checkIfOperationIsAllowed('list_users');
     $data = getUserContext($this);
     $config['upload_path'] = './uploads/';
     $config['allowed_types'] = 'xls|xlsx|csv';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         $error = array('error' => $this->upload->display_errors());
         $this->load->view('upload_form', $error);
         //redirect index ?
     } else {
         $data = array('upload_data' => $this->upload->data());
         $messages = array();
         array_push($messages, 'Try to detect the file format');
         //TODO : suggest template in upload popup
         //TODO: can we read from buffer?
         $valid = false;
         $types = array('Excel2007', 'Excel5');
         foreach ($types as $type) {
             $reader = PHPExcel_IOFactory::createReader($type);
             //$objPHPExcel = PHPExcel_IOFactory::load($inputFile);
             //Identify
             //http://stackoverflow.com/questions/9695695/how-to-use-phpexcel-to-read-data-and-insert-into-database
             //Below is can read method
             //http://stackoverflow.com/questions/13626678/phpexcel-how-to-check-whether-a-xls-file-is-valid-or-not
             if ($reader->canRead($file_path)) {
                 array_push($messages, 'File format detected: ' . $type);
                 $valid = true;
                 break;
             }
         }
         if ($valid) {
             // TODO: load file
             // e.g. PHPExcel_IOFactory::load($file_path)
         } else {
             array_push($messages, 'Unable to detect the file format');
         }
         $data['title'] = lang('users_index_title');
         $data['help'] = $this->help->create_help_link('global_link_doc_page_list_users');
         $data['messages'] = $messages;
         $this->load->view('templates/header', $data);
         $this->load->view('menu/index', $data);
         $this->load->view('users/import', $data);
         $this->load->view('templates/footer');
     }
 }
Exemple #30
-2
 /**
  * Displays a page that allows you to :
  * 1. Select a list of employees (using organization tree).
  * 2. Credit entitled days to them.
  * @author Benjamin BALET <*****@*****.**>
  */
 public function organization()
 {
     setUserContext($this);
     $this->auth->checkIfOperationIsAllowed('entitleddays_user');
     $data = getUserContext($this);
     $this->lang->load('organization', $this->language);
     $this->lang->load('datatable', $this->language);
     $this->lang->load('treeview', $this->language);
     $data['title'] = lang('organization_index_title');
     $data['help'] = '';
     $this->load->view('templates/header', $data);
     $this->load->view('menu/index', $data);
     $this->load->view('entitleddays/organization', $data);
     $this->load->view('templates/footer');
 }