?
Current Path : /home1/savoy/public_html/savoyglobal.net/simsdemo/school/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/simsdemo/school/application/controllers/master.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Master extends BaseController { function __construct() { parent::BaseController(); $this->load->library('Fpaginate'); $this->load->model('mastermodel'); $this->load->model('studentmodel'); $this->load->model('settingsmodel'); } function index($moduleid="",$tabid="") { if(empty($tabid)) { $data['tabname']='Dashboard'; $data['tabid']=1; $addressdata=$this->mastermodel->getdatas('schoolsetup'); } else { $tab=$this->mastermodel->get_data_tab($tabid); foreach($tab as $id) { $tabname=$id['tab_name']; $tabid=$id['tab_id']; } $data['tabname']=$tabname; $data['tabid']=$tabid; } if(empty($moduleid)) { $tart='index'; $data['modulename']=''; $data['module_id']=$moduleid; $data['modulelist']=$this->mastermodel->getmoduledata(); } else { $tar=$this->mastermodel->getmoduledata($moduleid); foreach($tar as $target) { $tart=$target['target']; $data['modulename']=$target['module_caption']; } } $_SESSION['searchdata']=""; $_SESSION['current_mode']=$moduleid; $_SESSION['modename']=$data['modulename']; $data['tabs']=$this->mastermodel->get_data_tab(); $this->load->view(''.$data['tabname'].'/'.$tart.'',$data); } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } /* common function loading pages through jquery load method . * Usages:-used for displaying addform. */ function addformdisplay($page,$directory,$table="",$pagenum="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->load->view(''.$directory.'/'.$page.''); } } /* used for viewdatagrid for all modules- This is loaded from commonfunctions * which is re-routed to view function in corresponding controllers. * Both search and view uses same function in corresponding controllers , but search uses * forsubmitdata function in master controller and view uses viewdata in master controller, both * routed to same view function in corresponding controller.pagination can be done in view function * */ function viewdata($controller,$controllerfunction,$modelfunction,$page,$pagenum="") { $encoded_data=NULL; /* As there is no data to send we just declare it as an array*/ $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->wick->light($controller.'/'.$controllerfunction.'/'.$encoded_data.'/'.$modelfunction.'/'.$page.'/'.$pagenum); } } /* Function used for submitting the form,each form in the application * $controllerfunction variable is used to determine which corresponding controller * function has to be called.This is passed as an argument from the form. * The same argument is used in the controller as wellas in the model. * forsubmitdata is called from forms. * formsubmitdata is used also in search . Search function is routed * to this function and then re-routed to corresponding controller function. * For initial view and search same function is used in corresponding controllers , for eg. * in HR viewinhr function is used for view and search. * */ function formsubmitdata($controller,$controllerfunction,$modelfunction='',$page='',$pagenum="") { $data = $this->get_post_values(); $json = json_encode($data); $encoded_data= urlencode($json); $this->wick->light($controller.'/'.$controllerfunction.'/'.$encoded_data.'/'.$modelfunction.'/'.$page.'/'.$pagenum); } /* Function is called from view , via onclick. * Onclick function from viewgrid to javascript function in commonfunctions.php ie * editformdata(),this is redirected to editform function in masters, from where forwareded * to corresponding controller and method. */ function editform($controller,$controllerfunction,$id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->wick->light($controller.'/'.$controllerfunction.'/'.$id); } } function editformgeneral($folder,$page,$table,$field,$id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $data['viewinfo']= $this->mastermodel->get_data_srow($table,$id,$field); $this->load->view($folder."/".$page,$data); } } function viewform($controller,$controllerfunction,$id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->wick->light($controller.'/'.$controllerfunction.'/'.$id); } } /* called from view via onclick * performs as previous function redirected to corresponding controller. */ function deletedata($id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],2); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $res=$this->mastermodel->deletemaster($id); if($res==1) { $this->load->view('deletesuccess'); } else { $this->load->view('deletefailure'); } } } function formeditsubmitdata($controller,$controllerfunction) { redirect($controller.'/'.$controllerfunction); } function checkexistence($table,$field,$value) { if($this->mastermodel->checkexistence($table,$field,$value)>0) { echo 1; } } function checkexistencearray($table,$field,$value) { if($this->mastermodel->checkexistencearray($table,$field,$value)>0) { echo 1; } } function checkexistenceedit($table,$field,$value,$masterfield,$masterid) { if($this->mastermodel->checkexistenceedit($table,$field,$value,$masterid,$masterfield)>0) { echo 1; } } function deletedataperm($id,$table,$field) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],2); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $res=$this->mastermodel->deletedataperm($id,$table,$field); if($res==1) { $this->load->view('deletesuccess'); } else { $this->load->view('deletefailure'); } } } /* used for viewdatagrid for all modules- This is loaded from commonfunctions * which is re-routed to view function in corresponding controllers. * Both search and view uses same function in corresponding controllers , but search uses * forsubmitdata function in master controller and view uses viewdata in master controller, both * routed to same view function in corresponding controller.pagination can be done in view function * */ function viewdatadoc($controller,$controllerfunction,$modelfunction,$page,$pagenum="",$parent_id) { $encoded_data=NULL; /* As there is no data to send we just declare it as an array*/ $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->wick->light($controller.'/'.$controllerfunction.'/'.$encoded_data.'/'.$modelfunction.'/'.$page.'/'.$pagenum.'/'.$parent_id); } } function uploadform($masterid) { $data=array(); $data['masterid']=$masterid; $this->load->view('Dashboard/uploadform',$data); } function editstatus($forgot_password_id) { $data=array(); $data['forgot_password_id']=$forgot_password_id; $data['username']= $this->mastermodel->getsinglefieldvalue('forgot_password','username','forgot_password_id',$forgot_password_id); $this->load->view('Dashboard/editstatus',$data); } function change_password() { $this->load->view('Dashboard/change_password'); } function passwordsubmit($password) { $this->mastermodel->insertpassword($password); } function submitupload() { $data=array(); $postdata=$this->get_post_values(); $path = './school/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->uploadfile($postdata); $data['msg']= "File Uploaded successfully!"; } } else { $data['msg']= "File already exists"; } $this->load->view('Dashboard/afterupload',$data); } function submitedit() { $this->mastermodel->reset_user_password_request(); redirect('master/index/'); } function autosuggeststudent($class_type) { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getstudents($class_type); foreach ($c_list as $items) { $name = $items['reg_no']." - ".$items['first_name']." ".$items['last_name']; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.'#'.$items['student_id'].'#'; echo "\n"; } } } function autosuggestparentf() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getparentf(); foreach ($c_list as $items) { $name = $items['name']; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.'#'.$items['parent_id'].'#'; echo "\n"; } } } function autosuggestparentm() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getparentm(); foreach ($c_list as $items) { $name = $items['name']; //$parentId=$items['parent_id']+1; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.' #'.$items['parent_id'].'#'; echo "\n"; } } } function autosuggestteacher() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getteacher(); foreach ($c_list as $items) { $name1 = $items['first_name']." ".$items['last_name']; if (strpos(strtolower($name1), $q) !== false) { echo ''.$name1.'#'.$items['teacher_id'].'#'; echo "\n"; } } } function autosuggeststaff() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getstaff(); foreach ($c_list as $items) { $name1 = $items['name']; if (strpos(strtolower($name1), $q) !== false) { echo ''.$name1.'#'.$items['staff_id'].'#'; echo "\n"; } } } function autosuggestsubject() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getsubject(); foreach ($c_list as $items) { $classcode = $this->mastermodel->getSingleFieldValue('classlevel','classlevel_code','classlevel_id',$items['classlevel_id']); $name1 = $items['subject_name']; $sub_code = $items['subject_code']; $class = $items['classlevel_id']; if (strpos(strtolower($name1), $q) !== false) { echo '#'.$items['subject_id'].'#'.$name1.'#'.$classcode; echo "\n"; } } } function autosuggeststudents() { $q = strtolower($_POST["q"]); if (!$q) return; $c_list=$this->mastermodel->getstudent(); foreach ($c_list as $items) { $classcode = $this->mastermodel->getSingleFieldValue('classlevel','classlevel_code','classlevel_id',$items['classlevel_id']); $name = $items['reg_no']." - ".$items['first_name']." ".$items['last_name']; if (strpos(strtolower($name), $q) !== false) { echo '#'.$items['student_id'].'#'.$name.'#'.$classcode; echo "\n"; } } } function loadpage($directory,$page) { $this->load->view($directory.'/'.$page); } } /* End of file master.php */ /* Location: ./system/application/controllers/master.php */