Commit a89a8adb authored by Mateus Ravedutti's avatar Mateus Ravedutti
Browse files

Fix shifts time validations

parent 6b0cbd2b
......@@ -254,10 +254,14 @@ class ShiftsController < ApplicationController
@errorMsg = "A duração de tempo da escala é de 0 minutos!"
if params[:shift_execution_start_time] =='%d/%m/%Y') and (params[:execution_start_hour].to_i < or (params[:exeuction_start_hour].to_i == and params[:execution_end_minute].to_i <
if params[:shift_execution_start_time] =='%d/%m/%Y') and (params[:execution_start_hour].to_i < or (params[:exeuction_start_hour].to_i == and params[:execution_start_minute].to_i <
@errorMsg = "Data e hora inicial no passado!"
if params[:execution_end_hour].to_i < params[:execution_start_hour].to_i or (params[:execution_end_hour].to_i == params[:execution_start_hour].to_i and params[:execution_end_minute].to_i < params[:execution_start_minute].to_i)
@errorMsg = "Data e hora final antes de inicial"
#Caso tenha dado erro, retorna para o mesmo path, porém com o erro correspondente
if (@errorMsg!= "")
return redirect_to new_shift_path(@redirect_shift_params), alert: @errorMsg
......@@ -521,7 +525,7 @@ class ShiftsController < ApplicationController
selected_shifts = params[:removed_shifts]"Escalas selecionadas: ##{selected_shifts}")
@canceled_situation_id = Situation.where(:description => "Cancelado")
selectted_shifts.each do |shift_id|
selected_shifts.each do |shift_id|
shift = Shift.find(shift_id)
shift.schedules.each do |a|
a.situation_id = @canceled_situation_id
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment