From a1e1883ddc8a2033d35e6d9f91730764ee0a880a Mon Sep 17 00:00:00 2001 From: Padungsak Date: Fri, 11 Jul 2014 22:32:47 +0700 Subject: [PATCH] Add quantity column in item page Fix bug about validating stock location config PS --- application/helpers/table_helper.php | 9 +++++++ application/models/item_quantitys.php | 14 ++++++++++- application/views/config.php | 4 ++-- application/views/items/form.php | 10 -------- application/views/receivings/receiving.php | 28 +++++++++------------- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index c3b55cddc..8c4c61907 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -159,6 +159,7 @@ 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_quantity'), $CI->lang->line('items_tax_percents'), ' ', $CI->lang->line('items_inventory') @@ -209,6 +210,13 @@ 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) + { + $item_quantity .= $location['location_name'].': '.$CI->Item_quantitys->get_item_quantity($item->item_id, $location['location_id'])->quantity . '
'; + } + $table_data_row=''; $table_data_row.=""; $table_data_row.=''.$item->item_number.''; @@ -216,6 +224,7 @@ 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.=''.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; diff --git a/application/models/item_quantitys.php b/application/models/item_quantitys.php index cc12e1a81..78a1d31a9 100644 --- a/application/models/item_quantitys.php +++ b/application/models/item_quantitys.php @@ -31,7 +31,19 @@ class Item_quantitys extends CI_Model $this->db->from('item_quantitys'); $this->db->where('item_id',$item_id); $this->db->where('location_id',$location_id); - return $this->db->get()->row(); + $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 + $fields = $this->db->list_fields('item_quantitys'); + foreach ($fields as $field) + { + $result->$field=''; + } + } + return $result; } } ?> \ No newline at end of file diff --git a/application/views/config.php b/application/views/config.php index fb526b819..264f5ced8 100644 --- a/application/views/config.php +++ b/application/views/config.php @@ -431,7 +431,7 @@ $(document).ready(function() }, email:"email", return_policy: "required", - stock_location_number:"required" + stock_location:"required" }, messages: @@ -446,7 +446,7 @@ $(document).ready(function() }, email: "lang->line('common_email_invalid_format'); ?>", return_policy:"lang->line('config_return_policy_required'); ?>", - stock_location_number:"lang->line('config_stock_location_required'); ?>" + stock_location:"lang->line('config_stock_location_required'); ?>" } }); diff --git a/application/views/items/form.php b/application/views/items/form.php index 2dcdc17ce..212470860 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -502,11 +502,6 @@ $(document).ready(function() required:true, number:true }, - quantity: - { - required:true, - number:true - }, reorder_level: { required:true, @@ -533,11 +528,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/receivings/receiving.php b/application/views/receivings/receiving.php index 1d3219d3d..1d65d6b2c 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -16,24 +16,18 @@ if(isset($error)) lang->line('recvs_mode') ?> - - lang->line('recvs_stock_source') ?> - - lang->line('recvs_stock_destination') ?> - - - lang->line('recvs_stock_locaiton') ?> - - lang->line('recvs_stock_source') ?> + + + > lang->line('recvs_stock_destination') ?> + 'add_item_form')); ?>