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
55
56
57
58
59
60
61
62
|
# File 'lib/oddb/util/mail.rb', line 27
def Mail.notify_invoice(invoice)
config = ODDB.config
lnf = Html::Util::LookandfeelStub.new('de')
mpart = RMail::Message.new
= mpart.
.to = recipient = invoice.yus_name
.from = config.mail_invoice_from
.subject = lnf.lookup(:poweruser_mail_subject)
.date = Time.now
.add('Content-Type', 'text/plain', nil,
'charset' => config.mail_charset)
recipients = [recipient].concat config.debug_recipients
yus = Util::Yus.get_preferences(recipient, :salutation, :name_last)
parts = [
lnf.lookup(:poweruser_mail_salut, lnf.lookup(yus[:salutation]),
yus[:name_last]),
]
invoice.items.each { |item|
case item.type
when :poweruser
days = item.quantity
duration = (days == 1) \
? lnf.lookup(:days_one_genitive) \
: lnf.lookup(:days_genitive, days)
parts.push lnf.lookup(:poweruser_mail_body)
parts.push lnf.lookup(:poweruser_mail_instr,
duration, lnf._event_url(:login))
when :export
parts.push lnf.lookup(:download_export_mail_body)
parts.push lnf.lookup(:download_export_mail_instr)
parts.push lnf._event_url(:collect, [:invoice, invoice.id])
end
}
mpart.body = parts.join("\n\n")
sendmail(mpart, config.mail_invoice_smtp, recipients)
end
|