image import from csv

This commit is contained in:
phyusin
2018-06-21 15:42:11 +06:30
parent 6ed3cb64e8
commit 57a6f03917
2 changed files with 13 additions and 6 deletions

View File

@@ -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