diff --git a/.gitignore b/.gitignore
index 4b53de03f..58bf03044 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@ git-svn-diff.py
.buildpath
.project
.settings/*
+*.swp
+*.rej
+*.orig
diff --git a/application/config/autoload.php b/application/config/autoload.php
index 9cd3f57ff..6f237f4ef 100644
--- a/application/config/autoload.php
+++ b/application/config/autoload.php
@@ -66,6 +66,7 @@ $autoload['libraries'] = array('database','form_validation','session','user_agen
$autoload['helper'] = array('form','url','table','text','currency', 'html', 'download', 'directory');
+
/*
| -------------------------------------------------------------------
| Auto-load Config files
@@ -108,7 +109,7 @@ $autoload['language'] = array();
|
*/
-$autoload['model'] = array('Appconfig','Person','Customer','Employee','Module','Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier','Inventory','Receiving','Giftcard', 'Item_kit', 'Item_kit_items');
+$autoload['model'] = array('Appconfig','Person','Customer','Employee','Module','Item', 'Item_taxes', 'Sale', 'Sale_suspended', 'Supplier','Inventory','Receiving','Giftcard', 'Item_kit', 'Item_kit_items','Stock_locations','Item_quantities');
/* End of file autoload.php */
diff --git a/application/config/config.php b/application/config/config.php
index c59d11d95..315d10762 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -9,7 +9,7 @@
|
|
*/
-$config['application_version'] = '2.2.1';
+$config['application_version'] = '2.3';
/*
|--------------------------------------------------------------------------
diff --git a/application/config/routes.php b/application/config/routes.php
index 331fff2ff..f5fe358a1 100644
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -50,7 +50,7 @@ $route['reports/inventory_:any'] = "reports/excel_export";
$route['reports/(detailed_sales)/(:any)/(:any)'] = "reports/$1/$2/$3";
$route['reports/detailed_sales'] = "reports/date_input";
$route['reports/(detailed_receivings)/(:any)/(:any)'] = "reports/$1/$2/$3";
-$route['reports/detailed_receivings'] = "reports/date_input";
+$route['reports/detailed_receivings'] = "reports/date_input_recv";
$route['reports/(specific_:any)/(:any)/(:any)/(:any)'] = "reports/$1/$2/$3/$4";
$route['reports/specific_customer'] = "reports/specific_customer_input";
$route['reports/specific_employee'] = "reports/specific_employee_input";
diff --git a/application/controllers/config.php b/application/controllers/config.php
index 028c4bff5..476c223ed 100644
--- a/application/controllers/config.php
+++ b/application/controllers/config.php
@@ -9,7 +9,14 @@ class Config extends Secure_area
function index()
{
- $this->load->view("config");
+ $location_names = array();
+ $locations = $this->Stock_locations->get_location_names();
+ foreach($locations->result_array() as $array)
+ {
+ array_push($location_names, $array['location_name']);
+ }
+ $data['location_names'] = implode(',', $location_names);
+ $this->load->view("config", $data);
}
function save()
@@ -43,7 +50,25 @@ class Config extends Secure_area
'custom10_name'=>$this->input->post('custom10_name')/**GARRISON ADDED 4/20/2013**/
);
- if( $this->Appconfig->batch_save( $batch_save_data ) )
+ $stock_locations = explode( ',', $this->input->post('stock_location'));
+ $stock_locations_trimmed=array();
+ foreach($stock_locations as $location)
+ {
+ array_push($stock_locations_trimmed, trim($location, ' '));
+ }
+ $current_locations = $this->Stock_locations->concat_location_names()->location_names;
+ if ($this->input->post('stock_locations') != $current_locations)
+ {
+ $this->load->library('sale_lib');
+ $this->sale_lib->clear_sale_location();
+ $this->sale_lib->clear_all();
+ $this->load->library('receiving_lib');
+ $this->receiving_lib->clear_stock_source();
+ $this->receiving_lib->clear_stock_destination();
+ $this->receiving_lib->clear_all();
+ }
+
+ if( $this->Appconfig->batch_save( $batch_save_data ) && $this->Stock_locations->array_save($stock_locations_trimmed))
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('config_saved_successfully')));
}
diff --git a/application/controllers/items.php b/application/controllers/items.php
index 7f5b504f0..4526148d6 100644
--- a/application/controllers/items.php
+++ b/application/controllers/items.php
@@ -24,21 +24,19 @@ class Items extends Secure_area implements iData_controller
function refresh()
{
- $low_inventory=$this->input->post('low_inventory');
$is_serialized=$this->input->post('is_serialized');
$no_description=$this->input->post('no_description');
- $search_custom=$this->input->post('search_custom');//GARRISON ADDED 4/13/2013
- $is_deleted=$this->input->post('is_deleted'); // Parq 131215
-
+ $search_custom=$this->input->post('search_custom');//GARRISON ADDED 4/13/2013
+ $is_deleted=$this->input->post('is_deleted'); // Parq 131215
+
$data['search_section_state']=$this->input->post('search_section_state');
- $data['low_inventory']=$this->input->post('low_inventory');
$data['is_serialized']=$this->input->post('is_serialized');
$data['no_description']=$this->input->post('no_description');
$data['search_custom']=$this->input->post('search_custom');//GARRISON ADDED 4/13/2013
$data['is_deleted']=$this->input->post('is_deleted'); // Parq 131215
$data['controller_name']=strtolower(get_class());
$data['form_width']=$this->get_form_width();
- $data['manage_table']=get_items_manage_table($this->Item->get_all_filtered($low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted),$this);//GARRISON MODIFIED 4/13/2013, Parq 131215
+ $data['manage_table']=get_items_manage_table($this->Item->get_all_filtered($is_serialized,$no_description,$search_custom,$is_deleted),$this);//GARRISON MODIFIED 4/13/2013, Parq 131215
$this->load->view('items/manage',$data);
}
@@ -66,7 +64,7 @@ class Items extends Secure_area implements iData_controller
function item_search()
{
- $suggestions = $this->Item->get_item_search_suggestions($this->input->post('q'),$this->input->post('limit'));
+ $suggestions = $this->Item->get_item_search_suggestions($this->input->post('q'),$this->input->post('limit'),'warehouse');
echo implode("\n",$suggestions);
}
@@ -80,104 +78,104 @@ class Items extends Secure_area implements iData_controller
}
/**GARRISON ADDED 5/18/2013**/
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_location()
- {
- $suggestions = $this->Item->get_location_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_location()
+ {
+ $suggestions = $this->Item->get_location_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom1()
- {
- $suggestions = $this->Item->get_custom1_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom1()
+ {
+ $suggestions = $this->Item->get_custom1_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom2()
- {
- $suggestions = $this->Item->get_custom2_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom2()
+ {
+ $suggestions = $this->Item->get_custom2_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom3()
- {
- $suggestions = $this->Item->get_custom3_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom3()
+ {
+ $suggestions = $this->Item->get_custom3_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom4()
- {
- $suggestions = $this->Item->get_custom4_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom4()
+ {
+ $suggestions = $this->Item->get_custom4_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom5()
- {
- $suggestions = $this->Item->get_custom5_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom5()
+ {
+ $suggestions = $this->Item->get_custom5_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom6()
- {
- $suggestions = $this->Item->get_custom6_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom6()
+ {
+ $suggestions = $this->Item->get_custom6_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom7()
- {
- $suggestions = $this->Item->get_custom7_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom7()
+ {
+ $suggestions = $this->Item->get_custom7_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom8()
- {
- $suggestions = $this->Item->get_custom8_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom8()
+ {
+ $suggestions = $this->Item->get_custom8_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom9()
- {
- $suggestions = $this->Item->get_custom9_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom9()
+ {
+ $suggestions = $this->Item->get_custom9_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
- /*
- Gives search suggestions based on what is being searched for
- */
- function suggest_custom10()
- {
- $suggestions = $this->Item->get_custom10_suggestions($this->input->post('q'));
- echo implode("\n",$suggestions);
- }
+ /*
+ Gives search suggestions based on what is being searched for
+ */
+ function suggest_custom10()
+ {
+ $suggestions = $this->Item->get_custom10_suggestions($this->input->post('q'));
+ echo implode("\n",$suggestions);
+ }
/**END GARRISON ADDED**/
@@ -202,19 +200,49 @@ class Items extends Secure_area implements iData_controller
$data['selected_supplier'] = $this->Item->get_info($item_id)->supplier_id;
$data['default_tax_1_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_1_rate') : '';
$data['default_tax_2_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_2_rate') : '';
+
+ $locations_data = $this->Stock_locations->get_undeleted_all()->result_array();
+ $location_array;
+ foreach($locations_data as $location)
+ {
+ $quantity = $this->Item_quantities->get_item_quantity($item_id, $location['location_id'])->quantity;
+ $quantity = ($item_id == -1) ? null: $quantity;
+ $location_array[$location['location_id']] = array('location_name'=>$location['location_name'],
+ 'quantity'=>$quantity);
+ }
+ $data['stock_locations']= $location_array;
$this->load->view("items/form",$data);
}
-
+
+
//Ramel Inventory Tracking
function inventory($item_id=-1)
{
$data['item_info']=$this->Item->get_info($item_id);
+
+ $data['stock_locations'] = array();
+ $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
+ foreach($stock_locations as $location_data)
+ {
+ $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);
}
function count_details($item_id=-1)
{
$data['item_info']=$this->Item->get_info($item_id);
+
+ $data['stock_locations'] = array();
+ $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
+ foreach($stock_locations as $location_data)
+ {
+ $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);
} //------------------------------------------- Ramel
@@ -257,6 +285,7 @@ class Items extends Secure_area implements iData_controller
function save($item_id=-1)
{
+ //Save item data
$item_data = array(
'name'=>$this->input->post('name'),
'description'=>$this->input->post('description'),
@@ -265,13 +294,10 @@ class Items extends Secure_area implements iData_controller
'item_number'=>$this->input->post('item_number')=='' ? null:$this->input->post('item_number'),
'cost_price'=>$this->input->post('cost_price'),
'unit_price'=>$this->input->post('unit_price'),
- 'quantity'=>$this->input->post('quantity'),
'reorder_level'=>$this->input->post('reorder_level'),
- 'location'=>$this->input->post('location'),
'allow_alt_description'=>$this->input->post('allow_alt_description'),
'is_serialized'=>$this->input->post('is_serialized'),
'deleted'=>$this->input->post('is_deleted'), /** Parq 131215 **/
-
'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**/
@@ -303,15 +329,6 @@ class Items extends Secure_area implements iData_controller
$item_data['name'],'item_id'=>$item_id));
}
- $inv_data = array
- (
- 'trans_date'=>date('Y-m-d H:i:s'),
- 'trans_items'=>$item_id,
- 'trans_user'=>$employee_id,
- 'trans_comment'=>$this->lang->line('items_manually_editing_of_quantity'),
- 'trans_inventory'=>$cur_item_info ? $this->input->post('quantity') - $cur_item_info->quantity : $this->input->post('quantity')
- );
- $this->Inventory->insert($inv_data);
$items_taxes_data = array();
$tax_names = $this->input->post('tax_names');
$tax_percents = $this->input->post('tax_percents');
@@ -323,6 +340,33 @@ class Items extends Secure_area implements iData_controller
}
}
$this->Item_taxes->save($items_taxes_data, $item_id);
+
+
+ //Save item quantity
+ $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
+ foreach($stock_locations as $location_data)
+ {
+ $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']);
+ 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
{
@@ -337,21 +381,27 @@ 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->input->post('stock_location');
$inv_data = array
(
'trans_date'=>date('Y-m-d H:i:s'),
'trans_items'=>$item_id,
'trans_user'=>$employee_id,
+ 'trans_location'=>$location_id,
'trans_comment'=>$this->input->post('trans_comment'),
'trans_inventory'=>$this->input->post('newquantity')
);
$this->Inventory->insert($inv_data);
//Update stock quantity
- $item_data = array(
- 'quantity'=>$cur_item_info->quantity + $this->input->post('newquantity')
+
+ $item_quantity= $this->Item_quantities->get_item_quantity($item_id,$location_id);
+ $item_quantity_data = array(
+ 'item_id'=>$item_id,
+ 'location_id'=>$location_id,
+ 'quantity'=>$item_quantity->quantity + $this->input->post('newquantity')
);
- if($this->Item->save($item_data,$item_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));
@@ -455,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],
@@ -552,5 +601,11 @@ class Items extends Secure_area implements iData_controller
{
return 360;
}
+
+ function is_sale_store_item($item_number)
+ {
+ echo $this->Item->is_sale_store_item_exist($item_number);
+ }
+
}
?>
\ No newline at end of file
diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php
index 0a325e039..1dff8ad55 100644
--- a/application/controllers/receivings.php
+++ b/application/controllers/receivings.php
@@ -35,8 +35,20 @@ class Receivings extends Secure_area
function change_mode()
{
- $mode = $this->input->post("mode");
- $this->receiving_lib->set_mode($mode);
+ $stock_destination = $this->input->post('stock_destination');
+ $stock_source = $this->input->post("stock_source");
+ if ((!$stock_source || $stock_source == $this->receiving_lib->get_stock_source()) &&
+ (!$stock_destination || $stock_destination == $this->receiving_lib->get_stock_destination()))
+ {
+ $this->receiving_lib->empty_cart();
+ $mode = $this->input->post("mode");
+ $this->receiving_lib->set_mode($mode);
+ }
+ else
+ {
+ $this->receiving_lib->set_stock_source($stock_source);
+ $this->receiving_lib->set_stock_destination($stock_destination);
+ }
$this->_reload();
}
@@ -45,19 +57,20 @@ class Receivings extends Secure_area
$data=array();
$mode = $this->receiving_lib->get_mode();
$item_id_or_number_or_item_kit_or_receipt = $this->input->post("item");
- $quantity = $mode=="receive" ? 1:-1;
-
+ $quantity = ($mode=="receive" or $mode=="requisition") ? 1:-1;
+ $item_location = $this->receiving_lib->get_stock_source();
if($this->receiving_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt) && $mode=='return')
{
- $this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt);
+ $this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt,$item_location);
}
elseif($this->receiving_lib->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
{
- $this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt);
+ $this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt,$item_location);
}
- elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity))
+ else
{
- $data['error']=$this->lang->line('recvs_unable_to_add_item');
+ if(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity,$item_location))
+ $data['error']=$this->lang->line('recvs_unable_to_add_item');
}
$this->_reload($data);
}
@@ -75,6 +88,7 @@ class Receivings extends Secure_area
$price = $this->input->post("price");
$quantity = $this->input->post("quantity");
$discount = $this->input->post("discount");
+ $item_location = $this->input->post("location");
if ($this->form_validation->run() != FALSE)
{
@@ -88,6 +102,26 @@ class Receivings extends Secure_area
$this->_reload($data);
}
+ function edit_item_unit($item_id)
+ {
+ $data= array();
+
+ $this->form_validation->set_rules('quantity', 'lang:items_quantity', 'required|integer');
+ $quantity = $this->input->post("quantity");
+
+
+ if ($this->form_validation->run() != FALSE)
+ {
+ $this->receiving_lib->edit_item_unit($item_id,$description,$quantity,0,0);
+ }
+ else
+ {
+ $data['error']=$this->lang->line('recvs_error_editing_item');
+ }
+
+ $this->_reload($data);
+ }
+
function delete_item($item_number)
{
$this->receiving_lib->delete_item($item_number);
@@ -106,12 +140,16 @@ class Receivings extends Secure_area
$data['total']=$this->receiving_lib->get_total();
$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();
+ $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;
$comment = $this->input->post('comment');
$emp_info=$this->Employee->get_info($employee_id);
$payment_type = $this->input->post('payment_type');
$data['payment_type']=$this->input->post('payment_type');
+ $data['stock_location']=$this->receiving_lib->get_stock_source();
if ($this->input->post('amount_tendered'))
{
@@ -127,7 +165,7 @@ class Receivings extends Secure_area
}
//SAVE receiving to database
- $data['receiving_id']='RECV '.$this->Receiving->save($data['cart'], $supplier_id,$employee_id,$comment,$payment_type);
+ $data['receiving_id']='RECV '.$this->Receiving->save($data['cart'], $supplier_id,$employee_id,$comment,$payment_type,$data['stock_location']);
if ($data['receiving_id'] == 'RECV -1')
{
@@ -139,14 +177,37 @@ class Receivings extends Secure_area
$this->_remove_duplicate_cookies();
}
+ function requisition_complete()
+ {
+ if ($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
+ {
+ foreach($this->receiving_lib->get_cart() as $item)
+ {
+ $this->receiving_lib->delete_item($item['line']);
+ $this->receiving_lib->add_item($item['item_id'],$item['quantity'],$this->receiving_lib->get_stock_destination());
+ $this->receiving_lib->add_item($item['item_id'],-$item['quantity'],$this->receiving_lib->get_stock_source());
+ }
+
+ $this->complete();
+ }
+ else
+ {
+ $data['error']=$this->lang->line('recvs_error_requisition');
+ $this->_reload($data);
+ }
+ }
+
function receipt($receiving_id)
{
$receiving_info = $this->Receiving->get_info($receiving_id)->row_array();
$this->receiving_lib->copy_entire_receiving($receiving_id);
$data['cart']=$this->receiving_lib->get_cart();
$data['total']=$this->receiving_lib->get_total();
+ $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();
+ $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']);
$data['payment_type']=$receiving_info['payment_type'];
@@ -166,10 +227,28 @@ class Receivings extends Secure_area
function _reload($data=array())
{
+ $data['stock_locations'] = array();
+ $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
+ $show_stock_locations = count($stock_locations) > 1;
+
$person_info = $this->Employee->get_logged_in_employee_info();
$data['cart']=$this->receiving_lib->get_cart();
$data['modes']=array('receive'=>$this->lang->line('recvs_receiving'),'return'=>$this->lang->line('recvs_return'));
+
$data['mode']=$this->receiving_lib->get_mode();
+
+ if ($show_stock_locations) {
+ $data['modes']['requisition'] = $this->lang->line('recvs_requisition');
+ foreach($stock_locations as $location_data)
+ {
+ $data['stock_locations'][$location_data['location_id']] = $location_data['location_name'];
+ }
+
+ $data['stock_source']=$this->receiving_lib->get_stock_source();
+ $data['stock_destination']=$this->receiving_lib->get_stock_destination();
+ }
+ $data['show_stock_locations'] = $show_stock_locations;
+
$data['total']=$this->receiving_lib->get_total();
$data['items_module_allowed'] = $this->Employee->has_permission('items', $person_info->person_id);
$data['payment_options']=array(
diff --git a/application/controllers/reports.php b/application/controllers/reports.php
index 029303de6..294594f0e 100644
--- a/application/controllers/reports.php
+++ b/application/controllers/reports.php
@@ -302,9 +302,24 @@ class Reports extends Secure_area
function date_input()
{
$data = $this->_get_common_report_data();
+ $data['mode'] = 'sale';
$this->load->view("reports/date_input",$data);
}
+ function date_input_recv()
+ {
+ $data = $this->_get_common_report_data();
+ $data['mode'] = 'receiving';
+ $this->load->view("reports/date_input",$data);
+ }
+
+ function date_input_reqs()
+ {
+ $data = $this->_get_common_report_data();
+ $data['mode'] = 'requisition';
+ $this->load->view("reports/date_input",$data);
+ }
+
//Graphical summary sales report
function graphical_summary_sales($start_date, $end_date, $sale_type)
{
@@ -827,14 +842,14 @@ class Reports extends Secure_area
$this->load->view("reports/tabular_details",$data);
}
-
- function detailed_receivings($start_date, $end_date, $sale_type, $export_excel=0)
+
+ function detailed_receivings($start_date, $end_date, $receiving_type, $export_excel=0)
{
$this->load->model('reports/Detailed_receivings');
$model = $this->Detailed_receivings;
$headers = $model->getDataColumns();
- $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type));
+ $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'receiving_type' => $receiving_type));
$summary_data = array();
$details_data = array();
@@ -855,13 +870,46 @@ class Reports extends Secure_area
"headers" => $model->getDataColumns(),
"summary_data" => $summary_data,
"details_data" => $details_data,
- "overall_summary_data" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type)),
+ "overall_summary_data" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date, 'receiving_type' => $receiving_type)),
"export_excel" => $export_excel
);
$this->load->view("reports/tabular_details",$data);
}
-
+
+ function detailed_requisition($start_date, $end_date , $export_excel=0)
+ {
+ $this->load->model('reports/Detailed_requisition');
+ $model = $this->Detailed_requisition;
+ $report_data = $model->getData(array('start_date'=>$start_date, 'end_date'=>$end_date));
+
+ $summary_data = array();
+ $details_data = array();
+
+ foreach($report_data['summary'] as $key=>$row)
+ {
+ $summary_data[] = array(anchor('receivings/requisition_receipt/'.$row['requisition_id'], 'REQS '.$row['requisition_id'], array('target' => '_blank')), $row['requisition_date'], $row['employee_name'], $row['comment']);
+
+ foreach($report_data['details'][$key] as $drow)
+ {
+ $details_data[$key][] = array($drow['name'], $drow['requisition_quantity'],
+ $drow['related_item_id'], $drow['related_item_quantity'],
+ $drow['related_item_total_quantity']);
+ }
+ }
+
+ $data = array(
+ "title" =>$this->lang->line('reports_detailed_requisition_report'),
+ "subtitle" => date('m/d/Y', strtotime($start_date)) .'-'.date('m/d/Y', strtotime($end_date)),
+ "headers" => $model->getDataColumns(),
+ "summary_data" => $summary_data,
+ "details_data" => $details_data,
+ "overall_summary_data" => '',
+ "export_excel" => $export_excel
+ );
+ $this->load->view("reports/tabular_details",$data);
+ }
+
function excel_export()
{
$this->load->view("reports/excel_export",array());
@@ -875,7 +923,7 @@ class Reports extends Secure_area
$report_data = $model->getData(array());
foreach($report_data as $row)
{
- $tabular_data[] = array($row['name'], $row['item_number'], $row['description'], $row['quantity'], $row['reorder_level']);
+ $tabular_data[] = array($row['name'], $row['item_number'], $row['description'], $row['quantity'], $row['reorder_level'], $row['location_name']);
}
$data = array(
@@ -898,7 +946,7 @@ class Reports extends Secure_area
$report_data = $model->getData(array());
foreach($report_data as $row)
{
- $tabular_data[] = array($row['name'], $row['item_number'], $row['description'], $row['quantity'], $row['reorder_level']);
+ $tabular_data[] = array($row['name'], $row['item_number'], $row['description'], $row['quantity'], $row['reorder_level'],$row['location_name']);
}
$data = array(
diff --git a/application/controllers/sales.php b/application/controllers/sales.php
index 30df2132c..c6eeddb17 100644
--- a/application/controllers/sales.php
+++ b/application/controllers/sales.php
@@ -35,8 +35,17 @@ class Sales extends Secure_area
function change_mode()
{
- $mode = $this->input->post("mode");
- $this->sale_lib->set_mode($mode);
+ $stock_location = $this->input->post("stock_location");
+ if (!$stock_location || $stock_location == $this->sale_lib->get_sale_location())
+ {
+ $this->sale_lib->clear_all();
+ $mode = $this->input->post("mode");
+ $this->sale_lib->set_mode($mode);
+ }
+ else
+ {
+ $this->sale_lib->set_sale_location($stock_location);
+ }
$this->_reload();
}
@@ -112,7 +121,8 @@ class Sales extends Secure_area
$data=array();
$mode = $this->sale_lib->get_mode();
$item_id_or_number_or_item_kit_or_receipt = $this->input->post("item");
- $quantity = $mode=="sale" ? 1:-1;
+ $quantity = ($mode=="return")? -1:1;
+ $item_location = $this->sale_lib->get_sale_location();
if($this->sale_lib->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt) && $mode=='return')
{
@@ -120,14 +130,14 @@ class Sales extends Secure_area
}
elseif($this->sale_lib->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
{
- $this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt);
+ $this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt,$item_location);
}
- elseif(!$this->sale_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity))
+ elseif(!$this->sale_lib->add_item($item_id_or_number_or_item_kit_or_receipt,$quantity,$item_location))
{
$data['error']=$this->lang->line('sales_unable_to_add_item');
}
- if($this->sale_lib->out_of_stock($item_id_or_number_or_item_kit_or_receipt))
+ if($this->sale_lib->out_of_stock($item_id_or_number_or_item_kit_or_receipt,$item_location))
{
$data['warning'] = $this->lang->line('sales_quantity_less_than_zero');
}
@@ -146,6 +156,7 @@ class Sales extends Secure_area
$price = $this->input->post("price");
$quantity = $this->input->post("quantity");
$discount = $this->input->post("discount");
+ $item_location = $this->input->post("location");
if ($this->form_validation->run() != FALSE)
@@ -157,7 +168,7 @@ class Sales extends Secure_area
$data['error']=$this->lang->line('sales_error_editing_item');
}
- if($this->sale_lib->out_of_stock($this->sale_lib->get_item_id($line)))
+ if($this->sale_lib->out_of_stock($this->sale_lib->get_item_id($line),$item_location))
{
$data['warning'] = $this->lang->line('sales_quantity_less_than_zero');
}
@@ -186,6 +197,8 @@ 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();
+ $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;
$comment = $this->sale_lib->get_comment();
@@ -193,7 +206,7 @@ class Sales extends Secure_area
$data['payments']=$this->sale_lib->get_payments();
$data['amount_change']=to_currency($this->sale_lib->get_amount_due() * -1);
$data['employee']=$emp_info->first_name.' '.$emp_info->last_name;
-
+
if($customer_id!=-1)
{
$cust_info=$this->Customer->get_info($customer_id);
@@ -230,6 +243,8 @@ 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();
+ $data['show_stock_locations'] = count($stock_locations) > 1;
$data['cart']=$this->sale_lib->get_cart();
$data['payments']=$this->sale_lib->get_payments();
$data['subtotal']=$this->sale_lib->get_subtotal();
@@ -330,7 +345,8 @@ class Sales extends Secure_area
}
/* Changed the conditional to account for floating point rounding */
- if ( ( $this->sale_lib->get_mode() == 'sale' ) && ( ( to_currency_no_money( $this->sale_lib->get_total() ) - $total_payments ) > 1e-6 ) )
+ if ( ($this->sale_lib->get_mode() == 'sale') &&
+ ( ( to_currency_no_money( $this->sale_lib->get_total() ) - $total_payments ) > 1e-6 ) )
{
return false;
}
@@ -341,9 +357,22 @@ class Sales extends Secure_area
function _reload($data=array())
{
$person_info = $this->Employee->get_logged_in_employee_info();
- $data['cart']=$this->sale_lib->get_cart();
- $data['modes']=array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return'));
- $data['mode']=$this->sale_lib->get_mode();
+ $data['cart']=$this->sale_lib->get_cart();
+ $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'] = array();
+ $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array();
+ $show_stock_locations = count($stock_locations) > 1;
+ if ($show_stock_locations) {
+ foreach($stock_locations as $location_data)
+ {
+ $data['stock_locations'][$location_data['location_id']] = $location_data['location_name'];
+ }
+ $data['stock_location']=$this->sale_lib->get_sale_location();
+ }
+ $data['show_stock_locations'] = $show_stock_locations;
+
$data['subtotal']=$this->sale_lib->get_subtotal();
$data['taxes']=$this->sale_lib->get_taxes();
$data['total']=$this->sale_lib->get_total();
diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php
index fec23e5ef..dd1f5751e 100644
--- a/application/helpers/table_helper.php
+++ b/application/helpers/table_helper.php
@@ -159,8 +159,8 @@ function get_items_manage_table($items,$controller)
$CI->lang->line('items_category'),
$CI->lang->line('items_cost_price'),
$CI->lang->line('items_unit_price'),
- $CI->lang->line('items_tax_percents'),
$CI->lang->line('items_quantity'),
+ $CI->lang->line('items_tax_percents'),
' ',
$CI->lang->line('items_inventory')
);
@@ -210,6 +210,17 @@ function get_item_data_row($item,$controller)
$controller_name=strtolower(get_class($CI));
$width = $controller->get_form_width();
+ $item_quantity='';
+ $locations_data = $CI->Stock_locations->get_undeleted_all()->result_array();
+ foreach($locations_data as $location)
+ {
+ if (count($locations_data) > 1)
+ {
+ $item_quantity .= $location['location_name'].': ';
+ }
+ $item_quantity .= $CI->Item_quantities->get_item_quantity($item->item_id, $location['location_id'])->quantity . ' ';
+ }
+
$table_data_row='
';
$table_data_row.=" ";
$table_data_row.=''.$item->item_number.' ';
@@ -217,8 +228,8 @@ function get_item_data_row($item,$controller)
$table_data_row.=''.$item->category.' ';
$table_data_row.=''.to_currency($item->cost_price).' ';
$table_data_row.=''.to_currency($item->unit_price).' ';
+ $table_data_row.=''.$item_quantity.' ';
$table_data_row.=''.$tax_percents.' ';
- $table_data_row.=''.$item->quantity.' ';
$table_data_row.=''.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).' ';
//Ramel Inventory Tracking
diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php
index 6f9a5a8ac..eb9bb7c95 100644
--- a/application/language/en/config_lang.php
+++ b/application/language/en/config_lang.php
@@ -32,4 +32,7 @@ $lang['config_custom7'] = 'Custom Field 7'; //GARRISON ADDED 4/21/2013
$lang['config_custom8'] = 'Custom Field 8'; //GARRISON ADDED 4/21/2013
$lang['config_custom9'] = 'Custom Field 9'; //GARRISON ADDED 4/21/2013
$lang['config_custom10'] = 'Custom Field 10'; //GARRISON ADDED 4/21/2013
+
+$lang['config_stock_location'] = 'Stock location';
+$lang['config_stock_location_required'] = 'Stock location number is a required field';
?>
\ No newline at end of file
diff --git a/application/language/en/employees_lang.php b/application/language/en/employees_lang.php
index f70776bd7..5f77c5a85 100644
--- a/application/language/en/employees_lang.php
+++ b/application/language/en/employees_lang.php
@@ -23,4 +23,5 @@ $lang['employees_login_info'] = 'Employee Login Info';
$lang['employees_permission_info'] = 'Employee Permissions and Access';
$lang['employees_permission_desc'] = 'Check the boxes below to grant access to modules';
$lang['employees_error_updating_demo_admin'] = 'You can not change the demo admin user';
+$lang['employees_error_deleting_demo_admin'] = 'You can not delete the demo admin user';
?>
diff --git a/application/language/en/items_lang.php b/application/language/en/items_lang.php
index 84a3118ad..a3b18c509 100644
--- a/application/language/en/items_lang.php
+++ b/application/language/en/items_lang.php
@@ -1,56 +1,56 @@
diff --git a/application/language/en/receivings_lang.php b/application/language/en/receivings_lang.php
index 5212e5b22..e3546689e 100644
--- a/application/language/en/receivings_lang.php
+++ b/application/language/en/receivings_lang.php
@@ -1,26 +1,40 @@
diff --git a/application/language/en/reports_lang.php b/application/language/en/reports_lang.php
index 3f92d44bb..e380f931a 100644
--- a/application/language/en/reports_lang.php
+++ b/application/language/en/reports_lang.php
@@ -43,8 +43,8 @@ $lang['reports_all_time'] = 'All Time';
$lang['reports_detailed_sales_report'] = 'Detailed Sales Report';
$lang['reports_comments'] = 'Comments';
$lang['reports_discount'] = 'Discount';
+$lang['reports_sales']= 'Sale';
$lang['reports_payment_type'] = 'Payment Type';
-$lang['reports_sales'] = 'Sales';
$lang['reports_categories'] = 'Categories';
$lang['reports_customers'] = 'Customers';
$lang['reports_suppliers'] = 'Suppliers';
@@ -84,7 +84,12 @@ $lang['reports_supplied_by'] = 'Supplied by';
$lang['reports_items_received'] = 'Items Received';
$lang['reports_detailed_receivings_report'] = 'Detailed Receivings Report';
$lang['reports_sale_type'] = 'Sale Type';
+$lang['reports_receiving_type'] = 'Receiving Type';
$lang['reports_all'] = 'All';
$lang['reports_returns'] = 'Returns';
$lang['reports_discount'] = 'Discounts';
+$lang['reports_sales'] = 'Sales';
+$lang['reports_requisitions'] = 'Requisitions';
+$lang['reports_receiving_id'] = 'Receiving ID';
+$lang['reports_stock_location'] = 'Stock location';
?>
diff --git a/application/language/en/sales_lang.php b/application/language/en/sales_lang.php
index a0ab4134e..be0d2dc4e 100644
--- a/application/language/en/sales_lang.php
+++ b/application/language/en/sales_lang.php
@@ -1,42 +1,40 @@
diff --git a/application/language/th/items_lang.php b/application/language/th/items_lang.php
index a22680d57..ce415f097 100644
--- a/application/language/th/items_lang.php
+++ b/application/language/th/items_lang.php
@@ -79,92 +79,7 @@ $lang['items_inventory'] = 'สินค้าคงเหลือ';
$lang['items_location'] = 'ที่ตั้ง';
$lang['items_unit_quantity'] = 'จำนวนหน่วย';
$lang['items_related_number'] = 'สินค้าที่เกี่ยวข้อง';
-$lang['items_stock_type_sale'] = 'สินค้าหน้าร้าน';
-$lang['items_stock_type_warehouse'] = 'สินค้าหลังร้าน';
-$lang['items_stock_type'] = 'ชนิดของสินค้า';
-?>
-
diff --git a/application/language/th/reports_lang.php b/application/language/th/reports_lang.php
index 854f67638..05a198ca0 100644
--- a/application/language/th/reports_lang.php
+++ b/application/language/th/reports_lang.php
@@ -43,8 +43,6 @@ $lang['reports_comments'] = 'หมายเหตุ';
$lang['reports_discount'] = 'ส่วนลด';
$lang['reports_payment_type'] = 'ชนิดของการจ่าย';
$lang['reports_sales'] = 'ขาย';
-$lang['reports_sales_retail'] = 'ขายปลีก';
-$lang['reports_sales_wholesale'] = 'ขายส่ง';
$lang['reports_categories'] = 'หมวดหมู่';
$lang['reports_customers'] = 'ลูกค้า';
$lang['reports_suppliers'] = 'ผู้ผลิต';
@@ -145,8 +143,6 @@ $lang['reports_comments'] = 'หมายเหตุ';
$lang['reports_discount'] = 'ส่วนลด';
$lang['reports_payment_type'] = 'ชนิดของการจ่าย';
$lang['reports_sales'] = 'ขาย';
-$lang['reports_sales_retail'] = 'ขายปลีก';
-$lang['reports_sales_wholesale'] = 'ขายส่ง';
$lang['reports_categories'] = 'หมวดหมู่';
$lang['reports_customers'] = 'ลูกค้า';
$lang['reports_suppliers'] = 'ผู้ผลิต';
diff --git a/application/language/th/sales_lang.php b/application/language/th/sales_lang.php
index 684597900..66a7fa4ab 100644
--- a/application/language/th/sales_lang.php
+++ b/application/language/th/sales_lang.php
@@ -34,8 +34,6 @@ $lang['sales_cancel_sale']='ยกเลิกการขาย';
$lang['sales_add_payment']='เพิ่มบิล';
$lang['sales_receipt']='บิลขาย';
$lang['sales_id']='เลขที่ขาย';
-$lang['sales_sale_retail']='ขายปลีก';
-$lang['sales_wholesale']='ขายส่ง';
$lang['sales_return']='คืน';
$lang['sales_confirm_finish_sale'] = 'แน่ใจหรือไม่ที่จะสำเร็จการขาย? ไม่สามารถย้อนกลับได้.';
$lang['sales_confirm_cancel_sale'] = 'แน่ใจหรือไม่ที่จะล้างรายการขาย? สินค้าทุกอย่างจะถูกลบจากบอร์ด.';
@@ -114,8 +112,6 @@ $lang['sales_cancel_sale']='ยกเลิกการขาย';
$lang['sales_add_payment']='เพิ่มบิล';
$lang['sales_receipt']='บิลขาย';
$lang['sales_id']='เลขที่ขาย';
-$lang['sales_sale_retail']='ขายปลีก';
-$lang['sales_wholesale']='ขายส่ง';
$lang['sales_return']='คืน';
$lang['sales_confirm_finish_sale'] = 'แน่ใจหรือไม่ที่จะสำเร็จการขาย? ไม่สามารถย้อนกลับได้.';
$lang['sales_confirm_cancel_sale'] = 'แน่ใจหรือไม่ที่จะล้างรายการขาย? สินค้าทุกอย่างจะถูกลบจากบอร์ด.';
diff --git a/application/libraries/Receiving_lib.php b/application/libraries/Receiving_lib.php
index 407293658..a00d14fda 100644
--- a/application/libraries/Receiving_lib.php
+++ b/application/libraries/Receiving_lib.php
@@ -46,8 +46,50 @@ class Receiving_lib
{
$this->CI->session->set_userdata('recv_mode',$mode);
}
+
+ function get_stock_source()
+ {
+ if(!$this->CI->session->userdata('recv_stock_source'))
+ {
+ $stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
+ $location_name = $stock_locations[0]['location_id'];
+ $this->set_stock_source($location_name);
+ }
+ return $this->CI->session->userdata('recv_stock_source');
+ }
- function add_item($item_id,$quantity=1,$discount=0,$price=null,$description=null,$serialnumber=null)
+ function set_stock_source($stock_source)
+ {
+ $this->CI->session->set_userdata('recv_stock_source',$stock_source);
+ }
+
+ function clear_stock_source()
+ {
+ $this->CI->session->unset_userdata('recv_stock_source');
+ }
+
+ function get_stock_destination()
+ {
+ 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);
+ }
+ return $this->CI->session->userdata('recv_stock_destination');
+ }
+
+ function set_stock_destination($stock_destination)
+ {
+ $this->CI->session->set_userdata('recv_stock_destination',$stock_destination);
+ }
+
+ function clear_stock_destination()
+ {
+ $this->CI->session->unset_userdata('recv_stock_destination');
+ }
+
+ function add_item($item_id,$quantity=1,$item_location,$discount=0,$price=null,$description=null,$serialnumber=null)
{
//make sure item exists in database.
if(!$this->CI->Item->exists($item_id))
@@ -84,7 +126,7 @@ class Receiving_lib
$maxkey = $item['line'];
}
- if($item['item_id']==$item_id)
+ if($item['item_id']==$item_id && $item['item_location']==$item_location)
{
$itemalreadyinsale=TRUE;
$updatekey=$item['line'];
@@ -92,20 +134,23 @@ class Receiving_lib
}
$insertkey=$maxkey+1;
-
+ $item_info=$this->CI->Item->get_info($item_id);
//array records are identified by $insertkey and item_id is just another field.
$item = array(($insertkey)=>
array(
'item_id'=>$item_id,
+ 'item_location'=>$item_location,
+ 'stock_name'=>$this->CI->Stock_locations->get_location_name($item_location),
'line'=>$insertkey,
- 'name'=>$this->CI->Item->get_info($item_id)->name,
- 'description'=>$description!=null ? $description: $this->CI->Item->get_info($item_id)->description,
+ 'name'=>$item_info->name,
+ 'description'=>$description!=null ? $description: $item_info->description,
'serialnumber'=>$serialnumber!=null ? $serialnumber: '',
- 'allow_alt_description'=>$this->CI->Item->get_info($item_id)->allow_alt_description,
- 'is_serialized'=>$this->CI->Item->get_info($item_id)->is_serialized,
+ 'allow_alt_description'=>$item_info->allow_alt_description,
+ 'is_serialized'=>$item_info->is_serialized,
'quantity'=>$quantity,
'discount'=>$discount,
- 'price'=>$price!=null ? $price: $this->CI->Item->get_info($item_id)->cost_price
+ 'in_stock'=>$this->CI->Item_quantities->get_item_quantity($item_id, $item_location)->quantity,
+ 'price'=>$price!=null ? $price: $item_info->cost_price
)
);
@@ -140,7 +185,7 @@ class Receiving_lib
return false;
}
-
+
function is_valid_receipt($receipt_receiving_id)
{
//RECV #
@@ -178,12 +223,12 @@ class Receiving_lib
foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
{
- $this->add_item($row->item_id,-$row->quantity_purchased,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
+ $this->add_item($row->item_id,-$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
}
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
}
- function add_item_kit($external_item_kit_id)
+ function add_item_kit($external_item_kit_id,$item_location)
{
//KIT #
$pieces = explode(' ',$external_item_kit_id);
@@ -191,7 +236,7 @@ class Receiving_lib
foreach ($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
{
- $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity']);
+ $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'],$item_location);
}
}
@@ -202,11 +247,24 @@ class Receiving_lib
foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
{
- $this->add_item($row->item_id,$row->quantity_purchased,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
+ $this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
}
$this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
}
+
+ function copy_entire_requisition($requisition_id,$item_location)
+ {
+ $this->empty_cart();
+ $this->delete_supplier();
+
+ foreach($this->CI->Receiving->get_requisition_items($requisition_id)->result() as $row)
+ {
+ $this->add_item_unit($row->item_id,$row->requisition_quantity,$item_location,$row->description);
+ }
+ $this->set_supplier($this->CI->Receiving->get_supplier($requisition_id)->person_id);
+
+ }
function delete_item($line)
{
diff --git a/application/libraries/Sale_lib.php b/application/libraries/Sale_lib.php
index f7c75eb44..c965d4f3d 100644
--- a/application/libraries/Sale_lib.php
+++ b/application/libraries/Sale_lib.php
@@ -167,18 +167,34 @@ class Sale_lib
$this->CI->session->set_userdata('sale_mode',$mode);
}
- function add_item($item_id,$quantity=1,$discount=0,$price=null,$description=null,$serialnumber=null)
+ function get_sale_location()
+ {
+ if(!$this->CI->session->userdata('sale_location'))
+ {
+ $stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
+ $location_name = $stock_locations[0]['location_id'];
+ $this->set_sale_location($location_name);
+ }
+ return $this->CI->session->userdata('sale_location');
+ }
+
+ function set_sale_location($location)
+ {
+ $this->CI->session->set_userdata('sale_location',$location);
+ }
+
+ function clear_sale_location()
+ {
+ $this->CI->session->unset_userdata('sale_location');
+ }
+
+ function add_item($item_id,$quantity=1,$item_location,$discount=0,$price=null,$description=null,$serialnumber=null)
{
- //make sure item exists
- if(!$this->CI->Item->exists($item_id))
- {
- //try to get item id given an item_number
- $item_id = $this->CI->Item->get_item_id($item_id);
-
- if(!$item_id)
- return false;
- }
-
+ //make sure item exists
+ if($this->validate_item($item_id) == false)
+ {
+ return false;
+ }
//Alain Serialization and Description
@@ -205,7 +221,7 @@ class Sale_lib
$maxkey = $item['line'];
}
- if($item['item_id']==$item_id)
+ if($item['item_id']==$item_id && $item['item_location']==$item_location)
{
$itemalreadyinsale=TRUE;
$updatekey=$item['line'];
@@ -213,26 +229,29 @@ class Sale_lib
}
$insertkey=$maxkey+1;
-
+ $item_info=$this->CI->Item->get_info($item_id);
//array/cart records are identified by $insertkey and item_id is just another field.
$item = array(($insertkey)=>
array(
'item_id'=>$item_id,
+ 'item_location'=>$item_location,
+ 'stock_name'=>$this->CI->Stock_locations->get_location_name($item_location),
'line'=>$insertkey,
- 'name'=>$this->CI->Item->get_info($item_id)->name,
- 'item_number'=>$this->CI->Item->get_info($item_id)->item_number,
- 'description'=>$description!=null ? $description: $this->CI->Item->get_info($item_id)->description,
+ 'name'=>$item_info->name,
+ 'item_number'=>$item_info->item_number,
+ 'description'=>$description!=null ? $description: $item_info->description,
'serialnumber'=>$serialnumber!=null ? $serialnumber: '',
- 'allow_alt_description'=>$this->CI->Item->get_info($item_id)->allow_alt_description,
- 'is_serialized'=>$this->CI->Item->get_info($item_id)->is_serialized,
+ 'allow_alt_description'=>$item_info->allow_alt_description,
+ 'is_serialized'=>$item_info->is_serialized,
'quantity'=>$quantity,
'discount'=>$discount,
- 'price'=>$price!=null ? $price: $this->CI->Item->get_info($item_id)->unit_price
+ 'in_stock'=>$this->CI->Item_quantities->get_item_quantity($item_id, $item_location)->quantity,
+ 'price'=>$price!=null ? $price: $item_info->unit_price
)
);
//Item already exists and is not serialized, add to quantity
- if($itemalreadyinsale && ($this->CI->Item->get_info($item_id)->is_serialized ==0) )
+ if($itemalreadyinsale && ($item_info->is_serialized ==0) )
{
$items[$updatekey]['quantity']+=$quantity;
}
@@ -247,22 +266,20 @@ class Sale_lib
}
- function out_of_stock($item_id)
+ function out_of_stock($item_id,$item_location)
{
//make sure item exists
- if(!$this->CI->Item->exists($item_id))
- {
- //try to get item id given an item_number
- $item_id = $this->CI->Item->get_item_id($item_id);
+ if($this->validate_item($item_id) == false)
+ {
+ return false;
+ }
- if(!$item_id)
- return false;
- }
- $item = $this->CI->Item->get_info($item_id);
- $quanity_added = $this->get_quantity_already_added($item_id);
+ //$item = $this->CI->Item->get_info($item_id);
+ $item_quantity = $this->CI->Item_quantities->get_item_quantity($item_id,$item_location)->quantity;
+ $quanity_added = $this->get_quantity_already_added($item_id,$item_location);
- if ($item->quantity - $quanity_added < 0)
+ if ($item_quantity - $quanity_added < 0)
{
return true;
}
@@ -270,13 +287,13 @@ class Sale_lib
return false;
}
- function get_quantity_already_added($item_id)
+ function get_quantity_already_added($item_id,$item_location)
{
$items = $this->get_cart();
$quanity_already_added = 0;
foreach ($items as $item)
{
- if($item['item_id']==$item_id)
+ if($item['item_id']==$item_id && $item['item_location']==$item_location)
{
$quanity_already_added+=$item['quantity'];
}
@@ -353,12 +370,12 @@ class Sale_lib
foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
{
- $this->add_item($row->item_id,-$row->quantity_purchased,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
+ $this->add_item($row->item_id,-$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
}
$this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
}
- function add_item_kit($external_item_kit_id)
+ function add_item_kit($external_item_kit_id,$item_location)
{
//KIT #
$pieces = explode(' ',$external_item_kit_id);
@@ -366,7 +383,7 @@ class Sale_lib
foreach ($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
{
- $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity']);
+ $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'],$item_location);
}
}
@@ -377,7 +394,7 @@ class Sale_lib
foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
{
- $this->add_item($row->item_id,$row->quantity_purchased,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
+ $this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
}
foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
{
@@ -394,7 +411,7 @@ class Sale_lib
foreach($this->CI->Sale_suspended->get_sale_items($sale_id)->result() as $row)
{
- $this->add_item($row->item_id,$row->quantity_purchased,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
+ $this->add_item($row->item_id,$row->quantity_purchased,$row->item_location,$row->discount_percent,$row->item_unit_price,$row->description,$row->serialnumber);
}
foreach($this->CI->Sale_suspended->get_sale_payments($sale_id)->result() as $row)
{
@@ -494,5 +511,20 @@ class Sale_lib
return to_currency_no_money($total);
}
+
+ function validate_item(&$item_id)
+ {
+ //make sure item exists
+ if(!$this->CI->Item->exists($item_id))
+ {
+ //try to get item id given an item_number
+ $mode = $this->get_mode();
+ $item_id = $this->CI->Item->get_item_id($item_id);
+
+ if(!$item_id)
+ return false;
+ }
+ return true;
+ }
}
?>
\ No newline at end of file
diff --git a/application/models/inventory.php b/application/models/inventory.php
index 2c18e0277..d6e8b5f74 100644
--- a/application/models/inventory.php
+++ b/application/models/inventory.php
@@ -6,10 +6,14 @@ class Inventory extends CI_Model
return $this->db->insert('inventory',$inventory_data);
}
- function get_inventory_data_for_item($item_id)
+ function get_inventory_data_for_item($item_id, $location_id=false)
{
$this->db->from('inventory');
$this->db->where('trans_items',$item_id);
+ if($location_id != false)
+ {
+ $this->db->where('trans_location',$location_id);
+ }
$this->db->order_by("trans_date", "desc");
return $this->db->get();
}
diff --git a/application/models/item.php b/application/models/item.php
index ab9a9c8f1..2a5347118 100644
--- a/application/models/item.php
+++ b/application/models/item.php
@@ -33,13 +33,9 @@ class Item extends CI_Model
return $this->db->count_all_results();
}
- function get_all_filtered($low_inventory=0,$is_serialized=0,$no_description,$search_custom,$is_deleted)/**GARRISON MODIFIED 4/21/2013, Parq 131215 **/
+ function get_all_filtered($is_serialized=0,$no_description,$search_custom,$is_deleted)/**GARRISON MODIFIED 4/21/2013, Parq 131215 **/
{
$this->db->from('items');
- if ($low_inventory !=0 )
- {
- $this->db->where('quantity <=','reorder_level', false);
- }
if ($is_serialized !=0 )
{
$this->db->where('is_serialized',1);
@@ -47,11 +43,13 @@ class Item extends CI_Model
if ($no_description!=0 )
{
$this->db->where('description','');
- }
+ }
+
+
/**GARRISON SECTION ADDED 4/21/2013**/
/**
- if ($search_custom!=0 )
- {
+ if ($search_custom!=0 )
+ {
$this->db->like('custom1',$search);
$this->db->or_like('custom2',$search);
$this->db->or_like('custom3',$search);
@@ -63,7 +61,7 @@ class Item extends CI_Model
$this->db->or_like('custom9',$search);
$this->db->or_like('custom10',$search);
}
-**/
+**/
/* Parq 131215 start*/
if ($is_deleted !=0 )
{
@@ -114,8 +112,8 @@ class Item extends CI_Model
{
$this->db->from('items');
$this->db->where('item_number',$item_number);
- $this->db->where('deleted',0); // Parq 131226
-
+ $this->db->where('deleted',0); // Parq 131226
+
$query = $this->db->get();
if($query->num_rows()==1)
@@ -223,19 +221,19 @@ class Item extends CI_Model
}
/** GARRISON ADDED 4/21/2013 **/
//Search by description
- $this->db->from('items');
- $this->db->like('description', $search);
- $this->db->where('deleted',0);
- $this->db->order_by("description", "asc");
- $by_name = $this->db->get();
- foreach($by_name->result() as $row)
- {
- $suggestions[]=$row->name;
- }
+ $this->db->from('items');
+ $this->db->like('description', $search);
+ $this->db->where('deleted',0);
+ $this->db->order_by("description", "asc");
+ $by_name = $this->db->get();
+ foreach($by_name->result() as $row)
+ {
+ $suggestions[]=$row->name;
+ }
/** END GARRISON ADDED **/
/** GARRISON ADDED 4/22/2013 **/
- //Search by custom fields
+ //Search by custom fields
$this->db->from('items');
$this->db->like('custom1', $search);
$this->db->or_like('custom2', $search);
@@ -246,13 +244,13 @@ class Item extends CI_Model
$this->db->or_like('custom7', $search);
$this->db->or_like('custom8', $search);
$this->db->or_like('custom9', $search);
- $this->db->or_like('custom10', $search);
- $this->db->where('deleted',0);
- $this->db->order_by("name", "asc");
- $by_name = $this->db->get();
- foreach($by_name->result() as $row)
- {
- $suggestions[]=$row->name;
+ $this->db->or_like('custom10', $search);
+ $this->db->where('deleted',0);
+ $this->db->order_by("name", "asc");
+ $by_name = $this->db->get();
+ foreach($by_name->result() as $row)
+ {
+ $suggestions[]=$row->name;
}
/** END GARRISON ADDED **/
@@ -290,20 +288,21 @@ class Item extends CI_Model
}
/** GARRISON ADDED 4/21/2013 **/
//Search by description
- $this->db->from('items');
- $this->db->where('deleted',0);
- $this->db->like('description', $search);
- $this->db->order_by("description", "asc");
- $by_description = $this->db->get();
- foreach($by_description->result() as $row)
- {
- $suggestions[]=$row->item_id.'|'.$row->name;
- }
+ $this->db->from('items');
+ $this->db->where('deleted',0);
+ $this->db->like('description', $search);
+ $this->db->order_by("description", "asc");
+ $by_description = $this->db->get();
+ foreach($by_description->result() as $row)
+ {
+ $suggestions[]=$row->item_id.'|'.$row->name;
+ }
/** END GARRISON ADDED **/
/** GARRISON ADDED 4/22/2013 **/
- //Search by custom fields
- $this->db->from('items');
+ //Search by custom fields
+ /*$this->db->from('items');
$this->db->where('deleted',0);
+ $this->db->where('stock_type',$stock_type);
$this->db->like('custom1', $search);
$this->db->or_like('custom2', $search);
$this->db->or_like('custom3', $search);
@@ -313,13 +312,13 @@ class Item extends CI_Model
$this->db->or_like('custom7', $search);
$this->db->or_like('custom8', $search);
$this->db->or_like('custom9', $search);
- $this->db->or_like('custom10', $search);
- $this->db->order_by("name", "asc");
- $by_description = $this->db->get();
- foreach($by_description->result() as $row)
- {
- $suggestions[]=$row->item_id.'|'.$row->name;
- }
+ $this->db->or_like('custom10', $search);
+ $this->db->order_by("name", "asc");
+ $by_description = $this->db->get();
+ foreach($by_description->result() as $row)
+ {
+ $suggestions[]=$row->item_id.'|'.$row->name;
+ }*/
/** END GARRISON ADDED **/
//only return $limit suggestions
@@ -349,40 +348,40 @@ class Item extends CI_Model
}
/** GARRISON ADDED 5/18/2013 **/
- function get_location_suggestions($search)
- {
- $suggestions = array();
- $this->db->distinct();
- $this->db->select('location');
- $this->db->from('items');
- $this->db->like('location', $search);
- $this->db->where('deleted', 0);
- $this->db->order_by("location", "asc");
- $by_category = $this->db->get();
- foreach($by_category->result() as $row)
- {
- $suggestions[]=$row->location;
- }
-
- return $suggestions;
- }
+ function get_location_suggestions($search)
+ {
+ $suggestions = array();
+ $this->db->distinct();
+ $this->db->select('location');
+ $this->db->from('items');
+ $this->db->like('location', $search);
+ $this->db->where('deleted', 0);
+ $this->db->order_by("location", "asc");
+ $by_category = $this->db->get();
+ foreach($by_category->result() as $row)
+ {
+ $suggestions[]=$row->location;
+ }
+
+ return $suggestions;
+ }
- function get_custom1_suggestions($search)
- {
- $suggestions = array();
- $this->db->distinct();
- $this->db->select('custom1');
- $this->db->from('items');
- $this->db->like('custom1', $search);
- $this->db->where('deleted', 0);
- $this->db->order_by("custom1", "asc");
- $by_category = $this->db->get();
- foreach($by_category->result() as $row)
- {
- $suggestions[]=$row->custom1;
- }
-
- return $suggestions;
+ function get_custom1_suggestions($search)
+ {
+ $suggestions = array();
+ $this->db->distinct();
+ $this->db->select('custom1');
+ $this->db->from('items');
+ $this->db->like('custom1', $search);
+ $this->db->where('deleted', 0);
+ $this->db->order_by("custom1", "asc");
+ $by_category = $this->db->get();
+ foreach($by_category->result() as $row)
+ {
+ $suggestions[]=$row->custom1;
+ }
+
+ return $suggestions;
}
function get_custom2_suggestions($search)
@@ -583,5 +582,27 @@ class Item extends CI_Model
return $this->db->get();
}
+
+ function is_sale_store_item_exist($item_number)
+ {
+ $this->db->from('items');
+ $this->db->where('item_number',$item_number);
+ $this->db->where('stock_type','sale_stock');
+ $this->db->where('deleted',0);
+
+ $query = $this->db->get();
+ return ($query->num_rows()==1);
+ }
+
+ function is_warehouse_item_exist($item_number)
+ {
+ $this->db->from('items');
+ $this->db->where('item_number',$item_number);
+ $this->db->where('stock_type','warehouse');
+ $this->db->where('deleted',0);
+
+ $query = $this->db->get();
+ return ($query->num_rows()==1);
+ }
}
-?>
+?>
\ No newline at end of file
diff --git a/application/models/item_quantities.php b/application/models/item_quantities.php
new file mode 100644
index 000000000..48059e535
--- /dev/null
+++ b/application/models/item_quantities.php
@@ -0,0 +1,51 @@
+db->from('item_quantities');
+ $this->db->where('item_id',$item_id);
+ $this->db->where('location_id',$location_id);
+ $query = $this->db->get();
+
+ return ($query->num_rows()==1);
+ }
+
+ function save($location_detail, $item_id, $location_id)
+ {
+ if (!($item_id && $location_id) or !$this->exists($item_id,$location_id))
+ {
+ if($this->db->insert('item_quantities',$location_detail))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ $this->db->where('item_id', $item_id);
+ $this->db->where('location_id', $location_id);
+ return $this->db->update('item_quantities',$location_detail);
+ }
+
+ function get_item_quantity($item_id, $location_id)
+ {
+ $this->db->from('item_quantities');
+ $this->db->where('item_id',$item_id);
+ $this->db->where('location_id',$location_id);
+ $result = $this->db->get()->row();
+ if(empty($result) == true)
+ {
+ //Get empty base parent object, as $item_id is NOT an item
+ $result=new stdClass();
+ //Get all the fields from items table (TODO to be reviewed)
+ $fields = $this->db->list_fields('item_quantities');
+ foreach ($fields as $field)
+ {
+ $result->$field='';
+ }
+ $result->quantity = 0;
+ }
+ return $result;
+ }
+}
+?>
\ No newline at end of file
diff --git a/application/models/receiving.php b/application/models/receiving.php
index da28232d1..94273115d 100644
--- a/application/models/receiving.php
+++ b/application/models/receiving.php
@@ -1,13 +1,13 @@
db->from('receivings');
$this->db->where('receiving_id',$receiving_id);
return $this->db->get();
}
-
+
function exists($receiving_id)
{
$this->db->from('receivings');
@@ -50,14 +50,18 @@ class Receiving extends CI_Model
'quantity_purchased'=>$item['quantity'],
'discount_percent'=>$item['discount'],
'item_cost_price' => $cur_item_info->cost_price,
- 'item_unit_price'=>$item['price']
+ 'item_unit_price'=>$item['price'],
+ 'item_location'=>$item['item_location']
);
$this->db->insert('receivings_items',$receivings_items_data);
//Update stock quantity
- $item_data = array('quantity'=>$cur_item_info->quantity + $item['quantity']);
- $this->Item->save($item_data,$item['item_id']);
+ $item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
+ $this->Item_quantities->save(array('quantity'=>$item_quantity->quantity + $item['quantity'],
+ 'item_id'=>$item['item_id'],
+ 'location_id'=>$item['item_location']), $item['item_id'], $item['item_location']);
+
$qty_recv = $item['quantity'];
$recv_remarks ='RECV '.$receiving_id;
@@ -66,6 +70,7 @@ class Receiving extends CI_Model
'trans_date'=>date('Y-m-d H:i:s'),
'trans_items'=>$item['item_id'],
'trans_user'=>$employee_id,
+ 'trans_location'=>$item['item_location'],
'trans_comment'=>$recv_remarks,
'trans_inventory'=>$qty_recv
);
@@ -89,7 +94,7 @@ class Receiving extends CI_Model
$this->db->where('receiving_id',$receiving_id);
return $this->db->get();
}
-
+
function get_supplier($receiving_id)
{
$this->db->from('receivings');
@@ -112,7 +117,6 @@ class Receiving extends CI_Model
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('receivings_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."
GROUP BY receiving_id, item_id, line)");
}
-
-
+
}
?>
diff --git a/application/models/reports/detailed_receivings.php b/application/models/reports/detailed_receivings.php
index 0af71d504..0ff381ed7 100644
--- a/application/models/reports/detailed_receivings.php
+++ b/application/models/reports/detailed_receivings.php
@@ -21,14 +21,18 @@ class Detailed_receivings extends Report
$this->db->join('people as employee', 'receivings_items_temp.employee_id = employee.person_id');
$this->db->join('people as supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
$this->db->where('receiving_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
- if ($inputs['sale_type'] == 'sales')
+ if ($inputs['receiving_type'] == 'receiving')
{
$this->db->where('quantity_purchased > 0');
}
- elseif ($inputs['sale_type'] == 'returns')
+ elseif ($inputs['receiving_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
+ elseif ($inputs['receiving_type'] == 'requisitions')
+ {
+ $this->db->having('items_purchased = 0');
+ }
$this->db->group_by('receiving_id');
$this->db->order_by('receiving_date');
@@ -53,14 +57,18 @@ class Detailed_receivings extends Report
$this->db->select('sum(total) as total');
$this->db->from('receivings_items_temp');
$this->db->where('receiving_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
- if ($inputs['sale_type'] == 'sales')
+ if ($inputs['receiving_type'] == 'receiving')
{
$this->db->where('quantity_purchased > 0');
}
- elseif ($inputs['sale_type'] == 'returns')
+ elseif ($inputs['receiving_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
+ elseif ($inputs['receiving_type'] == 'requisitions')
+ {
+ $this->db->where('quantity_purchased = 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/detailed_sales.php b/application/models/reports/detailed_sales.php
index 9a19decb4..edb330aa7 100644
--- a/application/models/reports/detailed_sales.php
+++ b/application/models/reports/detailed_sales.php
@@ -40,13 +40,14 @@ class Detailed_sales extends Report
$this->db->join('people as customer', 'sales_items_temp.customer_id = customer.person_id', 'left');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ $this->db->where('sale_type', 'sale_stock');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('sale_id');
$this->db->order_by('sale_date');
@@ -72,13 +73,13 @@ class Detailed_sales extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
diff --git a/application/models/reports/inventory_low.php b/application/models/reports/inventory_low.php
index 98652e6a7..3c460a7b8 100644
--- a/application/models/reports/inventory_low.php
+++ b/application/models/reports/inventory_low.php
@@ -9,19 +9,25 @@ class Inventory_low extends Report
public function getDataColumns()
{
- return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'));
+ return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'), $this->lang->line('reports_stock_location'));
}
- public function getData(array $inputs)
- {
- $this->db->select('name, item_number, quantity, reorder_level, description');
- $this->db->from('items');
- $this->db->where('quantity <= reorder_level and deleted=0');
- $this->db->order_by('name');
-
- return $this->db->get()->result_array();
+ public function getData(array $inputs)
+ {
+ $this->db->from('items');
+ $this->db->join('item_quantities','items.item_id=item_quantities.item_id');
+ $this->db->join('stock_locations','item_quantities.location_id=stock_locations.location_id');
+
+ $this->db->select('name, item_number, reorder_level, item_quantities.quantity,description,location_name');
- }
+ $this->db->where('item_quantities.quantity <= reorder_level');
+ $this->db->where('items.deleted = 0');
+
+ $this->db->order_by('name');
+
+ return $this->db->get()->result_array();
+
+ }
public function getSummaryData(array $inputs)
{
diff --git a/application/models/reports/inventory_summary.php b/application/models/reports/inventory_summary.php
index a6130f891..4525f1255 100644
--- a/application/models/reports/inventory_summary.php
+++ b/application/models/reports/inventory_summary.php
@@ -9,15 +9,18 @@ class Inventory_summary extends Report
public function getDataColumns()
{
- return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'));
+ return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'),$this->lang->line('reports_stock_location'));
}
public function getData(array $inputs)
{
- $this->db->select('name, item_number, quantity, reorder_level, description');
- $this->db->from('items');
- $this->db->where('deleted', 0);
- $this->db->order_by('name');
+ $this->db->from('items');
+ $this->db->join('item_quantities','items.item_id=item_quantities.item_id');
+ $this->db->join('stock_locations','item_quantities.location_id=stock_locations.location_id');
+
+ $this->db->select('name, item_number, reorder_level, item_quantities.quantity, description,location_name');
+ $this->db->where('items.deleted', 0);
+ $this->db->order_by('items.name');
return $this->db->get()->result_array();
diff --git a/application/models/reports/specific_customer.php b/application/models/reports/specific_customer.php
index 0b2f8c342..5a9d93907 100644
--- a/application/models/reports/specific_customer.php
+++ b/application/models/reports/specific_customer.php
@@ -21,13 +21,13 @@ class Specific_customer extends Report
$this->db->join('people', 'sales_items_temp.employee_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('sale_id');
$this->db->order_by('sale_date');
@@ -53,13 +53,13 @@ class Specific_customer extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/specific_employee.php b/application/models/reports/specific_employee.php
index 39fff80f9..80b1cef39 100644
--- a/application/models/reports/specific_employee.php
+++ b/application/models/reports/specific_employee.php
@@ -22,13 +22,13 @@ class Specific_employee extends Report
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and employee_id='.$inputs['employee_id']);
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('sale_id');
$this->db->order_by('sale_date');
@@ -55,13 +55,13 @@ class Specific_employee extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and employee_id='.$inputs['employee_id']);
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_categories.php b/application/models/reports/summary_categories.php
index 27c30ae46..bf00bb974 100644
--- a/application/models/reports/summary_categories.php
+++ b/application/models/reports/summary_categories.php
@@ -19,13 +19,13 @@ class Summary_categories extends Report
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('category');
$this->db->order_by('category');
@@ -39,13 +39,13 @@ class Summary_categories extends Report
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
diff --git a/application/models/reports/summary_customers.php b/application/models/reports/summary_customers.php
index 1f8fa6aea..0e500be0c 100644
--- a/application/models/reports/summary_customers.php
+++ b/application/models/reports/summary_customers.php
@@ -20,13 +20,13 @@ class Summary_customers extends Report
$this->db->join('people', 'customers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('customer_id');
$this->db->order_by('last_name');
@@ -41,13 +41,13 @@ class Summary_customers extends Report
$this->db->join('people', 'customers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_discounts.php b/application/models/reports/summary_discounts.php
index 6b3949eb0..0b98450a8 100644
--- a/application/models/reports/summary_discounts.php
+++ b/application/models/reports/summary_discounts.php
@@ -18,13 +18,13 @@ class Summary_discounts extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and discount_percent > 0');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('sales_items_temp.discount_percent');
$this->db->order_by('discount_percent');
return $this->db->get()->result_array();
@@ -36,13 +36,13 @@ class Summary_discounts extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_employees.php b/application/models/reports/summary_employees.php
index 5308e8e95..214293f8e 100644
--- a/application/models/reports/summary_employees.php
+++ b/application/models/reports/summary_employees.php
@@ -20,13 +20,13 @@ class Summary_employees extends Report
$this->db->join('people', 'employees.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('employee_id');
$this->db->order_by('last_name');
@@ -41,13 +41,13 @@ class Summary_employees extends Report
$this->db->join('people', 'employees.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
diff --git a/application/models/reports/summary_items.php b/application/models/reports/summary_items.php
index 8aefb5475..e1d08ad3d 100644
--- a/application/models/reports/summary_items.php
+++ b/application/models/reports/summary_items.php
@@ -19,13 +19,13 @@ class Summary_items extends Report
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('items.item_id');
$this->db->order_by('name');
@@ -39,13 +39,13 @@ class Summary_items extends Report
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_payments.php b/application/models/reports/summary_payments.php
index 2c95ac69c..2bfa4317e 100644
--- a/application/models/reports/summary_payments.php
+++ b/application/models/reports/summary_payments.php
@@ -19,13 +19,13 @@ class Summary_payments extends Report
$this->db->join('sales', 'sales.sale_id=sales_payments.sale_id');
$this->db->where('date(sale_time) BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('payment_amount > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('payment_amount < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by("payment_type");
return $this->db->get()->result_array();
}
@@ -37,13 +37,13 @@ class Summary_payments extends Report
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_sales.php b/application/models/reports/summary_sales.php
index e7914a9ee..97c90757b 100644
--- a/application/models/reports/summary_sales.php
+++ b/application/models/reports/summary_sales.php
@@ -17,14 +17,14 @@ class Summary_sales extends Report
$this->db->select('sale_date, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit');
$this->db->from('sales_items_temp');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
-
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
+
$this->db->group_by('sale_date');
$this->db->having('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
$this->db->order_by('sale_date');
@@ -37,13 +37,13 @@ class Summary_sales extends Report
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
diff --git a/application/models/reports/summary_suppliers.php b/application/models/reports/summary_suppliers.php
index 98566c343..6ee376a3f 100644
--- a/application/models/reports/summary_suppliers.php
+++ b/application/models/reports/summary_suppliers.php
@@ -20,13 +20,13 @@ class Summary_suppliers extends Report
$this->db->join('people', 'suppliers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
$this->db->group_by('supplier_id');
$this->db->order_by('last_name');
@@ -41,14 +41,13 @@ class Summary_suppliers extends Report
$this->db->join('people', 'suppliers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
-
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
return $this->db->get()->row_array();
}
}
diff --git a/application/models/reports/summary_taxes.php b/application/models/reports/summary_taxes.php
index 824a72749..d434b5818 100644
--- a/application/models/reports/summary_taxes.php
+++ b/application/models/reports/summary_taxes.php
@@ -52,13 +52,14 @@ class Summary_taxes extends Report
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
- {
- $this->db->where('quantity_purchased > 0');
- }
- elseif ($inputs['sale_type'] == 'returns')
- {
- $this->db->where('quantity_purchased < 0');
- }
+ {
+ $this->db->where('quantity_purchased > 0');
+ }
+ elseif ($inputs['sale_type'] == 'returns')
+ {
+ $this->db->where('quantity_purchased < 0');
+ }
+
return $this->db->get()->row_array();
}
diff --git a/application/models/sale.php b/application/models/sale.php
index f649afe6e..ccd2fb7c2 100644
--- a/application/models/sale.php
+++ b/application/models/sale.php
@@ -88,14 +88,18 @@ class Sale extends CI_Model
'quantity_purchased'=>$item['quantity'],
'discount_percent'=>$item['discount'],
'item_cost_price' => $cur_item_info->cost_price,
- 'item_unit_price'=>$item['price']
+ 'item_unit_price'=>$item['price'],
+ 'item_location'=>$item['item_location']
);
$this->db->insert('sales_items',$sales_items_data);
//Update stock quantity
- $item_data = array('quantity'=>$cur_item_info->quantity - $item['quantity']);
- $this->Item->save($item_data,$item['item_id']);
+ $item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
+ $this->Item_quantities->save(array('quantity'=>$item_quantity->quantity - $item['quantity'],
+ 'item_id'=>$item['item_id'],
+ 'location_id'=>$item['item_location']), $item['item_id'], $item['item_location']);
+
//Ramel Inventory Tracking
//Inventory Count Details
@@ -106,6 +110,7 @@ class Sale extends CI_Model
'trans_date'=>date('Y-m-d H:i:s'),
'trans_items'=>$item['item_id'],
'trans_user'=>$employee_id,
+ 'trans_location'=>$item['item_location'],
'trans_comment'=>$sale_remarks,
'trans_inventory'=>$qty_buy
);
diff --git a/application/models/sale_suspended.php b/application/models/sale_suspended.php
index 3c46b6274..78bfd453c 100644
--- a/application/models/sale_suspended.php
+++ b/application/models/sale_suspended.php
@@ -84,7 +84,8 @@ class Sale_suspended extends CI_Model
'quantity_purchased'=>$item['quantity'],
'discount_percent'=>$item['discount'],
'item_cost_price' => $cur_item_info->cost_price,
- 'item_unit_price'=>$item['price']
+ 'item_unit_price'=>$item['price'],
+ 'item_location'=>$item['item_location']
);
$this->db->insert('sales_suspended_items',$sales_items_data);
diff --git a/application/models/stock_locations.php b/application/models/stock_locations.php
new file mode 100644
index 000000000..4ad2107de
--- /dev/null
+++ b/application/models/stock_locations.php
@@ -0,0 +1,110 @@
+db->from('stock_locations');
+ $this->db->where('location_name',$location_name);
+ $query = $this->db->get();
+
+ return ($query->num_rows()==1);
+ }
+
+ function get_all($limit=10000, $offset=0)
+ {
+ $this->db->from('stock_locations');
+ $this->db->limit($limit);
+ $this->db->offset($offset);
+ return $this->db->get();
+ }
+
+ function get_location_names()
+ {
+ $this->db->select('location_name');
+ $this->db->from('stock_locations');
+ $this->db->where('deleted', 0);
+ return $this->db->get();
+ }
+
+ function concat_location_names()
+ {
+ $this->db->select('GROUP_CONCAT(location_name SEPARATOR\',\') AS location_names', FALSE);
+ $this->db->from('stock_locations');
+ $this->db->where('deleted', 0);
+ return $this->db->get()->row();
+ }
+
+ function get_undeleted_all($limit=10000, $offset=0)
+ {
+ $this->db->from('stock_locations');
+ $this->db->where('deleted',0);
+ $this->db->limit($limit);
+ $this->db->offset($offset);
+ return $this->db->get();
+ }
+
+ function get_location_id($location_name)
+ {
+ $this->db->from('stock_locations');
+ $this->db->where('deleted',0);
+ $this->db->where('location_name',$location_name);
+ return $this->db->get()->row()->location_id;
+ }
+
+ function get_location_name($location_id)
+ {
+ $this->db->from('stock_locations');
+ $this->db->where('deleted',0);
+ $this->db->where('location_id',$location_id);
+ return $this->db->get()->row()->location_name;
+ }
+
+ function array_save($stock_locations)
+ {
+ $location_db = $this->get_all()->result_array();
+ //Delete all in db
+ $this->db->trans_start();
+ $location_ids=array();
+ foreach($location_db as $db)
+ {
+ array_push($location_ids,$db['location_id']);
+ }
+ if (sizeof($location_ids) > 0)
+ {
+ $this->db->where_in('location_id', $location_ids);
+ $this->db->update('stock_locations',array('deleted'=>1));
+ $this->db->trans_complete();
+ }
+
+ $location_db = $this->get_all()->result_array();
+ //Update the stock location
+ $this->db->trans_start();
+ foreach ($stock_locations as $location)
+ {
+ $to_create = true;
+ foreach($location_db as $db)
+ {
+ if($db['location_name'] == $location)
+ {
+ if($db['deleted'] == 1)
+ {
+ $this->db->where('location_id', $db['location_id']);
+
+ $this->db->update('stock_locations',array('location_name'=>$db['location_name'],'deleted'=>0));
+ }
+ $to_create = false;
+ break;
+ }
+ }
+
+ if($to_create)
+ {
+ $location_data = array('location_name'=>$location,'deleted'=>0);
+ $this->db->insert('stock_locations',$location_data);
+ }
+ }
+ $this->db->trans_complete();
+ return true;
+ }
+}
+?>
diff --git a/application/views/config.php b/application/views/config.php
index b85afcba9..83637776f 100644
--- a/application/views/config.php
+++ b/application/views/config.php
@@ -258,6 +258,16 @@ echo form_open('config/save/',array('id'=>'config_form'));
+
+lang->line('config_stock_location').':', 'stock_location',array('class'=>'required wide')); ?>
+
+ 'stock_location',
+ 'id'=>'stock_location',
+ 'value'=>$location_names)); ?>
+
+
+
lang->line('config_print_after_sale').':', 'print_after_sale',array('class'=>'wide')); ?>
@@ -420,7 +430,9 @@ $(document).ready(function()
number:true
},
email:"email",
- return_policy: "required"
+ return_policy: "required",
+ stock_location:"required"
+
},
messages:
{
@@ -433,7 +445,8 @@ $(document).ready(function()
number:"lang->line('config_default_tax_rate_number'); ?>"
},
email: "lang->line('common_email_invalid_format'); ?>",
- return_policy:"lang->line('config_return_policy_required'); ?>"
+ return_policy:"lang->line('config_return_policy_required'); ?>",
+ stock_location:"lang->line('config_stock_location_required'); ?>"
}
});
diff --git a/application/views/items/count_details.php b/application/views/items/count_details.php
index 22b48115c..276f4e08b 100644
--- a/application/views/items/count_details.php
+++ b/application/views/items/count_details.php
@@ -59,6 +59,16 @@ echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_for
+lang->line('items_stock_location').':', 'stock_location',array('class'=>'wide')); ?>
+
+
+
+
+
+
+
lang->line('items_current_quantity').':', 'quantity',array('class'=>'wide')); ?>
@@ -66,7 +76,7 @@ echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_for
'name'=>'quantity',
'id'=>'quantity',
- 'value'=>$item_info->quantity,
+ 'value'=>current($item_quantities),
'style' => 'border:none',
'readonly' => 'readonly'
);
@@ -89,26 +99,73 @@ echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_for
-
-Inventory Data Tracking
-Date Employee In/Out Qty Remarks
Inventory->get_inventory_data_for_item($item_info->item_id)->result_array() as $row)
+$inventory_array = $this->Inventory->get_inventory_data_for_item($item_info->item_id)->result_array();
+$employee_name = array();
+foreach( $inventory_array as $row)
{
-?>
-
-
-Employee->get_info($person_id);
- echo $employee->first_name." ".$employee->last_name;
- ?>
-
-
-
-
-
-Employee->get_info($person_id);
+ array_push($employee_name, $employee->first_name." ".$employee->last_name);
}
?>
-
\ No newline at end of file
+
+Inventory Data Tracking
+Date Employee In/Out Qty Remarks
+
+
+
\ No newline at end of file
diff --git a/application/views/items/form.php b/application/views/items/form.php
index 449c9ee49..8b67c77c3 100644
--- a/application/views/items/form.php
+++ b/application/views/items/form.php
@@ -112,17 +112,25 @@ echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form'));
-
-
-lang->line('items_quantity').':', 'quantity',array('class'=>'required wide')); ?>
-
- 'quantity',
- 'id'=>'quantity',
- 'value'=>$item_info->quantity)
- );?>
-
-
+$location_detail)
+{
+?>
+
+ lang->line('items_quantity').' '.$location_detail['location_name'] .':',
+ $key.'_quantity',
+ array('class'=>'required wide')); ?>
+
+ $key.'_quantity',
+ 'id'=>$key.'_quantity',
+ 'value'=>$location_detail['quantity'])
+ );?>
+
+
+
lang->line('items_reorder_level').':', 'reorder_level',array('class'=>'required wide')); ?>
@@ -135,17 +143,6 @@ echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form'));
-
-lang->line('items_location').':', 'location',array('class'=>'wide')); ?>
-
- 'location',
- 'id'=>'location',
- 'value'=>$item_info->location)
- );?>
-
-
-
lang->line('items_description').':', 'description',array('class'=>'wide')); ?>
@@ -373,11 +370,6 @@ $(document).ready(function()
$("#category").result(function(event, data, formatted){});
$("#category").search();
-/** GARRISON ADDED 5/18/2013 **/
- $("#location").autocomplete("",{max:100,minChars:0,delay:10});
- $("#location").result(function(event, data, formatted){});
- $("#location").search();
-
$("#custom1").autocomplete("",{max:100,minChars:0,delay:10});
$("#custom1").result(function(event, data, formatted){});
$("#custom1").search();
@@ -419,7 +411,6 @@ $(document).ready(function()
$("#custom10").search();
/** END GARRISON ADDED **/
-
$('#item_form').validate({
submitHandler:function(form)
{
@@ -460,16 +451,12 @@ $(document).ready(function()
required:true,
number:true
},
- quantity:
- {
- required:true,
- number:true
- },
reorder_level:
{
required:true,
number:true
}
+
},
messages:
{
@@ -490,11 +477,6 @@ $(document).ready(function()
required:"lang->line('items_tax_percent_required'); ?>",
number:"lang->line('items_tax_percent_number'); ?>"
},
- quantity:
- {
- required:"lang->line('items_quantity_required'); ?>",
- number:"lang->line('items_quantity_number'); ?>"
- },
reorder_level:
{
required:"lang->line('items_reorder_level_required'); ?>",
diff --git a/application/views/items/inventory.php b/application/views/items/inventory.php
index 178c2d3b4..9cb5be9f7 100644
--- a/application/views/items/inventory.php
+++ b/application/views/items/inventory.php
@@ -62,6 +62,16 @@ echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_for
+lang->line('items_stock_location').':', 'stock_location',array('class'=>'wide')); ?>
+
+
+
+
+
+
+
lang->line('items_current_quantity').':', 'quantity',array('class'=>'wide')); ?>
@@ -69,7 +79,7 @@ echo form_open('items/save_inventory/'.$item_info->item_id,array('id'=>'item_for
'name'=>'quantity',
'id'=>'quantity',
- 'value'=>$item_info->quantity,
+ 'value'=>current($item_quantities),
'style' => 'border:none',
'readonly' => 'readonly'
);
@@ -154,4 +164,11 @@ $(document).ready(function()
}
});
});
+
+
+function fill_quantity(val)
+{
+ var item_quantities= ;
+ document.getElementById("quantity").value = item_quantities[val];
+}
\ No newline at end of file
diff --git a/application/views/items/manage.php b/application/views/items/manage.php
index a9002f4c7..7210092d1 100644
--- a/application/views/items/manage.php
+++ b/application/views/items/manage.php
@@ -22,7 +22,7 @@ $(document).ready(function()
$(this).attr('href','index.php/items/generate_barcodes/'+selected.join(':'));
});
- $("#low_inventory, #is_serialized, #no_description, #search_custom, #is_deleted").click(function()
+ $("#is_serialized, #no_description, #search_custom, #is_deleted").click(function()
{
$('#items_filter_form').submit();
});
@@ -135,16 +135,12 @@ function show_hide_search_filter(search_filter_section, switchImgTag) {
'items_filter_form')); ?>
- lang->line('items_low_inventory_items').' '.':', 'low_inventory');?>
- 'low_inventory','id'=>'low_inventory','value'=>1,'checked'=> isset($low_inventory)? ( ($low_inventory)? 1 : 0) : 0)).' | ';?>
lang->line('items_serialized_items').' '.':', 'is_serialized');?>
'is_serialized','id'=>'is_serialized','value'=>1,'checked'=> isset($is_serialized)? ( ($is_serialized)? 1 : 0) : 0)).' | ';?>
lang->line('items_no_description_items').' '.':', 'no_description');?>
'no_description','id'=>'no_description','value'=>1,'checked'=> isset($no_description)? ( ($no_description)? 1 : 0) : 0)).' | ';?>
lang->line('items_search_custom_items').' '.':', 'search_custom');//GARRISON ADDED 4/21/2013?>
- 'search_custom','id'=>'search_custom','value'=>1,'checked'=> isset($search_custom)? ( ($search_custom)? 1 : 0) : 0)).' | ';//GARRISON ADDED 4/21/2013?>
- lang->line('items_is_deleted').' '.':', 'is_deleted');// Parq 131215?>
- 'is_deleted','id'=>'is_deleted','value'=>1,'checked'=> isset($is_deleted)? ( ($is_deleted)? 1 : 0) : 0)).' | ';// Parq 131215?>
+ 'search_custom','id'=>'search_custom','value'=>1,'checked'=> isset($search_custom)? ( ($search_custom)? 1 : 0) : 0));//GARRISON ADDED 4/21/2013?>
@@ -163,8 +159,8 @@ function show_hide_search_filter(search_filter_section, switchImgTag) {
-
+
-load->view("partial/footer"); ?>
+load->view("partial/footer"); ?>
\ No newline at end of file
diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php
index f8d3cf4cd..004f21ef1 100644
--- a/application/views/receivings/receipt.php
+++ b/application/views/receivings/receipt.php
@@ -41,7 +41,9 @@ if (isset($error_message))
-
+
@@ -58,11 +60,15 @@ if (isset($error_message))
lang->line('sales_total'); ?>
-
+
lang->line('sales_payment'); ?>
+
+
diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php
index 09912398f..bb19ce513 100644
--- a/application/views/receivings/receiving.php
+++ b/application/views/receivings/receiving.php
@@ -13,14 +13,30 @@ if(isset($error))
'mode_form')); ?>
-
lang->line('recvs_mode') ?>
+
lang->line('recvs_mode') ?>
+
+
+
lang->line('recvs_stock_source') ?>
+
+
+
lang->line('recvs_stock_destination') ?>
+
'add_item_form')); ?>
lang->line('recvs_find_or_scan_item');
}
@@ -45,14 +61,13 @@ if(isset($error))
-lang->line('common_delete'); ?>
-
-lang->line('recvs_item_name'); ?>
-lang->line('recvs_cost'); ?>
-lang->line('recvs_quantity'); ?>
-lang->line('recvs_discount'); ?>
-lang->line('recvs_total'); ?>
-lang->line('recvs_edit'); ?>
+ lang->line('common_delete'); ?>
+ lang->line('recvs_item_name'); ?>
+ lang->line('recvs_cost'); ?>
+ lang->line('recvs_quantity'); ?>
+ lang->line('recvs_discount'); ?>
+ lang->line('recvs_total'); ?>
+ lang->line('recvs_edit'); ?>
@@ -69,48 +84,59 @@ else
{
foreach(array_reverse($cart, true) as $line=>$item)
{
- echo form_open("receivings/edit_item/$line");
- ?>
-
- lang->line('common_delete').']');?>
+ echo form_open("receivings/edit_item/$line");
+
+?>
+
+ lang->line('common_delete').']');?>
+ [ in ]
+
-
-
-
-
+?>
-
-
- 'price','value'=>$item['price'],'size'=>'6'));?>
-
-
-
-
-
- 'quantity','value'=>$item['quantity'],'size'=>'2'));
- ?>
-
-
-
- 'discount','value'=>$item['discount'],'size'=>'3'));?>
-
- lang->line('sales_edit_item'));?>
-
-
-
+ 'price','value'=>$item['price'],'size'=>'6'));?>
+
+
+
+
+
+'quantity','value'=>$item['quantity'],'size'=>'2'));
+?>
+
+
+
+ 'discount','value'=>$item['discount'],'size'=>'3'));?>
+
+
+
+
+
+ lang->line('sales_edit_item'));?>
+
+
+
@@ -144,13 +170,49 @@ else
}
?>
+
lang->line('sales_total'); ?>:
+
+
+
0)
{
+ if($mode == 'requisition')
+ {
+ ?>
+
+
+
+ 'finish_sale_form')); ?>
+
+
+ 'comment','value'=>'','rows'=>'4','cols'=>'23'));?>
+
+
+ ".$this->lang->line('recvs_complete_receiving')."
";
+ ?>
+
+
+ 'cancel_sale_form')); ?>
+
+ Cancel
+
+
+
+
'finish_sale_form')); ?>
@@ -194,6 +256,7 @@ else
diff --git a/application/views/reports/date_input.php b/application/views/reports/date_input.php
index 3f2095ad2..332476204 100644
--- a/application/views/reports/date_input.php
+++ b/application/views/reports/date_input.php
@@ -39,6 +39,36 @@ if(isset($error))
}
?>
+
+
+ lang->line('reports_sale_type'), 'reports_sale_type_label', array('class'=>'required')); ?>
+
+ $this->lang->line('reports_all'),
+ 'sales' => $this->lang->line('reports_sales'),
+ 'returns' => $this->lang->line('reports_returns')), 'all', 'id="input_type"'); ?>
+
+
+ lang->line('reports_receiving_type'), 'reports_receiving_type_label', array('class'=>'required')); ?>
+
+ $this->lang->line('reports_all'),
+ 'receiving' => $this->lang->line('reports_receivings'),
+ 'returns' => $this->lang->line('reports_returns'),
+ 'requisitions' => $this->lang->line('reports_requisitions')), 'all', 'id="input_type"'); ?>
+
+
'generate_report',
@@ -55,18 +85,24 @@ $(document).ready(function()
{
$("#generate_report").click(function()
{
- var sale_type = $("#sale_type").val();
+ var input_type = $("#input_type").val();
if ($("#simple_radio").attr('checked'))
{
- window.location = window.location+'/'+$("#report_date_range_simple option:selected").val() + '/' + sale_type;
+ window.location = window.location+'/'+$("#report_date_range_simple option:selected").val() + '/' + input_type;
}
else
{
var start_date = $("#start_year").val()+'-'+$("#start_month").val()+'-'+$('#start_day').val();
var end_date = $("#end_year").val()+'-'+$("#end_month").val()+'-'+$('#end_day').val();
-
- window.location = window.location+'/'+start_date + '/'+ end_date+ '/' + sale_type;
+ if(input_type == null)
+ {
+ window.location = window.location+'/'+start_date + '/'+ end_date;
+ }
+ else
+ {
+ window.location = window.location+'/'+start_date + '/'+ end_date+ '/' + input_type;
+ }
}
});
diff --git a/application/views/reports/date_input_excel_export.php b/application/views/reports/date_input_excel_export.php
index 188e26b79..951258a52 100644
--- a/application/views/reports/date_input_excel_export.php
+++ b/application/views/reports/date_input_excel_export.php
@@ -25,7 +25,9 @@ if(isset($error))
lang->line('reports_sale_type'), 'reports_sale_type_label', array('class'=>'required')); ?>
- $this->lang->line('reports_all'), 'sales' => $this->lang->line('reports_sales'), 'returns' => $this->lang->line('reports_returns')), 'all', 'id="sale_type"'); ?>
+ $this->lang->line('reports_all'),
+ 'sales' => $this->lang->line('reports_sales'),
+ 'returns' => $this->lang->line('reports_returns')), 'all', 'id="sale_type"'); ?>
diff --git a/application/views/reports/listing.php b/application/views/reports/listing.php
index 28e3152ce..37589ae9b 100644
--- a/application/views/reports/listing.php
+++ b/application/views/reports/listing.php
@@ -57,3 +57,8 @@ if(isset($error))
?>
load->view("partial/footer"); ?>
+
diff --git a/application/views/reports/specific_input.php b/application/views/reports/specific_input.php
index 7bb1710ac..3e65bb2cb 100644
--- a/application/views/reports/specific_input.php
+++ b/application/views/reports/specific_input.php
@@ -31,7 +31,9 @@ if(isset($error))
lang->line('reports_sale_type'), 'reports_sale_type_label', array('class'=>'required')); ?>
- $this->lang->line('reports_all'), 'sales' => $this->lang->line('reports_sales'), 'returns' => $this->lang->line('reports_returns')), 'all', 'id="sale_type"'); ?>
+ $this->lang->line('reports_all'),
+ 'sales' => $this->lang->line('reports_sales'),
+ 'returns' => $this->lang->line('reports_returns')) , 'all', 'id="sale_type"'); ?>
diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php
index 6031cc643..57dc7960d 100644
--- a/application/views/sales/receipt.php
+++ b/application/views/sales/receipt.php
@@ -43,7 +43,9 @@ if (isset($error_message))
-
+
diff --git a/application/views/sales/register.php b/application/views/sales/register.php
index 6444afaa4..d22ba61ef 100644
--- a/application/views/sales/register.php
+++ b/application/views/sales/register.php
@@ -1,5 +1,5 @@
load->view("partial/header"); ?>
-
lang->line('sales_register'); ?>
+
lang->line('sales_register'); ?>
'mode_form')); ?>
lang->line('sales_mode') ?>
+
+
lang->line('sales_stock_location') ?>
+
+
".$this->lang->line('sales_suspended_sales')."
",
array('class'=>'thickbox none','title'=>$this->lang->line('sales_suspended_sales')));
?>
-
+
'add_item_form')); ?>
lang->line('sales_find_or_scan_item');
}
@@ -41,36 +45,41 @@ else
}
?>
+
'item','id'=>'item','size'=>'40'));?>
+
+
+
+
+
+ lang->line('common_delete'); ?>
+ lang->line('sales_item_number'); ?>
+ lang->line('sales_item_name'); ?>
+ lang->line('sales_price'); ?>
+ lang->line('sales_quantity'); ?>
+ lang->line('sales_discount'); ?>
+ lang->line('sales_total'); ?>
+ lang->line('sales_edit'); ?>
+
+
+
-
-lang->line('sales_no_items_in_cart'); ?>
-
+
+
+ lang->line('sales_no_items_in_cart'); ?>
+
+
+
- lang->line('common_delete').']');?>
-
- [quantity; ?> in stock]
-
+ lang->line('common_delete').']');?>
+
+ [ in ]
+
+
'price','value'=>$item['price'],'size'=>'6'));?>
+
- 'discount','value'=>$item['discount'],'size'=>'3'));?>
-
- lang->line('sales_edit_item'));?>
-
-
- lang->line('sales_description_abbrv').':';?>
-
+ 'discount','value'=>$item['discount'],'size'=>'3'));?>
+
+ lang->line('sales_edit_item'));?>
+
+
+ lang->line('sales_description_abbrv').':';?>
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
+
-
+
@@ -193,29 +205,29 @@ else
lang->line('sales_select_customer'); ?>
'customer','id'=>'customer','size'=>'30','value'=>$this->lang->line('sales_start_typing_customer_name')));?>
-
+
lang->line('common_or'); ?>
".$this->lang->line('sales_new_customer')." ",
array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_customer')));
?>
-
+
-
lang->line('sales_sub_total'); ?>:
-
+
lang->line('sales_sub_total'); ?>:
+
$value) { ?>
-
:
-
+
:
+
-
lang->line('sales_total'); ?>:
-
+
lang->line('sales_total'); ?>:
+
@@ -229,12 +241,13 @@ else
'cancel_sale_form')); ?>
-
-
+
+
+
0)
@@ -244,7 +257,8 @@ else
'finish_sale_form')); ?>
'comment', 'id' => 'comment', 'value'=>$comment,'rows'=>'4','cols'=>'23'));?>
-
+
+
".$this->lang->line('sales_suspend_sale')." ";
?>
-
+
-
- lang->line('sales_payments_total').':';?>
-
-
-
- lang->line('sales_amount_due').':';?>
-
-
+
+
+ lang->line('sales_payments_total').':';?>
+
+
+
+ lang->line('sales_amount_due').':';?>
+
+
+
-
+
-
+
'add_payment_form')); ?>
-
-
+
+
lang->line('sales_payment').': ';?>
-
+
-
-
-
- lang->line( 'sales_amount_tendered' ).': '; ?>
-
-
+
+
+ lang->line( 'sales_amount_tendered' ).': '; ?>
+
+
'amount_tendered', 'id'=>'amount_tendered', 'value'=>to_currency_no_money($amount_due), 'size'=>'10' ) ); ?>
-
-
-
@@ -316,14 +334,14 @@ else
{
?>
-
-
- lang->line('common_delete'); ?>
- lang->line('sales_payment_type'); ?>
- lang->line('sales_payment_amount'); ?>
+
+
+ lang->line('common_delete'); ?>
+ lang->line('sales_payment_type'); ?>
+ lang->line('sales_payment_amount'); ?>
-
+
'edit_payment_form'.$payment_id));
?>
- lang->line('common_delete').']' ); ?>
+ lang->line('common_delete').']' ); ?>
-
-
+
+
@@ -344,8 +362,8 @@ else
}
?>
-
-
+
+
@@ -358,7 +376,7 @@ else
}
?>
-
+
load->view("partial/footer"); ?>
@@ -462,7 +480,8 @@ function post_item_form_submit(response)
{
if(response.success)
{
- $("#item").attr("value",response.item_id);
+ var $stock_location = $("select[name='stock_location']").val();
+ $("#item_location").val($stock_location);
$("#add_item_form").submit();
}
}
diff --git a/database/2.2.2_to_2.3.sql b/database/2.2.2_to_2.3.sql
new file mode 100644
index 000000000..458bf9063
--- /dev/null
+++ b/database/2.2.2_to_2.3.sql
@@ -0,0 +1,53 @@
+CREATE TABLE IF NOT EXISTS `ospos_stock_locations` (
+ `location_id` int(11) NOT NULL AUTO_INCREMENT,
+ `location_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
+ `deleted` int(1) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`location_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;
+
+CREATE TABLE IF NOT EXISTS `ospos_item_quantities` (
+ `item_id` int(11) NOT NULL,
+ `location_id` int(11) NOT NULL,
+ `quantity` int(11) NOT NULL,
+ PRIMARY KEY (`item_id`,`location_id`),
+ KEY `item_id` (`item_id`),
+ KEY `location_id` (`location_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
+
+ALTER TABLE ospos_inventory
+ ADD COLUMN trans_location int(11) NOT NULL,
+ ADD KEY `trans_location` (`trans_location`),
+ ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`);
+
+-- ALTER TABLE ospos_items DROP COLUMN location;
+
+INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES ('0', 'stock');
+
+ALTER TABLE ospos_receivings_items
+ ADD COLUMN item_location int(11) NOT NULL,
+ ADD KEY `item_location` (`item_location`),
+ ADD CONSTRAINT `ospos_receivings_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
+
+
+ALTER TABLE ospos_sales_items
+ ADD COLUMN item_location int(11) NOT NULL,
+ ADD KEY `item_location` (`item_location`),
+ ADD KEY `sale_id` (`sale_id`),
+ ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
+
+ALTER TABLE ospos_sales_items_taxes
+ ADD KEY `sale_id` (`sale_id`);
+
+ALTER TABLE ospos_sales_payments
+ ADD KEY `sale_id` (`sale_id`);
+
+ALTER TABLE ospos_sales_suspended_items
+ ADD COLUMN item_location int(11) NOT NULL,
+ ADD KEY `item_location` (`item_location`),
+ ADD KEY `sale_id` (`sale_id`),
+ ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
+
+ALTER TABLE `ospos_item_quantities`
+ ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
+ ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`);
+
diff --git a/database/2.3_migrate_locations.sql b/database/2.3_migrate_locations.sql
new file mode 100644
index 000000000..cb1ec3087
--- /dev/null
+++ b/database/2.3_migrate_locations.sql
@@ -0,0 +1,2 @@
+INSERT INTO ospos_stock_locations (location_name) (SELECT location FROM ospos_items WHERE NOT EXISTS (select location from ospos_stock_locations where location_name = location));
+INSERT INTO ospos_item_quantities (item_id, location_id, quantity) (SELECT item_id, location_id, quantity FROM ospos_items, ospos_stock_locations where ospos_items.location = ospos_stock_locations.location_name);
diff --git a/database/database.sql b/database/database.sql
index eaad159a7..18830c997 100644
--- a/database/database.sql
+++ b/database/database.sql
@@ -113,10 +113,12 @@ CREATE TABLE `ospos_inventory` (
`trans_user` int(11) NOT NULL DEFAULT '0',
`trans_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`trans_comment` text NOT NULL,
+ `trans_location` int(11) NOT NULL,
`trans_inventory` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`trans_id`),
- KEY `ospos_inventory_ibfk_1` (`trans_items`),
- KEY `ospos_inventory_ibfk_2` (`trans_user`)
+ KEY `trans_items` (`trans_items`),
+ KEY `trans_user` (`trans_user`),
+ KEY `trans_location` (`trans_location`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
@@ -219,6 +221,20 @@ CREATE TABLE `ospos_item_kit_items` (
-- Dumping data for table `ospos_item_kit_items`
--
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `ospos_item_quantities`
+--
+
+CREATE TABLE IF NOT EXISTS `ospos_item_quantities` (
+ `item_id` int(11) NOT NULL,
+ `location_id` int(11) NOT NULL,
+ `quantity` int(11) NOT NULL,
+ PRIMARY KEY (`item_id`,`location_id`),
+ KEY `item_id` (`item_id`),
+ KEY `location_id` (`location_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
-- --------------------------------------------------------
@@ -349,6 +365,7 @@ CREATE TABLE `ospos_receivings_items` (
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
+ `item_location` int(11) NOT NULL,
PRIMARY KEY (`receiving_id`,`item_id`,`line`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -397,8 +414,11 @@ CREATE TABLE `ospos_sales_items` (
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
+ `item_location` int(11) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`),
- KEY `item_id` (`item_id`)
+ KEY `sale_id` (`sale_id`),
+ KEY `item_id` (`item_id`),
+ KEY `item_location` (`item_location`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@@ -419,6 +439,7 @@ CREATE TABLE `ospos_sales_items_taxes` (
`name` varchar(255) NOT NULL,
`percent` decimal(15,2) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`),
+ KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -437,7 +458,8 @@ CREATE TABLE `ospos_sales_payments` (
`sale_id` int(10) NOT NULL,
`payment_type` varchar(40) NOT NULL,
`payment_amount` decimal(15,2) NOT NULL,
- PRIMARY KEY (`sale_id`,`payment_type`)
+ PRIMARY KEY (`sale_id`,`payment_type`),
+ KEY `sale_id` (`sale_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@@ -484,7 +506,9 @@ CREATE TABLE `ospos_sales_suspended_items` (
`item_cost_price` decimal(15,2) NOT NULL,
`item_unit_price` decimal(15,2) NOT NULL,
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
+ `item_location` int(11) NOT NULL,
PRIMARY KEY (`sale_id`,`item_id`,`line`),
+ KEY `sale_id` (`sale_id`),
KEY `item_id` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -551,6 +575,25 @@ CREATE TABLE `ospos_sessions` (
-- Dumping data for table `ospos_sessions`
--
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `ospos_stock_locations`
+--
+
+CREATE TABLE `ospos_stock_locations` (
+ `location_id` int(11) NOT NULL AUTO_INCREMENT,
+ `location_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
+ `deleted` int(1) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`location_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8;
+
+
+--
+-- Dumping data for table `ospos_stock_locations`
+--
+
+INSERT INTO `ospos_stock_locations` ( `deleted` ) VALUES ('0');
-- --------------------------------------------------------
@@ -647,7 +690,8 @@ ALTER TABLE `ospos_sales`
--
ALTER TABLE `ospos_sales_items`
ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
- ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
+ ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`),
+ ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
--
-- Constraints for table `ospos_sales_items_taxes`
@@ -674,7 +718,8 @@ ALTER TABLE `ospos_sales_suspended`
--
ALTER TABLE `ospos_sales_suspended_items`
ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
- ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`);
+ ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`),
+ ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`);
--
-- Constraints for table `ospos_sales_suspended_items_taxes`
@@ -689,6 +734,13 @@ ALTER TABLE `ospos_sales_suspended_items_taxes`
ALTER TABLE `ospos_sales_suspended_payments`
ADD CONSTRAINT `ospos_sales_suspended_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`);
+--
+-- Constraints for table `ospos_item_quantities`
+--
+ALTER TABLE `ospos_item_quantities`
+ ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
+ ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`);
+
--
-- Constraints for table `ospos_suppliers`
--