?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec/draft/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/sec/draft/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('franchiseemodel'); $this->load->model('accountingmodel'); $this->load->model('hrmodel'); } 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; } if ($data['module_title'] == 'Home') { $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); } function student_fee_alert($page, $batch_id) { $data['batch'] = $this->mastermodel->get_data_srow('batch', $batch_id, 'batch_id'); $output = $this->mastermodel->get_fee_payment_alert($batch_id); $data['fee_alert'] = $output; $this->load->view('home/' . $page, $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']; $this->output->cache(60); $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 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 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 deletedata($table, $id, $field) { $data = array(); $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 3); if (!$perm) $data['msg'] = "Access is restricted"; 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['return_page'] = $return_page; $perm = $this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'], 1); if (!$perm) { $data['msg'] = "Access is restricted"; $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'] = "Access is restricted"; $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'] = "Access is restricted"; $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'] = "Access is restricted"; $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'] = "Access is restricted"; $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('performance_exam_subject', '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 get_batch_code($course_id) { $cod = $this->mastermodel->get_batch_code($course_id); echo $cod; } function get_course_franchisee($course_id) { $course = $this->mastermodel->get_data_joined('franchisee_course', 'course', 'course_id', 'course_id', $course_id, 'franchisee_course.franchisee_id'); echo "<option value=''>Select</option>"; foreach ($course as $items) { echo '<option value=' . $items['course_id'] . '>' . $items['course_name'] . "</option>"; } } 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 autosuggestbatch() { $q = strtolower($_POST["q"]); if (!$q) return; $batch_details = $this->mastermodel->get_data('batch', '0', 'close'); foreach ($batch_details as $value) { $batch_code = $value['batch_no']; $batch_id = $value['batch_id']; if (strpos(strtolower($batch_code), $q) !== false) { echo $batch_code . '#' . $batch_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', 'bank_account_id'); 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 getStudentDetails($id) { $data = array(); $res = $this->mastermodel->get_data_srow('student', $id, 'student_id'); $data['student_id'] = $id; $data['gender'] = $res->gender; $data['reg_no'] = $res->reg_no; $data['nationality'] = $res->nationality; 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 close_batch($id) { echo $this->mastermodel->close_batch($id); } function reopen_batch($id) { echo $this->mastermodel->reopen_batch($id); } 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 remove_fee_alert($student_batch_id) { $remove_status = $this->mastermodel->remove_fee_alert($student_batch_id); } function add_school($modelfunction, $page) { $data = array(); $postdata = $_POST; $path = './assets/uploads/school'; $file_name = date("Y-m-d-H-i-s"); $uploaded_file = pathinfo($_FILES["logo"]["name"]); $extension = $uploaded_file['extension']; $image_file = $file_name . '.' . $extension; if (isset($_FILES['logo']) && $_FILES['logo']['name'] != "") { $_FILES['logo']['name'] = $image_file; if (!is_file("$path/" . $_FILES["logo"]["name"])) { move_uploaded_file($_FILES["logo"]["tmp_name"], $path . "/" . $_FILES["logo"]["name"]); $postdata['logo'] = $_FILES["logo"]["name"]; } else { echo "File already exists"; $postdata['logo'] = ''; } } else { $postdata['logo'] = ""; } if (isset($postdata['unique_form'])) { if ($postdata['unique_form'] != $_SESSION['unique_form']) { $_SESSION['unique_form'] = $postdata['unique_form']; $data = $this->mastermodel->$modelfunction($postdata); } } else $data = $this->mastermodel->$modelfunction($postdata); $msg = 'photo'; $this->load->view('message', $data); redirect("master/index/" . $_SESSION['current_mode'] . '/' . $_SESSION['current_module'] . '/1/' . $msg); } } /* End of file master.php */ /* Location: ./application/controllers/master.php */