From cd7da404bca0d5401476bc4fd94cd46c5785dc1d Mon Sep 17 00:00:00 2001 From: rulingcom Date: Wed, 22 Oct 2025 22:13:06 +0800 Subject: [PATCH] fix for reserve button for admin and reserve button logic --- app/controllers/property_hires_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 6d23ada..a288d05 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -430,7 +430,7 @@ class PropertyHiresController < ApplicationController end end if check === true - @user_total_hired_hours = @property.get_user_total_user_hired_hours(OrbitHelper.current_user.id.to_s, sd, ed) + @user_total_hired_hours = @property.get_user_total_user_hired_hours(sd, ed) end if @user_total_hired_hours >= @property.hours_restriction available = false @@ -440,7 +440,11 @@ class PropertyHiresController < ApplicationController if available if DateTime.now >= (@property.start_date || DateTime.now - 1.day) && DateTime.now <= (@property.end_date || DateTime.now + 1.month) - available = date > (DateTime.now + (@property.need_hire_before).send(@property.need_hire_before_unit)) + if @is_user_manager === false + available = date > (DateTime.now + (@property.need_hire_before).send(@property.need_hire_before_unit)) + else + available = true + end end end @@ -481,7 +485,7 @@ class PropertyHiresController < ApplicationController end_date = endt.to_date @end_date = end_date @first_check_time = startt.strftime("%H:%M") - @all_day_settings = all_day_settings + @all_day_settings = all_day_settings.sort_by { |k, _| k.to_i }.to_h @startt = startt @endt = endt @weeknumber = 0 @@ -559,6 +563,7 @@ class PropertyHiresController < ApplicationController check_events = @need_check_events[0..i] end @need_check_events = @need_check_events[(i+1)..-1] + if check_events.count != 0 settings = settings.select do |s| if s[4] == 0 #reservation_limit == 0 => no limit