Forked from anonymous/hospitalbooking_controller.rb
Last active
December 15, 2015 16:58
-
-
Save andyh/5292591 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class HospitalBooking | |
| def self.send_overtime_mail(user, bookings) | |
| OvertimeMailer.overtime_pdf(user, hospital_booking).deliver | |
| end | |
| end |
This file contains hidden or 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
| def index | |
| @hospital_bookings = HospitalBooking.scoped | |
| if params[:format] == 'pdf' | |
| @hospital_bookings = @hospital_bookings.where(:day => Date.today.beginning_of_month..Date.today.end_of_month) | |
| HospitalBooking.send_overtime_mail(current_user, @hospital_bookings) | |
| end | |
| respond_to do |format| | |
| format.html | |
| format.pdf do | |
| render :pdf => "#{Date.today.strftime('%B')} Overtime Report", | |
| :header => {:html => {:template => 'layouts/pdf.html.erb'}} | |
| end | |
| end | |
| end |
This file contains hidden or 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
| task :overtime_report => :environment do | |
| if Date.today.day == 18 | |
| user = User.where(:role => :administrator).first | |
| bookings = HospitalBooking.where(:day => Date.today.beginning_of_month..Date.today.end_of_month) | |
| HospitalBooking.send_overtime_mail(user, bookings) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment