File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/modules/cpd/controllers/Cpd.php
Back
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Cpd extends MY_Controller { function __construct() { parent::__construct(); $this->load->model('Cpd_model'); } function listing() { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('VIEW_ALL_CPD')) show_error($this->lang->line('no_permission_error')); $data = $this->data; $data['header'] = TRUE; $data['sidebar'] = TRUE; $data['_view'] = "cpd/all"; $data['quickbar'] = TRUE; $data['footer'] = TRUE; $data['top_menu'] = "cpd_top"; $data['sub_menu'] = "cpd_all"; $data['pagetitle'] = 'CPD '. $this->lang->line('reports'); $this->load->view('basetemplate', $data); } else { redirect("login"); } } function getUser($user, $year) { echo json_encode($this->Cpd_model->getUser($user,$year)); } function getAllCPDDT() { return $this->Cpd_model->getAllCPDDT(1); } function download() { $keys = array('dates','time','venue','organizer','domain','details','hours','username'); $data = array(); export_xls($keys,$data,'CPD Template'); } function export() { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('VIEW_ALL_CPD')) show_error($this->lang->line('no_permission_error')); $data = $this->Cpd_model->getAllCPD(1,0); if(!empty($data)) { $keys = array_keys($data[0]); $hide = array(0,1,1,1,1,1,1,1,0,1); export_xls($keys,$data,'CPD Report',$hide); } else { show_error('No data found'); } } else { redirect("login"); } } function import() { if($this->session->userdata("user_id")) { $config['upload_path'] = './files/import'; $config['allowed_types'] = 'csv|xlsx|xls'; $config['max_size'] = 10000; $config['max_width'] = 10024; $config['max_height'] = 10008; $this->load->library('upload', $config); if ( ! $this->upload->do_upload('cpd_import')) { $error = array('error' => $this->upload->display_errors()); $this->session->set_flashdata('error', $error); redirect($_SERVER['HTTP_REFERER']); } else { $data = $this->upload->data(); $file = $data['full_path']; //load the excel library $this->load->library('excel'); //read file from path $objPHPExcel = PHPExcel_IOFactory::load($file); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $exceldata=[]; for ($row = 2; $row <= $highestRow; $row++) { // Read a row of data into an array $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, TRUE); if($rowData[0][0]=="" && $rowData[0][1]=="" && $rowData[0][2]=="" && $rowData[0][3]=="" && $rowData[0][6]=="" && $rowData[0][7]=="") {} else { $exceldata[]=$rowData[0]; } } if(!empty($exceldata)) { $return = $this->Cpd_model->import($exceldata); if($return !="") { $this->session->set_flashdata('error', $return); } else { $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); } } else { $this->session->set_flashdata('error', $this->lang->line('action_performed_error')); } redirect($_SERVER['HTTP_REFERER']); } } else { redirect("login"); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings