Promotion Time Fixed

This commit is contained in:
Phyo
2017-08-23 19:09:44 +06:30
parent 790b7939fc
commit 857fcd419f
8 changed files with 100 additions and 18 deletions

View File

@@ -28,8 +28,14 @@ class Settings::PromotionsController < ApplicationController
def create
@promotion = Promotion.new(promotion_params)
@promotion.created_by = current_login_employee.id
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
respond_to do |format|
if @promotion.save
promo_pros = @promotion.promotion_products
promo_pros.each do |promo_pro|
promo_pro.save
end
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully created.' }
format.json { render :show, status: :created, location: @promotion }
else
@@ -44,6 +50,13 @@ class Settings::PromotionsController < ApplicationController
def update
respond_to do |format|
if @promotion.update(promotion_params)
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
@promotion.save
promo_pros = @promotion.promotion_products
promo_pros.each do |promo_pro|
promo_pro.save
end
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully updated.' }
format.json { render :show, status: :ok, location: @promotion }
else