mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 02:33:56 -04:00
Implement dropdown into item form view
- Created business logic in view to show dropdown if enabled - Created business logic in controller to calculate key/value pairs of dropdown - Adjusted attribute model get_definition values to send values also if definition_id is -1 or > 0 but not 0 which is what we are now using as no definition instead of -1
This commit is contained in:
@@ -227,6 +227,17 @@ class Items extends Secure_Controller
|
||||
|
||||
$use_destination_based_tax = (boolean)$this->config->item('use_destination_based_tax');
|
||||
$data['include_hsn'] = $this->config->item('include_hsn') == '1';
|
||||
$data['category_dropdown'] = $this->config->item('category_dropdown') == 0;
|
||||
|
||||
if($data['category_dropdown'] == 1)
|
||||
{
|
||||
$categories = array('' => $this->lang->line('items_none'));
|
||||
$category_options = $this->Attribute->get_definition_values(-1);
|
||||
$category_options = array_combine($category_options,$category_options); //Overwrite indexes with values for saving in items table instead of attributes
|
||||
$data['categories'] = array_merge($categories,$category_options);
|
||||
|
||||
$data['selected_category'] = $item_info->category;
|
||||
}
|
||||
|
||||
if($item_id == -1)
|
||||
{
|
||||
@@ -256,7 +267,7 @@ class Items extends Secure_Controller
|
||||
$data['item_info'] = $item_info;
|
||||
|
||||
$suppliers = array('' => $this->lang->line('items_none'));
|
||||
|
||||
|
||||
foreach($this->Supplier->get_all()->result_array() as $row)
|
||||
{
|
||||
$suppliers[$this->xss_clean($row['person_id'])] = $this->xss_clean($row['company_name']);
|
||||
@@ -301,7 +312,7 @@ class Items extends Secure_Controller
|
||||
|
||||
$data['logo_exists'] = $item_info->pic_filename != '';
|
||||
$ext = pathinfo($item_info->pic_filename, PATHINFO_EXTENSION);
|
||||
|
||||
|
||||
if($ext == '')
|
||||
{
|
||||
//If file extension is not found guess it (legacy)
|
||||
@@ -545,7 +556,7 @@ class Items extends Secure_Controller
|
||||
{
|
||||
$success = TRUE;
|
||||
$new_item = FALSE;
|
||||
|
||||
|
||||
//New item
|
||||
if($item_id == -1)
|
||||
{
|
||||
@@ -831,7 +842,7 @@ class Items extends Secure_Controller
|
||||
$invalidated = FALSE;
|
||||
|
||||
$line = array_combine($keys,$this->xss_clean($line_array[$i])); //Build a XSS-cleaned associative array with the row to use to assign values
|
||||
|
||||
|
||||
$item_data = array(
|
||||
'name' => $line['Item Name'],
|
||||
'description' => $line['Description'],
|
||||
@@ -847,7 +858,7 @@ class Items extends Secure_Controller
|
||||
);
|
||||
|
||||
$item_number = $line['Barcode'];
|
||||
|
||||
|
||||
if(!empty($item_number))
|
||||
{
|
||||
$item_data['item_number'] = $item_number;
|
||||
@@ -867,7 +878,7 @@ class Items extends Secure_Controller
|
||||
$this->save_inventory_quantities($line, $item_data);
|
||||
$this->save_attribute_data($line, $item_data);
|
||||
}
|
||||
|
||||
|
||||
//Insert or update item failure
|
||||
else
|
||||
{
|
||||
@@ -1031,7 +1042,7 @@ class Items extends Secure_Controller
|
||||
|
||||
$status = $this->Attribute->save_value($line['attribute_' . $definition_name], $attribute_data['definition_id'], $item_data['item_id'], FALSE, $attribute_data['definition_type']);
|
||||
}
|
||||
|
||||
|
||||
//All other Attribute types (0 value means attribute not created)
|
||||
elseif(!empty($line['attribute_' . $definition_name]))
|
||||
{
|
||||
|
||||
@@ -207,7 +207,7 @@ class Attribute extends CI_Model
|
||||
$this->db->from('attribute_definitions');
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->order_by('definition_name','ASC');
|
||||
|
||||
|
||||
if($groups === FALSE)
|
||||
{
|
||||
$this->db->where_not_in('definition_type',GROUP);
|
||||
@@ -224,7 +224,7 @@ class Attribute extends CI_Model
|
||||
{
|
||||
$attribute_values = [];
|
||||
|
||||
if($definition_id > -1)
|
||||
if($definition_id > 0 || $definition_id == -1)
|
||||
{
|
||||
$this->db->from('attribute_links');
|
||||
$this->db->join('attribute_values', 'attribute_values.attribute_id = attribute_links.attribute_id');
|
||||
@@ -684,4 +684,4 @@ class Attribute extends CI_Model
|
||||
|
||||
return $this->db->update('attribute_definitions', array('deleted'=>0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,12 +36,21 @@
|
||||
<div class='col-xs-8'>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
|
||||
<?php echo form_input(array(
|
||||
'name'=>'category',
|
||||
'id'=>'category',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$item_info->category)
|
||||
);?>
|
||||
<?php
|
||||
if($this->Appconfig->get('category_dropdown'))
|
||||
{
|
||||
echo form_dropdown('category', $categories, $selected_category, array('class'=>'form-control'));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo form_input(array(
|
||||
'name'=>'category',
|
||||
'id'=>'category',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>$item_info->category)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user