Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring

* 'august_spring' of bitbucket.org:code2lab/sxrestaurant:
  Timepicker Bug Fix
  Show data in Edit
  Promotion Destory Bug Fix
This commit is contained in:
Zin Lin Phyo
2017-09-06 18:28:09 +06:30
4 changed files with 80 additions and 21 deletions

View File

@@ -69,6 +69,9 @@ class Settings::PromotionsController < ApplicationController
# DELETE /promotions/1
# DELETE /promotions/1.json
def destroy
@promotion.promotion_products.each do |pp|
pp.destroy
end
@promotion.destroy
respond_to do |format|
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' }
@@ -87,6 +90,21 @@ class Settings::PromotionsController < ApplicationController
end
end
def find_parent_item
res = []
item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
if item.nil?
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
res.push(product.name)
res.push(product.item_code)
else
# menu_item = item.menu_item.pluck(:name,:item_code)
res.push(item.item_instance_name)
res.push(item.menu_item.item_code)
end
render json: res
end
private
# Use callbacks to share common setup or constraints between actions.
def set_promotion