From 963566e192ba7c5fd7a1937cbaeeea546f43c732 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 13 Feb 2011 08:59:48 +0000 Subject: [PATCH] Improved report mailing error handling. --- reporting/includes/pdf_report.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 98bd06a2..e3aedbf6 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -979,7 +979,7 @@ class FrontReport extends Cpdf $this->SetLang(user_language()); display_error(_("You have no email contact defined for this type of document")); } else { - $sent = 0; + $sent = $try = 0; foreach($this->contactData as $contact) { if (!isset($contact['email'])) continue; @@ -1010,7 +1010,7 @@ class FrontReport extends Cpdf } $msg .= $doc_Kindest_regards . "\n\n"; $sender = $this->user . "\n" . $this->company['coy_name'] . "\n" . $this->company['postal_address'] . "\n" . $this->company['email'] . "\n" . $this->company['phone']; - $mail->to($to); + $mail->to($to); $try++; $mail->subject($subject); $mail->text($msg . $sender); $mail->attachment($fname); @@ -1018,7 +1018,9 @@ class FrontReport extends Cpdf } // foreach contact unlink($fname); $this->SetLang(user_language()); - if (!$sent) + if (!$try) { + display_error(_("There is no contact email set for this document type.")); + } elseif (!$sent) display_error(_("Sending document by email failed")); else display_notification($this->title . " " . $myrow['reference'] . " " -- 2.30.2