File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/modules/students/controllers/Students.php
Back
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Students extends MY_Controller { function __construct() { parent::__construct(); $this->load->model('Students_model'); $this->load->model('Academic_year/Academic_year_model'); $this->load->model('Class_group/Class_group_model'); } function listing() { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_STUDENTS')) show_error($this->lang->line('no_permission_error')); $data = $this->data; $data['header'] = TRUE; $data['sidebar'] = TRUE; $data['_view'] = "listing"; $data['quickbar'] = TRUE; $data['footer'] = TRUE; $data['top_menu'] = "st_top"; $ac_years = $this->Academic_year_model->getAcademicYears(); $data['ac_years'] = $ac_years; foreach($ac_years as $year) { $classes[$year['id']] = $this->Class_group_model->getClasses($year['id']); } $data['classes'] = $classes; $data['sub_menu'] = "st_list"; $data['pagetitle'] = $this->lang->line('students'); $this->load->view('basetemplate', $data); } else { redirect("login"); } } function getUser($id) { echo json_encode($this->Students_model->getUser($id)); } function getUserByStudentNo($sno) { $student = $this->db->get_where('students',['student_no'=>$sno])->row(); echo json_encode($this->Students_model->getUser($student->id)); } function getProfileImg($student_no) { echo student_pic($student_no); } function editUser($id) { echo $this->Students_model->editUser($id,$this->input->post()); } function addUser() { echo $this->Students_model->addUser($this->input->post()); } function delete($id) { if($this->Students_model->deleteUser($id)){ redirect($_SERVER["HTTP_REFERER"]); } } function bulkAction() { if(!empty($this->input->post('ids'))) { $ids = explode(':',$this->input->post('ids')); foreach ($ids as $id) { if($this->input->post('action')=="active") { $this->Students_model->updateStatus($id,1); } if($this->input->post('action')=="inactive") { $this->Students_model->updateStatus($id,0); } } } echo json_encode(['return'=>'true']); } function bulk_delete() { if(!empty($this->input->post('ids'))) { $ids = explode(':',$this->input->post('ids')); foreach ($ids as $id) { $this->Students_model->deleteUser($id); } } echo json_encode(['return'=>'true']); } function getUsersDT() { return $this->Students_model->getUsersDT(); } function export() { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_STUDENTS')) show_error($this->lang->line('no_permission_error')); $data = $this->Students_model->getUsers(); if(!empty($data)) { $keys = array_keys($data[0]); $hide = array(0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1); export_xls($keys,$data,'Students Scores',$hide); } else { show_error('No data found'); } } else { redirect("login"); } } function download() { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_STUDENTS')) show_error($this->lang->line('no_permission_error')); $keys = array("username","email","name_chinese","name_english","gender","registration_no","student_no"); $data = array(); export_xls($keys,$data,'Students List Template'); } 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('students_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][4]=="" && $rowData[0][5]=="" && $rowData[0][6]=="") {} else { $exceldata[]=$rowData[0]; } } if(!empty($exceldata)) { $this->Students_model->import($exceldata); $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.37 |
proxy
|
phpinfo
|
Settings