Class: Notifier

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/models/notifier.rb

Instance Method Summary collapse

Instance Method Details

#invoice_available(invoice, client, payment_notice, attachments) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/notifier.rb', line 26

def invoice_available( invoice, client, payment_notice, attachments )
  tmpl_parameters = {
    :client => client,
    :payment_notice => payment_notice
  }.merge common_tmpl_parameters
  
  notifiers_bcc  = Setting.grab(:bcc_invoices_to)[0].split ','

  representative_emails = client.client_representatives.collect{|cr| '%s <%s>' % [cr.name,cr.email_address]}
  is_production = (RAILS_ENV == 'production')
  
  subject_line = "%s invoice %d (%s) now available"
  subject_line += " | Intended Recipients: "+representative_emails.join(', ') unless is_production

  # Here's the real deal
  from       from_address(tmpl_parameters)
  bcc        notifiers_bcc if is_production
  recipients (is_production) ? representative_emails : from_address(tmpl_parameters)
  subject    subject_line % [
    tmpl_parameters[:company_name],
    invoice.id,
    invoice.issued_on.strftime('%m/%d/%Y'),
    representative_emails.join(', ')
  ]

  generate_view_parts :invoice_available, tmpl_parameters

  attachments.each { |attach_params| attachment attach_params }
end

#reset_password_requested(credential_name, credential_email, reset_token, host) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/notifier.rb', line 3

def reset_password_requested( credential_name, credential_email, reset_token, host )
  tmpl_parameters = {
    :reset_token      => reset_token,
    :credential_name  => credential_name,
    :credential_email => credential_email,
    :reset_password_url_for => {
      :controller    => 'authentication', 
      :action        => 'reset_password_via_token', 
      :email_address => credential_email,
      :token         => reset_token,
      :only_path     => false,
      :host          => host
    }
  }.merge common_tmpl_parameters

  from       from_address(tmpl_parameters)
  bcc        from_address(tmpl_parameters)
  recipients '%s <%s>' % [credential_name, credential_email] 
  subject    "%s - Password Reset Instructions" % tmpl_parameters[:company_name]
  
  generate_view_parts :reset_password_requested, tmpl_parameters
end