mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-23 00:34:45 -04:00
Fix loading attribute values in item search (#2232)
This commit is contained in:
1 parent
f2d2b1d3e2
commit
d3d051ee72
19 files changed
+41
-45
No files matched your search
@@ -484,19 +484,6 @@ class Items extends Secure_Controller
|
||||
}
|
||||
$default_pack_name = $this->lang->line('items_default_pack_name');
|
||||
|
||||
|
||||
if ($item_id == -1)
|
||||
{
|
||||
// Set low_sell_item_id to -1 for a new item so that when it is saved the item will point to itself for the
|
||||
// low sell item.
|
||||
$low_sell_item_id = $this->input->post('low_sell_item_id') == NULL ? -1 : $this->input->post('low_sell_item_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
// On an existing item where the low sell item is not prompted for always force the item_id as the low sell item Id
|
||||
$low_sell_item_id = $this->input->post('low_sell_item_id') == NULL ? $item_id : $this->input->post('low_sell_item_id');
|
||||
}
|
||||
|
||||
//Save item data
|
||||
$item_data = array(
|
||||
'name' => $this->input->post('name'),
|
||||
@@ -514,7 +501,7 @@ class Items extends Secure_Controller
|
||||
'is_serialized' => $this->input->post('is_serialized') != NULL,
|
||||
'qty_per_pack' => $this->input->post('qty_per_pack') == NULL ? 1 : $this->input->post('qty_per_pack'),
|
||||
'pack_name' => $this->input->post('pack_name') == NULL ? $default_pack_name : $this->input->post('pack_name'),
|
||||
'low_sell_item_id' => $low_sell_item_id,
|
||||
'low_sell_item_id' => $this->input->post('low_sell_item_id') == NULL ? $item_id : $this->input->post('low_sell_item_id'),
|
||||
'deleted' => $this->input->post('is_deleted') != NULL,
|
||||
'hsn_code' => $this->input->post('hsn_code') == NULL ? '' : $this->input->post('hsn_code')
|
||||
);
|
||||
|
||||
@@ -1345,6 +1345,7 @@ class Reports extends Secure_Controller
|
||||
}
|
||||
|
||||
$attribute_values = (isset($drow['attribute_values'])) ? $drow['attribute_values'] : '';
|
||||
$attribute_values = (isset($drow['attribute_dtvalues'])) ? $attribute_values . '|' . $drow['attribute_dtvalues'] : $attribute_values;
|
||||
$attribute_values = expand_attribute_values($definition_names, $attribute_values);
|
||||
|
||||
$details_data[$row['sale_id']][] = $this->xss_clean(array_merge(array(
|
||||
@@ -1462,6 +1463,8 @@ class Reports extends Secure_Controller
|
||||
}
|
||||
|
||||
$attribute_values = (isset($drow['attribute_values'])) ? $drow['attribute_values'] : '';
|
||||
$attribute_values = (isset($drow['attribute_dtvalues'])) ? $attribute_values . '|' . $drow['attribute_dtvalues'] : $attribute_values;
|
||||
|
||||
$attribute_values = expand_attribute_values($definition_names, $attribute_values);
|
||||
|
||||
$details_data[$row['receiving_id']][] = $this->xss_clean(array_merge(array(
|
||||
@@ -1471,7 +1474,6 @@ class Reports extends Secure_Controller
|
||||
$quantity_purchased,
|
||||
to_currency($drow['total']),
|
||||
($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])), $attribute_values));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ function get_item_data_row($item)
|
||||
);
|
||||
|
||||
$attribute_values = (property_exists($item, 'attribute_values')) ? $item->attribute_values : "";
|
||||
$attribute_values = (property_exists($item, 'attribute_datetimevalues')) ? $item->attribute_datetimevalues : $attribute_values;
|
||||
$attribute_values = (property_exists($item, 'attribute_dtvalues')) ? $attribute_values . $item->attribute_dtvalues : $attribute_values;
|
||||
return $columns + expand_attribute_values($definition_names, $attribute_values) + $icons;
|
||||
}
|
||||
|
||||
@@ -531,14 +531,21 @@ function expand_attribute_values($definition_names, $attribute_values)
|
||||
foreach($values as $attribute_value)
|
||||
{
|
||||
$exploded_value = explode('_', $attribute_value);
|
||||
$indexed_values[$exploded_value[0]] = isset($exploded_value[1]) ? $exploded_value[1] : '-';
|
||||
if (sizeof($exploded_value) > 1)
|
||||
{
|
||||
$indexed_values[$exploded_value[0]] = $exploded_value[1];
|
||||
}
|
||||
}
|
||||
|
||||
$attribute_values = array();
|
||||
foreach($definition_names as $definition_id => $definition_name)
|
||||
{
|
||||
$attribute_value = isset($indexed_values[$definition_id]) ? $indexed_values[$definition_id] : '-';
|
||||
$attribute_values["$definition_id"] = $attribute_value;
|
||||
if (isset($indexed_values[$definition_id]))
|
||||
{
|
||||
$attribute_value = $indexed_values[$definition_id];
|
||||
$attribute_values["$definition_id"] = $attribute_value;
|
||||
}
|
||||
|
||||
}
|
||||
return $attribute_values;
|
||||
}
|
||||
|
||||
@@ -231,6 +231,8 @@ class Receiving_lib
|
||||
$receiving_quantity = $item_info->receiving_quantity;
|
||||
}
|
||||
|
||||
$attribute_links = $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS)->row_object();
|
||||
|
||||
$item = array($insertkey => array(
|
||||
'item_id' => $item_id,
|
||||
'item_location' => $item_location,
|
||||
@@ -240,7 +242,8 @@ class Receiving_lib
|
||||
'name' => $item_info->name,
|
||||
'description' => $description != NULL ? $description: $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber: '',
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'receiving_id', $receiving_id, Attribute::SHOW_IN_RECEIVINGS),
|
||||
'attribute_values' => $attribute_links->attribute_values,
|
||||
'attribute_dtvalues' => $attribute_links->attribute_dtvalues,
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
'is_serialized' => $item_info->is_serialized,
|
||||
'quantity' => $quantity,
|
||||
|
||||
@@ -719,6 +719,8 @@ class Sale_lib
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$price = 0.00;
|
||||
$cost_price = 0.00;
|
||||
$item_id = $item_info->item_id;
|
||||
$item_type = $item_info->item_type;
|
||||
$stock_type = $item_info->stock_type;
|
||||
@@ -745,16 +747,7 @@ class Sale_lib
|
||||
$price = $item_info->unit_price;
|
||||
$cost_price = $item_info->cost_price;
|
||||
}
|
||||
else
|
||||
{
|
||||
$price = 0.00;
|
||||
$cost_price = 0.00;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$price= 0.00;
|
||||
$cost_price = 0.00;
|
||||
|
||||
}
|
||||
|
||||
if($price_override != NULL)
|
||||
@@ -840,6 +833,7 @@ class Sale_lib
|
||||
$item_info->name .= NAME_SEPARATOR . $item_info->pack_name;
|
||||
}
|
||||
|
||||
$attribute_links = $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES)->row_object();
|
||||
|
||||
//Item already exists and is not serialized, add to quantity
|
||||
if(!$itemalreadyinsale || $item_info->is_serialized)
|
||||
@@ -851,7 +845,8 @@ class Sale_lib
|
||||
'line' => $insertkey,
|
||||
'name' => $item_info->name,
|
||||
'item_number' => $item_info->item_number,
|
||||
'attribute_values' => $this->CI->Attribute->get_link_values($item_id, 'sale_id', $sale_id, Attribute::SHOW_IN_SALES),
|
||||
'attribute_values' => $attribute_links->attribute_values,
|
||||
'attribute_dtvalues' => $attribute_links->attribute_dtvalues,
|
||||
'description' => $description != NULL ? $description : $item_info->description,
|
||||
'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
|
||||
'allow_alt_description' => $item_info->allow_alt_description,
|
||||
|
||||
@@ -453,8 +453,8 @@ class Attribute extends CI_Model
|
||||
public function get_link_values($item_id, $sale_receiving_fk, $id, $definition_flags)
|
||||
{
|
||||
$format = $this->db->escape(dateformat_mysql());
|
||||
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR ', ') AS attribute_values');
|
||||
$this->db->select("GROUP_CONCAT(DATE_FORMAT(attribute_datetime, $format) SEPARATOR ', ') AS attribute_datetimevalues");
|
||||
$this->db->select("GROUP_CONCAT(attribute_value SEPARATOR ', ') AS attribute_values");
|
||||
$this->db->select("GROUP_CONCAT(DATE_FORMAT(attribute_datetime, $format) SEPARATOR ', ') AS attribute_dtvalues");
|
||||
$this->db->from('attribute_links');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id');
|
||||
$this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id');
|
||||
@@ -521,7 +521,7 @@ class Attribute extends CI_Model
|
||||
|
||||
public function save_value($attribute_value, $definition_id, $item_id = FALSE, $attribute_id = FALSE, $definition_type = DROPDOWN)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->trans_start();
|
||||
|
||||
if(empty($attribute_id) || empty($item_id))
|
||||
{
|
||||
@@ -531,7 +531,6 @@ class Attribute extends CI_Model
|
||||
if(empty($attribute_id_check))
|
||||
{
|
||||
$this->db->insert('attribute_values', array('attribute_value' => $attribute_value));
|
||||
$attribute_id = $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -541,14 +540,14 @@ class Attribute extends CI_Model
|
||||
else if($definition_type == DECIMAL)
|
||||
{
|
||||
$this->db->insert('attribute_values', array('attribute_decimal' => $attribute_value));
|
||||
$attribute_id = $this->db->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->insert('attribute_values', array('attribute_datetime' => date('Y-m-d H:i:s', strtotime($attribute_value))));
|
||||
$attribute_id = $this->db->insert_id();
|
||||
}
|
||||
|
||||
$attribute_id = $this->db->insert_id();
|
||||
|
||||
$this->db->insert('attribute_links', array(
|
||||
'attribute_id' => empty($attribute_id) ? NULL : $attribute_id,
|
||||
'item_id' => empty($item_id) ? NULL : $item_id,
|
||||
@@ -557,8 +556,6 @@ class Attribute extends CI_Model
|
||||
else
|
||||
{
|
||||
$this->db->where('attribute_id', $attribute_id);
|
||||
$this->db->update('attribute_values', array('attribute_value' => $attribute_value));
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ class Item extends CI_Model
|
||||
{
|
||||
$format = $this->db->escape(dateformat_mysql());
|
||||
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\'_\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_datetime, $format)) SEPARATOR '|') AS attribute_datetimevalues");
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_datetime, $format)) SEPARATOR '|') AS attribute_dtvalues");
|
||||
$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');
|
||||
}
|
||||
@@ -281,6 +281,7 @@ class Item extends CI_Model
|
||||
{
|
||||
$this->db->select('items.*');
|
||||
$this->db->select('GROUP_CONCAT(attribute_value SEPARATOR \'|\') AS attribute_values');
|
||||
$this->db->select('GROUP_CONCAT(attribute_datetime SEPARATOR \'|\') AS attribute_dtvalues');
|
||||
$this->db->select('suppliers.company_name');
|
||||
$this->db->from('items');
|
||||
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
|
||||
@@ -379,7 +380,7 @@ class Item extends CI_Model
|
||||
$this->db->select('items.*');
|
||||
$this->db->select('company_name');
|
||||
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
|
||||
$this->db->select('items.category');
|
||||
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_datetime) ORDER BY definition_id SEPARATOR \'|\') AS attribute_dtvalues');
|
||||
$this->db->select('quantity');
|
||||
$this->db->from('items');
|
||||
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
|
||||
|
||||
@@ -102,7 +102,9 @@ class Detailed_receivings extends Report
|
||||
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
|
||||
if (count($inputs['definition_ids']) > 0)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
|
||||
$format = $this->db->escape(dateformat_mysql());
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, attribute_value) ORDER BY definition_id SEPARATOR '|') AS attribute_values");
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_datetime, $format)) SEPARATOR '|') AS attribute_dtvalues");
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id = receivings_items_temp.receiving_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
|
||||
$this->db->group_by('receivings_items_temp.receiving_id, receivings_items_temp.item_id');
|
||||
|
||||
@@ -148,7 +148,9 @@ class Detailed_sales extends Report
|
||||
$this->db->from('sales_items_temp');
|
||||
if (count($inputs['definition_ids']) > 0)
|
||||
{
|
||||
$this->db->select('GROUP_CONCAT(DISTINCT CONCAT_WS(\':\', definition_id, attribute_value) ORDER BY definition_id SEPARATOR \'|\') AS attribute_values');
|
||||
$format = $this->db->escape(dateformat_mysql());
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, attribute_value) ORDER BY definition_id SEPARATOR '|') AS attribute_values");
|
||||
$this->db->select("GROUP_CONCAT(DISTINCT CONCAT_WS('_', definition_id, DATE_FORMAT(attribute_datetime, $format)) SEPARATOR '|') AS attribute_datetimevalues");
|
||||
$this->db->join('attribute_links', 'attribute_links.item_id = sales_items_temp.item_id AND attribute_links.sale_id = sales_items_temp.sale_id AND definition_id IN (' . implode(',', $inputs['definition_ids']) . ')', 'left');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id', 'left');
|
||||
$this->db->group_by('sales_items_temp.sale_id, sales_items_temp.item_id');
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -136,7 +136,7 @@ if (isset($success))
|
||||
<td><?php echo anchor($controller_name."/delete_item/$line", '<span class="glyphicon glyphicon-trash"></span>');?></td>
|
||||
<td><?php echo $item['item_number']; ?></td>
|
||||
<td style="align:center;">
|
||||
<?php echo $item['name'] . ' ' . $item['attribute_values']; ?><br /> <?php echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; ?>
|
||||
<?php echo $item['name'] . ' '. implode(' ', array($item['attribute_values'], $item['attribute_dtvalues'])); ?><br /> <?php echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; ?>
|
||||
<?php echo form_hidden('location', $item['item_location']); ?>
|
||||
</td>
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ if(isset($success))
|
||||
?>
|
||||
<td><?php echo $item['item_number']; ?></td>
|
||||
<td style="align: center;">
|
||||
<?php echo $item['name'] . ' ' . $item['attribute_values']; ?>
|
||||
<?php echo $item['name'] . ' '. implode(' ', array($item['attribute_values'], $item['attribute_dtvalues'])); ?>
|
||||
<br/>
|
||||
<?php if ($item['stock_type'] == '0'): echo '[' . to_quantity_decimals($item['in_stock']) . ' in ' . $item['stock_name'] . ']'; endif; ?>
|
||||
</td>
|
||||
|
||||
Reference in new issue
Block a user