Permalink
Browse files

Added a list of wicktes available to select for filter

  • Loading branch information...
fabianoalmeida committed Mar 6, 2012
1 parent 83156bd commit 9eef36d5782ba21281531560e7085ff915e63b4d
@@ -7,7 +7,7 @@ def index
end
def tickets_per_day
- filter_date
+ filter_date
@report = Report.tickets_per_day(@first_date, @second_date).to(@place)
handle_result @report, :tickets_per_day
end
@@ -52,13 +52,17 @@ def attendances_by_days_per_wicket
def waiting_time_by_client
filter_date
- @report = Report.waiting_time_by_client(@first_date, @second_date).to(@place)
+ @report = Report.waiting_time_by_client(@first_date, @second_date)
+ .to(@place)
+ .filtered_by(@wicket_ids)
handle_result @report, :waiting_time_by_client
end
def waiting_time_by_client_per_month
- filter_place
- @report = Report.waiting_time_by_client_per_month(params[:start_date], params[:end_date]).to(@place)
+ filter_wicket
+ @report = Report.waiting_time_by_client_per_month(params[:start_date], params[:end_date])
+ .to(@place)
+ .filtered_by(@wicket_ids)
handle_result @report, :waiting_time_clients_per_month
end
View
@@ -170,9 +170,12 @@ def waiting_time_by_client(start_date, end_date)
to_char(trunc(t.created_at), 'dd/MM/yyyy') as data, count(attended.ticket_id) as total, avg(attended.created - t.created_at) * 24 * 60 as time
SQL
+ filter = @wicket_ids ? { "wickets.id" => @wicket_ids } : ""
+
CallHistory.select(select)
.from("tickets t, #{attended_table}")
.where("attended.ticket_id = t.id")
+ .where(filter)
.where("t.created_at" => start_date.midnight..end_date.tomorrow.midnight,
"t.place_id" => @place)
.group("trunc(t.created_at)")
@@ -318,6 +321,8 @@ def tickets_per_month(start_date, end_date)
end
def waiting_time_by_client_per_month(start_date, end_date)
+
+ filter = @wicket_ids ? { "wickets.id" => @wicket_ids } : ""
format = "{%Y, %m, %d}"
start = Date.strptime("{#{start_date[:year]},#{start_date[:month]},01}", format)
@@ -338,6 +343,7 @@ def waiting_time_by_client_per_month(start_date, end_date)
CallHistory.select(select)
.from("tickets t, #{attended_table}")
.where("attended.ticket_id = t.id")
+ .where(filter)
.where("t.created_at" => start..ending.end_of_month.tomorrow,
"t.place_id" => @place)
.group("to_char(trunc(t.created_at), 'MM/yyyy')")
@@ -20,11 +20,24 @@ text {
<h1 class="spotlight"><%= t('application.reports.waiting_time_by_client.name') %></h1>
<div class="search" style="width:95%; margin-bottom: 30px">
<%= form_tag( waiting_time_by_client_place_reports_path, :method => "get" ) do %>
- <%= label_tag t('application.reports.since') %>
- <%= text_field_tag :start_date, nil, :class => "date from", :readonly => true %>
- <%= label_tag t('application.reports.to') %>
- <%= text_field_tag :end_date, nil, :class => "date to", :readonly => true %>
- <%= submit_tag( t('application.search'), :class => "button medium" ) %>
+ <div style="float: right;">
+ <%= submit_tag( t('application.search'), :class => "button medium" ) %>
+ </div>
+ <div style="float: right;">
+ <%= label_tag t('application.reports.since') %>
+ <%= text_field_tag :start_date, nil, :class => "date from", :readonly => true %>
+ <%= label_tag t('application.reports.to') %>
+ <%= text_field_tag :end_date, nil, :class => "date to", :readonly => true %>
+ </div>
+ <% if @wickets %>
+ <div style="float: right; width: 90%">
+ <%= label_tag t('model.wicket.name') %>:
+ <% @wickets.each do |wicket| %>
+ <%= check_box_tag "wicket[ids][]", wicket.id %>
+ <%= (truncate wicket.value, :length => 9, :omission => '') %>
+ <% end %>
+ </div>
+ <% end %>
<% end %>
</div>
<div id="graph" class="graph" style="text-align:center"></div>
@@ -20,13 +20,26 @@ text {
<h1 class="spotlight"><%= t('application.reports.waiting_time_by_client_per_month.name') %></h1>
<div class="search" style="width:95%; margin-bottom: 30px">
<%= form_tag( waiting_time_by_client_per_month_place_reports_path, :method => "get" ) do %>
- <div class="select-date">
- <%= label_tag t('application.reports.since') %>
- <%= select_date(nil, :prefix => "start_date", :discard_day => true, :prompt => {:month => t('application.reports.chose.month'), :year => t('application.reports.chose.year')}) %>
- <%= label_tag t('application.reports.to') %>
- <%= select_date(nil, :prefix => "end_date", :discard_day => true, :prompt => {:month => t('application.reports.chose.month'), :year => t('application.reports.chose.year')}) %>
- <%= submit_tag( t('application.search'), :class => "button medium" ) %>
- </div>
+ <div class="select-date">
+ <div style="float: right;">
+ <%= submit_tag( t('application.search'), :class => "button medium" ) %>
+ </div>
+ <div style="float: right;">
+ <%= label_tag t('application.reports.since') %>
+ <%= select_date(nil, :prefix => "start_date", :discard_day => true, :prompt => {:month => t('application.reports.chose.month'), :year => t('application.reports.chose.year')}) %>
+ <%= label_tag t('application.reports.to') %>
+ <%= select_date(nil, :prefix => "end_date", :discard_day => true, :prompt => {:month => t('application.reports.chose.month'), :year => t('application.reports.chose.year')}) %>
+ </div>
+ <% if @wickets %>
+ <div style="float: right;">
+ <%= label_tag t('model.wicket.name') %>:
+ <% @wickets.each do |wicket| %>
+ <%= check_box_tag "wicket[ids][]", wicket.id %>
+ <%= (truncate wicket.value, :length => 9, :omission => '') %>
+ <% end %>
+ </div>
+ <% end %>
+ </div>
<% end %>
</div>
<div id="graph" class="graph" style="text-align:center"></div>

0 comments on commit 9eef36d

Please sign in to comment.