Improved email sending of documents. With help of Tom Moulton
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 13 Jun 2009 14:45:25 +0000 (14:45 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 13 Jun 2009 14:45:25 +0000 (14:45 +0000)
CHANGELOG.txt
reporting/includes/class.mail.inc
reporting/includes/pdf_report.inc
reporting/rep109.php
reporting/rep209.php

index 33e87ed70a4296a5a4c2d9122231c522ebca663d..17d44a9dc2b87b17b3f4cacea355e826d4578112 100644 (file)
@@ -19,10 +19,15 @@ Legend:
 ! -> Note
 $ -> Affected files
 
-13-Jun-2009 Joe Hunt
+13-Jun-2009 Joe Hunt/Pete/Tom Moulton
 ! Changed next reference method to also include partly alpha characters in front, fi. WA036 increments to WA037
 $ /includes/references.inc
-
+! Improved email sending of documents. With help of Tom Moulton
+$ /reporting/rep109.php
+  /reporting/rep209.php
+  /reporting/includes/class.mail.inc
+  /reporting/includes/pdf.report.inc
+  
 12-Jun-2009 Joe Hunt
 ! Code clean-up
 $ /gl/includes/db/gl_db_trans.inc
index 3cc1d1d27f0f76d8717494b82294252092447215..7e6be6f93a1d958a5c2e003196287d667e8d6799 100644 (file)
@@ -67,6 +67,25 @@ class email
            $this->body .= "<html><body>\n".$html."\n</body></html>\n";
     }
 
+       function mime_type($filename)
+       {
+               $file = basename($filename, '.zip');
+               if ($filename == $file . '.zip') return 'application/x-zip-compressed';
+               $file = basename($filename, '.pdf');
+               if ($filename == $file . '.pdf') return 'application/pdf';
+               $file = basename($filename, '.csv');
+               if ($filename == $file . '.csv') return 'application/vnd.ms-excel';
+               $file = basename($filename, '.tar');
+               if ($filename == $file . '.tar') return 'application/x-tar';
+               $file = basename($filename, '.tar.gz');
+               if ($filename == $file . '.tar.gz') return 'application/x-tar-gz';
+               $file = basename($filename, '.tgz');
+               if ($filename == $file . '.tgz') return 'application/x-tar-gz';
+               $file = basename($filename, '.gz');
+               if ($filename == $file . '.gz') return 'application/x-gzip';
+               return 'application/unknown';
+       }
+
        function send()
     {
         // CC Empfänger hinzufügen
@@ -105,7 +124,7 @@ class email
             {
                 $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
                 $this->header .= "--".$this->boundary."\n";
-                $this->header .= "Content-Type: application/x-zip-compressed; name=".basename($this->attachment[$i])."\n";
+                $this->header .= "Content-Type: " .$this->mime_type(basename($this->attachment[$i])). "; name=".basename($this->attachment[$i])."\n";
                 $this->header .= "Content-Transfer-Encoding: base64\n";
                 $this->header .= "Content-Disposition: attachment; filename=".basename($this->attachment[$i])."\n\n";
                 $this->header .= chunk_split(base64_encode($file))."\n";
index dd4518596b8dd88c60178ff5ca018bfb239bb190..1a0f7174fc215543428aca5048a172398bacd150 100644 (file)
@@ -422,8 +422,9 @@ class FrontReport extends Cpdf
                                require_once($path_to_root . "/reporting/includes/class.mail.inc");
                        $mail = new email($this->company['coy_name'], $this->company['email']);
                        $from = $this->company['coy_name'] . " <" . $this->company['email'] . ">";
+                               if ($myrow['email'] == '') $myrow['email'] = $myrow['contact_email'];
                        $to = $myrow['DebtorName'] . " <" . $myrow['email'] . ">";
-                       $msg = $doc_Dear_Sirs . ",\n\n" . $doc_AttachedFile . " " . $subject .
+                       $msg = $doc_Dear_Sirs . " " . $myrow['DebtorName'] . ",\n\n" . $doc_AttachedFile . " " . $subject .
                                "\n\n";
                                if ($myrow['dimension_id'] > 0 && $doctype == 10) // helper for payment links
                                {
@@ -438,7 +439,7 @@ class FrontReport extends Cpdf
                                        }
                                }
                        $msg .= $doc_Kindest_regards . "\n\n";
-                       $sender = $this->user . "\n" . $this->company['coy_name'];
+                       $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->subject($subject);
                        $mail->text($msg . $sender);
index c5faf7692b4c7aa3cdb21e73acea1aabf54139f4..7c57da3f3f643afd30ff6d7ba4dda7ee85c3d351 100644 (file)
@@ -163,7 +163,7 @@ function print_sales_orders()
                                $myrow['contact_email'] = $branch['email'];
                                $myrow['DebtorName'] = $branch['br_name'];
                        }
-                       $rep->End($email, $doc_Invoice_no . " " . $myrow['reference'], $myrow);
+                       $rep->End($email, $doc_Invoice_no . " " . $i, $myrow);
                }
        }
        if ($email == 0)
index f369a0e7d9342e402afba83c7e474647ffa063eb..046738d025e47900f17d3530add9cc4db2d3dc3d 100644 (file)
@@ -31,7 +31,7 @@ function get_po($order_no)
 {
        $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name,  ".TB_PREF."suppliers.supp_account_no,
                ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name,
-               ".TB_PREF."suppliers.email, ".TB_PREF."suppliers.address
+               ".TB_PREF."suppliers.email, ".TB_PREF."suppliers.address, ".TB_PREF."suppliers.contact
                FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations
                WHERE ".TB_PREF."purch_orders.supplier_id = ".TB_PREF."suppliers.supplier_id
                AND ".TB_PREF."locations.loc_code = into_stock_location
@@ -170,6 +170,7 @@ function print_po()
                {
                        $myrow['contact_email'] = $myrow['email'];
                        $myrow['DebtorName'] = $myrow['supp_name'];
+                       if ($myrow['contact'] != '') $myrow['DebtorName'] = $myrow['contact'];
                        $myrow['reference'] = $myrow['order_no'];
                        $rep->End($email, $doc_Order_no . " " . $myrow['reference'], $myrow);
                }