1 (edited by apmuthu 02/03/2015 08:01:44 am)

Topic: xls mail patch

The current reporting/includes/class.mail.inc does not allow emailing of xls files. Also the CC and BCC constructs can be simplified using implode(). The following patch addresses them:

--- old/reporting/includes/class.mail.inc    Mon Sep 29 21:21:28 2014
+++ new/reporting/includes/class.mail.inc    Tue Feb 03 12:30:19 2015
@@ -97,6 +97,8 @@
         if ($filename == $file . '.zip') return 'application/x-zip-compressed';
         $file = basename($filename, '.pdf');
         if ($filename == $file . '.pdf') return 'application/pdf';
+        $file = basename($filename, '.xls');
+        if ($filename == $file . '.xls') return 'application/vnd.ms-excel';
         $file = basename($filename, '.csv');
         if ($filename == $file . '.csv') return 'application/vnd.ms-excel';
         $file = basename($filename, '.tar');
@@ -114,31 +116,17 @@
 
     function send()
     {
-        // CC Empfänger hinzufügen
-        $max = count($this->cc);
-        if ($max > 0)
-        {
-            $this->header .= "Cc: ".$this->cc[0];
-            for ($i = 1; $i < $max; $i++)
-            {
-                $this->header .= ", ".$this->cc[$i];
-            }
-            $this->header .= "\n";
-        }
-        // BCC Empfänger hinzufügen
-        $max = count($this->bcc);
-        if ($max > 0)
-        {
-            $this->header .= "Bcc: ".$this->bcc[0];
-            for ($i = 1; $i < $max; $i++)
-            {
-                $this->header .= ", ".$this->bcc[$i];
-            }
-            $this->header .= "\n";
-        }
+        // Add CC Recipients
+        if (!empty($this->cc))
+            $this->header .= "Cc: " . implode(", ", $this->cc) . "\n" ;
+
+        // Add BCC Recipients
+        if (!empty($this->bcc))
+            $this->header .= "Bcc: " . implode(", ", $this->bcc) . "\n" ;
+
         $this->header .= "Content-Type: multipart/mixed;\n boundary=\"$this->boundary\"\n";
 
-        // Attachment hinzufügen
+        // Add Attachments
         $max = count($this->attachment);
         if ($max > 0)
         {

In the file reporting/includes/excel_report.inc this will enable the creation of an equivalent method End() (what a name for a  class method!) that now only exists in reporting/includes/pdf_report.inc file.

@joe: can incorporate into FA 2.4 and backport it.

References:
http://stackoverflow.com/questions/9740 … l-document
http://filext.com/faq/office_mime_types.php

Post's attachments

FA_xls_Mail_Patch.zip 7.8 kb, 1 downloads since 2015-02-03 

You don't have the permssions to download the attachments of this post.

Re: xls mail patch

The mail extensen XLS has been included in class.mail.inc and sent to HG repository 2.4.

Ehe End() functionality in excel_report.inc will be fixed during the 2.4 release.

/Joe

3 (edited by apmuthu 02/04/2015 07:58:52 am)

Re: xls mail patch

Thanks Joe. Check the indents.

Re: xls mail patch

Tabulators are set to 4 in our php editors.

/Joe

Re: xls mail patch

What I meant was the extra tabs in some lines added highlighted in the attachment.

Post's attachments

tabs.png 11.2 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: xls mail patch

Now included in FA 2.4