Fix default location in items, sales and receivings

This commit is contained in:
jekkos-t520
2014-10-04 13:38:52 +02:00
parent 5a4ac8dde3
commit 5e8367681b
5 changed files with 8 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ class Items extends Secure_area implements iData_controller
$stock_location=$this->item_lib->get_item_location();
$stock_locations=$this->Stock_locations->get_allowed_locations();
$data['stock_location']=$this->item_lib->get_item_location();
$data['stock_location']=$stock_location;
$data['stock_locations']=$stock_locations;
$data['controller_name']=strtolower(get_class());

View File

@@ -13,7 +13,7 @@ class Item_lib
{
if(!$this->CI->session->userdata('item_location'))
{
$location_name = $this->Stock_locations->get_default_location();
$location_name = $this->CI->Stock_locations->get_default_location_id();
$this->set_item_location($location_name);
}
return $this->CI->session->userdata('item_location');

View File

@@ -52,7 +52,7 @@ class Receiving_lib
{
if(!$this->CI->session->userdata('recv_stock_source'))
{
$location_name = $this->Stock_locations->get_default_location();
$location_name = $this->CI->Stock_locations->get_default_location_id();
$this->set_stock_source($location_name);
}
return $this->CI->session->userdata('recv_stock_source');
@@ -87,9 +87,8 @@ class Receiving_lib
{
if(!$this->CI->session->userdata('recv_stock_destination'))
{
$stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
$location_name = $stock_locations[0]['location_id'];
$this->set_stock_destination($location_name);
$location_name = $this->CI->Stock_locations->get_default_location_id();
$this->set_stock_destination($location_name);
}
return $this->CI->session->userdata('recv_stock_destination');
}

View File

@@ -172,7 +172,7 @@ class Sale_lib
{
if(!$this->CI->session->userdata('sale_location'))
{
$location_name = $this->Stock_locations->get_default_location();
$location_name = $this->CI->Stock_locations->get_default_location_id();
$this->set_sale_location($location_name);
}
return $this->CI->session->userdata('sale_location');

View File

@@ -61,7 +61,7 @@ class Stock_locations extends CI_Model
return $stock_locations;
}
function get_default_location_name()
function get_default_location_id()
{
$this->db->from('stock_locations');
// TODO replace with extra join on ospos_grants
@@ -70,7 +70,7 @@ class Stock_locations extends CI_Model
$this->db->where('person_id', $this->session->userdata('person_id'));
$this->db->where('deleted',0);
$this->db->limit(1);
return $this->db->get()->row()->location_name;
return $this->db->get()->row()->location_id;
}
function get_location_name($location_id)