Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
This commit is contained in:
77
app/controllers/settings/promotion_products_controller.rb
Normal file
77
app/controllers/settings/promotion_products_controller.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
class Settings::PromotionProductsController < ApplicationController
|
||||
before_action :set_promotion, only: [:show, :edit, :update, :destroy,:new]
|
||||
before_action :set_promotion_product, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /promotion_products
|
||||
# GET /promotion_products.json
|
||||
def index
|
||||
@promotion_products = PromotionProduct.all
|
||||
end
|
||||
|
||||
# GET /promotion_products/1
|
||||
# GET /promotion_products/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /promotion_products/new
|
||||
def new
|
||||
@promotion_product = PromotionProduct.new
|
||||
end
|
||||
|
||||
# GET /promotion_products/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /promotion_products
|
||||
# POST /promotion_products.json
|
||||
def create
|
||||
@promotion_product = PromotionProduct.new(promotion_params)
|
||||
respond_to do |format|
|
||||
if @promotion_product.save
|
||||
format.html { redirect_to edit_settings_promotion_path(@promotion), notice: 'PromotionProduct was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @promotion_product }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @promotion_product.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /promotion_products/1
|
||||
# PATCH/PUT /promotion_products/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @promotion_product.update(promotion_params)
|
||||
format.html { redirect_to edit_settings_promotion_path(@promotion), notice: 'PromotionProduct was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @promotion_product }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @promotion_product.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /promotion_products/1
|
||||
# DELETE /promotion_products/1.json
|
||||
def destroy
|
||||
@promotion_product.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to edit_settings_promotion_path(@promotion) , notice: 'PromotionProduct was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_promotion
|
||||
@promotion = Promotion.find(params[:promotion_id])
|
||||
end
|
||||
def set_promotion_product
|
||||
@promotion_product = PromotionProduct.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def promotion_params
|
||||
params.require(:promotion_product).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by)
|
||||
end
|
||||
end
|
||||
@@ -71,6 +71,6 @@ class Settings::PromotionsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def promotion_params
|
||||
params.require(:promotion).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by)
|
||||
params.require(:promotion).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by,:promotion_products_attributes => [:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user