Class: Crm::Scheduler::BookingsController
- Inherits:
-
CrmController
- Object
- CrmController
- Crm::Scheduler::BookingsController
- Defined in:
- app/controllers/crm/scheduler/bookings_controller.rb
Overview
Admin listing, detail, and cancellation for SchedulerBooking records —
either a paginated table or a FullCalendar month view, both filterable by
status and employee.
Instance Method Summary collapse
-
#cancel ⇒ void
Cancels the booking if cancellable, else redirects with an error.
-
#index ⇒ void
Lists bookings, filterable by status/employee, as either a paginated table or (when
params[:view] == 'calendar') the full filtered set serialized for FullCalendar. -
#show ⇒ void
Shows a single booking (loaded by the
find_bookingbefore_action).
Instance Method Details
#cancel ⇒ void
This method returns an undefined value.
Cancels the booking if cancellable, else redirects with an error.
39 40 41 42 43 44 45 46 |
# File 'app/controllers/crm/scheduler/bookings_controller.rb', line 39 def cancel if @booking.can_cancel? @booking.cancel! redirect_to scheduler_admin_booking_path(@booking), notice: 'Booking cancelled.' else redirect_to scheduler_admin_booking_path(@booking), alert: 'Cannot cancel this booking.' end end |
#index ⇒ void
This method returns an undefined value.
Lists bookings, filterable by status/employee, as either a paginated
table or (when params[:view] == 'calendar') the full filtered set
serialized for FullCalendar.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/crm/scheduler/bookings_controller.rb', line 16 def index @bookings = SchedulerBooking.includes(:scheduler_booking_page, :employee) .order(starts_at: :desc) @bookings = @bookings.where(status: params[:status]) if params[:status].present? @bookings = @bookings.where(employee_id: params[:employee_id]) if params[:employee_id].present? if calendar_view? # Booking volume per month is small, so the whole filtered set is # serialized — no date-range endpoint and no pagination on this view. @calendar_events_json = calendar_events_json elsif @bookings.respond_to?(:page) @bookings = @bookings.page(params[:page]).per(25) end end |
#show ⇒ void
This method returns an undefined value.
Shows a single booking (loaded by the find_booking before_action).
34 |
# File 'app/controllers/crm/scheduler/bookings_controller.rb', line 34 def show; end |