Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -103,6 +103,9 @@ For Sidekiq
|
|||||||
1) If you want to use sidekiq
|
1) If you want to use sidekiq
|
||||||
=> Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0
|
=> Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0
|
||||||
|
|
||||||
|
For Clear Menu
|
||||||
|
1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set
|
||||||
|
|
||||||
For Check CUp status
|
For Check CUp status
|
||||||
###please open
|
###please open
|
||||||
sudo cat /etc/sudoers
|
sudo cat /etc/sudoers
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ $(function() {
|
|||||||
$('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
|
$('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
|
||||||
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
|
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
|
||||||
var item_data = $(this);
|
var item_data = $(this);
|
||||||
item = get_item(item_data);
|
item = get_item(item_data,"add_to_order");
|
||||||
customer_display_view(item,"add");
|
customer_display_view(item,"add");
|
||||||
show_item_detail(item_data,"add_to_order");
|
show_item_detail(item_data,"add_to_order");
|
||||||
calculate_sub_total();
|
calculate_sub_total();
|
||||||
@@ -710,7 +710,7 @@ $(function() {
|
|||||||
// click plus icon for add
|
// click plus icon for add
|
||||||
$(document).on('click', '.add_icon', function(event){
|
$(document).on('click', '.add_icon', function(event){
|
||||||
var item_data = $(this);
|
var item_data = $(this);
|
||||||
item = get_item(item_data);
|
item = get_item(item_data,"add_icon");
|
||||||
customer_display_view(item,"add");
|
customer_display_view(item,"add");
|
||||||
show_item_detail(item_data,"add_icon");
|
show_item_detail(item_data,"add_icon");
|
||||||
calculate_sub_total();
|
calculate_sub_total();
|
||||||
@@ -745,8 +745,6 @@ $(function() {
|
|||||||
item_code = $(item_row[i]).attr('data-code');
|
item_code = $(item_row[i]).attr('data-code');
|
||||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||||
r_option = $(item_row[i]).attr('data-opt');
|
r_option = $(item_row[i]).attr('data-opt');
|
||||||
console.log(r_option)
|
|
||||||
console.log(d_option)
|
|
||||||
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
|
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
|
||||||
if (qty > 1) {
|
if (qty > 1) {
|
||||||
qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
|
qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
|
||||||
@@ -1195,7 +1193,7 @@ console.log(d_option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get Item rows */
|
/* Get Item rows */
|
||||||
function get_item(data){
|
function get_item(data,click_type){
|
||||||
var sale_items = [];
|
var sale_items = [];
|
||||||
|
|
||||||
var sale_item = {};
|
var sale_item = {};
|
||||||
@@ -1206,6 +1204,8 @@ console.log(d_option)
|
|||||||
sale_item.instance_code = data.attr('data-instance-code')
|
sale_item.instance_code = data.attr('data-instance-code')
|
||||||
sale_item.attributes = data.attr('data-attributes')
|
sale_item.attributes = data.attr('data-attributes')
|
||||||
sale_item.options = data.attr('data-options')
|
sale_item.options = data.attr('data-options')
|
||||||
|
sale_item.opt = data.attr('data-opt')
|
||||||
|
sale_item.click_type = click_type
|
||||||
sale_item.instance = data.attr('data-instance')
|
sale_item.instance = data.attr('data-instance')
|
||||||
sale_items.push(sale_item);
|
sale_items.push(sale_item);
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,20 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
|||||||
instance = "("+items[i].instance+")";
|
instance = "("+items[i].instance+")";
|
||||||
}
|
}
|
||||||
|
|
||||||
d_option = items[i].options;
|
// d_option = items[i].options;
|
||||||
if (d_option){
|
// if (d_option){
|
||||||
option_name = "-"+items[i].options;
|
// option_name = "-"+items[i].options;
|
||||||
|
// }else{
|
||||||
|
// option_name = '';
|
||||||
|
// }
|
||||||
|
|
||||||
|
d_option = items[i].opt;
|
||||||
|
if (items[i].click_type != "add_icon"){
|
||||||
|
option_name = "-"+items[i].options;
|
||||||
|
data_option = items[i].options ;
|
||||||
}else{
|
}else{
|
||||||
option_name = '';
|
option_name = ' ';
|
||||||
|
data_option = '[]';
|
||||||
}
|
}
|
||||||
|
|
||||||
var rowCount = $('.second_display_items tbody tr').length+1;
|
var rowCount = $('.second_display_items tbody tr').length+1;
|
||||||
@@ -68,7 +77,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
|||||||
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
|
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
|
||||||
+items[i].instance_code+"' data-attributes='"
|
+items[i].instance_code+"' data-attributes='"
|
||||||
+items[i].attributes+"' data-options ='"
|
+items[i].attributes+"' data-options ='"
|
||||||
+items[i].options+"' data-row ='"+rowCount+ "'>"
|
+data_option+"' data-opt ='"
|
||||||
|
+items[i].options+"' data-row ='"+rowCount+ "'>"
|
||||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||||
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
|
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
|
||||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||||
|
|||||||
@@ -46,30 +46,98 @@ class Menu < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.import(file)
|
def self.import(file)
|
||||||
spreadsheet = Roo::Spreadsheet.open(file.path)
|
|
||||||
|
spreadsheet = open_spreadsheet(file)
|
||||||
|
sheet_count = spreadsheet.sheets.count-1
|
||||||
|
for i in 0..sheet_count do
|
||||||
|
header = spreadsheet.sheet(i).row(1)
|
||||||
|
sheet_name = spreadsheet.sheets[i]
|
||||||
|
|
||||||
spreadsheet = Roo::Excelx.new(file.path)
|
(2..spreadsheet.sheet(i).last_row).each do |ii|
|
||||||
|
row = Hash[[header,spreadsheet.sheet(i).row(ii)].transpose]
|
||||||
# Use the extension option if the extension is ambiguous.
|
if sheet_name == "Account"
|
||||||
spreadsheet = Roo::Spreadsheet.open(file.path, extension: :xlsx)
|
# Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||||
|
account = Account.find_by_id(row["id"])
|
||||||
puts spreadsheet.info
|
if account
|
||||||
|
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||||
header = spreadsheet.row(1)
|
else
|
||||||
|
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
|
||||||
(2..spreadsheet.last_row).each do |i|
|
end
|
||||||
|
elsif sheet_name == "Item Set"
|
||||||
row = Hash[[header,spreadsheet.row(i)].transpose]
|
# ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||||
|
item_set = ItemSet.find_by_id(row["id"])
|
||||||
menu = Menu.new
|
if item_set
|
||||||
menu.name = row["name"]
|
ItemSet.create( name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||||
menu.is_active = row["is_active"]
|
else
|
||||||
menu.valid_days = row["valid_days"]
|
ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
|
||||||
menu.valid_time_from = row["valid_time_from"]
|
end
|
||||||
menu.valid_time_to = row["valid_time_to"]
|
elsif sheet_name == "Menu Item Options"
|
||||||
menu.created_by = row["created_by"]
|
# MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||||
menu.save
|
item_options = MenuItemOption.find_by_id(row["id"])
|
||||||
|
if item_options
|
||||||
|
MenuItemOption.create( option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||||
|
else
|
||||||
|
MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Item Attributes"
|
||||||
|
# MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||||
|
item_attributes = MenuItemAttribute.find_by_id(row["id"])
|
||||||
|
if item_attributes
|
||||||
|
MenuItemAttribute.create( attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||||
|
else
|
||||||
|
MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu"
|
||||||
|
menu = Menu.find_by_id(row["id"])
|
||||||
|
if menu
|
||||||
|
Menu.create(name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||||
|
else
|
||||||
|
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Category"
|
||||||
|
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||||
|
menu_category = MenuCategory.find_by_id(row["id"])
|
||||||
|
if menu_category
|
||||||
|
MenuCategory.create(menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||||
|
else
|
||||||
|
MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Item"
|
||||||
|
# MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: row["item_attributes"], item_options: row["item_options"], account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||||
|
menu_item = MenuItem.find_by_id(row["id"])
|
||||||
|
if menu_item
|
||||||
|
MenuItem.create(item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||||
|
else
|
||||||
|
MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Item Instance"
|
||||||
|
# MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: row["item_attributes"], price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||||
|
item_instance = MenuItemInstance.find_by_id(row["id"])
|
||||||
|
if item_instance
|
||||||
|
MenuItemInstance.create(menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||||
|
else
|
||||||
|
MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Instance Item Set"
|
||||||
|
# MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||||
|
menu_instance_set = MenuInstanceItemSet.find_by_id(row["id"])
|
||||||
|
if menu_instance_set
|
||||||
|
MenuInstanceItemSet.create(item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||||
|
else
|
||||||
|
MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
|
||||||
|
end
|
||||||
|
elsif sheet_name == "Menu Item Set"
|
||||||
|
# MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||||
|
menu_item_set = MenuItemSet.find_by_id(row["id"])
|
||||||
|
if menu_item_set
|
||||||
|
MenuItemSet.create(item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||||
|
else
|
||||||
|
MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.open_spreadsheet(file)
|
def self.open_spreadsheet(file)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class MenuCategory < ApplicationRecord
|
class MenuCategory < ApplicationRecord
|
||||||
# before_create :generate_menu_category_code
|
# before_create :generate_menu_category_code
|
||||||
|
|
||||||
belongs_to :menu , counter_cache: true
|
belongs_to :menu
|
||||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||||
has_many :menu_items
|
has_many :menu_items
|
||||||
|
|||||||
@@ -12,75 +12,74 @@ wb.styles do |s|
|
|||||||
:alignment => { :horizontal => :left,
|
:alignment => { :horizontal => :left,
|
||||||
:vertical => :center ,
|
:vertical => :center ,
|
||||||
:header_text => true}
|
:header_text => true}
|
||||||
|
wb.add_worksheet(name: "Account") do |sheet|
|
||||||
wb.add_worksheet(name: "Menu") do |sheet|
|
sheet.add_row %w(id title account_type discount point bonus rebate), :style=>header_text
|
||||||
sheet.add_row %w( name is_active valid_days valid_time_from valid_time_to created_by ), :style=>header_text
|
|
||||||
@settings_menus.each do |menu|
|
|
||||||
sheet.add_row [ menu.name, menu.is_active, menu.valid_days, menu.valid_time_from,menu.valid_time_to, menu.created_by], :style=>[date,wrap_text]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Category") do |sheet|
|
|
||||||
sheet.add_row %w(menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at), :style=>header_text
|
|
||||||
MenuCategory.all.each do |mc|
|
|
||||||
sheet.add_row [mc.menu_id, mc.code, mc.name, mc.alt_name, mc.order_by, mc.created_by, mc.menu_category_id, mc.is_available, mc.created_at, mc.updated_at], :style=>wrap_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Item") do |sheet|
|
|
||||||
sheet.add_row %w(item_code name alt_name image_path description information unit type menu_category_id item_attributes item_options account_id _qty taxable is_sub_item is_available created_by created_at updated_at), :style=>header_text
|
|
||||||
MenuItem.all.each do |mi|
|
|
||||||
sheet.add_row [mi.item_code, mi.name, mi.alt_name, mi.image_path, mi.description, mi.information, mi.unit, mi.type, mi.menu_category_id, mi.item_attributes, mi.item_options, mi.account_id, mi.min_qty, mi.taxable, mi.is_sub_item, mi.is_available, mi.created_by, mi.created_at, mi.updated_at], :style=>wrap_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Item Instance") do |sheet|
|
|
||||||
sheet.add_row %w(menu_item_id item_instance_code item_instance_name item_attributes price is_on_promotion promotion_price is_available is_default created_at updated_at), :style=>header_text
|
|
||||||
MenuItemInstance.all.each do |mii|
|
|
||||||
sheet.add_row [mii.menu_item_id, mii.item_instance_code, mii.item_instance_name, mii.item_attributes, mii.price, mii.is_on_promotion, mii.promotion_price, mii.is_available, mii.is_default, mii.created_at, mii.updated_at], :style=>wrap_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Options") do |sheet|
|
|
||||||
sheet.add_row %w(option_type name value created_at updated_at), :style=>header_text
|
|
||||||
MenuItemOption.all.each do |option|
|
|
||||||
sheet.add_row [option.option_type, option.name, option.value, option.created_at, option.updated_at], :style=>wrap_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Item Attributes") do |sheet|
|
|
||||||
sheet.add_row %w(attribute_type name value created_at updated_at), :style=>header_text
|
|
||||||
MenuItemAttribute.all.each do |attr|
|
|
||||||
sheet.add_row [ attr.attribute_type,attr.name,attr.value,attr.created_at,attr.updated_at], :style=>wrap_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wb.add_worksheet(name: "Account") do |sheet|
|
|
||||||
sheet.add_row %w(title account_type discount point bonus rebate created_at updated_at), :style=>header_text
|
|
||||||
Account.all.each do |acc|
|
Account.all.each do |acc|
|
||||||
sheet.add_row [acc.title,acc.account_type,acc.discount,acc.point,acc.bonus,acc.rebate,acc.created_at,acc.updated_at], :style=>wrap_text
|
sheet.add_row [acc.id, acc.title,acc.account_type,acc.discount,acc.point,acc.bonus,acc.rebate], :style=>wrap_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wb.add_worksheet(name: "Item Set") do |sheet|
|
wb.add_worksheet(name: "Item Set") do |sheet|
|
||||||
sheet.add_row %w(name alt_name min_selectable_qty max_selectable_qty created_at updated_at), :style=>header_text
|
sheet.add_row %w(id name alt_name min_selectable_qty max_selectable_qty), :style=>header_text
|
||||||
ItemSet.all.each do |set|
|
ItemSet.all.each do |set|
|
||||||
sheet.add_row [set.name, set.alt_name, set.min_selectable_qty, set.max_selectable_qty, set.created_at, set.updated_at], :style=>wrap_text
|
sheet.add_row [set.id,set.name, set.alt_name, set.min_selectable_qty, set.max_selectable_qty], :style=>wrap_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu Item Options") do |sheet|
|
||||||
|
sheet.add_row %w(id option_type name value), :style=>header_text
|
||||||
|
MenuItemOption.all.each do |option|
|
||||||
|
sheet.add_row [option.id, option.option_type, option.name, option.value], :style=>wrap_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu Item Attributes") do |sheet|
|
||||||
|
sheet.add_row %w(id attribute_type name value), :style=>header_text
|
||||||
|
MenuItemAttribute.all.each do |attr|
|
||||||
|
sheet.add_row [attr.id, attr.attribute_type,attr.name,attr.value], :style=>wrap_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu") do |sheet|
|
||||||
|
sheet.add_row %w( id name is_active valid_days valid_time_from valid_time_to created_by ), :style=>header_text
|
||||||
|
@settings_menus.each do |menu|
|
||||||
|
sheet.add_row [ menu.id, menu.name, menu.is_active, menu.valid_days, menu.valid_time_from,menu.valid_time_to, menu.created_by], :style=>[wrap_text]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu Category") do |sheet|
|
||||||
|
sheet.add_row %w(id menu_id code name alt_name order_by created_by menu_category_id is_available), :style=>header_text
|
||||||
|
MenuCategory.all.each do |mc|
|
||||||
|
sheet.add_row [mc.id, mc.menu_id, mc.code, mc.name, mc.alt_name, mc.order_by, mc.created_by, mc.menu_category_id, mc.is_available], :style=>wrap_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu Item") do |sheet|
|
||||||
|
sheet.add_row %w(id item_code name alt_name image_path description information unit type menu_category_id item_attributes item_options account_id min_qty taxable is_sub_item is_available created_by), :style=>header_text
|
||||||
|
MenuItem.all.each do |mi|
|
||||||
|
sheet.add_row [mi.id,mi.item_code, mi.name, mi.alt_name, mi.image_path, mi.description, mi.information, mi.unit, mi.type, mi.menu_category_id, mi.item_attributes, mi.item_options, mi.account_id, mi.min_qty, mi.taxable, mi.is_sub_item, mi.is_available, mi.created_by], :style=>wrap_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wb.add_worksheet(name: "Menu Item Instance") do |sheet|
|
||||||
|
sheet.add_row %w(id menu_item_id item_instance_code item_instance_name item_attributes price is_on_promotion promotion_price is_available is_default), :style=>header_text
|
||||||
|
MenuItemInstance.all.each do |mii|
|
||||||
|
sheet.add_row [mii.id, mii.menu_item_id, mii.item_instance_code, mii.item_instance_name, mii.item_attributes, mii.price, mii.is_on_promotion, mii.promotion_price, mii.is_available, mii.is_default], :style=>wrap_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Instance Item Set") do |sheet|
|
wb.add_worksheet(name: "Menu Instance Item Set") do |sheet|
|
||||||
sheet.add_row %w(item_set_id menu_item_instance_id created_at updated_at), :style=>header_text
|
sheet.add_row %w(id item_set_id menu_item_instance_id), :style=>header_text
|
||||||
MenuInstanceItemSet.all.each do |miis|
|
MenuInstanceItemSet.all.each do |miis|
|
||||||
sheet.add_row [miis.item_set_id, miis.menu_item_instance_id, miis.created_at, miis.updated_at], :style=>wrap_text
|
sheet.add_row [miis.id ,miis.item_set_id, miis.menu_item_instance_id], :style=>wrap_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wb.add_worksheet(name: "Menu Item Set") do |sheet|
|
wb.add_worksheet(name: "Menu Item Set") do |sheet|
|
||||||
sheet.add_row %w(item_set_id menu_item_id created_at updated_at), :style=>header_text
|
sheet.add_row %w(id item_set_id menu_item_id), :style=>header_text
|
||||||
MenuItemSet.all.each do |mis|
|
MenuItemSet.all.each do |mis|
|
||||||
sheet.add_row [mis.item_set_id, mis.menu_item_id, mis.created_at, mis.updated_at], :style=>wrap_text
|
sheet.add_row [mis.id,mis.item_set_id, mis.menu_item_id], :style=>wrap_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,4 +20,26 @@ namespace :clear do
|
|||||||
SeedGenerator.where("id > 1").update(:current => 0, :next => 1)
|
SeedGenerator.where("id > 1").update(:current => 0, :next => 1)
|
||||||
puts "Clear Data Done."
|
puts "Clear Data Done."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Clear Menu"
|
||||||
|
task :menu => :environment do
|
||||||
|
|
||||||
|
|
||||||
|
MenuItemOption.destroy_all
|
||||||
|
MenuItemAttribute.destroy_all
|
||||||
|
|
||||||
|
MenuItemSet.destroy_all
|
||||||
|
|
||||||
|
MenuInstanceItemSet.destroy_all
|
||||||
|
ItemSet.destroy_all
|
||||||
|
|
||||||
|
MenuItemInstance.destroy_all
|
||||||
|
MenuItem.destroy_all
|
||||||
|
|
||||||
|
MenuCategory.destroy_all
|
||||||
|
Menu.destroy_all
|
||||||
|
|
||||||
|
Account.destroy_all
|
||||||
|
puts "Clear all Menu Done."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user