aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorCamil Staps2016-08-01 12:17:53 +0200
committerCamil Staps2016-08-01 12:17:53 +0200
commit79fa054c32f9c58c7cc27539755365535f3c0aec (patch)
treef3d309d157a40c5b9c91955a6cb2a95673ecdff3 /classes
parentFix lowercase class names (diff)
Error when sending email when invoice is not generated yet
Diffstat (limited to 'classes')
-rw-r--r--classes/Offer.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/classes/Offer.php b/classes/Offer.php
index 7d8e8b8..a4d6b7f 100644
--- a/classes/Offer.php
+++ b/classes/Offer.php
@@ -273,11 +273,16 @@ class Offer extends Model{
* @return Mailer The mailer
*/
public function mailer() {
+ $file = $this->getInvoiceFile();
+ if (is_null($file)) {
+ throw new Exception("The invoice for this offer has not been generated yet.");
+ }
+
$mailer = new Mailer($this->pdo);
$mailer->setOffer($this);
$lang = $this->getContact()->language;
- $mailer->addAttachment($this->getInvoiceFile()->getFilenamePath());
+ $mailer->addAttachment($file->getFilenamePath());
$mailer->Subject = Correspondence::__('mail-offer-subject', $lang);
$mailer->Body = Correspondence::__r('mail-offer', $lang, $this);