File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/modules/class_group/controllers/Arrangement.php
Back
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Arrangement extends MY_Controller { function __construct() { parent::__construct(); $this->load->model('core/User_model'); $this->load->model('Arrangement_model'); $this->load->model('Academic_year/Academic_year_model'); $this->load->model('Class_group/Class_group_model'); $this->load->model('Subject/Subject_model'); $this->load->model('Academic_year/Term_model'); } function teacher($ay_id=0) { if($this->session->userdata("user_id")) { //if(!$this->acl->hasPermission('DELETE_ALL_INVENTORY')) // show_error($this->lang->line('no_permission_error')); $data = $this->data; if($ay_id==0) $ay_id = $this->Academic_year_model->getCurrentAcademicYear()['id']; $data['ay_id'] = $ay_id; $data['terms'] = $this->Term_model->getTerms($ay_id); $data['classes'] = $this->Arrangement_model->getTeachersGroup($ay_id); $data['ac_years'] = $this->Academic_year_model->getAcademicYears(); $data['header'] = TRUE; $data['sidebar'] = TRUE; $data['_view'] = "arrangement_teacher"; $data['quickbar'] = TRUE; $data['footer'] = TRUE; $data['top_menu'] = "class_group"; $data['sub_menu'] = "cg_tea_arrangement"; $data['subjects'] = $this->Subject_model->getSubjects(); $data['pagetitle'] = ts('teacher group',1); $this->load->view('basetemplate', $data); } else { redirect("login"); } } function teacher_import($ay_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); $import = import_xls('class','./files/tmp_upload',array(1,1,1)); //print_r($import);exit; if(empty($import['error'])) { if($this->Arrangement_model->importTeacherGroup($import['data'],$ay_id)) $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); } else { $err_msg = ''; if(!empty($import['error']['upload'])) { $err_msg .= $import['error']['upload'] . PHP_EOL; } $empty = ''; if(!empty($import['error']['empty'])) { foreach($import['error']['empty'] as $e_row => $e_column) { $empty .= 'row ' . $e_row . ' of column ' . $e_column . ' cannot be empty. ' . PHP_EOL; } } $err_msg .= $empty; $this->session->set_flashdata('error', $err_msg); } redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function teacher_del($class_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); if($this->Arrangement_model->deleteTeacher($class_id)) $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); else { $this->session->set_flashdata('error', 'Error'); } redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function teacher_add($ay_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); if($this->Arrangement_model->addTeacher($this->input->post(),$ay_id)) $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); else { $this->session->set_flashdata('error', 'Error'); } redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function teacher_edit($ay_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); if($this->Arrangement_model->editTeacher($this->input->post(),$ay_id)) $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); else { $this->session->set_flashdata('error', 'Error'); } redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function teacher_preview() { $import = import_xls('class','./files/tmp_upload',array(1,1,1)); $err_msg = ''; if(!empty($import['error']['upload'])) { echo '<h3 style="color:red">' . $import['error']['upload'] . '</h3>'; } echo '<table class="table table-striped table-bordered table-hover" id="data_table" data-always-visible="1">'; echo '<tr>'; foreach($import['header'] as $h_row) { echo '<th>' . $h_row . '</th>'; } echo '</tr>'; //print_r($import['data']); foreach($import['data'] as $n_row=>$row) { echo '<tr>'; foreach($row as $n_col=>$col) { if(!empty($import['error']['empty'][$n_row+1]) && $import['error']['empty'][$n_row+1]==$n_col+1) { echo '<td style="color:red">EMPTY</td>'; } else { if($n_col===0 && $col!=''){ $subject_info=checkUnique(array('field'=>'shortname_eng','shortname_eng'=>$col),'tb_subjects'); if(!$subject_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='0'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==1 && $col!=''){ $class_info=checkUnique(array('field'=>'title','title'=>$col),'tb_class'); if(!$class_info){ echo '<td><span style="color:orange">[NEW RECORD] </span>'.$col.'</td>'; //$import['error']['repeat'][]='1'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==2 && $col!=''){ $no_user=0; $users = explode(',',$col); foreach ($users as $user) { $user_info = checkUnique(array('field'=>'username','username'=>$user),'users'); if(!$user_info){ $no_user++; } } if($no_user>0){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='1'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==3 && $col!=''){ $term_info=checkUnique(array('field'=>'name','name'=>$col),'ay_terms'); if(!$term_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='0'; }else{ echo '<td>'.$col.'</td>'; } }else{ if($col==NULL){ echo '<td style="color:red">EMPTY</td>'; }else{ echo '<td>'.$col.'</td>'; } } } } echo '</tr>'; } echo '</table>'; if(!empty($import['error'])) echo '<input id="duplicate" name="duplicate" type="hidden" value="1" />'; } function teacher_export($ay_id) { if($this->session->userdata("user_id")) { $data = $this->Arrangement_model->getTeachersGroup($ay_id); $keys = array('','','','Subject','Class','','Teachers','','Term'); $hide = array(0,0,0,1,1,0,1,0,1); if(!empty($data)) { export_xls($keys,$data,'Teacher Arrangement',$hide); } else { export_xls($keys,array(),'Teacher Arrangement',$hide); } } else { redirect("login"); } } function student($ay_id=0) { if($this->session->userdata("user_id")) { //if(!$this->acl->hasPermission('DELETE_ALL_INVENTORY')) // show_error($this->lang->line('no_permission_error')); $data = $this->data; if($ay_id==0) $ay_id = $this->Academic_year_model->getCurrentAcademicYear()['id']; $data['ay_id'] = $ay_id; $data['ac_years'] = $this->Academic_year_model->getAcademicYears(); $data['header'] = TRUE; $data['sidebar'] = TRUE; $data['_view'] = "arrangement_student"; $data['quickbar'] = TRUE; $data['footer'] = TRUE; $data['top_menu'] = "class_group"; $data['sub_menu'] = "cg_stu_arrangement"; $data['classes'] = $this->Class_group_model->getClassesOnly($ay_id); $data['groups'] = $this->Class_group_model->getGroupsOnly($ay_id); $data['terms'] = $this->Term_model->getTerms($ay_id); $data['pagetitle'] = $this->lang->line('student') . ' ' . $this->lang->line('class_group'); $this->load->view('basetemplate', $data); } else { redirect("login"); } } function getStudent($id,$ay_id) { if($this->session->userdata("user_id")) { //if(!$this->acl->hasPermission('DELETE_ALL_INVENTORY')) // show_error($this->lang->line('no_permission_error')); echo json_encode($this->Arrangement_model->getStudent($id,$ay_id)); } } function getStudentDT($ay_id) { if($this->session->userdata("user_id")) { //if(!$this->acl->hasPermission('DELETE_ALL_INVENTORY')) // show_error($this->lang->line('no_permission_error')); $this->Arrangement_model->getStudentsDT($ay_id); } } function student_import_class($ay_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); $import = import_xls('class','./files/tmp_upload',array(1,1)); //print_r($import);exit; if(empty($import['error'])) { $err_msg = $this->Arrangement_model->importStudentClass($import['data'],$ay_id); } else { $err_msg = ''; if(!empty($import['error']['upload'])) { $err_msg .= $import['error']['upload'] . PHP_EOL; } $empty = ''; if(!empty($import['error']['empty'])) { foreach($import['error']['empty'] as $e_row => $e_column) { $empty .= 'row ' . $e_row . ' of column ' . $e_column . ' cannot be empty. ' . PHP_EOL; } } $err_msg .= $empty; $this->session->set_flashdata('error', $err_msg); } if($err_msg=='') { $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); } else { $this->session->set_flashdata('error', $err_msg); } redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function student_import_group($ay_id) { if($this->session->userdata("user_id")) { if(!$this->acl->hasPermission('MANAGE_CLASS_GROUP')) show_error($this->lang->line('no_permission_error')); $import = import_xls('class','./files/tmp_upload',array(1,1)); if(empty($import['error'])) { $err_msg = $this->Arrangement_model->importStudentGroup($import['data'],$ay_id); echo $err_msg; } else { $err_msg = ''; if(!empty($import['error']['upload'])) { $err_msg .= $import['error']['upload'] . PHP_EOL; } $empty = ''; if(!empty($import['error']['empty'])) { foreach($import['error']['empty'] as $e_row => $e_column) { $empty .= 'row ' . $e_row . ' of column ' . $e_column . ' cannot be empty. ' . PHP_EOL; } } $err_msg .= $empty; } if($err_msg=="") $this->session->set_flashdata('success', $this->lang->line('action_performed_success')); else $this->session->set_flashdata('error', $err_msg); redirect($_SERVER['HTTP_REFERER']); }else { redirect("login"); } } function student_import_group_preview($ay_id) { $import = import_xls('class','./files/tmp_upload',array(1,1,1)); //print_r($import);exit; if(empty($import)) echo '<input id="duplicate" name="duplicate" type="hidden" value="0" />'; else { $err_msg = ''; if(!empty($import['error']['upload'])) { echo '<h3 style="color:red">' . $import['error']['upload'] . '</h3>'; } echo '<table class="table table-striped table-bordered table-hover" id="data_table" data-always-visible="1">'; echo '<tr>'; foreach($import['header'] as $h_row) { echo '<th>' . $h_row . '</th>'; } echo '</tr>'; //print_r($import['data']); foreach($import['data'] as $n_row=>$row) { echo '<tr>'; foreach($row as $n_col=>$col) { if(!empty($import['error']['empty'][$n_row+1]) && $import['error']['empty'][$n_row+1]==$n_col+1) { echo '<td style="color:red">EMPTY</td>'; } else { if($n_col===0 && $col!=''){ $student_info=checkUnique(array('field'=>'student_no','student_no'=>$col),'students'); if(!$student_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='0'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==1 && $col!=''){ $class_info=checkUnique(array('field'=>'title','title'=>$col),'tb_class'); if(!$class_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='1'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==2 && $col!=''){ $subject_info = checkUnique(array('field'=>'shortname_eng','shortname_eng'=>$col),'tb_subjects'); if(!$subject_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='2'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==3 && $col!=''){ $subject_info = checkUnique(array('field'=>array('name','ay_id'),'value'=>array($col,$ay_id)),'ay_terms'); if(!$subject_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='2'; }else{ echo '<td>'.$col.'</td>'; } }else{ if($col==NULL){ echo '<td style="color:red">EMPTY</td>'; }else{ echo '<td>'.$col.'</td>'; } } } } echo '</tr>'; } echo '</table>'; if(!empty($import['error'])) echo '<input id="duplicategroup" name="duplicategroup" type="hidden" value="1" />'; } } function student_import_class_preview($ay_id) { $import = import_xls('class','./files/tmp_upload',array(1,1,1)); //print_r($import);exit; if(empty($import)) echo '<input id="duplicate" name="duplicate" type="hidden" value="0" />'; else { $err_msg = ''; if(!empty($import['error']['upload'])) { echo '<h3 style="color:red">' . $import['error']['upload'] . '</h3>'; } echo '<table class="table table-striped table-bordered table-hover" id="data_table" data-always-visible="1">'; echo '<tr>'; foreach($import['header'] as $h_row) { echo '<th>' . $h_row . '</th>'; } echo '</tr>'; //print_r($import['data']); foreach($import['data'] as $n_row=>$row) { echo '<tr>'; foreach($row as $n_col=>$col) { if(!empty($import['error']['empty'][$n_row+1]) && $import['error']['empty'][$n_row+1]==$n_col+1) { echo '<td style="color:red">EMPTY</td>'; } else { if($n_col===0 && $col!=''){ $student_info=checkUnique(array('field'=>'student_no','student_no'=>$col),'students'); if(!$student_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='0'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==1 && $col!=''){ $class_info = checkUnique(array('field'=>['title','ac_year_id'],'value'=>[$col,$ay_id]),'tb_class'); if(!$class_info){ echo '<td><span style="color:red">[RECORD DOES NOT EXISTS]</span>'.$col.'</td>'; $import['error']['repeat'][]='1'; }else{ echo '<td>'.$col.'</td>'; } }else if($n_col==2 && $col!=''){ $class_info = checkUnique(array('field'=>['title','ac_year_id'],'value'=>[$row[$n_col-1],$ay_id]),'tb_class'); $student_class_info = checkUnique(array('field'=>array('class_no','class_id'),'value'=>array($col,$class_info['id'])),'student_class'); if($student_class_info){ echo '<td><span style="color:red">[DUPLICATE CLASS / CLASS NO COMBO (id: '.$class_info['id'].')]</span>'.$col.'</td>'; $import['error']['repeat'][]='2'; }else{ echo '<td>'.$col.'</td>'; } }else{ if($col==NULL){ echo '<td style="color:red">EMPTY</td>'; }else{ echo '<td>'.$col.'</td>'; } } } } echo '</tr>'; } echo '</table>'; if(!empty($import['error'])) echo '<input id="duplicate" name="duplicate" type="hidden" value="1" />'; } } function student_class_export($ay_id) { if($this->session->userdata("user_id")) { $data = $this->Arrangement_model->getstudentsClass($ay_id); $keys = array('Student no','Class','Class No'); if(!empty($data)) { export_xls($keys,$data,'Student Class'); } else { export_xls($keys,array(),'Student Class'); } } else { redirect("login"); } } function student_group_export($ay_id) { if($this->session->userdata("user_id")) { $data = $this->Arrangement_model->getstudentsGroup($ay_id); $keys = array('Student no','Class','Subject','Term'); if(!empty($data)) { export_xls($keys,$data,'Student Group'); } else { export_xls($keys,array(),'Student Group'); } } else { redirect("login"); } } }
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.21 |
proxy
|
phpinfo
|
Settings