Prev | Current Page 219 | Next

David Berube

"Practical Reporting with Ruby and Rails"


class User < ActiveRecord::Base
has_many :meetings, :foreign_key=>:assigned_user_id
def reward
Reward.find(:first,
:conditions=>['meeting_count < ? ',
self.meetings.count],
:order=>'meeting_count DESC',
:limit=>1)
end
end
class Meeting < ActiveRecord::Base
belongs_to :users, :foreign_key=>:assigned_user_id
end
class Reward < ActiveRecord::Base
end
html = '

Salesperson Reward Report








'
users = User.find(:all,
:conditions=>['not is_admin'],
CHAPTER 8 n CREATING SALES PERFORMANCE REPORTS WITH SUGARCRM 159
:order=>'last_name ASC, first_name ASC'
)
html = Erubis::Eruby.new(File.read('rewards_report_template.rhtml')
).evaluate({ :users=>users })
open('|"'+path_to_html2ps+'"', 'wb+') do |process_handle|
process_handle.puts html
process_handle.close_write
ps_source = process_handle.read
end
pdf_source = ''
open('|"' + path_to_ps2pdf +'" - -', 'wb+') do |process_handle|
process_handle.puts ps_source
process_handle.


Pages:
207208209210211212213214215216217218 219 220221222223224225226227228229230231
życzenia na walentynkiCiążatonery lublinprzepisyhodowla jamników długowłosych
NameMeetingsReward