?
Current Path : /home1/savoy/www/savoyglobal.net/rms/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/rms/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'); } public function index($menuid="",$modid="",$upload=0) { $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($upload==1) { $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']; $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; } } function checkexistence($table,$field,$value,$primary_field) { if($this->mastermodel->checkexistence($table,$field,$value,$primary_field)>0) { echo 1; } } 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 deletedata($table,$id,$field) { $data=array(); $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],2); 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['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) { $postdata=$this->get_post_values(); $data=$this->mastermodel->$modelfunction($postdata); $data['msg']=$data['msg']; if($data['res']==1) { $this->viewinmastersearch($data['resfunction'],$page,$_SESSION['pagenum']); $this->load->view('message',$data); } else { $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'],1); } 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); } } public function relogin($id) { $_SESSION['login_type']=$id; redirect('master/index/'); } function edit_contract($id,$table,$field,$page) { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],1); } 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 single_contract($id,$table,$field,$page) { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],1); } 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 edit_maintenance_contract($id,$table,$field,$page) { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],1); } 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('maintenance_cc_details',$id,$field); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function single_maintenance_contract($id,$table,$field,$page) { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],1); } 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('maintenance_cc_details',$id,$field); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function edit_building_details($id,$table,$field,$page) { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],1); } else { $perm=1; } if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data['viewinfo']=$this->mastermodel->get_building_details($id); $data['amenity_details']=$this->mastermodel->get_data('building_amenities_details',$id,$field); $data['facility_details']=$this->mastermodel->get_data('building_facility_details',$id,$field); $data['commercial_details']=$this->mastermodel->get_data('building_commercial_building_details',$id,$field); $data['commercial_villa_details']=$this->mastermodel->get_data('building_commercial_villa_details',$id,$field); $data['apartment_details']=$this->mastermodel->get_data('building_apartment_details',$id,$field); $data['residential_villa_details']=$this->mastermodel->get_data('building_residential_villa_details',$id,$field); $data['watchman']=$this->mastermodel->get_data('building_watchman',$id,$field); $data['supervisor']=$this->mastermodel->get_data('building_supervisor',$id,$field); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function single_building_details($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_building_details($id); $data['amenity_details']=$this->mastermodel->get_data('building_amenities_details',$id,$field); $data['facility_details']=$this->mastermodel->get_data('building_facility_details',$id,$field); $data['commercial_details']=$this->mastermodel->get_data('building_commercial_building_details',$id,$field); $data['commercial_villa_details']=$this->mastermodel->get_data('building_commercial_villa_details',$id,$field); $data['apartment_details']=$this->mastermodel->get_data('building_apartment_details',$id,$field); $data['residential_villa_details']=$this->mastermodel->get_data('building_residential_villa_details',$id,$field); $data['watchman']=$this->mastermodel->get_data('building_watchman',$id,$field); $data['supervisor']=$this->mastermodel->get_data('building_supervisor',$id,$field); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function get_building_info($building_id) { $data['building']=$this->mastermodel->get_data_srow('building_details',$building_id,'building_id'); $data['location']=$this->mastermodel->get_single_field_value('location','location_name','location_id',$data['building']->building_location_id); $this->load->view('building_management/building_details',$data); } function autosuggestaccount() { $q = strtolower($_POST["q"]); if (!$q) return; $accounts=$this->mastermodel->getdatas('finance_chart_master','chart_type_id','','chart_master_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','chart_master_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"; } } } } /* End of file master.php */ /* Location: ./application/controllers/master.php */