diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb
index af8bedc1..8acc7764 100644
--- a/app/controllers/settings/promotions_controller.rb
+++ b/app/controllers/settings/promotions_controller.rb
@@ -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
diff --git a/app/models/promotion.rb b/app/models/promotion.rb
index 624818f1..41dfaec6 100644
--- a/app/models/promotion.rb
+++ b/app/models/promotion.rb
@@ -1,5 +1,5 @@
class Promotion < ApplicationRecord
- validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_day,:promo_type,:original_product,:min_qty
+ validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_type,:original_product,:min_qty
has_many :promotion_products
diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb
index c832461d..1760f894 100644
--- a/app/views/settings/promotions/_form.html.erb
+++ b/app/views/settings/promotions/_form.html.erb
@@ -39,18 +39,19 @@
<% end %>
-
+