diff --git a/.travis.yml b/.travis.yml
index d4fe152bd..8eb3f1d8b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,9 +25,6 @@ env:
after_success: '[ -n ${DOCKER_USERNAME} ] && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
&& docker tag opensourcepos_php "jekkos/opensourcepos:$TAG" && docker push "jekkos/opensourcepos:$TAG"'
deploy:
- edge:
- source: travis-ci/dpl
- branch: master
file: deployment.json
provider: bintray
skip_cleanup: true
diff --git a/application/controllers/Attributes.php b/application/controllers/Attributes.php
index e7557cd55..6eff28f28 100644
--- a/application/controllers/Attributes.php
+++ b/application/controllers/Attributes.php
@@ -42,37 +42,16 @@ class Attributes extends Secure_Controller
echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
}
- public function save_attribute_link($item_id)
- {
- if (!empty($this->input->post('attribute_id')))
- {
- $success = $this->Attribute->save_link($item_id, $this->input->post('definition_id'), $this->input->post('attribute_id'));
- }
- else
- {
- $success = $this->Attribute->set_selected_category($item_id, $this->input->post('definition_id'));
- }
-
- echo json_encode(array('success' => $success));
- }
-
- public function delete_attribute_link($item_id)
- {
- $success = $this->Attribute->delete_link($item_id);
-
- echo json_encode(array('success' => $success));
- }
-
public function save_attribute_value($attribute_value)
{
- $success = $this->Attribute->save_value($attribute_value, $this->input->post('definition_id'), $this->input->post('item_id'), $this->input->post('attribute_id'));
+ $success = $this->Attribute->save_value(urldecode($attribute_value), $this->input->post('definition_id'), $this->input->post('item_id'), $this->input->post('attribute_id'));
echo json_encode(array('success' => $success));
}
public function delete_attribute_value($attribute_value)
{
- $success = $this->Attribute->delete_value($attribute_value, $this->input->post('$definition_id'));
+ $success = $this->Attribute->delete_value($attribute_value, $this->input->post('definition_id'));
echo json_encode(array('success' => $success));
}
@@ -90,7 +69,7 @@ class Attributes extends Secure_Controller
'definition_name' => $this->input->post('definition_name'),
'definition_type' => DEFINITION_TYPES[$this->input->post('definition_type')],
'definition_flags' => $definition_flags,
- 'definition_fk' => $this->input->post('definition_parent') != '' ? $this->input->post('definition_parent') : NULL
+ 'definition_fk' => $this->input->post('definition_group') != '' ? $this->input->post('definition_group') : NULL
);
$definition_name = $this->xss_clean($definition_data['definition_name']);
@@ -162,8 +141,8 @@ class Attributes extends Secure_Controller
$data['definition_id'] = $definition_id;
$data['definition_values'] = $this->Attribute->get_definition_values($definition_id);
- $data['definition_parent'] = $this->Attribute->get_definitions_by_type(CATEGORY, $definition_id);
- $data['definition_parent'][''] = $this->lang->line('common_none_selected_text');
+ $data['definition_group'] = $this->Attribute->get_definitions_by_type(GROUP, $definition_id);
+ $data['definition_group'][''] = $this->lang->line('common_none_selected_text');
$data['definition_info'] = $info;
$data['definition_flags'] = $this->_get_attributes();
diff --git a/application/controllers/Items.php b/application/controllers/Items.php
index b445eedf7..4ba260807 100644
--- a/application/controllers/Items.php
+++ b/application/controllers/Items.php
@@ -192,11 +192,9 @@ class Items extends Secure_Controller
$data['default_tax_2_rate'] = '';
$data['item_kits_enabled'] = $this->Employee->has_grant('item_kits', $this->Employee->get_logged_in_employee_info()->person_id);
$data['definition_values'] = $this->Attribute->get_attributes_by_item($item_id);
- $categories = array(-1 => $this->lang->line('common_none_selected_text'));
- $categories = $categories + $this->Attribute->get_definitions_by_type(CATEGORY);
- $selected_category = $this->Attribute->get_selected_category($item_id);
- $data['selected_category'] = empty($selected_category) ? NULL : $selected_category->definition_id;
- $data['categories'] = $categories;
+ $definition_names = array(-1 => $this->lang->line('common_none_selected_text'));
+
+ $data['definition_names'] = $definition_names + $this->Attribute->get_definition_names();
$item_info = $this->Item->get_info($item_id);
foreach(get_object_vars($item_info) as $property => $value)
@@ -386,10 +384,18 @@ class Items extends Secure_Controller
$this->load->view('barcodes/barcode_sheet', $data);
}
- public function attributes($item_id, $definition_id)
+ public function attributes($item_id)
{
$data['item_id'] = $item_id;
- $data['definition_values'] = $this->Attribute->get_values_by_parent($definition_id);
+ $definition_ids = json_decode($this->input->post('definition_ids'), TRUE);
+ $data['definition_values'] = $this->Attribute->get_attributes_by_item($item_id) + $this->Attribute->get_values_by_definitions($definition_ids);
+ $data['definition_names'] = $this->Attribute->get_definition_names();
+
+ foreach($data['definition_values'] as $definition_value)
+ {
+ unset($data['definition_names'][$definition_value['definition_id']]);
+ }
+
$this->load->view('attributes/item', $data);
}
@@ -536,6 +542,13 @@ class Items extends Secure_Controller
}
}
+ // Save item attributes
+ $definition_values = json_decode($this->input->post('definition_values'), TRUE);
+ $this->Attribute->delete_link($item_id);
+ foreach ($definition_values as $definition_id => $attribute_id) {
+ $success &= $this->Attribute->save_link($item_id, $definition_id, $attribute_id);
+ }
+
if($success && $upload_success)
{
$message = $this->xss_clean($this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) . ' ' . $item_data['name']);
diff --git a/application/helpers/tabular_helper.php b/application/helpers/tabular_helper.php
index 041115e5e..c6a5f69fe 100644
--- a/application/helpers/tabular_helper.php
+++ b/application/helpers/tabular_helper.php
@@ -532,7 +532,7 @@ function get_attribute_definition_manage_table_headers()
array('definition_name' => $CI->lang->line('attributes_definition_name')),
array('definition_type' => $CI->lang->line('attributes_definition_type')),
array('definition_flags' => $CI->lang->line('attributes_definition_flags')),
- array('category' => $CI->lang->line('attributes_category')),
+ array('definition_group' => $CI->lang->line('attributes_definition_group')),
);
return transform_headers($headers);
@@ -547,7 +547,7 @@ function get_attribute_definition_data_row($attribute)
'definition_id' => $attribute->definition_id,
'definition_name' => $attribute->definition_name,
'definition_type' => $attribute->definition_type,
- 'category' => $attribute->parent_name,
+ 'definition_group' => $attribute->definition_group,
'definition_flags' => count($attribute->definition_flags) == 0 ? $CI->lang->line('common_none_selected_text') : implode(', ', $attribute->definition_flags),
'edit' => anchor("$controller_name/view/$attribute->definition_id", '',
array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
diff --git a/application/language/ar-EG/attributes_lang.php b/application/language/ar-EG/attributes_lang.php
index 00229b05e..9008114b6 100644
--- a/application/language/ar-EG/attributes_lang.php
+++ b/application/language/ar-EG/attributes_lang.php
@@ -1,6 +1,6 @@
db->select('parent_definition.definition_name AS parent_name, definition.*');
+ $this->db->select('definition_group.definition_name AS definition_group, definition.*');
$this->db->from('attribute_definitions AS definition');
- $this->db->join('attribute_definitions AS parent_definition', 'parent_definition.definition_id = definition.definition_fk', 'left');
+ $this->db->join('attribute_definitions AS definition_group', 'definition_group.definition_id = definition.definition_fk', 'left');
$this->db->group_start();
$this->db->like('definition.definition_name', $search);
@@ -115,20 +115,23 @@ class Attribute extends CI_Model
return $this->db->get()->result_array();
}
- public function get_values_by_parent($definition_fk)
+ public function get_values_by_definitions($definition_ids)
{
- $this->db->from('attribute_definitions');
- if ($definition_fk != -1)
- {
- $this->db->where('definition_fk', $definition_fk);
- }
- else
- {
- $this->db->where('definition_fk');
- }
- $this->db->where('deleted', 0);
+ if (count($definition_ids) > 0) {
+ $this->db->from('attribute_definitions');
- return $this->db->get()->result_array();
+ $this->db->group_start();
+ $this->db->where_in('definition_fk', array_keys($definition_ids));
+ $this->db->or_where_in('definition_id', array_keys($definition_ids));
+ $this->db->where('definition_type !=', GROUP);
+ $this->db->group_end();
+
+ $this->db->where('deleted', 0);
+
+ return $this->db->get()->result_array();
+ }
+
+ return array();
}
public function get_definitions_by_type($attribute_type, $definition_id = -1)
@@ -153,6 +156,19 @@ class Attribute extends CI_Model
return $attribute_definitions;
}
+ public function get_definition_names()
+ {
+ $this->db->from('attribute_definitions');
+ $results = $this->db->get()->result_array();
+
+ $attribute_definitions = array();
+ foreach($results as $result)
+ {
+ $attribute_definitions[$result['definition_id']] = $result['definition_name'];
+ }
+ return $attribute_definitions;
+ }
+
public function get_definition_values($definition_id)
{
$attribute_values = [];
@@ -257,37 +273,7 @@ class Attribute extends CI_Model
return $this->db->delete('attribute_links', array('item_id' => $item_id));
}
- public function set_selected_category($item_id, $definition_id)
- {
- $this->db->trans_start();
-
- if ($this->link_exists($item_id))
- {
- $this->db->where('item_id', $item_id);
- $this->db->where('attribute_id');
- $this->db->update('attribute_links', array('definition_id' => $definition_id));
- }
- else
- {
- $this->db->insert('attribute_links', array('item_id' => $item_id, 'definition_id' => $definition_id));
- }
-
- $this->db->trans_complete();
-
- return $this->db->trans_status();
- }
-
- public function get_selected_category($item_id)
- {
- $this->db->from('attribute_links');
- $this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id');
- $this->db->where('item_id', $item_id);
- $this->db->where('definition_type', CATEGORY);
- $this->db->where('definition_fk');
- return $this->db->get()->row();
- }
-
- public function get_link_value($item_id, $definition_id)
+ public function get_link_value($item_id, $definition_id)
{
$this->db->where('item_id', $item_id);
$this->db->where('definition_id', $definition_id);
@@ -302,7 +288,7 @@ class Attribute extends CI_Model
$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');
- $this->db->where('definition_type <>', CATEGORY);
+ $this->db->where('definition_type <>', GROUP);
if (!empty($id))
{
$this->db->where($sale_receiving_fk, $id);
diff --git a/application/models/Item.php b/application/models/Item.php
index e074dd75d..b0ebb854f 100644
--- a/application/models/Item.php
+++ b/application/models/Item.php
@@ -370,7 +370,7 @@ class Item extends CI_Model
sale_id, receiving_id, attribute_links.definition_id
FROM ' . $this->db->dbprefix('attribute_links') . ' AS attribute_links
INNER JOIN ' . $this->db->dbprefix('attribute_definitions') . ' AS attribute_definitions
- ON attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'CATEGORY\'
+ ON attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'GROUP\'
WHERE sale_id IS NULL AND receiving_id IS NULL
)'
);
diff --git a/application/models/Item_kit.php b/application/models/Item_kit.php
index 15e100cb1..e2d4b9ac7 100644
--- a/application/models/Item_kit.php
+++ b/application/models/Item_kit.php
@@ -62,7 +62,7 @@ class Item_kit extends CI_Model
kit_discount_type,
price_option,
print_option,
- definition_name,
+ category,
supplier_id,
item_number,
cost_price,
@@ -78,8 +78,6 @@ class Item_kit extends CI_Model
$this->db->from('item_kits');
$this->db->join('items', 'item_kits.item_id = items.item_id', 'left');
- $this->db->join('attribute_links', 'attribute_links.item_id = items.item_id', 'left');
- $this->db->join('attribute_definitions', 'attribute_links.definition_id = attribute_definitions.definition_id AND definition_type = \'CATEGORY\'', 'left');
$this->db->where('item_kit_id', $item_kit_id);
$query = $this->db->get();
diff --git a/application/models/Receiving.php b/application/models/Receiving.php
index 02f87455c..29958d52f 100644
--- a/application/models/Receiving.php
+++ b/application/models/Receiving.php
@@ -59,7 +59,7 @@ class Receiving extends CI_Model
return $this->db->update('receivings', $receiving_data);
}
- public function save($items, $supplier_id, $employee_id, $comment, $reference, $payment_type)
+ public function save($items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE)
{
if(count($items) == 0)
{
diff --git a/application/models/Sale.php b/application/models/Sale.php
index d23e45860..fd44d2891 100644
--- a/application/models/Sale.php
+++ b/application/models/Sale.php
@@ -937,7 +937,8 @@ class Sale extends CI_Model
item_location,
print_option,
' . $this->Item->get_item_name('name') . ',
- definition_name,
+ category,
+ definition_name,
item_type,
stock_type');
$this->db->from('sales_items AS sales_items');
@@ -946,7 +947,7 @@ class Sale extends CI_Model
$this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id', 'left');
$this->db->where('sales_items.sale_id', $sale_id);
- // Entry sequenate (this will render kits in the expected sequence)
+ // Entry sequence (this will render kits in the expected sequence)
if($this->config->item('line_sequence') == '0')
{
$this->db->order_by('line', 'asc');
@@ -962,7 +963,7 @@ class Sale extends CI_Model
// Group by Item Category
elseif($this->config->item('line_sequence') == '2')
{
- $this->db->order_by('definition_name', 'asc');
+ $this->db->order_by('category', 'asc');
$this->db->order_by('sales_items.description', 'asc');
$this->db->order_by('items.name', 'asc');
$this->db->order_by('items.qty_per_pack', 'asc');
@@ -1193,7 +1194,8 @@ class Sale extends CI_Model
items.item_id AS item_id,
MAX(' . $this->Item->get_item_name() . ') AS name,
MAX(items.item_number) AS item_number,
- MAX(definition_name) AS category,
+ MAX(items.category) AS category,
+ MAX(definition_name) AS definition_name,
MAX(items.supplier_id) AS supplier_id,
MAX(sales_items.quantity_purchased) AS quantity_purchased,
MAX(sales_items.item_cost_price) AS item_cost_price,
@@ -1221,7 +1223,7 @@ class Sale extends CI_Model
LEFT OUTER JOIN ' . $this->db->dbprefix('attribute_links') . ' AS attribute_links
ON attribute_links.item_id = items.item_id AND attribute_links.sale_id = sales_items.sale_id
LEFT OUTER JOIN ' . $this->db->dbprefix('attribute_definitions') . ' AS attribute_definitions
- ON attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'CATEGORY\'
+ ON attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'GROUP\'
LEFT OUTER JOIN ' . $this->db->dbprefix('sales_payments_temp') . ' AS payments
ON sales_items.sale_id = payments.sale_id
LEFT OUTER JOIN ' . $this->db->dbprefix('suppliers') . ' AS supplier
diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php
index c034e6962..da25d0283 100644
--- a/application/models/reports/Detailed_receivings.php
+++ b/application/models/reports/Detailed_receivings.php
@@ -97,11 +97,11 @@ class Detailed_receivings extends Report
foreach($data['summary'] as $key=>$value)
{
- $this->db->select('name, item_number, category, quantity_purchased, serialnumber, total, discount, discount_type, item_location, receivings_items_temp.receiving_quantity');
+ $this->db->select('name, item_number, category, definition_name, quantity_purchased, serialnumber, total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
$this->db->from('receivings_items_temp');
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
$this->db->join('attribute_links', 'attribute_links.item_id = items.item_id AND attribute_links.receiving_id = receivings_items_temp.receiving_id', 'left');
- $this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'CATEGORY\'', 'left');
+ $this->db->join('attribute_definitions', 'attribute_definitions.definition_id = attribute_links.definition_id AND definition_type = \'GROUP\'', 'left');
$this->db->where('receivings_items_temp.receiving_id', $value['receiving_id']);
$data['details'][$key] = $this->db->get()->result_array();
}
diff --git a/application/views/attributes/form.php b/application/views/attributes/form.php
index 14a902089..cef04002e 100644
--- a/application/views/attributes/form.php
+++ b/application/views/attributes/form.php
@@ -19,15 +19,14 @@
@@ -170,4 +169,4 @@
}
}, form_support.error));
});
-
\ No newline at end of file
+
diff --git a/application/views/attributes/item.php b/application/views/attributes/item.php
index a3dad96e5..ec158c2e2 100644
--- a/application/views/attributes/item.php
+++ b/application/views/attributes/item.php
@@ -1,69 +1,98 @@
+ ?>
-
+
- $("input[name*='definition'][type='text']").change(function() {
- $.post('' + $(this).val(), {
- item_id: ,
- definition_id: ,
- attribute_id: $(this).data('attribute-id')
- });
- });
- })();
-
-
-
+
+
+
+
+
+
+
diff --git a/application/views/items/form.php b/application/views/items/form.php
index eaa360773..673f52876 100644
--- a/application/views/items/form.php
+++ b/application/views/items/form.php
@@ -423,47 +423,7 @@
focus: fill_value
});
- $("#category").autocomplete({source: "",delay:10,appendTo: '.modal-content'});
-
- var load_attributes = function(just_opened)
- {
- var definition_id = $(this).val() || 0;
- var item_id = $("form").attr('action').split("/").pop();
-
- var save_link = function()
- {
- var definition_attr_id = $(this).data('definition-id');
- if (definition_attr_id)
- {
- $.post('' + item_id, {definition_id : definition_attr_id, attribute_id : $(this).val()});
- }
- else if (definition_id && definition_id != -1)
- {
- $.post('' + item_id, {definition_id : definition_id});
- }
- };
-
- var delete_link = function()
- {
- $.get('' + item_id);
- };
-
- save_link.call(this);
-
- $("#attributes").load('/' + [item_id, definition_id].join("/"), function()
- {
- var new_def = definition_id < 0;
- new_def && typeof just_opened != 'boolean' && delete_link.call(this);
-
- $("#attributes select, #attributes input[type='text']").each(function()
- {
- $(this).change(save_link) && save_link.call(this);
- });
- });
- };
-
- $("#category").change(load_attributes);
- load_attributes.call($("#category"), true);
+ $("#category").autocomplete({source: "", delay:10, appendTo: '.modal-content'});
$("a.fileinput-exists").click(function() {
$.ajax({
@@ -510,13 +470,13 @@
{
url: "",
type: 'POST',
- data: {
+ data: {
"item_id" : "item_id; ?>",
"item_number" : function()
{
return $("#item_number").val();
},
- })
+ }
}
},
cost_price:
diff --git a/application/views/partial/header.php b/application/views/partial/header.php
index b7533f8fb..e4a776263 100644
--- a/application/views/partial/header.php
+++ b/application/views/partial/header.php
@@ -77,7 +77,7 @@
-
+
diff --git a/database/3.0_to_attributes.sql b/database/3.0_to_attributes.sql
deleted file mode 100644
index 1af1970ff..000000000
--- a/database/3.0_to_attributes.sql
+++ /dev/null
@@ -1,191 +0,0 @@
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_definitions` (
- `definition_id` INT(10) NOT NULL AUTO_INCREMENT,
- `definition_name` VARCHAR(255) NOT NULL,
- `definition_type` VARCHAR(45) NOT NULL,
- `definition_flags` TINYINT(4) NOT NULL,
- `definition_fk` INT(10) NULL,
- `deleted` TINYINT(1) NOT NULL DEFAULT 0,
- PRIMARY KEY (`definition_id`),
- KEY `definition_fk` (`definition_fk`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_values` (
- `attribute_id` INT NOT NULL AUTO_INCREMENT,
- `attribute_value` VARCHAR(45) NULL,
- PRIMARY KEY (`attribute_id`)
-) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_links` (
- `attribute_id` INT NULL,
- `definition_id` INT NOT NULL,
- `item_id` INT NULL,
- `sale_id` INT NULL,
- `receiving_id` INT NULL,
- KEY `attribute_id` (`attribute_id`),
- KEY `definition_id` (`definition_id`),
- KEY `item_id` (`item_id`),
- KEY `sale_id` (`sale_id`),
- KEY `receiving_id` (`receiving_id`),
- UNIQUE `attribute_links_uq1` (`attribute_id`, `definition_id`, `item_id`, `sale_id`, `receiving_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-ALTER TABLE `ospos_attribute_definitions`
- ADD CONSTRAINT `fk_ospos_attribute_definitions_ibfk_1` FOREIGN KEY (`definition_fk`) REFERENCES `ospos_attribute_definitions` (`definition_id`);
-
-
-ALTER TABLE `ospos_attribute_links`
- ADD CONSTRAINT `ospos_attribute_links_ibfk_1` FOREIGN KEY (`definition_id`) REFERENCES `ospos_attribute_definitions` (`definition_id`) ON DELETE CASCADE,
- ADD CONSTRAINT `ospos_attribute_links_ibfk_2` FOREIGN KEY (`attribute_id`) REFERENCES `ospos_attribute_values` (`attribute_id`) ON DELETE CASCADE,
- ADD CONSTRAINT `ospos_attribute_links_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
- ADD CONSTRAINT `ospos_attribute_links_ibfk_4` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`),
- ADD CONSTRAINT `ospos_attribute_links_ibfk_5` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
-
-
-UPDATE `ospos_modules` SET `sort` = 120 WHERE `name_lang_key` = 'module_config';
-
-INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_id`) VALUES
- ('module_attributes', 'module_attributes_desc', 110, 'attributes');
-
-INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES
- ('attributes', 'attributes');
-
-INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES
- ('attributes', 1);
-
--- migrate categories to attribute table
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT category, 'CATEGORY' from ospos_items;
-INSERT INTO `ospos_attribute_links` (item_id, definition_id)
- SELECT item_id, definition_id FROM ospos_items
- JOIN ospos_attribute_definitions ON ospos_attribute_definitions.definition_name = ospos_items.category;
-
--- migrate custom fields to text attributes
--- NOTE: items with custom attributes won't keep their selected category!!
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom1';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom2';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom3';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom4';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom5';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom6';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom7';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom8';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom9';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config where `key` = 'custom10';
-
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom1_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom1 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom2_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom2 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom3_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom3 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom4_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom4 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom5_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom5 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom6_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom6 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom7_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom7 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom8_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom8 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom9_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom9 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom10_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom10 IS NOT NULL;
-
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom1 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom2 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom3 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom4 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom5 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom6 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom7 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom8 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom9 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT custom10 FROM ospos_items;
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom1
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom1_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom2
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom2_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom3
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom3_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom4
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom4_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom5
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom5_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom6
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom6_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom7
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom7_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom8
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom8_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom9
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom9_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom10
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom10_name'));
-
-ALTER TABLE `ospos_items`
- DROP COLUMN `custom1`,
- DROP COLUMN `custom2`,
- DROP COLUMN `custom3`,
- DROP COLUMN `custom4`,
- DROP COLUMN `custom5`,
- DROP COLUMN `custom6`,
- DROP COLUMN `custom7`,
- DROP COLUMN `custom8`,
- DROP COLUMN `custom9`,
- DROP COLUMN `custom10`,
- DROP COLUMN `category`;
\ No newline at end of file
diff --git a/database/3.1.0_to_attributes.sql b/database/3.1.0_to_attributes.sql
deleted file mode 100644
index 95e4dfbdb..000000000
--- a/database/3.1.0_to_attributes.sql
+++ /dev/null
@@ -1,191 +0,0 @@
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_definitions` (
- `definition_id` INT(10) NOT NULL AUTO_INCREMENT,
- `definition_name` VARCHAR(255) NOT NULL,
- `definition_type` VARCHAR(45) NOT NULL,
- `definition_flags` TINYINT(4) NOT NULL,
- `definition_fk` INT(10) NULL,
- `deleted` TINYINT(1) NOT NULL DEFAULT 0,
- PRIMARY KEY (`definition_id`),
- KEY `definition_fk` (`definition_fk`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_values` (
- `attribute_id` INT NOT NULL AUTO_INCREMENT,
- `attribute_value` VARCHAR(45) NULL,
- PRIMARY KEY (`attribute_id`)
-) ENGINE = InnoDB DEFAULT CHARSET=utf8;
-
-
-CREATE TABLE IF NOT EXISTS `ospos_attribute_links` (
- `attribute_id` INT NULL,
- `definition_id` INT NOT NULL,
- `item_id` INT NULL,
- `sale_id` INT NULL,
- `receiving_id` INT NULL,
- KEY `attribute_id` (`attribute_id`),
- KEY `definition_id` (`definition_id`),
- KEY `item_id` (`item_id`),
- KEY `sale_id` (`sale_id`),
- KEY `receiving_id` (`receiving_id`),
- UNIQUE `attribute_links_uq1` (`attribute_id`, `definition_id`, `item_id`, `sale_id`, `receiving_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-ALTER TABLE `ospos_attribute_definitions`
- ADD CONSTRAINT `fk_ospos_attribute_definitions_ibfk_1` FOREIGN KEY (`definition_fk`) REFERENCES `ospos_attribute_definitions` (`definition_id`);
-
-
-ALTER TABLE `ospos_attribute_links`
- ADD CONSTRAINT `ospos_attribute_links_ibfk_1` FOREIGN KEY (`definition_id`) REFERENCES `ospos_attribute_definitions` (`definition_id`) ON DELETE CASCADE,
- ADD CONSTRAINT `ospos_attribute_links_ibfk_2` FOREIGN KEY (`attribute_id`) REFERENCES `ospos_attribute_values` (`attribute_id`) ON DELETE CASCADE,
- ADD CONSTRAINT `ospos_attribute_links_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`),
- ADD CONSTRAINT `ospos_attribute_links_ibfk_4` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`),
- ADD CONSTRAINT `ospos_attribute_links_ibfk_5` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`);
-
-
-UPDATE `ospos_modules` SET `sort` = 120 WHERE `name_lang_key` = 'module_config';
-
-INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_id`) VALUES
- ('module_attributes', 'module_attributes_desc', 110, 'attributes');
-
-INSERT INTO `ospos_permissions` (`permission_id`, `module_id`) VALUES
- ('attributes', 'attributes');
-
-INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES
- ('attributes', 1);
-
--- migrate categories to attribute table
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT DISTINCT category, 'CATEGORY' from ospos_items;
-INSERT INTO `ospos_attribute_links` (item_id, definition_id)
- SELECT item_id, definition_id FROM ospos_items
- JOIN ospos_attribute_definitions ON ospos_attribute_definitions.definition_name = ospos_items.category;
-
--- migrate custom fields to text attributes
--- NOTE: items with custom attributes won't keep their selected category!!
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom1_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom2_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom3_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom4_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom5_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom6_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom7_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom8_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom9_name';
-INSERT INTO `ospos_attribute_definitions` (definition_name, definition_type) SELECT `value`, 'TEXT' FROM ospos_app_config WHERE `key` = 'custom10_name';
-
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom1_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom1 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom2_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom2 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom3_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom3 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom4_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom4 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom5_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom5 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom6_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom6 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom7_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom7 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom8_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom8 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom9_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom9 IS NOT NULL;
-INSERT INTO ospos_attribute_links (definition_id, item_id) SELECT definition_id, item_id FROM ospos_attribute_definitions, ospos_app_config, ospos_items
- WHERE ospos_app_config.`key` = 'custom10_name' AND ospos_app_config.`value` = ospos_attribute_definitions.definition_name AND custom10 IS NOT NULL;
-
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom1 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom2 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom3 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom4 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom5 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom6 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom7 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom8 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom9 FROM ospos_items;
-INSERT INTO ospos_attribute_values (attribute_value) SELECT DISTINCT custom10 FROM ospos_items;
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom1
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom1_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom2
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom2_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom3
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom3_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom4
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom4_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom5
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom5_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom6
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom6_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom7
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom7_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom8
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom8_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom9
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom9_name'));
-
-UPDATE ospos_attribute_links
- INNER JOIN ospos_items ON ospos_attribute_links.item_id = ospos_items.item_id
- INNER JOIN ospos_attribute_values ON attribute_value = custom10
- SET ospos_attribute_links.attribute_id = ospos_attribute_values.attribute_id
- WHERE definition_id IN (SELECT definition_id FROM ospos_attribute_definitions
- WHERE definition_name = (SELECT `value` FROM ospos_app_config WHERE `key` = 'custom10_name'));
-
-ALTER TABLE `ospos_items`
- DROP COLUMN `custom1`,
- DROP COLUMN `custom2`,
- DROP COLUMN `custom3`,
- DROP COLUMN `custom4`,
- DROP COLUMN `custom5`,
- DROP COLUMN `custom6`,
- DROP COLUMN `custom7`,
- DROP COLUMN `custom8`,
- DROP COLUMN `custom9`,
- DROP COLUMN `custom10`,
- DROP COLUMN `category`;
diff --git a/database/tables.sql b/database/tables.sql
index 32d304fb0..6e6e83f69 100644
--- a/database/tables.sql
+++ b/database/tables.sql
@@ -229,6 +229,7 @@ CREATE TABLE `ospos_inventory` (
CREATE TABLE `ospos_items` (
`name` varchar(255) NOT NULL,
+ `category` varchar(255) NOT NULL,
`supplier_id` int(11) DEFAULT NULL,
`item_number` varchar(255) DEFAULT NULL,
`description` varchar(255) NOT NULL,