mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-03 21:33:15 -04:00
Fixed sale suspending / unsuspending (adapt db scripts)
Cleanup old code More code review Update item_quantities database model (composite pk)
This commit is contained in:
@@ -207,7 +207,7 @@ class Items extends Secure_area implements iData_controller
|
||||
{
|
||||
$quantity = $this->Item_quantities->get_item_quantity($item_id, $location['location_id'])->quantity;
|
||||
$quantity = ($item_id == -1) ? null: $quantity;
|
||||
$location_array['stock_'.$location['location_id']] = array('location_name'=>$location['location_name'],
|
||||
$location_array[$location['location_id']] = array('location_name'=>$location['location_name'],
|
||||
'quantity'=>$quantity);
|
||||
}
|
||||
$data['stock_locations']= $location_array;
|
||||
@@ -224,8 +224,8 @@ class Items extends Secure_area implements iData_controller
|
||||
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location_data)
|
||||
{
|
||||
$data['stock_locations']['stock_'.$location_data['location_id']] = $location_data['location_name'];
|
||||
$data['item_quantities']['stock_'.$location_data['location_id']] = $this->Item_quantities->get_item_quantity($item_id,$location_data['location_id'])->quantity;
|
||||
$data['stock_locations'][$location_data['location_id']] = $location_data['location_name'];
|
||||
$data['item_quantities'][$location_data['location_id']] = $this->Item_quantities->get_item_quantity($item_id,$location_data['location_id'])->quantity;
|
||||
}
|
||||
|
||||
$this->load->view("items/inventory",$data);
|
||||
@@ -236,11 +236,11 @@ class Items extends Secure_area implements iData_controller
|
||||
$data['item_info']=$this->Item->get_info($item_id);
|
||||
|
||||
$data['stock_locations'] = array();
|
||||
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
|
||||
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location_data)
|
||||
{
|
||||
$data['stock_locations']['stock_'.$location_data['location_id']] = $location_data['location_name'];
|
||||
$data['item_quantities']['stock_'.$location_data['location_id']] = $this->Item_quantities->get_item_quantity($item_id,$location_data['location_id'])->quantity;
|
||||
$data['stock_locations'][$location_data['location_id']] = $location_data['location_name'];
|
||||
$data['item_quantities'][$location_data['location_id']] = $this->Item_quantities->get_item_quantity($item_id,$location_data['location_id'])->quantity;
|
||||
}
|
||||
|
||||
$this->load->view("items/count_details",$data);
|
||||
@@ -298,7 +298,6 @@ class Items extends Secure_area implements iData_controller
|
||||
'allow_alt_description'=>$this->input->post('allow_alt_description'),
|
||||
'is_serialized'=>$this->input->post('is_serialized'),
|
||||
'deleted'=>$this->input->post('is_deleted'), /** Parq 131215 **/
|
||||
'stock_type'=>$this->input->post('stock_type'),
|
||||
'custom1'=>$this->input->post('custom1'), /**GARRISON ADDED 4/21/2013**/
|
||||
'custom2'=>$this->input->post('custom2'),/**GARRISON ADDED 4/21/2013**/
|
||||
'custom3'=>$this->input->post('custom3'),/**GARRISON ADDED 4/21/2013**/
|
||||
@@ -347,24 +346,26 @@ class Items extends Secure_area implements iData_controller
|
||||
$stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
|
||||
foreach($stock_locations as $location_data)
|
||||
{
|
||||
$updated_quantity = $this->input->post('stock_'.$location_data['location_id'].'_quantity');
|
||||
$updated_quantity = $this->input->post($location_data['location_id'].'_quantity');
|
||||
$location_detail = array('item_id'=>$item_id,
|
||||
'location_id'=>$location_data['location_id'],
|
||||
'quantity'=>$updated_quantity);
|
||||
|
||||
$item_quantity = $this->Item_quantities->get_item_quantity($item_id, $location_data['location_id']);
|
||||
$this->Item_quantities->save($location_detail, $item_quantity->item_quantity_id);
|
||||
|
||||
$inv_data = array
|
||||
(
|
||||
'trans_date'=>date('Y-m-d H:i:s'),
|
||||
'trans_items'=>$item_id,
|
||||
'trans_user'=>$employee_id,
|
||||
'trans_location'=>$location_data['location_id'],
|
||||
'trans_comment'=>$this->lang->line('items_manually_editing_of_quantity'),
|
||||
'trans_inventory'=>$item_quantity->item_quantity_id ? $updated_quantity - $item_quantity->quantity : $updated_quantity
|
||||
);
|
||||
$this->Inventory->insert($inv_data);
|
||||
$item_quantity = $this->Item_quantities->get_item_quantity($item_id, $location_data['location_id']);
|
||||
if ($item_quantity->quantity != $updated_quantity)
|
||||
{
|
||||
$this->Item_quantities->save($location_detail, $item_id, $location_data['location_id']);
|
||||
|
||||
$inv_data = array
|
||||
(
|
||||
'trans_date'=>date('Y-m-d H:i:s'),
|
||||
'trans_items'=>$item_id,
|
||||
'trans_user'=>$employee_id,
|
||||
'trans_location'=>$location_data['location_id'],
|
||||
'trans_comment'=>$this->lang->line('items_manually_editing_of_quantity'),
|
||||
'trans_inventory'=>$updated_quantity - $item_quantity->quantity
|
||||
);
|
||||
$this->Inventory->insert($inv_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
@@ -380,7 +381,7 @@ class Items extends Secure_area implements iData_controller
|
||||
{
|
||||
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
|
||||
$cur_item_info = $this->Item->get_info($item_id);
|
||||
$location_id = $this->get_location_id_from_stock_location($this->input->post('stock_location'));
|
||||
$location_id = $this->input->post('stock_location');
|
||||
$inv_data = array
|
||||
(
|
||||
'trans_date'=>date('Y-m-d H:i:s'),
|
||||
@@ -400,7 +401,7 @@ class Items extends Secure_area implements iData_controller
|
||||
'location_id'=>$location_id,
|
||||
'quantity'=>$item_quantity->quantity + $this->input->post('newquantity')
|
||||
);
|
||||
if($this->Item_quantities->save($item_quantity_data,$item_quantity->item_quantity_id))
|
||||
if($this->Item_quantities->save($item_quantity_data,$item_id,$location_id))
|
||||
{
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_updating').' '.
|
||||
$cur_item_info->name,'item_id'=>$item_id));
|
||||
@@ -504,7 +505,6 @@ class Items extends Secure_area implements iData_controller
|
||||
$item_data = array(
|
||||
'name' => $data[1],
|
||||
'description' => $data[13],
|
||||
'location' => $data[12],
|
||||
'category' => $data[2],
|
||||
'cost_price' => $data[4],
|
||||
'unit_price' => $data[5],
|
||||
@@ -607,9 +607,5 @@ class Items extends Secure_area implements iData_controller
|
||||
echo $this->Item->is_sale_store_item_exist($item_number);
|
||||
}
|
||||
|
||||
function get_location_id_from_stock_location($location)
|
||||
{
|
||||
return substr($location, 6);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user