?
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/inventory.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Inventory extends MY_Controller { public function __construct() { parent::__construct(); $this->load->model('inventorymodel'); $this->load->model('mastermodel'); } function viewininventorysearch($modelfunction='',$page,$pagenum) { $output=$this->inventorymodel->$modelfunction($pagenum); $data['viewinfo']=$output['results']; $this->load->view('inventory/'.$page.'',$data); } function addininventory($modelfunction,$page) { $postdata=$this->get_post_values(); $data=$this->inventorymodel->$modelfunction($postdata); $data['msg']=$data['msg']; if($data['res']==1) { $this->viewininventorysearch($data['resfunction'],$page,$_SESSION['pagenum']); $this->load->view('message',$data); } else { $this->viewininventorysearch($data['resfunction'],$page,$_SESSION['pagenum']); $this->load->view('message',$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"; else { $data=$this->inventorymodel->deletedata($table,$id,$field); } $arr = array('msg' =>$data['msg'],'res'=>$data['res']); echo json_encode($arr); } function deletestockmaintenancedata($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->inventorymodel->deletestockmaintenancedata($table,$id,$field); } $arr = array('msg' =>$data['msg'],'res'=>$data['res']); echo json_encode($arr); } function deleteutilization($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->inventorymodel->deleteutilization($table,$id,$field); } $arr = array('msg' =>$data['msg'],'res'=>$data['res']); echo json_encode($arr); } function deletereturn($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->inventorymodel->deletereturn($table,$id,$field); } $arr = array('msg' =>$data['msg'],'res'=>$data['res']); echo json_encode($arr); } 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('inventory/'.$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('inventory/'.$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 edit_vendor_purchase($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,'',$field); $data['details']=$this->mastermodel->get_data('vendor_purchase_details',$id,$field,'',$field); $data['id']=$id; $this->load->view('inventory/'.$page,$data); } } function edit_stock_maintenance($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,'',$field); $data['details']=$this->mastermodel->get_data('stock_maintenance_details',$id,$field,'',$field); $data['id']=$id; $this->load->view('inventory/'.$page,$data); } } function edit_inventory_utilization($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,'',$field); $data['details']=$this->mastermodel->get_data('inventory_utilization_details',$id,$field,'',$field); $data['id']=$id; $this->load->view('inventory/'.$page,$data); } } function edit_inventory_return($id,$table,$field,$page) { $quantity=0; $current_qty=array(); $current_id=array(); $inventory_id=array(); $inventory_qty=array(); 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('inventory_return_details',$id,$field,'',$field); $availability=$this->mastermodel->get_data_joined('inventory_utilization','inventory_utilization_details','inventory_utilization_id','inventory_utilization_id',$data['viewinfo']->inventory_return_building_id ,'inventory_utilization_building_id'); foreach($availability as $row) { if(in_array($row['inventory_utilization_stock_id'], $inventory_id)) { $qty=$inventory_qty[$row['inventory_utilization_stock_id']]+$row['inventory_utilization_stock_qty']; $inventory_qty[$row['inventory_utilization_stock_id']]=$qty; } else { $inventory_id[]=$row['inventory_utilization_stock_id']; $inventory_qty[$row['inventory_utilization_stock_id']]=$row['inventory_utilization_stock_qty']; } } foreach($inventory_id as $row) { $current_id[]=$row; $this->db->select('*'); $this->db->from('inventory_return_details'); $this->db->join('inventory_return','inventory_return.inventory_return_id=inventory_return_details.inventory_return_id'); $this->db->where('inventory_return_stock_id',$row); $this->db->where('inventory_return_building_id',$data['viewinfo']->inventory_return_building_id); $value=$this->db->get(); if ($value->num_rows() > 0) { $quantity=0; foreach($value->result_array() as $list) { $quantity=$quantity+$list['inventory_return_stock_qty']; } } $current_qty[$row]=$inventory_qty[$row]-$quantity; } $data['current_id']=$current_id; $data['current_qty']=$current_qty; $data['inventory_id']=$inventory_id; // $data['inventory_qty']=$inventory_qty; $data['id']=$id; $this->load->view('inventory/'.$page,$data); } } function checklocation($id) { echo $this->mastermodel->get_single_field_value('inventory_utilization','inventory_utilization_id','inventory_utilization_building_id',$id); } function loadlocation($id) { $quantity=0; $data=array(); $current_qty=array(); $current_id=array(); $inventory_id=array(); $inventory_qty=array(); $availability=array(); $availability=$this->mastermodel->get_data_joined('inventory_utilization','inventory_utilization_details','inventory_utilization_id','inventory_utilization_id',$id,'inventory_utilization_building_id'); foreach($availability as $row) { if(in_array($row['inventory_utilization_stock_id'], $inventory_id)) { $qty=$inventory_qty[$row['inventory_utilization_stock_id']]+$row['inventory_utilization_stock_qty']; $inventory_qty[$row['inventory_utilization_stock_id']]=$qty; } else { $inventory_id[]=$row['inventory_utilization_stock_id']; $inventory_qty[$row['inventory_utilization_stock_id']]=$row['inventory_utilization_stock_qty']; } } foreach($inventory_id as $row) { $current_id[]=$row; $this->db->select('*'); $this->db->from('inventory_return_details'); $this->db->join('inventory_return','inventory_return.inventory_return_id=inventory_return_details.inventory_return_id'); $this->db->where('inventory_return_stock_id',$row); $this->db->where('inventory_return_building_id',$id); $value=$this->db->get(); if ($value->num_rows() > 0) { $quantity=0; foreach($value->result_array() as $list) { $quantity=$quantity+$list['inventory_return_stock_qty']; } } $current_qty[$row]=$inventory_qty[$row]-$quantity; } $data['current_id']=$current_id; $data['current_qty']=$current_qty; $data['inventory_qty']=$inventory_qty; $this->load->view('inventory/load_inventory',$data); } function checkstock($stock_id) { echo $this->mastermodel->get_single_field_value('stock','stock_inventory_qty','stock_inventory_id',$stock_id); } } ?>