mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-02 14:37:55 -05:00
Add stock location filtering on items
This commit is contained in:
@@ -6,6 +6,7 @@ class Items extends Secure_area implements iData_controller
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct('items');
|
||||
$this->load->library('item_lib');
|
||||
}
|
||||
|
||||
function index()
|
||||
@@ -16,9 +17,14 @@ class Items extends Secure_area implements iData_controller
|
||||
$config['uri_segment'] = 3;
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$stock_location=$this->item_lib->get_item_location();
|
||||
$stock_locations=$this->Stock_locations->get_allowed_locations();
|
||||
$data['stock_location']=$this->item_lib->get_item_location();
|
||||
$data['stock_locations']=$stock_locations;
|
||||
|
||||
$data['controller_name']=strtolower(get_class());
|
||||
$data['form_width']=$this->get_form_width();
|
||||
$data['manage_table']=get_items_manage_table( $this->Item->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this );
|
||||
$data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this );
|
||||
$this->load->view('items/manage',$data);
|
||||
}
|
||||
|
||||
@@ -27,7 +33,13 @@ class Items extends Secure_area implements iData_controller
|
||||
$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
|
||||
$is_deleted=$this->input->post('is_deleted'); // Parq 131215
|
||||
$this->item_lib->set_item_location($this->input->post('stock_location'));
|
||||
|
||||
$stock_location=$this->input->post('stock_location');
|
||||
$stock_locations=$this->Stock_locations->get_allowed_locations();
|
||||
$data['stock_location']=$this->item_lib->get_item_location();
|
||||
$data['stock_locations']=$stock_locations;
|
||||
|
||||
$data['search_section_state']=$this->input->post('search_section_state');
|
||||
$data['is_serialized']=$this->input->post('is_serialized');
|
||||
@@ -36,7 +48,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$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($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($stock_location,$is_serialized,$no_description,$search_custom,$is_deleted),$this);//GARRISON MODIFIED 4/13/2013, Parq 131215
|
||||
$this->load->view('items/manage',$data);
|
||||
}
|
||||
|
||||
@@ -182,13 +194,15 @@ class Items extends Secure_area implements iData_controller
|
||||
function get_row()
|
||||
{
|
||||
$item_id = $this->input->post('row_id');
|
||||
$data_row=get_item_data_row($this->Item->get_info($item_id),$this);
|
||||
$stock_location_id=$this->item_lib->get_item_location();
|
||||
$data_row=get_item_data_row($this->Item->get_info($item_id,$stock_location_id),$this);
|
||||
echo $data_row;
|
||||
}
|
||||
|
||||
function view($item_id=-1)
|
||||
{
|
||||
$data['item_info']=$this->Item->get_info($item_id);
|
||||
$stock_location_id=$this->item_lib->get_item_location();
|
||||
$data['item_info']=$this->Item->get_info($item_id,$stock_location_id);
|
||||
$data['item_tax_info']=$this->Item_taxes->get_info($item_id);
|
||||
$suppliers = array('' => $this->lang->line('items_none'));
|
||||
foreach($this->Supplier->get_all()->result_array() as $row)
|
||||
@@ -197,20 +211,19 @@ class Items extends Secure_area implements iData_controller
|
||||
}
|
||||
|
||||
$data['suppliers']=$suppliers;
|
||||
$data['selected_supplier'] = $this->Item->get_info($item_id)->supplier_id;
|
||||
$data['selected_supplier'] = $this->Item->get_info($item_id,$stock_location_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;
|
||||
}
|
||||
$data['stock_locations']= $location_array;
|
||||
$this->load->view("items/form",$data);
|
||||
}
|
||||
|
||||
|
||||
@@ -361,17 +361,8 @@ class Sales extends Secure_area
|
||||
$data['modes']=array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return'));
|
||||
$data['mode']=$this->sale_lib->get_mode();
|
||||
|
||||
$data['stock_locations'] = 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['stock_locations']=$this->Stock_locations->get_allowed_locations();
|
||||
$data['stock_location']=$this->sale_lib->get_sale_location();
|
||||
|
||||
$data['subtotal']=$this->sale_lib->get_subtotal();
|
||||
$data['taxes']=$this->sale_lib->get_taxes();
|
||||
|
||||
@@ -211,7 +211,7 @@ function get_item_data_row($item,$controller)
|
||||
$width = $controller->get_form_width();
|
||||
|
||||
$item_quantity='';
|
||||
$locations_data = $CI->Stock_locations->get_undeleted_all()->result_array();
|
||||
/* $locations_data = $CI->Stock_locations->get_allowed_locations()->result_array();
|
||||
foreach($locations_data as $location)
|
||||
{
|
||||
if (count($locations_data) > 1)
|
||||
@@ -219,7 +219,7 @@ function get_item_data_row($item,$controller)
|
||||
$item_quantity .= $location['location_name'].': ';
|
||||
}
|
||||
$item_quantity .= $CI->Item_quantities->get_item_quantity($item->item_id, $location['location_id'])->quantity . '<br/>';
|
||||
}
|
||||
} */
|
||||
|
||||
$table_data_row='<tr>';
|
||||
$table_data_row.="<td width='3%'><input type='checkbox' id='item_$item->item_id' value='".$item->item_id."'/></td>";
|
||||
@@ -228,7 +228,7 @@ function get_item_data_row($item,$controller)
|
||||
$table_data_row.='<td width="14%">'.$item->category.'</td>';
|
||||
$table_data_row.='<td width="14%">'.to_currency($item->cost_price).'</td>';
|
||||
$table_data_row.='<td width="14%">'.to_currency($item->unit_price).'</td>';
|
||||
$table_data_row.='<td width="14%">'.$item_quantity.'</td>';
|
||||
$table_data_row.='<td width="14%">'.$item->quantity.'</td>';
|
||||
$table_data_row.='<td width="14%">'.$tax_percents.'</td>';
|
||||
$table_data_row.='<td width="5%">'.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
|
||||
|
||||
|
||||
34
application/libraries/Item_lib.php
Normal file
34
application/libraries/Item_lib.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class Item_lib
|
||||
{
|
||||
var $CI;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->CI =& get_instance();
|
||||
}
|
||||
|
||||
function get_item_location()
|
||||
{
|
||||
if(!$this->CI->session->userdata('item_location'))
|
||||
{
|
||||
$stock_locations = $this->CI->Stock_locations->get_undeleted_all()->result_array();
|
||||
$location_name = $stock_locations[0]['location_id'];
|
||||
$this->set_item_location($location_name);
|
||||
}
|
||||
return $this->CI->session->userdata('item_location');
|
||||
}
|
||||
|
||||
function set_item_location($location)
|
||||
{
|
||||
$this->CI->session->set_userdata('item_location',$location);
|
||||
}
|
||||
|
||||
function clear_item_location()
|
||||
{
|
||||
$this->CI->session->unset_userdata('item_location');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
define("PRECISION", 3);
|
||||
|
||||
class Receiving_lib
|
||||
{
|
||||
@@ -135,7 +136,7 @@ class Receiving_lib
|
||||
}
|
||||
|
||||
$insertkey=$maxkey+1;
|
||||
$item_info=$this->CI->Item->get_info($item_id);
|
||||
$item_info=$this->CI->Item->get_info($item_id,$item_location);
|
||||
//array records are identified by $insertkey and item_id is just another field.
|
||||
$item = array(($insertkey)=>
|
||||
array(
|
||||
|
||||
@@ -231,7 +231,7 @@ class Sale_lib
|
||||
}
|
||||
|
||||
$insertkey=$maxkey+1;
|
||||
$item_info=$this->CI->Item->get_info($item_id);
|
||||
$item_info=$this->CI->Item->get_info($item_id,$item_location);
|
||||
//array/cart records are identified by $insertkey and item_id is just another field.
|
||||
$item = array(($insertkey)=>
|
||||
array(
|
||||
|
||||
@@ -16,11 +16,13 @@ class Item extends CI_Model
|
||||
/*
|
||||
Returns all the items
|
||||
*/
|
||||
function get_all($limit=10000, $offset=0)
|
||||
function get_all($stock_location_id,$limit=10000,$offset=0)
|
||||
{
|
||||
$this->db->from('items');
|
||||
$this->db->join('item_quantities','item_quantities.item_id=items.item_id');
|
||||
$this->db->where('deleted',0);
|
||||
$this->db->order_by("name", "asc");
|
||||
$this->db->where('location_id',$stock_location_id);
|
||||
$this->db->order_by("name","asc");
|
||||
$this->db->limit($limit);
|
||||
$this->db->offset($offset);
|
||||
return $this->db->get();
|
||||
@@ -33,9 +35,11 @@ class Item extends CI_Model
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
function get_all_filtered($is_serialized=0,$no_description,$search_custom,$is_deleted)/**GARRISON MODIFIED 4/21/2013, Parq 131215 **/
|
||||
function get_all_filtered($stock_location_id,$is_serialized=0,$no_description,$search_custom,$is_deleted)/**GARRISON MODIFIED 4/21/2013, Parq 131215 **/
|
||||
{
|
||||
$this->db->from('items');
|
||||
$this->db->join('item_quantities','item_quantities.item_id=items.item_id');
|
||||
$this->db->where('location_id',$stock_location_id);
|
||||
if ($is_serialized !=0 )
|
||||
{
|
||||
$this->db->where('is_serialized',1);
|
||||
@@ -62,14 +66,7 @@ class Item extends CI_Model
|
||||
$this->db->or_like('custom10',$search);
|
||||
}
|
||||
**/
|
||||
/* Parq 131215 start*/
|
||||
if ($is_deleted !=0 )
|
||||
{
|
||||
$this->db->where('deleted',1);
|
||||
} else {
|
||||
$this->db->where('deleted',0);
|
||||
}
|
||||
/* Parq 131215 end*/
|
||||
$this->db->where('deleted',$is_deleted);
|
||||
$this->db->order_by("name", "asc");
|
||||
return $this->db->get();
|
||||
}
|
||||
@@ -77,10 +74,15 @@ class Item extends CI_Model
|
||||
/*
|
||||
Gets information about a particular item
|
||||
*/
|
||||
function get_info($item_id)
|
||||
function get_info($item_id,$stock_location_id=0)
|
||||
{
|
||||
$this->db->from('items');
|
||||
$this->db->where('item_id',$item_id);
|
||||
$this->db->join('item_quantities','item_quantities.item_id=items.item_id');
|
||||
if ($stock_location_id > 0)
|
||||
{
|
||||
$this->db->where('location_id',$stock_location_id);
|
||||
}
|
||||
$this->db->where('items.item_id',$item_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
|
||||
@@ -40,18 +40,27 @@ class Stock_locations extends CI_Model
|
||||
return $this->db->get()->row();
|
||||
}
|
||||
|
||||
function get_undeleted_all($limit=10000, $offset=0)
|
||||
function get_undeleted_all()
|
||||
{
|
||||
$this->db->from('stock_locations');
|
||||
$this->db->join('modules', 'modules.module_id=concat(\'items_stock\', location_id)');
|
||||
$this->db->join('permissions', 'permissions.module_id=modules.module_id');
|
||||
$this->db->where('person_id', $this->session->userdata('person_id'));
|
||||
$this->db->where('deleted',0);
|
||||
$this->db->limit($limit);
|
||||
$this->db->offset($offset);
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_allowed_locations()
|
||||
{
|
||||
$stock = $this->get_undeleted_all()->result_array();
|
||||
$stock_locations = array();
|
||||
foreach($stock as $location_data)
|
||||
{
|
||||
$stock_locations[$location_data['location_id']] = $location_data['location_name'];
|
||||
}
|
||||
return $stock_locations;
|
||||
}
|
||||
|
||||
function get_location_name($location_id)
|
||||
{
|
||||
$this->db->from('stock_locations');
|
||||
|
||||
@@ -152,6 +152,12 @@ function show_hide_search_filter(search_filter_section, switchImgTag) {
|
||||
<li class="float_left"><span><?php echo anchor("$controller_name/delete",$this->lang->line("common_delete"),array('id'=>'delete')); ?></span></li>
|
||||
<li class="float_left"><span><?php echo anchor("$controller_name/bulk_edit/width:$form_width",$this->lang->line("items_bulk_edit"),array('id'=>'bulk_edit','title'=>$this->lang->line('items_edit_multiple_items'))); ?></span></li>
|
||||
<li class="float_left"><span><?php echo anchor("$controller_name/generate_barcodes",$this->lang->line("items_generate_barcodes"),array('id'=>'generate_barcodes', 'target' =>'_blank','title'=>$this->lang->line('items_generate_barcodes'))); ?></span></li>
|
||||
<?php if (count($stock_locations) > 1): ?>
|
||||
<li class="float_left"><span>
|
||||
<?php echo form_open("$controller_name/refresh",array('id'=>'stock_filter_form')); ?>
|
||||
<?php echo form_dropdown('stock_location',$stock_locations,$stock_location,'id="stock_location" onchange="$(\'#stock_filter_form\').submit();"'); ?>
|
||||
</form></span></li>
|
||||
<?php endif; ?>
|
||||
<li class="float_right">
|
||||
<img src='<?php echo base_url()?>images/spinner_small.gif' alt='spinner' id='spinner' />
|
||||
<?php echo form_open("$controller_name/search",array('id'=>'search_form')); ?>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
$this->load->view("partial/header");
|
||||
var_dump($data_file);
|
||||
?>
|
||||
<div id="page_title" style="margin-bottom:8px;"><?php echo $title ?></div>
|
||||
<div id="page_subtitle" style="margin-bottom:8px;"><?php echo $subtitle ?></div>
|
||||
|
||||
@@ -20,7 +20,7 @@ if (isset($success))
|
||||
<?php echo form_open("sales/change_mode",array('id'=>'mode_form')); ?>
|
||||
<span><?php echo $this->lang->line('sales_mode') ?></span>
|
||||
<?php echo form_dropdown('mode',$modes,$mode,'onchange="$(\'#mode_form\').submit();"'); ?>
|
||||
<?php if ($show_stock_locations): ?>
|
||||
<?php if (count($stock_locations) > 0): ?>
|
||||
<span><?php echo $this->lang->line('sales_stock_location') ?></span>
|
||||
<?php echo form_dropdown('stock_location',$stock_locations,$stock_location,'onchange="$(\'#mode_form\').submit();"'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -145,6 +145,11 @@ input#search
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
select#stock_location
|
||||
{
|
||||
border: none;
|
||||
}
|
||||
|
||||
#select_customer_form input, #select_supplier_form input
|
||||
{
|
||||
width: 95%;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
}
|
||||
|
||||
#table_action_header ul li span
|
||||
#table_action_header ul li span a
|
||||
{
|
||||
background-color:#0a6184;
|
||||
border:2px solid #DDDDDD;
|
||||
|
||||
Reference in New Issue
Block a user