check induties process
This commit is contained in:
@@ -2,10 +2,9 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
|
||||
|
||||
def index_in_duty
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@duty_in = InDuty.where('dinning_id=? and sale_id=?', booking.dining_facility_id, @sale_id)
|
||||
@booking_id = params[:booking_id]
|
||||
booking = Booking.where("booking_id=?",@booking_id).first
|
||||
@duty_in = InDuty.where('dinning_id=? and booking_id=?', booking.dining_facility_id, @booking_id)
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@in_duty = InDuty.new
|
||||
@duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
|
||||
@@ -29,8 +28,7 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
def edit_in_duty
|
||||
@in_duty = InDuty.find(params[:id])
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
booking = Booking.where("booking_id=?",@in_duty.booking_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@commissioner = @in_duty.commissioner
|
||||
@@ -60,10 +58,14 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
unless in_duty_id.empty?
|
||||
@in_duty = InDuty.find(in_duty_id.to_i)
|
||||
end
|
||||
|
||||
data = InDuty.find_by_booking_id(in_duty_params[:booking_id])
|
||||
if !data.nil?
|
||||
if !data.sale_id.nil?
|
||||
@in_duty.sale_id = data.sale_id
|
||||
end
|
||||
end
|
||||
@in_duty.dinning_id = in_duty_params[:dinning_id]
|
||||
@in_duty.booking_id = in_duty_params[:booking_id]
|
||||
@in_duty.sale_id = in_duty_params[:sale_id]
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_duty['in_time']
|
||||
@in_duty.out_time = in_duty['out_time']
|
||||
@@ -97,7 +99,7 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
@in_duty.out_time = in_duty_params[:out_time]
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:sale_id]), notice: 'In duty was successfully updated.' }
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:booking_id]), notice: 'In duty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_duty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -110,9 +112,8 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
# DELETE /in_duties/1.json
|
||||
def destroy_in_duty
|
||||
@table_id = params[:table_id]
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@booking_id = params[:booking_id]
|
||||
booking = Booking.where("booking_id=?",@booking_id).first
|
||||
@in_duty.destroy
|
||||
|
||||
flash[:notice] = 'In duty was successfully destroyed.'
|
||||
@@ -128,7 +129,7 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def in_duty_params
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :sale_id, :commissioner_ids, :in_time, :out_time)
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user