mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Enable attributes in items table (#68)
This commit is contained in:
@@ -45,6 +45,8 @@ class Items extends Secure_Controller
|
||||
|
||||
$this->item_lib->set_item_location($this->input->get('stock_location'));
|
||||
|
||||
$definition_names = $this->Attribute->get_definitions_by_flags(Attribute::SHOW_IN_ITEMS);
|
||||
|
||||
$filters = array('start_date' => $this->input->get('start_date'),
|
||||
'end_date' => $this->input->get('end_date'),
|
||||
'stock_location_id' => $this->item_lib->get_item_location(),
|
||||
@@ -54,7 +56,8 @@ class Items extends Secure_Controller
|
||||
'no_description' => FALSE,
|
||||
'search_custom' => FALSE,
|
||||
'is_deleted' => FALSE,
|
||||
'temporary' => FALSE);
|
||||
'temporary' => FALSE,
|
||||
'definition_ids' => array_keys($definition_names));
|
||||
|
||||
// check if any filter is set in the multiselect dropdown
|
||||
$filledup = array_fill_keys($this->input->get('filters'), TRUE);
|
||||
|
||||
@@ -321,6 +321,8 @@ function get_items_manage_table_headers()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
$definition_names = $CI->Attribute->get_definitions_by_flags(Attribute::SHOW_IN_ITEMS);
|
||||
|
||||
$headers = array(
|
||||
array('items.item_id' => $CI->lang->line('common_id')),
|
||||
array('item_number' => $CI->lang->line('items_item_number')),
|
||||
@@ -336,6 +338,11 @@ function get_items_manage_table_headers()
|
||||
array('stock' => '')
|
||||
);
|
||||
|
||||
foreach($definition_names as $definition_id => $definition_name)
|
||||
{
|
||||
$headers[] = array($definition_name => $definition_name);
|
||||
}
|
||||
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
@@ -381,7 +388,7 @@ function get_item_data_row($item)
|
||||
$item->name .= NAME_SEPARATOR . $item->pack_name;
|
||||
}
|
||||
|
||||
return array (
|
||||
return array_merge(array (
|
||||
'items.item_id' => $item->item_id,
|
||||
'item_number' => $item->item_number,
|
||||
'name' => $item->name,
|
||||
@@ -400,7 +407,7 @@ function get_item_data_row($item)
|
||||
),
|
||||
'edit' => anchor($controller_name."/view/$item->item_id", '<span class="glyphicon glyphicon-edit"></span>',
|
||||
array('class' => 'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_update'))
|
||||
));
|
||||
), explode(',', $item->attribute_values)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const DEFINITION_TYPES = [GROUP, DROPDOWN, TEXT, DATETIME];
|
||||
|
||||
class Attribute extends CI_Model
|
||||
{
|
||||
//const SHOW_IN_ITEMS = 1;
|
||||
const SHOW_IN_ITEMS = 1;
|
||||
const SHOW_IN_SALES = 2;
|
||||
const SHOW_IN_RECEIVINGS = 4;
|
||||
|
||||
|
||||
@@ -180,18 +180,24 @@ class Item extends CI_Model
|
||||
$this->db->like('name', $search);
|
||||
$this->db->or_like('item_number', $search);
|
||||
$this->db->or_like('items.item_id', $search);
|
||||
$this->db->or_like('definition_name', $search);
|
||||
$this->db->or_like('company_name', $search);
|
||||
$this->db->or_like('items.category', $search);
|
||||
$this->db->group_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->like('attribute_value', $search);
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id');
|
||||
$this->db->join('attribute_values', 'attribute_links.attribute_id = attribute_values.attribute_id');
|
||||
$this->db->like('attribute_value', $search);
|
||||
}
|
||||
}
|
||||
else if (count($filters['definition_ids']) > 0)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(attribute_value) AS attribute_values');
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id IS NULL AND attribute_links.sale_id IS NULL AND definition_id IN (' . implode(',', $filters['definition_ids']) . ')', 'left');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
|
||||
$this->db->order_by('definition_id');
|
||||
}
|
||||
|
||||
$this->db->where('items.deleted', $filters['is_deleted']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user