Class: RestaurantPartners::ReportsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/restaurant_partners/reports_controller.rb

Defined Under Namespace

Classes: InvalidParam

Instance Method Summary collapse

Instance Method Details

#downloadObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/restaurant_partners/reports_controller.rb', line 7

def download
  param = params.require(:reports)
  date_type = param[:date_type].presence || 'date'
  start_date = param.require(:start_date).to_date
  end_date = param.require(:end_date).to_date
  start_time = param[:start_time]
  end_time = param[:end_time]
  cc_emails = param[:cc_emails].to_s.split(',').map(&:strip)
  validate!(start_date, end_date, start_time.dup, end_time.dup, cc_emails)

  NotificationWorkers::ReservationReport.fix_queue_perform_async(
    :restaurant_partner,
    {
      emails: cc_emails,
      restaurant_partner_id: current_restaurant_partners_staff.id,
      start_date: start_date,
      end_date: end_date,
      date_type: date_type,
      start_time: start_time,
      end_time: end_time
    },
  )
  redirect_to restaurant_partners_reservations_path, notice: 'We will send an excel report to your email within few minutes'
rescue ActionController::ParameterMissing, InvalidParam => error
  flash[:alert] = error.message
  render :download_form
end

#download_formObject



4
5
# File 'app/controllers/restaurant_partners/reports_controller.rb', line 4

def download_form
end