image import from csv
This commit is contained in:
@@ -72,7 +72,7 @@ class Settings::MenusController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def export
|
||||
def export
|
||||
@settings_menus = Menu.all.page(params[:page]).per(10)
|
||||
menu = Menu.find(params[:id])
|
||||
|
||||
@@ -135,7 +135,7 @@ class Settings::MenusController < ApplicationController
|
||||
if mii.item_attributes.length > 0
|
||||
attribute = MenuItemAttribute.find(mii.item_attributes[0]).name
|
||||
end
|
||||
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, mi.image_path.to_s.remove("/image/menu_images/")], :style=>wrap_text
|
||||
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, mi.image_path.to_s.remove("/image/menu_images")], :style=>wrap_text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,6 +140,14 @@ class Menu < ApplicationRecord
|
||||
end
|
||||
else
|
||||
# Menu by Menu Import
|
||||
@shop = Shop.first
|
||||
shop_code = ""
|
||||
if !@shop.nil?
|
||||
if @shop.shop_code
|
||||
shop_code = @shop.shop_code + "_"
|
||||
end
|
||||
end
|
||||
|
||||
sheet = spreadsheet.sheet(0)
|
||||
menu = sheet.row(1)[1]
|
||||
imported_menu = Menu.create({name: menu, is_active: true, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by})
|
||||
@@ -184,11 +192,10 @@ class Menu < ApplicationRecord
|
||||
account = Account.create({title: row["Account"], account_type: "0"})
|
||||
end
|
||||
|
||||
image_path = row["Image Path"] ? row["Image Path"] : ""
|
||||
image_path = row["Image Path"] ? URI.parse('public/image/menu_images/'+row["Image Path"]) : ""
|
||||
puts "image_path"
|
||||
puts image_path
|
||||
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: image_path.to_s, description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
|
||||
puts "menu_itm"
|
||||
puts menu_itm.to_json
|
||||
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: image_path, description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
|
||||
# else
|
||||
# status = status + "Item Code already exists for " + row["Item Name"] + "."
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user