[0005735] Problems with sending emails with encoding other than ASCII - fixed.
[fa-stable.git] / reporting / includes / pdf_report.inc
index 0d699731e75fbbdeaf80ac54f3a215b4e2031b1a..a803fe3f9a640a030b8f7208d16400a8d5c00d5d 100644 (file)
@@ -743,7 +743,7 @@ class FrontReport extends Cpdf
 
        function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 1, $spacebreak=false)
        {
-               $str = strtr($str, array("\r"=>''));
+               $str = ($str != NULL ? strtr($str, array("\r"=>'')) : "");
 
                if ($this->fontSize != $this->oldFontSize)
                {
@@ -799,7 +799,7 @@ class FrontReport extends Cpdf
 
        function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0, $spacebreak=true)
        {
-               $str = explode("\n", $txt);
+               $str = ($txt != NULL ? explode("\n", $txt) : array());
 
                for ($i = 0; $i < count($str); $i++)
                {
@@ -998,14 +998,13 @@ class FrontReport extends Cpdf
                                                        continue;
                                                $emailtype = true;
                                                $this->SetLang($contact['lang']);
+                                               $coy_name = @html_entity_decode($this->company['coy_name'], ENT_QUOTES, $_SESSION['language']->encoding=='iso-8859-2' ? 'ISO-8859-1' : $_SESSION['language']->encoding);
 
                                                require_once($path_to_root . "/reporting/includes/class.mail.inc");
-                                       $mail = new email(str_replace(",", "", $this->company['coy_name']),
+                                       $mail = new email(str_replace(",", "", $coy_name),
                                                $this->company['email']);
                                                $mail->charset = $this->encoding;
 
-                                       $to = str_replace(",", "", $contact['name'].' '.$contact['name2'])
-                                               ." <" . $contact['email'] . ">";
                                        $msg = _("Dear") . " " . $contact['name2'] . ",\n\n" 
                                                . _("Attached you will find ") . " " . $subject ."\n\n";
 
@@ -1024,8 +1023,9 @@ class FrontReport extends Cpdf
                                                }
 
                                        $msg .= _("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); $try++;
+                                       $sender = $this->user . "\n" . $coy_name . "\n" . $this->company['postal_address'] . "\n" . $this->company['email'] . "\n" . $this->company['phone'];
+                                       $mail->to(str_replace(",", "", $contact['name'].' '.$contact['name2']), $contact['email']);
+                                       $try++;
                                        $mail->subject($subject);
                                        $mail->text($msg . $sender);
                                        $mail->attachment($fname, $this->filename);