?
Current Path : /home1/savoy/public_html/savoyglobal.net/gea/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/gea/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->helper('to_pdf'); $this->load->library('Fpaginate'); } public function index($menuid="",$modid="") { $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['modename']=$data['modname']; $_SESSION['menuname']=$data['menuname']; $data['modules']=$this->mastermodel->build_module(); $data['menus']=$this->mastermodel->build_menu($modid); $this->load->view(''.$data['modname'].'/'.$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,$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 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"; $this->load->view('message',$data); } else { $data=$this->mastermodel->deletedata($table,$id,$field); $data['msg']=$data['msg']; if($data['res']==1) { $this->load->view('message',$data); } else { $this->load->view('message',$data); } } } 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 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 viewinmastersearch($modelfunction,$page,$pagenum) { /*<---------------- For pagination purpose------------>*/ $perpage= $this->config->item('perpage'); $_SESSION['pagenum']=$pagenum; $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } if(isset($_POST['tab_name'])) { $postdata =""; } else { $postdata=$this->get_post_values(); } if(!empty ($postdata)) $_SESSION['searchdata']=$postdata; else if(!isset($_SESSION['searchdata'])) $_SESSION['searchdata']=""; /*<---------------- For pagination purpose------------> */ $output=$this->mastermodel->$modelfunction($pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['viewinfo']=$output['results']; $this->load->view('master/'.$page.'',$data); } /* Function to edit table details*/ 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); } } function edit_customer($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['customer']=$this->mastermodel->get_data_srow('customer',$id,'customer_id'); $data['customer_contact']=$this->mastermodel->get_data('customer_contact',$id,'customer_id'); $data['customer_login']=$this->mastermodel->get_data_srow('customer_login',$id,'customer_id'); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function edit_agent($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['agent']=$this->mastermodel->get_data_srow('agent',$id,'agent_id'); $data['agent_bank']=$this->mastermodel->get_data('agent_bank',$id,'agent_id'); $data['agent_contact']=$this->mastermodel->get_data('agent_contact',$id,'agent_id'); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function edit_carrier($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['carrier']=$this->mastermodel->get_data_srow('carrier',$id,'carrier_id'); $data['carrier_contact']=$this->mastermodel->get_data('carrier_contact',$id,'carrier_id'); $data['id']=$id; $this->load->view('master/'.$page,$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 single_customer($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['customer']=$this->mastermodel->get_data_srow('customer',$id,'customer_id'); $data['customer_contact']=$this->mastermodel->get_data('customer_contact',$id,'customer_id'); $data['customer_login']=$this->mastermodel->get_data_srow('customer_login',$id,'customer_id'); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function single_agent($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['agent']=$this->mastermodel->get_data_srow('agent',$id,'agent_id'); $data['agent_contact']=$this->mastermodel->get_data('agent_contact',$id,'agent_id'); $data['agent_bank']=$this->mastermodel->get_data('agent_bank',$id,'agent_id'); $data['id']=$id; $this->load->view('master/'.$page,$data); } } function single_carrier($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['carrier']=$this->mastermodel->get_data_srow('carrier',$id,'carrier_id'); $data['carrier_contact']=$this->mastermodel->get_data('carrier_contact',$id,'carrier_id'); $data['id']=$id; $this->load->view('master/'.$page,$data); } } /* Functions to upload files.*/ function upload_form($master_id,$return_page,$upload_function='') { $data=array(); $data['master_id']=$master_id; $data['return_page']=$return_page; $data['upload_function']=$upload_function; $this->load->view('master/upload_form',$data); } function submit_upload($upload_function='upload_file') { $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_function($postdata); $data['msg']= "File Uploaded successfully!"; } } else { $data['msg']= "File already exists"; } $data['return_page']=$postdata['return_page']; $this->load->view('master/after_upload',$data); } function autosuggestemployee() { $q = strtolower($_POST["q"]); if (!$q) return; $employee_list=$this->mastermodel->getdatas('employee','employee_id'); 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 autosuggestcustomer() { $q = strtolower($_POST["q"]); if (!$q) return; $customer_list=$this->mastermodel->getdatas('customer','customer_id'); foreach ($customer_list as $items) { $name = $items['customer_name']; $customer_code= $items['customer_code']; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.'-'.$customer_code.'#'.$items['customer_id'].'#'; echo "\n"; } else if (strpos(strtolower($customer_code), $q) !== false) { echo ''.$name.'-'.$customer_code.'#'.$items['customer_id'].'#'; echo "\n"; } } } function autosuggestagent() { $q = strtolower($_POST["q"]); if (!$q) return; $agent_list=$this->mastermodel->getdatas('agent','agent_id'); foreach ($agent_list as $items) { $name = $items['agent_name']; $agent_code= $items['agent_code']; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.'-'.$agent_code.'#'.$items['agent_id'].'#'; echo "\n"; } else if (strpos(strtolower($agent_code), $q) !== false) { echo ''.$name.'-'.$agent_code.'#'.$items['agent_id'].'#'; echo "\n"; } } } function autosuggestshippercode() { $q = strtolower($_POST["q"]); if (!$q) return; $shipper_list=$this->mastermodel->getdatas('shipper','shipper_id'); foreach ($shipper_list as $items) { $name = $items['shipper_name']; $shipper_code= $items['shipper_code']; if (strpos(strtolower($name), $q) !== false) { echo ''.$name.'-'.$items['shipper_code'].'#'.$items['shipper_id'].'#'; echo "\n"; } else if (strpos(strtolower($shipper_code), $q) !== false) { echo ''.$name.'-'.$items['shipper_code'].'#'.$items['shipper_id'].'#'; echo "\n"; } } } function add_edit_bin($warehouse_id) { $data['viewinfo'] = $this->mastermodel->get_bin_by_warehouse($warehouse_id); $data['warehouse_id'] = $warehouse_id; $this->load->view('master/manage_bin',$data); } function add_new_bin($warehouse_id,$bin_name) { $bin_name = urldecode($bin_name); $this->mastermodel->add_new_bin($warehouse_id,$bin_name); echo "New Bin Added"; } function update_bin_name($bin_id,$bin_name) { $bin_name = urldecode($bin_name); $this->mastermodel->update_bin_name($bin_id,$bin_name); echo $bin_name; } function delete_bin($bin_id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],2); if(!$perm) { echo "User does not have permission to delete records"; } else { $num=$this->mastermodel->number_rows('warehousing_item_placement_details','warehousing_item_placement_bin_id',$bin_id); if($num>0) echo "Item(s) have been placed in bin and so cannot be deleted"; else { $this->mastermodel->deletedata('warehouse_bin',$bin_id,'bin_id'); echo 1; } } } function add_new_shelf($bin_id,$shelf_name) { $shelf_name = urldecode($shelf_name); $this->mastermodel->add_new_shelf($bin_id,$shelf_name); echo $shelf_name; } function update_shelf_name($shelf_id,$shelf_name) { $shelf_name = urldecode($shelf_name); $this->mastermodel->update_shelf_name($shelf_id,$shelf_name); echo $shelf_name; } function delete_shelf($shelf_id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],2); if(!$perm) { echo "User does not have permission to delete records"; } else { $num=$this->mastermodel->number_rows('warehousing_item_placement_details','warehousing_item_placement_shelf_id',$shelf_id); if($num>0) echo "Item(s) have been placed in shelf and so cannot be deleted"; else { $this->mastermodel->deletedata('warehouse_shelf',$shelf_id,'shelf_id'); echo 1; } } } function get_customer_address($customer_id) { echo json_encode($this->mastermodel->get_customer_address($customer_id)); // echo $this->mastermodel->get_single_field_value('customer','customer_address','customer_id',$customer_id); } function get_shipper_address($shipper_id) { echo json_encode($this->mastermodel->get_single_field_value('shipper','shipper_address','shipper_id',$shipper_id)); } function add_new_rack($shelf_id,$rack_name) { $rack_name = urldecode($rack_name); $this->mastermodel->add_new_rack($shelf_id,$rack_name); echo $rack_name; } function update_rack($rack_id,$rack_name) { return $this->mastermodel->update_rack($rack_id,$rack_name); } function delete_rack($rack_id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['user_id'],2); if(!$perm) { echo "User does not have permission to delete records"; } else { $num=$this->mastermodel->number_rows('warehousing_item_placement_history','warehousing_rack_id',$rack_id); if($num>0) echo "Item(s) have been placed in rack and so cannot be deleted"; else { $this->mastermodel->deletedata('warehouse_rack',$rack_id,'rack_id'); echo 1; } } } function show_items_warehouse($element_type,$element_id) { $data=array(); $data['items'] = $this->mastermodel->get_items_warehouse($element_type,$element_id); $this->load->view('master/items_warehouse',$data); } function get_description($description_id) { $data=$this->mastermodel->get_single_field_value('description','description_text','description_id',$description_id); echo json_encode($data); } function downloadpdf() { $postdata=$this->get_post_values(); $html=$postdata['htmlpost']; $filename=$postdata['filename']; pdf_create($html, $filename); } } /* End of file master.php */ /* Location: ./application/controllers/master.php */