Permalink
Browse files

Cleaned up the reports files to work better with Rails 2.3.x

  • Loading branch information...
1 parent 40e64e8 commit 774017deeda1e3e94529b7e033b286dab0169fd6 @rnhurt committed Jul 21, 2010
@@ -3,9 +3,6 @@ class ReportsController < ApplicationController
before_filter :load_reports, :only => [:index, :show]
append_before_filter :authorized?
- def index
- end
-
def show
report = Report.find_by_name(params[:id])
View
@@ -9,7 +9,7 @@ def self.all
return [
report.new("report_card", "Report Card", false),
report.new("progress_report", "Progress Report", false),
- report.new("student_transcript", "Student Transcript", false),
+# report.new("student_transcript", "Student Transcript", false),
report.new("student_roster", "Student Roster", false),
report.new("account_activity", "Account Activity", false),
report.new("password_reset", "Password Reset", true),
@@ -4,9 +4,6 @@ class AccountActivity
# Build the parameter screen for this report.
def self.get_params()
- # Get the homeroom information
- homerooms = Student.find_homerooms()
-
# Build the parameter screen
params = <<-EOS
@@ -19,8 +16,8 @@ def self.get_params()
<option value=''>ALL</option>
EOS
# Add the homerooms
- homerooms.each do |homeroom|
- params += "<option value='#{homeroom}'>#{homeroom}</option>"
+ Student.homerooms.each do |h|
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -38,18 +35,19 @@ def self.get_params()
# Build the report in PDF form and sent it to the users browser
def self.draw(params)
# Find all the students in a homeroom
- if params[:homeroom].length > 0
- students = Student.find_all_by_homeroom(params[:homeroom], :order => "first_name")
+ if params[:homeroom].size > 0
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom])
else
- students = Student.all(:order => "first_name")
- end
+ students = Student.active.sorted
+ end
# Create a new document
pdf = Prawn::Document.new(:page => "LETTER")
# Make it so we don't have to use pdf. everywhere. :)
pdf.instance_eval do
+ site_name = StaticData.site_name
fill_color "000000"
# Build the page header
@@ -61,7 +59,7 @@ def self.draw(params)
image logo, :at => bounds.top_left, :height => 35
# Insert the school name
- text StaticData.site_name, :align => :center, :size => 11
+ text site_name, :align => :center, :size => 11
text "ACCOUNT ACTIVITY", :align => :center, :size => 20
stroke_horizontal_rule # make it look pretty
end
@@ -4,9 +4,6 @@ class PasswordReset
# Build the parameter screen for this report.
def self.get_params()
- # Get the homeroom information
- homerooms = Student.find_homerooms()
-
# Build the parameter screen
params = <<-EOS
@@ -19,8 +16,8 @@ def self.get_params()
<option value=''>ALL</option>
EOS
# Add the homerooms
- homerooms.each do |homeroom|
- params += "<option value='#{homeroom}'>#{homeroom}</option>"
+ Student.homerooms.each do |h|
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -37,12 +34,11 @@ def self.get_params()
# Build the report in PDF form and sent it to the users browser
def self.draw(params)
- # Find all the students in a homeroom
- if params[:homeroom].length > 0
- students = Student.find_all_by_homeroom(params[:homeroom])
+ if params[:homeroom].size > 0
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom])
else
- students = Student.find(:all)
- end
+ students = Student.active.sorted
+ end
# Create a new document
pdf = Prawn::Document.new(:page => "LETTER")
@@ -12,8 +12,8 @@ class ProgressReport
# Build the parameter window to be shown to the user.
def self.get_params()
# Allow the user to select a single student or multiple students.
- students = Student.all(:order => "last_name ASC")
- homerooms = Student.find_homerooms()
+ students = Student.active.sorted
+ homerooms = Student.homerooms
years = SchoolYear.all(:order => "end_date DESC")
params = <<-EOS
@@ -41,7 +41,7 @@ def self.get_params()
# List each homeroom
homerooms.each do |h|
- params += "<option value='#{h}'>#{h}</option>"
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -78,10 +78,10 @@ def self.draw(params)
if params[:student_id].nil? then
# Process a whole homeroom
- students = Student.find_all_by_homeroom(params[:homeroom_id])
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom_id])
else
# Search for individual student(s)
- students = Student.find(:all, :conditions => { :id => params[:student_id]})
+ students = Student.sorted.find_all_by_id(params[:student_id])
end
# Create a new document
View
@@ -13,8 +13,8 @@ class ReportCard
# Build the parameter window to be shown to the user.
def self.get_params()
# Allow the user to select a single student or multiple students.
- students = Student.all(:order => "last_name ASC")
- homerooms = Student.find_homerooms()
+ students = Student.active.sorted
+ homerooms = Student.homerooms
years = SchoolYear.all(:order => "end_date DESC")
params = <<-EOS
@@ -42,7 +42,7 @@ def self.get_params()
# List each homeroom
homerooms.each do |h|
- params += "<option value='#{h}'>#{h}</option>"
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -79,12 +79,12 @@ def self.draw(params)
skills = SupportingSkillCode.active
cutoff_date = Date.today()
- if params[:student_id].nil? then
+ if params[:student_id].nil?
# Process a whole homeroom
- students = Student.find_all_by_homeroom(params[:homeroom_id], :order => 'last_name')
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom_id])
else
# Search for individual student(s)
- students = Student.find(:all, :conditions => { :id => params[:student_id]}, :order => 'last_name')
+ students = Student.sorted.find_all_by_id(params[:student_id])
end
# Create a new document
@@ -93,7 +93,6 @@ def self.draw(params)
# Make it so we don't have to use the 'pdf.' prefix everywhere. :)
@pdf.instance_eval do
@initial_cursor = cursor # Use this to reset the position on each new page
- skills = SupportingSkillCode.active
@terms = school_year.terms.sort!{|a,b| a.end_date <=> b.end_date}
print_final = true if @terms.last.end_date <= Date.today
@@ -3,10 +3,7 @@
class StudentRoster
# Build the parameter screen for this report.
- def self.get_params()
- # Get the homeroom information
- homerooms = Student.find_homerooms()
-
+ def self.get_params()
# Build the parameter screen
params = <<-EOS
@@ -19,8 +16,8 @@ def self.get_params()
<option value=''>ALL</option>
EOS
# Add the homerooms
- homerooms.each do |homeroom|
- params += "<option value='#{homeroom}'>#{homeroom}</option>"
+ Student.homerooms.each do |h|
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -38,10 +35,10 @@ def self.get_params()
# Build the report in PDF form and sent it to the users browser
def self.draw(params)
# Find all the students in a homeroom
- if params[:homeroom].length > 0
- students = Student.find_all_by_homeroom(params[:homeroom])
+ if params[:homeroom].size > 0
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom])
else
- students = Student.find(:all)
+ students = Student.active.sorted
end
# Create a new document
@@ -59,6 +56,9 @@ def self.draw(params)
move_down(5)
mask(:y) { text "page #{page_count}", :align => :right }
mask(:y) { text "#{Date.today.to_s(:long)}", :align => :left }
+
+ font "Helvetica", :size => 10
+ fill_color "000000"
end
# Build a table of students
@@ -73,8 +73,9 @@ def self.draw(params)
# Print the table of students in this homeroom
data = homeroom[1].map { |h| ["#{h.first_name} #{h.last_name}"] }
table data,
- :border_style => :grid,
+ :border_style => :grid,
:vertical_padding => 2,
+ :font_size => 10,
:row_colors => ["DBDBDB", "FFFFFF"],
:width => bounds.width
@@ -5,8 +5,8 @@ class StudentTranscript
# Build the parameter screen for this report.
def self.get_params()
# Allow the user to select a single student or multiple students.
- students = Student.all(:order => "last_name ASC")
- homerooms = Student.find_homerooms()
+ students = Student.active.sorted
+ homerooms = Student.homerooms
params = <<-EOS
<form action="/reports/student_transcript.pdf" method="get">
@@ -21,7 +21,7 @@ def self.get_params()
# List each homeroom
homerooms.each do |h|
- params += "<option value='#{h}'>#{h}</option>"
+ params += "<option value='#{h.name}'>#{h.name}</option>"
end
params += <<-EOS
@@ -59,10 +59,10 @@ def self.get_params()
def self.draw(params)
if params[:student_id].nil? then
# Process a whole homeroom
- students = Student.find_all_by_homeroom(params[:homeroom_id])
+ students = Student.active.sorted.find_all_by_homeroom(params[:homeroom_id])
else
# Search for individual student(s)
- students = Student.find(:all, :conditions => { :id => params[:student_id]})
+ students = Student.sorted.find_all_by_id(params[:student_id])
end
# Create a new document

0 comments on commit 774017d

Please sign in to comment.