?
Current Path : /home1/savoy/www/savoyglobal.net/koaladraft/application/controllers/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyglobal.net/koaladraft/application/controllers/master.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Master extends MY_Controller { public function __construct() { parent::__construct(); $this->load->model('mastermodel'); $this->load->model('settingsmodel'); $this->load->model('studentmodel'); } public function index($menuid = "", $modid = "", $upload = 0, $msg = "") { $ret = $this->mastermodel->chk_url_permission($menuid); if ($ret != 1) { $menuid = ""; $modid = ""; } if (empty($modid)) { $data['modname'] = 'home'; $data['module_title'] = 'Home'; } else { $mod_id = $this->mastermodel->get_data('module', $modid, 'module_id', 'sort'); foreach ($mod_id as $id) { $modname = $id['module_name']; $module_title = $id['module_title']; } $data['modname'] = $modname; $data['module_title'] = $module_title; } if (empty($menuid)) { $tart = 'index'; $data['menuname'] = ''; $data['men_id'] = $menuid; $data['modulelist'] = $this->mastermodel->getmoduledatamaster(); } else { $tar = $this->mastermodel->get_data('menu', $menuid, 'menu_id'); foreach ($tar as $target) { $tart = $target['target']; $data['menuname'] = $target['caption']; } } $_SESSION['searchdata'] = ""; $_SESSION['current_mode'] = $menuid; $_SESSION['current_module'] = $modid; $_SESSION['modename'] = $data['modname']; $_SESSION['menuname'] = $data['menuname']; $_SESSION['module_title'] = $data['module_title']; $data['modules'] = $this->mastermodel->build_module(); $data['submenuchild'] = $this->mastermodel->get_sub_menu_child(); $data['menus'] = $this->mastermodel->build_menu($modid); if ($data['modname'] == 'home') $this->load->view($data['modname'] . '/' . $tart . '', $data); else $this->load->view($tart, $data); if (isset($_SESSION['upload'])) { $upload = $_SESSION['upload']; $_SESSION['upload'] = 0; } if ($upload == 1) { $data['msg'] = 'Record Added Successfully!'; $this->load->view('message', $data); } } public function view($folder, $page) { $this->load->view($folder . '/' . $page); } function viewinmastersearch($modelfunction, $page, $pagenum) { $output = $this->mastermodel->$modelfunction($pagenum); $data['viewinfo'] = $output['results']; $data['pagenum'] = $pagenum; $this->load->view('master/' . $page . '', $data); } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if ($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } function get_TeacherAndCourse($class_name_id) { $class_name = $this->mastermodel->get_data_srow('class_name', $class_name_id, 'class_name_id'); $exam = $this->mastermodel->get_data_joined('exammaster', 'course', 'course_id', 'course_id', $class_name->course_id, 'course.course_id'); $opt = '<option value="">Select</option>'; foreach ($exam as $list) { $opt.= "<option value='" . $list['exammaster_id'] . "'>" . $list['exammaster_name'] . "</option>"; } $data = array(); $data['option'] = $opt; $data['course'] = $this->mastermodel->get_single_field_value('course', 'course_name', 'course_id', $class_name->course_id); $data['teacher'] = $this->mastermodel->get_single_field_value('employee', 'employee_name', 'employee_id', $class_name->teacher_id); echo json_encode($data); } function checkexistencearray($table, $field, $value) { if ($this->mastermodel->checkexistencearray($table, $field, $value) > 0) { echo 1; } else echo 0; } function checkexistence($table, $field, $value) { if ($this->mastermodel->checkexistence($table, $field, $value) > 0) { echo 1; } else echo 0; } function upload_form($controller, $controller_function, $master_id, $return_function, $return_page) { $data = array(); $data['master_id'] = $master_id; $data['return_function'] = $return_function; $data['controller'] = $controller; $data['controller_function'] = $controller_function; $data['return_page'] = $return_page; $this->load->view('master/upload_form', $data); } function submit_upload() { $data = array(); $postdata = $this->get_post_values(); $path = './assets/uploads'; $_FILES["upload_file"]["name"] = date('Y-m-d-h-i-s') . $_FILES["upload_file"]["name"]; if (!is_file("$path" . $_FILES["upload_file"]["name"])) { if (!(move_uploaded_file($_FILES["upload_file"]["tmp_name"], $path . "/" . $_FILES["upload_file"]["name"]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES["upload_file"]["name"]; $data = $this->mastermodel->upload_file($postdata); $data['msg'] = "File Uploaded successfully!"; } } else { $data['msg'] = "File already exists"; } redirect("master/index/" . $_SESSION['current_mode'] . '/' . $_SESSION['current_module'] . '/1'); } function submit_nursery_upload() { $data = array(); $postdata = $this->get_post_values(); if($_FILES["file_location"]["name"] != '') { $path = './assets/uploads/nursery'; $_FILES["file_location"]["name"] = date('Y-m-d-h-i-s') . $_FILES["file_location"]["name"]; if (!is_file("$path" . $_FILES["file_location"]["name"])) { if (!(move_uploaded_file($_FILES["file_location"]["tmp_name"], $path . "/" . $_FILES["file_location"]["name"]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES["file_location"]["name"]; $data = $this->mastermodel->upload_nursery_file($postdata); $data['msg'] = "File Uploaded successfully!"; } } else { $data['msg'] = "File already exists"; } } else { $postdata['file_location'] = ''; $data = $this->mastermodel->upload_nursery_file($postdata); $data['msg'] = "Record added successfully!"; } redirect("master/index/" . $_SESSION['current_mode'] . '/' . $_SESSION['current_module'] . '/1'); } function update_nursery_upload() { $data = array(); $postdata = $this->get_post_values(); if($_FILES["file_location"]["name"] != '') { $path = './assets/uploads/nursery'; $_FILES["file_location"]["name"] = date('Y-m-d-h-i-s') . $_FILES["file_location"]["name"]; if (!is_file("$path" . $_FILES["file_location"]["name"])) { if (!(move_uploaded_file($_FILES["file_location"]["tmp_name"], $path . "/" . $_FILES["file_location"]["name"]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES["file_location"]["name"]; $data = $this->mastermodel->update_nursery_upload($postdata); $data['msg'] = "File Uploaded successfully!"; } } else { $data['msg'] = "File already exists"; } } else { $postdata['file_location'] = ''; $data = $this->mastermodel->update_nursery_upload($postdata); $data['msg'] = "Record updated successfully!"; } redirect("master/index/" . $_SESSION['current_mode'] . '/' . $_SESSION['current_module'] . '/1'); } function deletedata($table, $id, $field) { $data = array(); $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 3); if (!$perm) $data['msg'] = "Permission Denied"; else $data = $this->mastermodel->deletedata($table, $id, $field); $arr = array('msg' => $data['msg'], 'res' => $data['res']); echo json_encode($arr); } function addformdisplay($page, $directory, $return_page = '') { $data = array(); $data['pagenum'] = 1; $data['return_page'] = $return_page; $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 1); if (!$perm) { $data['msg'] = "Permission Denied"; $this->load->view('message', $data); } else { $this->load->view('' . $directory . '/' . $page . '', $data); } } function addinmaster($modelfunction, $page) { $data = array(); $postdata = $this->get_post_values(); $data = $this->mastermodel->$modelfunction($postdata); $this->viewinmastersearch($data['resfunction'], $page, $_SESSION['pagenum']); $this->load->view('message', $data); } function single_page($id, $table, $field, $page, $alert_id = '') { if ($_SESSION['current_mode'] != "") { $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 0); } else { $perm = 1; } if (!$perm) { $data['msg'] = "Permission Denied"; $this->load->view('message', $data); } else { $data['viewinfo'] = $this->mastermodel->get_data_srow($table, $id, $field); $data['id'] = $id; $data['alert_id'] = $alert_id; $this->load->view('master/' . $page, $data); } } function edit_page($id, $table, $field, $page) { if ($_SESSION['current_mode'] != "") { $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 2); } else { $perm = 1; } if (!$perm) { $data['msg'] = "Permission Denied"; $this->load->view('message', $data); } else { $data['viewinfo'] = $this->mastermodel->get_data_srow($table, $id, $field); $data['id'] = $id; $this->load->view('master/' . $page, $data); } } function edit_course($id, $table, $field, $page) { if ($_SESSION['current_mode'] != "") { $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 2); } else { $perm = 1; } if (!$perm) { $data['msg'] = "Permission Denied"; $this->load->view('message', $data); } else { $data['viewinfo'] = $this->mastermodel->get_data_srow($table, $id, $field); $data['details'] = $this->mastermodel->get_data('course_subject', $id, $field); $data['id'] = $id; $this->load->view('master/' . $page, $data); } } function single_contract($id, $table, $field, $page) { if ($_SESSION['current_mode'] != "") { $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 0); } else { $perm = 1; } if (!$perm) { $data['msg'] = "Permission Denied"; $this->load->view('message', $data); } else { $data['viewinfo'] = $this->mastermodel->get_data_srow($table, $id, $field); $data['details'] = $this->mastermodel->get_data('contracting_company_details', $id, $field); $data['id'] = $id; $this->load->view('master/' . $page, $data); } } function checkid($id) { $cod = $this->mastermodel->checkexistence('teacher_subject', 'course_subject_id', $id); $perf = $this->mastermodel->checkexistence('student_assessment_details', 'course_subject_id', $id); if ($cod == 0 && $perf == 0) { $del = $this->mastermodel->deletsub($id); $data1 = 0; } else { $data1 = 1; } echo $data1; } function checkcodeexistence($code) { $cod = $this->mastermodel->checkexistence('course', 'course_code', $code); echo $cod; } function load_code($id) { $cod = $this->mastermodel->get_single_field_value('course', 'course_code', 'course_id', $id); echo $cod; } function autosuggeststudent() { $q = strtolower($_POST["q"]); if (!$q) return; $student = $this->mastermodel->getdatas('student', 'student_id', 'asc'); foreach ($student as $value) { $f_name = $value['first_name']; $l_name = $value['last_name']; $reg = $value['reg_no']; $id = $value['student_id']; if (strpos(strtolower($f_name), $q) !== false) { echo '' . $f_name . ' ' . $l_name . '-' . $reg . '#' . $id . '#'; echo "\n"; } else if (strpos(strtolower($l_name), $q) !== false) { echo '' . $l_name . ' ' . $f_name . '-' . $reg . '#' . $id . '#'; echo "\n"; } else if (strpos(strtolower($reg), $q) !== false) { echo '' . $reg . ' ' . $f_name . '-' . $l_name . '#' . $id . '#'; echo "\n"; } } } function autosuggestclass() { $q = strtolower($_POST["q"]); if (!$q) return; $class_details = $this->mastermodel->getdatas('class_name'); foreach ($class_details as $value) { $class_name_code = $value['class_name_code']; $class_name_id = $value['class_name_id']; if (strpos(strtolower($class_name_code), $q) !== false) { echo $class_name_code . '#' . $class_name_id . '#'; echo "\n"; } } } function autosuggestclassrollover($from_class_id) { $q = strtolower($_POST["q"]); if (!$q) return; $class_details = $this->mastermodel->get_class_rollover($from_class_id); foreach ($class_details as $value) { $class_name_code = $value['class_name_code']; $class_name_id = $value['class_name_id']; if (strpos(strtolower($class_name_code), $q) !== false) { echo $class_name_code . '#' . $class_name_id . '#'; echo "\n"; } } } function autosuggestclassstudent($class_name_id) { $q = strtolower($_POST["q"]); if (!$q) return; $class_student = $this->studentmodel->get_student_class_allocation_details($class_name_id); foreach ($class_student as $value) { $f_name = $value['first_name']; $l_name = $value['last_name']; $reg = $value['reg_no']; $id = $value['student_id']; if (strpos(strtolower($f_name), $q) !== false) { echo '' . $f_name . ' ' . $l_name . '-' . $reg . '#' . $value['student_class_id'] . '~' . $id . '#'; echo "\n"; } else if (strpos(strtolower($l_name), $q) !== false) { echo '' . $f_name . ' ' . $l_name . '-' . $reg . '#' . $value['student_class_id'] . '~' . $id . '#'; echo "\n"; } else if (strpos(strtolower($reg), $q) !== false) { echo '' . $f_name . ' ' . $l_name . '-' . $reg . '#' . $value['student_class_id'] . '~' . $id . '#'; echo "\n"; } } } /* get classes of a student */ function autosuggestclassByTerm($termid) { $q = strtolower($_POST["q"]); if (!$q) return; $class_details = $this->mastermodel->get_class_by_term($termid); foreach ($class_details as $value) { $class_code = $value['class_name_code']; $class_id = $value['class_name_id ']; if (strpos(strtolower($class_code), $q) !== false) { echo $class_code . '#' . $class_id . '#'; echo "\n"; } } } function autosuggestaccount() { $q = strtolower($_POST["q"]); if (!$q) return; $accounts = $this->mastermodel->getdatas('finance_chart_master', 'chart_type_id'); foreach ($accounts as $items) { $name = $items['chart_account_name']; $code = $items['chart_account_code']; if (strpos(strtolower($name), $q) !== false) { echo '' . $name . '-' . $code . '#' . $items['chart_master_id'] . '~' . $code . '~' . $name . '#'; echo "\n"; } else if (strpos(strtolower($code), $q) !== false) { echo '' . $name . '-' . $code . '#' . $items['chart_master_id'] . '~' . $code . '~' . $name . '#'; echo "\n"; } } } function autosuggestbankaccount() { $q = strtolower($_POST["q"]); if (!$q) return; $bankacc = $this->mastermodel->getdatas('finance_bank_account', 'bank_account_id', 'asc'); foreach ($bankacc as $value) { $name = $value['bank_name']; $code = $value['chart_account_code']; if (strpos(strtolower($name), $q) !== false) { echo '' . $name . '-' . $code . '#' . $value['bank_account_id'] . '~' . $value['chart_account_code'] . '~' . $value["bank_name"] . '#'; echo "\n"; } else if (strpos(strtolower($code), $q) !== false) { echo '' . $name . '-' . $code . '#' . $value['bank_account_id'] . '~' . $value['chart_account_code'] . '~' . $value["bank_name"] . '#'; echo "\n"; } } } function autosuggestmainaccount() { $q = strtolower($_POST["q"]); if (!$q) return; $acc_main = $this->mastermodel->get_data('finance_chart_master', '0', 'parent', 'chart_type_id'); foreach ($acc_main as $value) { $name = $value['chart_account_name']; $code = $value['chart_account_code']; if (strpos(strtolower($name), $q) !== false) { echo '' . $name . '-' . $code . '#' . $value['chart_master_id'] . '~' . $value['chart_type_id'] . '#'; echo "\n"; } else if (strpos(strtolower($code), $q) !== false) { echo '' . $name . '-' . $code . '#' . $value['chart_master_id'] . '~' . $value['chart_type_id'] . '#'; echo "\n"; } } } function autosuggestmainaccount_c() { $q = strtolower($_POST["q"]); if (!$q) return; $account_list = $this->mastermodel->get_data('finance_chart_master', 0, 'parent'); foreach ($account_list as $items) { $accountno = $items['chart_account_code']; $account_name = $items['chart_account_name']; if (strpos(strtolower($accountno), $q) !== false) { echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#'; echo "\n"; } else if (strpos(strtolower($account_name), $q) !== false) { echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#'; echo "\n"; } } } function autosuggestsubofmainaccount($parent = 0) { if ($parent != 0) { $q = strtolower($_POST["q"]); if (!$q) return; $account_list = $this->mastermodel->get_data('finance_chart_master', $parent, 'parent'); foreach ($account_list as $items) { $accountno = $items['chart_account_code']; $account_name = $items['chart_account_name']; if (strpos(strtolower($accountno), $q) !== false) { echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#'; echo "\n"; } else if (strpos(strtolower($account_name), $q) !== false) { echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#'; echo "\n"; } } // die(); } } function getStudentDetails($id) { $data = array(); $res = $this->mastermodel->get_data_srow_joined('student', 'nationality', 'nationality_id', 'nationality_id', $id, 'student_id'); $data['student_id'] = $id; $data['gender'] = $res->gender; $data['reg_no'] = $res->reg_no; $data['nationality'] = $res->nationality_name; echo json_encode($data); } function autosuggestemployeenotuser() { $q = strtolower($_POST["q"]); if (!$q) return; $employee_list = $this->mastermodel->get_employee_not_user(); foreach ($employee_list as $items) { $name = $items['employee_name']; $emp_no = $items['employee_no']; if (strpos(strtolower($name), $q) !== false) { echo '' . $name . '-' . $emp_no . '#' . $items['employee_id'] . '#'; echo "\n"; } else if (strpos(strtolower($emp_no), $q) !== false) { echo '' . $name . '-' . $emp_no . '#' . $items['employee_id'] . '#'; echo "\n"; } } } function update_psw($modelfunction) { $postdata = $this->get_post_values(); $data = $this->settingsmodel->$modelfunction($postdata); $data['msg'] = $data['msg']; json_encode($data['msg']); } function autosuggestchartaccount() { $q = strtolower($_POST["q"]); if (!$q) return; $bank_acc_list = $this->mastermodel->get_chart_account(); foreach ($bank_acc_list as $items) { $name = $items['chart_account_name']; $acc_code = $items['chart_account_code']; if (strpos(strtolower($name), $q) !== false) { echo '' . $name . '-' . $acc_code . '#' . $items['chart_master_id'] . '~' . $acc_code . '~' . $name . '#'; echo "\n"; } else if (strpos(strtolower($acc_code), $q) !== false) { echo '' . $name . '-' . $acc_code . '#' . $items['chart_master_id'] . '~' . $acc_code . '~' . $name . '#'; echo "\n"; } } } function list_payment_months($acc_year) { $data['accademic_details'] = $this->mastermodel->get_data_srow('academic_year', $acc_year, 'academic_year_id'); $data['academic_year_id'] = $acc_year; $this->load->view('master/list_payment_month', $data); } function set_academic_year_default($id) { $result = $this->mastermodel->set_academic_year_default($id); } function loadTermAcademicDetails($term, $session, $academic_year) { $id = 0; $data['academic_year_id'] = $academic_year; $data['term_academic_details'] = $this->mastermodel->get_data_dual_srow('term_academic_details', $academic_year, 'academic_year_id', $term, 'term_id'); $check_fee_term = $this->mastermodel->check_fee_term($term, $session, $academic_year); if (count($check_fee_term) == 0) { if (count($data['term_academic_details']) > 0) { $this->load->view('master/term_academic_details', $data); } else { $id = 1; echo $id; } } else { $id = 0; echo $id; } } function get_exammaster_name_by_class($class_name_id) { $assessment_names = $this->mastermodel->get_data('exammaster', $class_name_id, 'course_id'); echo json_encode($assessment_names); } function check_class_code($class_name_id, $class_room_id, $session, $term, $academic_year) { $code = $this->mastermodel->check_class_code($class_name_id, $class_room_id, $session, $term, $academic_year); echo json_encode(count($code)); } function view_fee_alert($class_name_id) { $data['class_name_id'] = $class_name_id; $this->load->view('home/student_fee_alerts', $data); } function get_academic_year($academic_year_id) { echo $this->mastermodel->get_single_field_value('academic_year', 'display_name', 'academic_year_id', $academic_year_id); } function get_session_details($session_id) { $session = $this->mastermodel->get_data_srow('session', $session_id, 'session_id'); $data = array(); $start_time = explode(":", $session->session_start); $end_time = explode(":", $session->session_end); $r = range(0, 23); $minutes = range(0, 59); $select = ""; foreach ($r as $hour) { $select .= "<option value=\"$hour\""; $select .= ($hour == $start_time[0]) ? ' selected="selected"' : ''; $select .= ">" . str_pad($hour, 2, '0', STR_PAD_LEFT) . "</option>\n"; } $start_time_m = ""; foreach ($minutes as $min) { $start_time_m .= "<option value=\"$min\""; $start_time_m .= ($min == $start_time[1]) ? ' selected="selected"' : ''; $start_time_m .= ">" . str_pad($min, 2, '0', STR_PAD_LEFT) . "</option>\n"; } $end_time_h = ""; foreach ($r as $hour) { $end_time_h .= "<option value=\"$hour\""; $end_time_h .= ($hour == $end_time[0]) ? ' selected="selected"' : ''; $end_time_h .= ">" . str_pad($hour, 2, '0', STR_PAD_LEFT) . "</option>\n"; } $end_time_minut = ""; foreach ($minutes as $min) { $end_time_minut .= "<option value=\"$min\""; $end_time_minut .= ($min == $end_time[1]) ? ' selected="selected"' : ''; $end_time_minut .= ">" . str_pad($min, 2, '0', STR_PAD_LEFT) . "</option>\n"; } $data['start_time_hour'] = $select; $data['start_time_minute'] = $start_time_m; $data['end_time_hour'] = $end_time_h; $data['end_time_minute'] = $end_time_minut; echo json_encode($data); } function update_student_no() { $i = 101; $students = $this->mastermodel->getdatas('student','student_id'); foreach($students as $row) { $studentno = 'S'.$i; $sql2="update student set reg_no='".$studentno."' where student_id = '".$row['student_id']."'"; $this->db->query($sql2); $i++; } } function update_chart_no() { $this->mastermodel->update_chart_no(); } }