Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* it's not complete but the outline is there * also added the Prawn-Format plugin to make some thing easier(possible)
- Loading branch information
Showing
22 changed files
with
1,726 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
<div class='box span-13'> | ||
<% form_for user do |f| %> | ||
<fieldset> | ||
<% if user.new_record? %> | ||
<%= content_tag :legend, "New #{user.class.name.titleize}" %> | ||
<% form_for user do |f| %> | ||
<fieldset> | ||
<% if user.new_record? %> | ||
<%= content_tag :legend, "New #{user.class.name.titleize}" %> | ||
<% else %> | ||
<%= content_tag :legend, "Editing: #{user.full_name}" %> | ||
<% end %> | ||
<%= f.label :login, {}, :class => 'req' %> | ||
<%= f.text_field :login, :id => 'user_login', :class=>'input' %> | ||
<%= f.label :first_name, {}, :class => 'req' %> | ||
<%= f.text_field :first_name, :class => 'input' %> | ||
<%= f.label :last_name, {}, :class => 'req' %> | ||
<%= f.text_field :last_name, :class => 'input' %> | ||
<%= f.label :email, {}, :class => 'req' %> | ||
<%= f.text_field :email, :class=>'input' %> | ||
|
||
<label><%= content_tag :span, f.object.new_record? ? 'Password' : 'Change password', | ||
!f.object.new_record? ? nil : :class=>'required' %></label> | ||
<%= f.password_field :password, :class=>'input' %> | ||
<label><%= content_tag :span, 'Confirm password', !f.object.new_record? ? nil : :class=>'required' %></label> | ||
<%= f.password_field :password_confirmation, :class=>'input' %> | ||
<%= f.label :site, {}, :class => 'req' %> | ||
<%= collection_select user.class.name.underscore, :site_id, Site.find(:all), :id, :name, {}, :class=>'input' %> | ||
<% if user.class.name == 'Student' %> | ||
<%= f.label :class_of, {}, :class => 'req' %> | ||
<%# FIXME: Get the class time properly and stop hardcoding values %> | ||
<%= f.select(:class_of, ((Time.now.year - 1)..(Time.now.year + 10)).to_a, {}, :class=>'input') %> | ||
<%= f.label :homeroom %> | ||
<%= text_field_tag :homeroom1, {}, :maxlength => 20 %> | ||
<%= f.select :homeroom, @homerooms, :include_blank => true %> | ||
<% end %> | ||
<div class="spacer"> | ||
<%= submit_tag 'Save', :class => 'btn positive' %> | ||
<%= link_to 'Cancel', {:action=> 'index', :controller=> 'users/'+user.class.name.tableize}, :class => 'btn standard' %> | ||
</div> | ||
</fieldset> | ||
<% end %> | ||
<% end %> | ||
<%= f.label :login, {}, :class => 'req' %> | ||
<%= f.text_field :login, :id => 'user_login', :class=>'input' %> | ||
<%= f.label :first_name, {}, :class => 'req' %> | ||
<%= f.text_field :first_name, :class => 'input' %> | ||
<%= f.label :last_name, {}, :class => 'req' %> | ||
<%= f.text_field :last_name, :class => 'input' %> | ||
<%= f.label :email, {}, :class => 'req' %> | ||
<%= f.text_field :email, :class=>'input' %> | ||
|
||
<label><%= content_tag :span, f.object.new_record? ? 'Password' : 'Change password', | ||
!f.object.new_record? ? nil : :class=>'required' %></label> | ||
<%= f.password_field :password, :class=>'input' %> | ||
|
||
<label><%= content_tag :span, 'Confirm password', !f.object.new_record? ? nil : :class=>'required' %></label> | ||
<%= f.password_field :password_confirmation, :class=>'input' %> | ||
<%= f.label :site, {}, :class => 'req' %> | ||
<%= collection_select user.class.name.underscore, :site_id, Site.find(:all), :id, :name, {}, :class=>'input' %> | ||
<% if user.class.name == 'Student' %> | ||
<%= f.label :class_of, {}, :class => 'req' %> | ||
<%# FIXME: Get the class time properly and stop hardcoding values %> | ||
<%= f.select(:class_of, ((Time.now.year - 1)..(Time.now.year + 10)).to_a, {}, :class=>'input') %> | ||
<%= f.label :homeroom %> | ||
<%= text_field_tag :homeroom1, {}, :maxlength => 20 %> | ||
<%= f.select :homeroom, @homerooms, :include_blank => true %> | ||
<% end %> | ||
|
||
<div class="spacer"> | ||
<%= submit_tag 'Save', :class => 'btn positive' %> | ||
<%= link_to 'Cancel', {:action=> 'index', :controller=> 'users/'+user.class.name.tableize}, :class => 'btn standard' %> | ||
</div> | ||
</fieldset> | ||
<% end %> | ||
</div> | ||
|
||
<%= set_focus_to_id 'user_login' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require "prawn/core" | ||
require "prawn/layout" | ||
require "prawn/format" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# This report prints a student transcript containing the students complete | ||
# academic career. | ||
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.find(:all) | ||
homerooms = Student.find_homerooms() | ||
|
||
params = <<-EOS | ||
<form action="/reports/student_transcript.pdf" method="get"> | ||
<fieldset> | ||
<legend>Student Transcript</legend> | ||
<hr /> | ||
<label>Homeroom</label> | ||
<select size='1' id="homeroom_id" name="homeroom_id"> | ||
EOS | ||
|
||
# List each homeroom | ||
homerooms.each do |h| | ||
params += "<option value='#{h}'>#{h}</option>" | ||
end | ||
|
||
params += <<-EOS | ||
</select> | ||
<br /> | ||
<label>OR<br /><br />Student(s)</label> | ||
<select multiple size="7" id="student_id" name="student_id[]"> | ||
EOS | ||
|
||
# List all of the students in the school | ||
students.each do |s| | ||
params += "<option value='#{s[:id]}'>#{s[:first_name]} #{s[:last_name]}</option>" | ||
end | ||
|
||
params += <<-EOS | ||
</select> | ||
<div class="spacer"> | ||
<input class="btn positive" name="commit" type="submit" value="Run Report" /> | ||
</div> | ||
</fieldset> | ||
</form> | ||
EOS | ||
|
||
end | ||
|
||
|
||
# Build the report as a PDF and send it to the browser. | ||
def self.draw(params) | ||
if params[:student_id].nil? then | ||
# Process a whole homeroom | ||
students = Student.find_all_by_homeroom(params[:homeroom_id]) | ||
else | ||
# Search for individual student(s) | ||
students = Student.find(:all, :conditions => { :id => params[:student_id]}) | ||
end | ||
|
||
# Create a new document | ||
@pdf = Prawn::Document.new :page_size => "LETTER", | ||
:skip_page_creation => false, | ||
:page_layout => :landscape | ||
|
||
# Make it so we don't have to use the 'pdf.' prefix everywhere. :) | ||
@pdf.instance_eval do | ||
# Loop through each student | ||
students.each_with_index do |student, sindex| | ||
|
||
# Count the number of pages each student requires so that we can duplex properly | ||
student_page_count = 0 | ||
|
||
# Build the page header | ||
header margin_box.top_left do | ||
# Insert the school logo | ||
logo = "#{RAILS_ROOT}/public/images/logo.png" | ||
image logo, :at => bounds.top_left, :height => 35 | ||
|
||
# Insert the school name | ||
text StaticData.site_name, :align => :center, :size => 11 | ||
text "STUDENT TRANSCRIPT", :align => :center, :size => 20 | ||
stroke_horizontal_rule # make it look pretty | ||
|
||
# Insert the student information | ||
move_down(15) | ||
mask(:y) { text "Social Security No. <u><pre>" + ' '*50 + "</pre></u>", | ||
:align => :right, :size => 10 | ||
} | ||
text "Student Name <u> #{student.full_name}<pre>" + | ||
' '*(50-student.full_name.length) + "</pre></u>", :align => :left, :size => 10 | ||
|
||
# move_down(font.height) | ||
# text "Student Address <u><pre>" + ' '*75 + "</pre></u>", | ||
# :align => :left, :size => 10 | ||
# | ||
# move_down(font.height) | ||
# text 'Date of Birth <u><pre>' + ' '*15 + '/' + ' '*15 + '/' + ' '*15 + | ||
# '</pre></u>', :align => :left, :size => 10 | ||
# | ||
# move_down(font.height) | ||
# text "Program Name <u><pre>" + ' '*75 + "</pre></u>", | ||
# :align => :left, :size => 10 | ||
|
||
student_page_count += 1 # reset the student page counter | ||
end | ||
|
||
# Set up the text options | ||
font "Helvetica" | ||
text_options.update(:size => 7, :align => :left) | ||
|
||
student.courses.each do |temp| | ||
puts "**** #{temp.name} " | ||
end | ||
|
||
# Print the grades for each class | ||
headers = ['School Year', 'Term', 'Course Name', 'Instructor', 'Grade'] | ||
data = [] | ||
student.courses.each_with_index do |course, index| | ||
data << [ | ||
course.term.school_year, | ||
course.term.name, | ||
course.name, | ||
course.teacher.full_name, | ||
course.calculate_grade(student)[:letter] | ||
] | ||
end # each course | ||
|
||
bounding_box([0,bounds.height-75], :width => bounds.width) do | ||
table( | ||
data, | ||
:headers => headers, | ||
:header_color => "0000A0", | ||
:header_text_color => "FFFFFF", | ||
:row_colors => :pdf_writer, | ||
:font_size => 7, | ||
:border_style => :grid, | ||
:width => bounds.width) | ||
end | ||
|
||
# Is this the last student? | ||
if sindex < students.count - 1 then | ||
# No, force a page break between students | ||
start_new_page | ||
else | ||
# Yes, make sure we don't add a page break unnecessarily | ||
student_page_count = 0 | ||
end | ||
|
||
# Always print an even number of pages for a student. This prevents the | ||
# start of one report from printing on the back of the previous report. | ||
start_new_page unless student_page_count.even? | ||
|
||
end # each student | ||
|
||
end # instance_eval | ||
|
||
|
||
# Render the document | ||
@pdf.render | ||
end | ||
|
||
end |
Oops, something went wrong.