mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 02:33:56 -04:00
Work in progress, still testing items form (#68)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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", '<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'))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "Category";
|
||||
$lang["attributes_definition_group"] = "Category";
|
||||
$lang["attributes_confirm_delete"] = "Are you sure you want to delete the selected attribute(s)?";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "Could not delete selected attribute(s)";
|
||||
$lang["attributes_definition_flags"] = "Attribute Visibility";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "Category";
|
||||
$lang["attributes_definition_group"] = "Group";
|
||||
$lang["attributes_confirm_delete"] = "Are you sure you want to delete the selected attribute(s)?";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "Could not delete selected attribute(s)";
|
||||
$lang["attributes_definition_flags"] = "Attribute Visibility";
|
||||
$lang["attributes_definition_id"] = "Id";
|
||||
$lang["attributes_definition_name"] = "Attribute Name";
|
||||
$lang["attributes_definition_name"] = "Add Attribute";
|
||||
$lang["attributes_definition_one_or_multiple"] = "attribute(s)";
|
||||
$lang["attributes_definition_successful_adding"] = "You have successfully added item";
|
||||
$lang["attributes_definition_successful_deleted"] = "You have successfully deleted";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "Category";
|
||||
$lang["attributes_definition_group"] = "Category";
|
||||
$lang["attributes_confirm_delete"] = "Are you sure you want to delete the selected attributes?";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "Could not deleted selected attributes.";
|
||||
$lang["attributes_definition_flags"] = "Attribute Visibility";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$lang["attributes_category"] = "";
|
||||
$lang["attributes_definition_group"] = "";
|
||||
$lang["attributes_confirm_delete"] = "";
|
||||
$lang["attributes_definition_cannot_be_deleted"] = "";
|
||||
$lang["attributes_definition_flags"] = "";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
define('CATEGORY', 'CATEGORY');
|
||||
define('GROUP', 'GROUP');
|
||||
define('DROPDOWN', 'DROPDOWN');
|
||||
define('DATE', 'DATE');
|
||||
define('TEXT', 'TEXT');
|
||||
|
||||
const DEFINITION_TYPES = [CATEGORY, DROPDOWN, TEXT];
|
||||
const DEFINITION_TYPES = [GROUP, DROPDOWN, TEXT];
|
||||
|
||||
class Attribute extends CI_Model
|
||||
{
|
||||
@@ -86,9 +86,9 @@ class Attribute extends CI_Model
|
||||
*/
|
||||
public function search($search, $rows = 0, $limit_from = 0, $sort = 'definition.definition_name', $order = 'asc')
|
||||
{
|
||||
$this->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);
|
||||
|
||||
@@ -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
|
||||
)'
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -19,15 +19,14 @@
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('attributes_definition_type'), 'definition_type', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<?php $disable_definition_type = $definition_info->definition_type == CATEGORY; ?>
|
||||
<?php echo form_dropdown('definition_type', DEFINITION_TYPES, array_search($definition_info->definition_type, DEFINITION_TYPES), 'id="definition_type" class="form-control" ' . ($disable_definition_type ? 'disabled="disabled"' : ''));?>
|
||||
<?php echo form_dropdown('definition_type', DEFINITION_TYPES, array_search($definition_info->definition_type, DEFINITION_TYPES), 'id="definition_type" class="form-control" ');?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('attributes_category'), 'definition_parent', array('class' => 'control-label col-xs-3')); ?>
|
||||
<?php echo form_label($this->lang->line('attributes_definition_group'), 'definition_group', array('class' => 'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<?php echo form_dropdown('definition_parent', $definition_parent, $definition_info->definition_fk, 'id="definition_parent" class="form-control" ' . (empty($definition_parent) ? 'disabled="disabled"' : ''));?>
|
||||
<?php echo form_dropdown('definition_group', $definition_group, $definition_info->definition_fk, 'id="definition_group" class="form-control" ' . (empty($definition_group) ? 'disabled="disabled"' : ''));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -170,4 +169,4 @@
|
||||
}
|
||||
}, form_support.error));
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -1,69 +1,98 @@
|
||||
<?php
|
||||
foreach($definition_values as $definition_value)
|
||||
{
|
||||
if ($definition_value['definition_type'] == CATEGORY)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($definition_value['definition_name'], $definition_value['definition_name'], array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
|
||||
<?php
|
||||
$definition_id = $definition_value['definition_id'];
|
||||
$definition_name = 'definition_' . $definition_id;
|
||||
if ($definition_value['definition_type'] == DATE)
|
||||
{
|
||||
echo form_input(array(
|
||||
'name' => $definition_name,
|
||||
'value' => date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($definition_value['attribute_value'])),
|
||||
'class' => 'form-control input-sm',
|
||||
'data-definition-id' => $definition_value['definition_id'],
|
||||
'readonly' => 'true'));
|
||||
}
|
||||
else if ($definition_value['definition_type'] == DROPDOWN)
|
||||
{
|
||||
$values = $this->Attribute->get_definition_values($definition_id);
|
||||
$selected_value = $this->Attribute->get_link_value($item_id, $definition_id);
|
||||
echo form_dropdown($definition_name, $values, (empty($selected_value) ? NULL : $selected_value->attribute_id), "class='form-control' data-definition-id='$definition_id'");
|
||||
}
|
||||
else if ($definition_value['definition_type'] == TEXT)
|
||||
{
|
||||
$attribute_value = $this->Attribute->get_attribute_value($item_id, $definition_id);
|
||||
$value = (empty($attribute_value) || empty($attribute_value->attribute_value)) ? NULL : $attribute_value->attribute_value;
|
||||
$id = (empty($attribute_value) || empty($attribute_value->attribute_id)) ? NULL : $attribute_value->attribute_id;
|
||||
echo form_input($definition_name, $value, "class='form-control' data-attribute-id='$id'");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($definition_value['definition_name'], $definition_value['definition_name'], array('class' => 'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
|
||||
<?php
|
||||
$definition_id = $definition_value['definition_id'];
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
$('input[name="<?php echo $definition_name; ?>"]').autocomplete({
|
||||
source: '<?php echo site_url("attributes/suggest_attribute/$definition_id");?>',
|
||||
appendTo: '.modal-content',
|
||||
select: function (a, ui) {
|
||||
$(this).data('attribute_id', ui.item.value);
|
||||
$(this).val(ui.item.label);
|
||||
},
|
||||
delay:10
|
||||
});
|
||||
if ($definition_value['definition_type'] == DATE)
|
||||
{
|
||||
echo form_input(array(
|
||||
'name' => 'definition_name[]',
|
||||
'value' => date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($definition_value['attribute_value'])),
|
||||
'class' => 'form-control input-sm',
|
||||
'data-definition-id' => $definition_value['definition_id'],
|
||||
'readonly' => 'true'));
|
||||
}
|
||||
else if ($definition_value['definition_type'] == DROPDOWN)
|
||||
{
|
||||
$values = $this->Attribute->get_definition_values($definition_id);
|
||||
$selected_value = $this->Attribute->get_link_value($item_id, $definition_id);
|
||||
echo form_dropdown('definition_name[]', $values, (empty($selected_value) ? NULL : $selected_value->attribute_id), "class='form-control' data-definition-id='$definition_id'");
|
||||
}
|
||||
else if ($definition_value['definition_type'] == TEXT)
|
||||
{
|
||||
$attribute_value = $this->Attribute->get_attribute_value($item_id, $definition_id);
|
||||
$value = (empty($attribute_value) || empty($attribute_value->attribute_value)) ? NULL : $attribute_value->attribute_value;
|
||||
$id = (empty($attribute_value) || empty($attribute_value->attribute_id)) ? NULL : $attribute_value->attribute_id;
|
||||
echo form_input('definition_name[]', $value, "class='form-control' data-attribute-id='$id'");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
$("input[name*='definition'][type='text']").change(function() {
|
||||
$.post('<?php echo site_url("attributes/save_attribute_value/");?>' + $(this).val(), {
|
||||
item_id: <?php echo $item_id; ?>,
|
||||
definition_id: <?php echo $definition_id; ?>,
|
||||
attribute_id: $(this).data('attribute-id')
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line("attributes_definition_name"), "definition_name_label", array('class' => 'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<?php echo form_dropdown('definition_name', $definition_names, -1, array('id' => 'definition_name', 'class' => 'form-control')); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var definition_values = <?php echo json_encode($definition_values, JSON_FORCE_OBJECT); ?>;
|
||||
|
||||
$('input[name*="definition"]').autocomplete({
|
||||
source: '<?php echo site_url("attributes/suggest_attribute/");?>' + $(this).data('definition-id'),
|
||||
appendTo: '.modal-content',
|
||||
select: function (a, ui) {
|
||||
$(this).data('attribute_id', ui.item.value);
|
||||
$(this).val(ui.item.label);
|
||||
},
|
||||
delay:10
|
||||
}).change(function() {
|
||||
var definition_id = $(this).data('definition-id');
|
||||
definition_values[definition_id] = $(this).data('attribute-id');
|
||||
});
|
||||
|
||||
$("#definition_name").change(function() {
|
||||
var definition_id = $(this).val();
|
||||
definition_values[definition_id] = {};
|
||||
$("#attributes").load('<?php echo site_url("items/attributes/$item_id");?>', {
|
||||
'definition_ids': JSON.stringify(definition_values)
|
||||
});
|
||||
});
|
||||
|
||||
$('#item_form').validate({
|
||||
submitHandler: function (form, event) {
|
||||
$(form).ajaxSubmit({
|
||||
beforeSerialize: function ($form, options) {
|
||||
$("<input>").attr({
|
||||
id: 'definition_values',
|
||||
type: 'hidden',
|
||||
name: 'definition_values',
|
||||
value: JSON.stringify(definition_values || [])
|
||||
}).appendTo($form);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -423,47 +423,7 @@
|
||||
focus: fill_value
|
||||
});
|
||||
|
||||
$("#category").autocomplete({source: "<?php echo site_url('items/suggest_category');?>",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('<?php echo site_url("attributes/save_attribute_link/");?>' + item_id, {definition_id : definition_attr_id, attribute_id : $(this).val()});
|
||||
}
|
||||
else if (definition_id && definition_id != -1)
|
||||
{
|
||||
$.post('<?php echo site_url("attributes/save_attribute_link/");?>' + item_id, {definition_id : definition_id});
|
||||
}
|
||||
};
|
||||
|
||||
var delete_link = function()
|
||||
{
|
||||
$.get('<?php echo site_url("attributes/delete_attribute_link/");?>' + item_id);
|
||||
};
|
||||
|
||||
save_link.call(this);
|
||||
|
||||
$("#attributes").load('<?php echo site_url("items/attributes");?>/' + [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: "<?php echo site_url('items/suggest_category');?>", delay:10, appendTo: '.modal-content'});
|
||||
|
||||
$("a.fileinput-exists").click(function() {
|
||||
$.ajax({
|
||||
@@ -510,13 +470,13 @@
|
||||
{
|
||||
url: "<?php echo site_url($controller_name . '/check_item_number')?>",
|
||||
type: 'POST',
|
||||
data: {
|
||||
data: {
|
||||
"item_id" : "<?php echo $item_info->item_id; ?>",
|
||||
"item_number" : function()
|
||||
{
|
||||
return $("#item_number").val();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
cost_price:
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=88039333a5"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=d261c92f4f"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=b84e7f49e4"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -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`;
|
||||
@@ -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`;
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user