?
Current Path : /home1/savoy/public_html/savoyglobal.net/eduplus2/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/public_html/savoyglobal.net/eduplus2/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'); $this->load->model('examinationmodel'); $this->load->model('hrmodel'); $this->load->model('emailmodel'); $this->load->model('smsmodel'); } public function index($menuid = "", $modid = "", $upload = 0, $msg = "") { $ret = $this->mastermodel->chk_url_permission($menuid); if ($ret != 1) { $menuid = ""; $modid = ""; } if (empty($modid)) { $data['module_name'] = 'home'; $data['module_title'] = 'Home'; $data['module_id'] = ''; } else { $mod_id = $this->mastermodel->get_data_srow('module', $modid, 'module_id'); $data['module_name'] = $mod_id->module_name; $data['module_title'] = $mod_id->module_title; $data['module_id'] = $modid; } if (empty($menuid)) { $target = 'index'; $data['menu_name'] = ''; $data['menu_id'] = $menuid; $data['is_menu_public'] = 1; $data['modulelist'] = $this->mastermodel->getmoduledatamaster(); } else { $tar = $this->mastermodel->get_data_srow('menu', $menuid, 'menu_id'); $target = $tar->target; $data['menu_name'] = $tar->caption; $data['menu_id'] = $menuid; } // $outout = $this->mastermodel->get_fee_payment_alert(); // $data['fee_alert'] = $outout; $_SESSION['menu_id'] = $data['menu_id']; $_SESSION['searchdata'] = ""; $_SESSION['current_mode'] = $menuid; $_SESSION['current_module'] = $modid; $_SESSION['module_name'] = $data['module_name']; $_SESSION['menu_name'] = $data['menu_name']; $_SESSION['module_title'] = $data['module_title']; $_SESSION['unique_form'] = ''; $data['modules'] = $this->mastermodel->build_module(); if ($data['module_name'] == 'home') $this->load->view($data['module_name'] . '/' . $target . '', $data); else $this->load->view($target, $data); if (isset($_SESSION['upload'])) { $upload = $_SESSION['upload']; $_SESSION['upload'] = 0; } if ($upload == 1) { if ($msg == 'photo') $data['msg'] = 'Record Added Successfully!'; else $data['msg'] = 'File uploaded 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($file_record_id, $return_page, $upload_function = '') { $data = array(); $data['file_record_id'] = $file_record_id; $data['return_page'] = $return_page; $data['upload_function'] = $upload_function; $data['menu_id'] = $this->mastermodel->get_single_field_value('master', 'menu_id', 'master_id', $file_record_id); $json_data = $this->load->view('master/upload_form', $data, TRUE); echo json_encode(array('json_data' => $json_data, 'json_perm' => 1)); } function upload_form1($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[0]["name"] = $this->security->sanitize_filename($_FILES[0]["name"]); $postdata['file_name'] = $_FILES[0]["name"]; $_FILES[0]["name"] = date('Y-m-d-h-i-s') . $_FILES[0]["name"]; if (!is_file("$path" . $_FILES[0]["name"])) { if (!(move_uploaded_file($_FILES[0]["tmp_name"], $path . "/" . $_FILES[0]["name"]))) { $data['msg'] = "File not uploaded.. Permission denied!"; } else { $postdata['file_location'] = $path . "/" . $_FILES[0]["name"]; $data = $this->mastermodel->upload_file($postdata); $data['msg'] = "File Uploaded successfully!"; } $json_perm = 1; } else { $data['msg'] = "File already exists"; $json_perm = 1; } $data['return_page'] = $postdata['return_page']; $json_data = $this->load->view('master/after_upload', $data, TRUE); echo json_encode(array('json_data' => $json_data, 'json_perm' => $json_perm, 'json_msg' => $data['msg'])); } function submit_nursery_upload() { $data = array(); $postdata = $this->get_post_values(); $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"; } echo "<script>alert('File Uploaded successfully!');</script>"; redirect("master/index/" . $_SESSION['current_mode'] . '/' . $_SESSION['current_module']); } 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 delete_file($file_id) { $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 3); if (!$perm) echo 0; else { $this->mastermodel->deletedata('nursery_file', $file_id, 'file_id'); echo 1; } } 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', 'academic_year_year', '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 autosuggestterm() { $q = strtolower($_POST["q"]); if (!$q) return; $term_list = $this->mastermodel->getdatas('term','term_name'); foreach ($term_list as $items) { if (strpos(strtolower($items['term_name']), $q) !== false) { echo '' . $items['term_name']; echo "\n"; } } } function autosuggestclassroom() { $q = strtolower($_POST["q"]); if (!$q) return; $room_list = $this->mastermodel->getdatas('class_room','class_room_name'); foreach ($room_list as $items) { if (strpos(strtolower($items['class_room_name']), $q) !== false) { echo '' . $items['class_room_name']; echo "\n"; } } } function autosuggestsession() { $q = strtolower($_POST["q"]); if (!$q) return; $session_name_list = $this->mastermodel->getdatas('session','session_name'); foreach ($session_name_list as $items) { if (strpos(strtolower($items['session_name']), $q) !== false) { echo '' . $items['session_name']; echo "\n"; } } } 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 checksessionname($name) { if ($this->mastermodel->session_name($name) > 0) { echo 1; } else { echo 0; } } }