Skip to content

Instantly share code, notes, and snippets.

@tbrooke
Created June 16, 2018 15:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tbrooke/9ff3a185e471c6ee0932b66203ca83bc to your computer and use it in GitHub Desktop.
%section.panel
%header
%h1
%i.icon-home.icon-large
&nbsp&nbsp&nbspHouseholds
.content
.span12
.span-one-third
= image_tag('second_logo.jpg')
#harvest_report
%h2 Monthly Report
.row
#msm_id.span-one-third
%h4 Agency ID: 590AD
%h4 Report for: #{Date.today.strftime('%B %d, %Y')}
= link_to 'Second Harvest', 'http://www.secondharvestmetrolina.org/'
- @month = "#{Date.today.strftime('%B %Y')}"
- @prev_month = "#{Date.today.prev_month.strftime('%B %Y')}"
- @ppre_month = "#{Date.today.months_ago(2).strftime('%B %Y')}"
- @three_month = "#{Date.today.months_ago(3).strftime('%B %Y')}"
- @four_month = "#{Date.today.months_ago(4).strftime('%B %Y')}"
- @five_month = "#{Date.today.months_ago(5).strftime('%B %Y')}"
- @six_month = "#{Date.today.months_ago(6).strftime('%B %Y')}"
- @year = 2018
- @pre_year = 2017
- @ppre_year = 2016
- @three_year = 2015
- @four_year = 2014
%h4 Month #{@month}
#h4 Previous Month #{@prev_month}
#h4 By Month #
#harvest_month
%br
-#= search_form_for @month do |f|
-# = f.label Select Month
-# = f.options_for_select(month_select)
-# = f.submit
/ = simple_form_for visit, html: { :class => 'form-inline' } do |f|
/ = f.input :visited_on, label: 'Report Month', collection: month_select, input_html: {class: 'span2'}
.row
.span11
%h4 The number of different Households served during: #{@ppre_month}, #{@prev_month} and #{@month}
- household_status_for do |stats|
.span11
%table.table.table-bordered
%thead
%tr
%th Month
/ - @visits = visits.all
%th Total Number of Visits
%th Total Number of Households
%th Total Number of Neighbors
- @h_month = visits.by_month(@month).select "DISTINCT(household_id)"
- @household_ids = visits.by_month(@month).pluck(:household_id).uniq
- @prev_month_ids = visits.by_month(@prev_month).pluck(:household_id).uniq
%tbody
%tr
%td= @month
%td= visits.by_month(@month).count
%td= @h_month.count
%td= @household_ids.map{|id| Household.find(id).neighbor_count}.inject(:+)
%tr
%td= @prev_month
%td= visits.by_month(@prev_month).count
%td= visits.by_month(@prev_month).select("DISTINCT(household_id)").count
%td= @prev_month_ids.map{|id| Household.find(id).neighbor_count}.inject(:+)
%br
.row
.span11
%h4 The total number of Individuals served during: #{@month}
- household_status_for(households.all) do |stats|
.span11
%table.table.table-bordered
%thead
%tr
%th < 19
%th Between 18 & 64
%th Over 64
%th Total Served
%tbody
%tr
%td= @household_ids.map{|id| Household.find(id).young_neighbor}.inject(:+)
%td= @household_ids.map{|id| Household.find(id).middle_neighbor}.inject(:+)
%td= @household_ids.map{|id| Household.find(id).old_neighbor}.inject(:+)
%td= @household_ids.map{|id| Household.find(id).neighbor_count}.inject(:+)
.row
%br
.row
.span11
%h4 The total number of Individuals served during: #{@prev_month}
- household_status_for(households.all) do |stats|
.span11
%table.table.table-bordered
%thead
%tr
%th < 19
%th Between 18 & 64
%th Over 64
%th Total Served
%tbody
%tr
%td= @prev_month_ids.map{|id| Household.find(id).young_neighbor}.inject(:+)
%td= @prev_month_ids.map{|id| Household.find(id).middle_neighbor}.inject(:+)
%td= @prev_month_ids.map{|id| Household.find(id).old_neighbor}.inject(:+)
%td= @prev_month_ids.map{|id| Household.find(id).neighbor_count}.inject(:+)
.row
%br
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment