From: Janusz Dobrowolski Date: Fri, 8 Feb 2013 10:24:16 +0000 (+0100) Subject: Fixed handling of undefined mailboxes when reports are sent via email; supressed... X-Git-Tag: 2.3-final~314 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c078c612309ab71d6873ad48629f9a269466ca51;p=fa-stable.git Fixed handling of undefined mailboxes when reports are sent via email; supressed duplicate errors display. --- diff --git a/includes/errors.inc b/includes/errors.inc index 6f9a2432..08a5e578 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -76,7 +76,9 @@ function error_handler($errno, $errstr, $file, $line) { // error_reporting==0 when messages are set off with @ if ($errno & error_reporting()) { - $messages[] = array($errno, $errstr, $file, $line, @$bt); + // suppress duplicated errors + if (!in_array(array($errno, $errstr, $file, $line, @$bt), $messages)) + $messages[] = array($errno, $errstr, $file, $line, @$bt); } else if($errno&~E_NOTICE) { // log all not displayed messages $user = @$_SESSION["wa_current_user"]->loginname; diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index 73bdaa10..bf45b1ce 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -271,4 +271,5 @@ $Footer[] = $line; } + $this->formData['recipient_name'] = $Addr1['name']; ?> diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 0a412ce8..caf01d96 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -976,15 +976,21 @@ class FrontReport extends Cpdf if ($email == 1) { - if(!count($this->contactData)) { + $contactData = array(); + if ($this->contactData) + foreach($this->contactData as $contact) + if (!empty($contact['email'])) + $contactData[] = $contact['email']; + + if(!count($contactData)) { $this->SetLang(user_language()); - display_error(_("You have no email contact defined for this type of document")); + display_warning(sprintf(_("You have no email contact defined for this type of document for '%s'."), $this->formData['recipient_name'])); } else { $sent = $try = 0; $emails = ""; if(!$subject) $subject = $this->formData['document_name'] . ' '. $this->formData['document_number']; - foreach($this->contactData as $contact) { + foreach($contactData as $contact) { if (!isset($contact['email'])) continue; $emailtype = true; @@ -1026,9 +1032,9 @@ class FrontReport extends Cpdf unlink($fname); $this->SetLang(user_language()); if (!$try) { - display_error(_("There is no contact email set for this document type.")); + display_warning(sprintf(_("You have no email contact defined for this type of document for '%s'."), $this->formData['recipient_name'])); } elseif (!$sent) - display_error($this->title . " " . $this->formData['document_number'] . ". " + display_warning($this->title . " " . $this->formData['document_number'] . ". " . _("Sending document by email failed") . ". " . _("Email:") . $emails); else display_notification($this->title . " " . $this->formData['document_number'] . " "