Permalink
Browse files

Add 'Late'

  • Loading branch information...
1 parent 5eb985e commit a25cbe5a8c717baf7c4b2296ab67f8fb3c515592 David Krider committed Feb 8, 2012
@@ -261,21 +261,28 @@ def commit_followup
def lookup
@person = Person.find(params[:person][:id])
- start_date = Date.new(params[:service]["start(1i)".to_s].to_i,
+ # Going to expand the range by a day on each side so that the dates get
+ # included properly. (Midnight is screwing me up.)
+ @start_date = Date.new(params[:service]["start(1i)".to_s].to_i,
params[:service]["start(2i)".to_s].to_i,
- params[:service]["start(3i)".to_s].to_i)
- end_date = Date.new(params[:service]["end(1i)".to_s].to_i,
+ params[:service]["start(3i)".to_s].to_i - 1)
+ @end_date = Date.new(params[:service]["end(1i)".to_s].to_i,
params[:service]["end(2i)".to_s].to_i,
- params[:service]["end(3i)".to_s].to_i)
- @services = Service.all(:conditions => "dateandtime >= '#{start_date}' " +
- "and dateandtime <= '#{end_date}'")
+ params[:service]["end(3i)".to_s].to_i + 1)
+ @services = Service.all(:conditions => "dateandtime >= '#{@start_date}' " +
+ "and dateandtime <= '#{@end_date}'")
@attendances = Attendance.find_all_by_person_id(@person.id, :conditions =>
- "services.dateandtime >= '#{start_date}' and services.dateandtime <= '#{end_date}'",
+ "services.dateandtime >= '#{@start_date}' and services.dateandtime <= '#{@end_date}'",
:include => :service, :order => 'services.dateandtime')
- # FIXME? "Present" relies on Status with id = 1
+ # FIXME? "Present" relies on Status with id = 1. I could add a "present" boolean
+ # to the Status model, but then I need to pull in that model and filter by string.
@absences = Attendance.find_all_by_person_id(@person.id, :conditions =>
- "services.dateandtime >= '#{start_date}' and services.dateandtime <= '#{end_date}'" +
- 'and status_id > 1', :include => :service, :order => 'services.dateandtime')
+ "services.dateandtime >= '#{@start_date}' and services.dateandtime <= '#{@end_date}'" +
+ 'and status_id > 1 and status_id < 9', :include => :service,
+ :order => 'services.dateandtime')
+ @tardies = Attendance.find_all_by_person_id(@person.id, :conditions =>
+ "services.dateandtime >= '#{@start_date}' and services.dateandtime <= '#{@end_date}'" +
+ 'and status_id = 9', :include => :service, :order => 'services.dateandtime')
end
def choose
@@ -1,5 +1,6 @@
module AttendancesHelper
+ # Might want to make this filter on a new field called "excused"
def colorize(status)
"warning" if status > 5
end
View
@@ -4,4 +4,11 @@ class Attendance < ActiveRecord::Base
has_one :network, :through => :service
belongs_to :status
validates_uniqueness_of :person_id, :scope => :service_id
+
+ # I _want_ the NULLs in there...
+ #before_save :default_status
+ #def default_status
+ # self.status_id = 1 unless self.status_id
+ #end
+
end
@@ -1,27 +1,43 @@
-<h2>History for <%= @person.full_name %></h2>
+<h2>History for <%= @person.full_name %> from <%= @start_date %> to <%= @end_date %></h2>
<% @person.groups.map { |g| g.network }.each do |network| %>
<% # This is a REALLY rough way of doing this, but it will work, for us, for now. %>
+ <% network_tardies_wed = @tardies.select { |a| a.service.network == network &&
+ a.service.dateandtime.wday == 3 } %>
<% network_absences_wed = @absences.select { |a| a.service.network == network &&
a.service.dateandtime.wday == 3 } %>
<% network_attendances_wed = @attendances.select { |a| a.service.network == network &&
a.service.dateandtime.wday == 3 } %>
+ <% network_tardies_sun = @tardies.select { |a| a.service.network == network &&
+ a.service.dateandtime.wday == 0 } %>
<% network_absences_sun = @absences.select { |a| a.service.network == network &&
a.service.dateandtime.wday == 0 } %>
<% network_attendances_sun = @attendances.select { |a| a.service.network == network &&
a.service.dateandtime.wday == 0 } %>
- <h3><%= network.designation %>, Wednesday</h3>
+ <h3><%= network.designation %></h3>
+
+ <h4>Wednesday</h4>
<table>
<tr><th>Service<th>Excuse<th>Note</tr>
- <% network_absences_wed.each do |absence| %>
+ <% (network_absences_wed + network_tardies_wed).each do |absence| %>
<tr><td><%= absence.service.printable_date %><td><%= absence.status.designation %>
<td><%= absence.note %></tr>
<% end %>
</table>
- <h3><%= network.designation %>, Sunday</h3>
+ <% possible_wed = @services.select { |s| s.network == network && s.dateandtime.wday == 3 }.count %>
+ <h5>
+ <%= network_tardies_wed.count %> tardies and
+ <%= network_absences_wed.count %> absences in <%= network_attendances_wed.count %> services
+ accounted for (<%= sprintf("%0.2f%% attendance", 100 - (network_absences_wed.count.to_f /
+ network_attendances_wed.count.to_f) * 100) %>)<br/>
+ out of <%= possible_wed %> in the time range (<%= sprintf("%0.2f%% on the roll",
+ (network_attendances_wed.count.to_f / possible_wed) * 100) %>)
+ </h5>
+
+ <h4>Sunday</h4>
<table>
<tr><th>Service<th>Excuse<th>Note</tr>
@@ -31,20 +47,16 @@
<% end %>
</table>
- <% possible_wed = @services.select { |s| s.network == network && s.dateandtime.wday == 3 }.count %>
<% possible_sun = @services.select { |s| s.network == network && s.dateandtime.wday == 0 }.count %>
- <h3>Wednesday</h3>
- <h4><%= network_absences_wed.count %> absences in <%= network_attendances_wed.count %> services
- accounted for (<%= sprintf("%0.2f%% attendance", 100 - (network_absences_wed.count.to_f /
- network_attendances_wed.count.to_f) * 100) %>)<br/>
- out of <%= possible_wed %> in the time range (<%= sprintf("%0.2f%% on the roll",
- (network_attendances_wed.count.to_f / possible_wed) * 100) %>)</h4>
- <h3>Sunday</h3>
- <h4><%= network_absences_sun.count %> absences in <%= network_attendances_sun.count %> services
+ <h5>
+ <%= network_tardies_sun.count %> tardies and
+ <%= network_absences_sun.count %> absences in <%= network_attendances_sun.count %> services
accounted for (<%= sprintf("%0.2f%% attendance", 100 - (network_absences_sun.count.to_f /
network_attendances_sun.count.to_f) * 100) %>)<br/>
out of <%= possible_sun %> in the time range (<%= sprintf("%0.2f%% on the roll",
- (network_attendances_sun.count.to_f / possible_sun) * 100) %>)</h4>
+ (network_attendances_sun.count.to_f / possible_sun) * 100) %>)
+ </h5>
+
<p>&nbsp;</p>
<% end %>
@@ -0,0 +1,8 @@
+class AddLate < ActiveRecord::Migration
+ def self.up
+ Status.create :designation => "Late"
+ end
+
+ def self.down
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110419013509) do
+ActiveRecord::Schema.define(:version => 20120208204715) do
create_table "attendances", :force => true do |t|
t.datetime "created_at"
@@ -80,7 +80,7 @@
create_table "schedules", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
- t.time "standard_time"
+ t.datetime "standard_time"
t.string "default_day"
t.integer "network_id"
t.string "description"
@@ -174,7 +174,7 @@ ul {
color: #972B1D;
}
-h4 {
+h4, h5 {
text-align: center;
}

0 comments on commit a25cbe5

Please sign in to comment.