check is_available for menu sync
This commit is contained in:
@@ -32,7 +32,7 @@ $(function(){
|
|||||||
/*new customer UI func:*/
|
/*new customer UI func:*/
|
||||||
|
|
||||||
$(".reservation_type").on("click", function(){
|
$(".reservation_type").on("click", function(){
|
||||||
if($(this).val() == "Dine-in"){
|
if(parseInt($(this).val()) == 0){
|
||||||
$(".dining_type").show();
|
$(".dining_type").show();
|
||||||
$(".room_type").hide();
|
$(".room_type").hide();
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -7,18 +7,20 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
|||||||
|
|
||||||
if (menu.menu_categories)
|
if (menu.menu_categories)
|
||||||
json.categories menu.menu_categories do |category|
|
json.categories menu.menu_categories do |category|
|
||||||
json.id category.id
|
if category.is_available
|
||||||
json.code category.code
|
json.id category.id
|
||||||
json.order_by category.order_by
|
json.code category.code
|
||||||
json.name category.name
|
json.order_by category.order_by
|
||||||
json.alt_name category.alt_name
|
json.name category.name
|
||||||
json.order_by category.order_by
|
json.alt_name category.alt_name
|
||||||
json.parent_id category.menu_category_id
|
json.order_by category.order_by
|
||||||
json.is_available category.is_available
|
json.parent_id category.menu_category_id
|
||||||
|
json.is_available category.is_available
|
||||||
|
|
||||||
if category.menu_items
|
if category.menu_items
|
||||||
json.items category.menu_items do |item|
|
json.items category.menu_items do |item|
|
||||||
json.partial! 'api/restaurant/menu/menu_item', item: item, request_url: request_url
|
json.partial! 'api/restaurant/menu/menu_item', item: item, request_url: request_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,126 +1,128 @@
|
|||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_attributes.count > 0
|
if item.is_available
|
||||||
item.item_attributes.each do|attr_id|
|
if item.item_attributes.count > 0
|
||||||
menu_attr = MenuItemAttribute.find(attr_id)
|
item.item_attributes.each do|attr_id|
|
||||||
if attr_format.count == 0
|
menu_attr = MenuItemAttribute.find(attr_id)
|
||||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
if attr_format.count == 0
|
||||||
next
|
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||||
end
|
next
|
||||||
|
end
|
||||||
|
|
||||||
attr_format.each do |af|
|
attr_format.each do |af|
|
||||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||||
if menu_attr.attribute_type == af[:type]
|
if menu_attr.attribute_type == af[:type]
|
||||||
af[:values].push(menu_attr.name)
|
af[:values].push(menu_attr.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||||
|
attr_format.push(new_attr)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
else
|
|
||||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
|
||||||
attr_format.push(new_attr)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_options.count > 0
|
if item.item_options.count > 0
|
||||||
item.item_options.each do|opt|
|
item.item_options.each do|opt|
|
||||||
menu_opt = MenuItemOption.find(opt)
|
menu_opt = MenuItemOption.find(opt)
|
||||||
if opt_format.count == 0
|
if opt_format.count == 0
|
||||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
opt_format.each do |of|
|
opt_format.each do |of|
|
||||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||||
if menu_opt.option_type == of[:type]
|
if menu_opt.option_type == of[:type]
|
||||||
of[:values].push(menu_opt.name)
|
of[:values].push(menu_opt.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||||
|
opt_format.push(new_opt)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
else
|
|
||||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
|
||||||
opt_format.push(new_opt)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
json.id item.id
|
json.id item.id
|
||||||
json.code item.item_code
|
json.code item.item_code
|
||||||
json.name item.name
|
json.name item.name
|
||||||
json.alt_name item.alt_name
|
json.alt_name item.alt_name
|
||||||
if !request_url.nil? && request_url != '' && !item.image_path.nil?
|
if !request_url.nil? && request_url != '' && !item.image_path.nil?
|
||||||
json.image request_url + item.image_path.to_s
|
json.image request_url + item.image_path.to_s
|
||||||
else
|
else
|
||||||
json.image item.image_path.url
|
json.image item.image_path.url
|
||||||
end
|
|
||||||
json.description item.description
|
|
||||||
json.information item.information
|
|
||||||
json.type item.type
|
|
||||||
json.account_id item.account_id
|
|
||||||
json.min_qty item.min_qty
|
|
||||||
json.is_available item.is_available
|
|
||||||
json.is_sub_item item.is_sub_item
|
|
||||||
json.unit item.unit
|
|
||||||
|
|
||||||
# Item Sets of Menu Item
|
|
||||||
json.item_sets item.item_sets do |its|
|
|
||||||
json.id its.id
|
|
||||||
json.name its.name
|
|
||||||
json.alt_name its.alt_name
|
|
||||||
json.min_selectable_qty its.min_selectable_qty
|
|
||||||
json.max_selectable_qty its.max_selectable_qty
|
|
||||||
json.instances its.menu_item_instances do |i|
|
|
||||||
json.id i.id
|
|
||||||
end
|
end
|
||||||
end
|
json.description item.description
|
||||||
|
json.information item.information
|
||||||
|
json.type item.type
|
||||||
|
json.account_id item.account_id
|
||||||
|
json.min_qty item.min_qty
|
||||||
|
json.is_available item.is_available
|
||||||
|
json.is_sub_item item.is_sub_item
|
||||||
|
json.unit item.unit
|
||||||
|
|
||||||
json.attributes attr_format
|
# Item Sets of Menu Item
|
||||||
json.options opt_format
|
json.item_sets item.item_sets do |its|
|
||||||
# json.min_selectable_item item.min_selectable_item
|
json.id its.id
|
||||||
# json.max_selectable_item item.max_selectable_item
|
json.name its.name
|
||||||
|
json.alt_name its.alt_name
|
||||||
#Item instance
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
# if item.menu_item_instances.count == 1 then
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
# item_instance = item.menu_item_instances[0]
|
json.instances its.menu_item_instances do |i|
|
||||||
# json.price = item_instance.price
|
json.id i.id
|
||||||
# json.is_available = item_instance.is_available
|
|
||||||
# json.is_on_promotion = item_instance.is_on_promotion
|
|
||||||
# json.promotion_price = item_instance.promotion_price
|
|
||||||
# json.item_attributes = item_instance.item_attributes
|
|
||||||
|
|
||||||
json.instances item.menu_item_instances do |is|
|
|
||||||
if is.is_available
|
|
||||||
# Convert id to name for attributes
|
|
||||||
instance_attr = []
|
|
||||||
|
|
||||||
is.item_attributes.each do |ia|
|
|
||||||
# mItemAttr = MenuItemAttribute.find(is)
|
|
||||||
# instance_attr.push(ia)
|
|
||||||
mItemAttr = MenuItemAttribute.find(ia).name
|
|
||||||
instance_attr.push(mItemAttr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json.id is.id
|
|
||||||
json.code is.item_instance_code
|
|
||||||
json.name is.item_instance_name
|
|
||||||
json.price is.price
|
|
||||||
json.is_available is.is_available
|
|
||||||
json.is_default is.is_default
|
|
||||||
json.is_on_promotion is.is_on_promotion
|
|
||||||
json.promotion_price is.promotion_price
|
|
||||||
json.values instance_attr
|
|
||||||
# json.item_sets is.item_sets
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
#Child Menu items
|
json.attributes attr_format
|
||||||
# if (item.children) then
|
json.options opt_format
|
||||||
# json.set_items item.children.each do |item|
|
# json.min_selectable_item item.min_selectable_item
|
||||||
# json.partial! 'api/restaurant/menu/menu_item', item: item
|
# json.max_selectable_item item.max_selectable_item
|
||||||
# end
|
|
||||||
# end
|
#Item instance
|
||||||
|
# if item.menu_item_instances.count == 1 then
|
||||||
|
# item_instance = item.menu_item_instances[0]
|
||||||
|
# json.price = item_instance.price
|
||||||
|
# json.is_available = item_instance.is_available
|
||||||
|
# json.is_on_promotion = item_instance.is_on_promotion
|
||||||
|
# json.promotion_price = item_instance.promotion_price
|
||||||
|
# json.item_attributes = item_instance.item_attributes
|
||||||
|
|
||||||
|
json.instances item.menu_item_instances do |is|
|
||||||
|
if is.is_available
|
||||||
|
# Convert id to name for attributes
|
||||||
|
instance_attr = []
|
||||||
|
|
||||||
|
is.item_attributes.each do |ia|
|
||||||
|
# mItemAttr = MenuItemAttribute.find(is)
|
||||||
|
# instance_attr.push(ia)
|
||||||
|
mItemAttr = MenuItemAttribute.find(ia).name
|
||||||
|
instance_attr.push(mItemAttr)
|
||||||
|
end
|
||||||
|
|
||||||
|
json.id is.id
|
||||||
|
json.code is.item_instance_code
|
||||||
|
json.name is.item_instance_name
|
||||||
|
json.price is.price
|
||||||
|
json.is_available is.is_available
|
||||||
|
json.is_default is.is_default
|
||||||
|
json.is_on_promotion is.is_on_promotion
|
||||||
|
json.promotion_price is.promotion_price
|
||||||
|
json.values instance_attr
|
||||||
|
# json.item_sets is.item_sets
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#Child Menu items
|
||||||
|
# if (item.children) then
|
||||||
|
# json.set_items item.children.each do |item|
|
||||||
|
# json.partial! 'api/restaurant/menu/menu_item', item: item
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user