Fix stock location permissions for github issue #34

This commit is contained in:
jekkos-t520
2015-02-10 16:04:52 +01:00
parent c40ad31ed0
commit 3594c348ee
3 changed files with 10 additions and 9 deletions

View File

@@ -178,7 +178,7 @@ class Receivings extends Secure_area
$data['receipt_title']=$this->lang->line('recvs_receipt');
$data['transaction_time']= date('m/d/Y h:i:s a');
$data['mode']=$this->receiving_lib->get_mode();
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
$stock_locations = $this->Stock_locations->get_undeleted_all('receivings')->result_array();
$data['show_stock_locations'] = count($stock_locations) > 1;
$supplier_id=$this->receiving_lib->get_supplier();
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
@@ -279,7 +279,7 @@ class Receivings extends Secure_area
$data['mode']=$this->receiving_lib->get_mode();
$data['receipt_title']=$this->lang->line('recvs_receipt');
$data['transaction_time']= date('m/d/Y h:i:s a', strtotime($receiving_info['receiving_time']));
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
$stock_locations = $this->Stock_locations->get_undeleted_all('receivings')->result_array();
$data['show_stock_locations'] = count($stock_locations) > 1;
$supplier_id=$this->receiving_lib->get_supplier();
$emp_info=$this->Employee->get_info($receiving_info['employee_id']);
@@ -307,7 +307,7 @@ class Receivings extends Secure_area
$data['modes']=array('receive'=>$this->lang->line('recvs_receiving'),'return'=>$this->lang->line('recvs_return'));
$data['mode']=$this->receiving_lib->get_mode();
$data['stock_locations']=$this->Stock_locations->get_allowed_locations();
$data['stock_locations']=$this->Stock_locations->get_allowed_locations('receivings');
$show_stock_locations = count($data['stock_locations']) > 1;
if ($show_stock_locations)
{

View File

@@ -216,7 +216,7 @@ class Sales extends Secure_area
$data['total']=$this->sale_lib->get_total();
$data['receipt_title']=$this->lang->line('sales_receipt');
$data['transaction_time']= date('m/d/Y h:i:s a');
$stock_locations=$this->Stock_locations->get_undeleted_all()->result_array();
$stock_locations=$this->Stock_locations->get_undeleted_all('sales')->result_array();
$data['show_stock_locations']=count($stock_locations) > 1;
$customer_id=$this->sale_lib->get_customer();
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
@@ -302,7 +302,7 @@ class Sales extends Secure_area
{
$sale_info = $this->Sale->get_info($sale_id)->row_array();
$this->sale_lib->copy_entire_sale($sale_id);
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
$stock_locations = $this->Stock_locations->get_undeleted_all('sales')->result_array();
$data['show_stock_locations'] = count($stock_locations) > 1;
$data['cart']=$this->sale_lib->get_cart();
$data['payments']=$this->sale_lib->get_payments();
@@ -424,7 +424,7 @@ class Sales extends Secure_area
$data['modes']=array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return'));
$data['mode']=$this->sale_lib->get_mode();
$data['stock_locations']=$this->Stock_locations->get_allowed_locations();
$data['stock_locations']=$this->Stock_locations->get_allowed_locations('sales');
$data['stock_location']=$this->sale_lib->get_sale_location();
$data['subtotal']=$this->sale_lib->get_subtotal();

View File

@@ -18,19 +18,20 @@ class Stock_locations extends CI_Model
return $this->db->get();
}
function get_undeleted_all()
function get_undeleted_all($module_id='items')
{
$this->db->from('stock_locations');
$this->db->join('permissions','permissions.location_id=stock_locations.location_id');
$this->db->join('grants','grants.permission_id=permissions.permission_id');
$this->db->where('person_id', $this->session->userdata('person_id'));
$this->db->like('permissions.permission_id', $module_id, 'after');
$this->db->where('deleted',0);
return $this->db->get();
}
function get_allowed_locations()
function get_allowed_locations($module_id='items')
{
$stock = $this->get_undeleted_all()->result_array();
$stock = $this->get_undeleted_all($module_id)->result_array();
$stock_locations = array();
foreach($stock as $location_data)
{