diff --git a/app/controllers/admin/physical_ticket_controller.rb b/app/controllers/admin/physical_ticket_controller.rb new file mode 100644 index 00000000..d43c5c33 --- /dev/null +++ b/app/controllers/admin/physical_ticket_controller.rb @@ -0,0 +1,14 @@ +module Admin + class PhysicalTicketController < Admin::BaseController + before_action :authenticate_user! + load_resource :conference, find_by: :short_title + load_and_authorize_resource + authorize_resource :conference_registrations, class: Registration + + def index + @physical_tickets = @conference.physical_tickets + @tickets_sold_distribution = @conference.tickets_sold_distribution + @tickets_turnover_distribution = @conference.tickets_turnover_distribution + end + end +end diff --git a/app/views/admin/physical_ticket/index.html.haml b/app/views/admin/physical_ticket/index.html.haml new file mode 100644 index 00000000..fe128932 --- /dev/null +++ b/app/views/admin/physical_ticket/index.html.haml @@ -0,0 +1,43 @@ +.container + .row + .col-md-12.page-header + %h2 + Tickets Sold + .text-muted + Tickets sold for the conference + .row + .col-md-4 + = render partial: 'admin/conferences/doughnut_chart', + locals: { title: 'Tickets sold', data: @tickets_sold_distribution } + .col-md-4 + = render partial: 'admin/conferences/doughnut_chart', + locals: {title: 'Tickets turnover', data: @tickets_turnover_distribution} + %br + - if @physical_tickets.any? + .row + .col-md-12 + %table.table.table-hover.datatable#tickets + %thead + %th ID + %th Type + %th User + %th Actions + %tbody + - @physical_tickets.each do |physical_ticket| + %tr + %td= physical_ticket.id + %td= physical_ticket.ticket.title + %td= physical_ticket.user.email + %td + .btn-group + = link_to 'Show', + conference_physical_ticket_path(@conference.short_title, + physical_ticket.id), + class: 'btn btn-primary' + = link_to 'Generate PDF', + conference_physical_ticket_path(@conference.short_title, + physical_ticket.id, + format: :pdf), + class: 'button btn btn-default btn-info' + - else + %h5 No Tickets sold! diff --git a/app/views/admin/tickets/index.html.haml b/app/views/admin/tickets/index.html.haml index 6a0c7dca..bb2804bf 100644 --- a/app/views/admin/tickets/index.html.haml +++ b/app/views/admin/tickets/index.html.haml @@ -4,11 +4,6 @@ %h1 Tickets %p.text-muted Tickets to get during registration -.row - .col-md-4 - = render partial: 'admin/conferences/doughnut_chart', locals: { title: 'Tickets sold', data: @tickets_sold_distribution,} - .col-md-4 - = render partial: 'admin/conferences/doughnut_chart', locals: { title: 'Tickets turnover', data: @tickets_turnover_distribution } %br - if @conference.tickets.any? .row @@ -42,3 +37,4 @@ .row .col-md-12 = link_to 'Add Ticket', new_admin_conference_ticket_path, class: 'btn btn-success pull-right' + = link_to 'Tickets Sold', admin_conference_physical_ticket_index_path, class: 'button btn btn-default btn-info pull-right' diff --git a/config/routes.rb b/config/routes.rb index 8fa4b857..ae67a820 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -81,6 +81,7 @@ Osem::Application.routes.draw do resources :targets, except: [:show] resources :campaigns, except: [:show] resources :emails, only: [:show, :update, :index] + resources :physical_ticket, only: [:index] resources :roles, except: [ :new, :create ] do member do post :toggle_user