Cleanup.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 7 Nov 2010 16:28:50 +0000 (16:28 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 7 Nov 2010 16:28:50 +0000 (16:28 +0000)
reporting/includes/pdf_report.inc
reporting/rep107.php
reporting/rep109.php
reporting/rep110.php
reporting/rep111.php
reporting/rep209.php
reporting/rep210.php
reporting/rep409.php

index a3713a248a33bd5d6eda05fd70183fb90ab3e350..6eb0b89e49da630b7ba4bdb24b674b9e4fd13d5f 100644 (file)
@@ -403,6 +403,8 @@ class FrontReport extends Cpdf
                }
                $this->formData['doctype'] = $doctype;
                if (count($contacts)) {
+                       if (!is_array($contacts[0]))
+                               $contacts = array($contacts); // change to array when single contact passed
                        $this->contactData = $contacts;
                        // as report is currently generated once despite number of email recipients
                        // we select language for the first recipient as report language
@@ -994,39 +996,41 @@ class FrontReport extends Cpdf
                                        display_error(_("You have no email contact defined for this type of document"));
                                } else {
                                        $sent = 0;
-                               foreach($this->contactData as $contact) {
-                                       $emailtype = true;
-                                       $this->SetLang($contact['lang']);
-                                       include("includes/doctext.inc");
-
-                                       require_once($path_to_root . "/reporting/includes/class.mail.inc");
-                               $mail = new email(str_replace(",", "", $this->company['coy_name']), $this->company['email']);
-                                       $mail->charset = $this->encoding;
-                                       if (!isset($contact['email']) || $contact['email'] == '') 
-                                               $contact['email'] = isset($myrow['contact_email']) ? $myrow['contact_email'] : '';
-
-                               $to = str_replace(",", "", $contact['name'].' '.$contact['name2'])." <" . $contact['email'] . ">";
-                               $msg = $doc_Dear_Sirs . " " . $myrow['DebtorName'] . ",\n\n" . $doc_AttachedFile . " " . $subject .
-                                       "\n\n";
-                                       if (isset($myrow['dimension_id']) && $myrow['dimension_id'] > 0 && $doctype == ST_SALESINVOICE) // helper for payment links
-                                       {
-                                               if ($myrow['dimension_id'] == 1)
+                                       foreach($this->contactData as $contact) {
+                                               if (!isset($contact['email'])) 
+                                                       continue;
+                                               $emailtype = true;
+                                               $this->SetLang($contact['lang']);
+                                               include("includes/doctext.inc");
+
+                                               require_once($path_to_root . "/reporting/includes/class.mail.inc");
+                                       $mail = new email(str_replace(",", "", $this->company['coy_name']),
+                                               $this->company['email']);
+                                               $mail->charset = $this->encoding;
+
+                                       $to = str_replace(",", "", $contact['name'].' '.$contact['name2'])
+                                               ." <" . $contact['email'] . ">";
+                                       $msg = $doc_Dear_Sirs . " " . $contact['name2'] . ",\n\n" 
+                                               . $doc_AttachedFile . " " . $subject ."\n\n";
+                                               if (isset($myrow['dimension_id']) && $myrow['dimension_id'] > 0 && $doctype == ST_SALESINVOICE) // helper for payment links
                                                {
-                                                       $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] +  $myrow["ov_amount"], user_price_dec());
-                                                       $txt = $doc_Payment_Link . " PayPal: ";
-                                                       $nn = urlencode($this->title . " " . $myrow['reference']);
-                                                       $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
-                                                               $nn . "&amount=" . $amt . "&currency_code=" . $myrow['curr_code'];
-                                                       $msg .= $txt . $url . "\n\n";
+                                                       if ($myrow['dimension_id'] == 1)
+                                                       {
+                                                               $amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] +  $myrow["ov_amount"], user_price_dec());
+                                                               $txt = $doc_Payment_Link . " PayPal: ";
+                                                               $nn = urlencode($this->title . " " . $myrow['reference']);
+                                                               $url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
+                                                                       $nn . "&amount=" . $amt . "&currency_code=" . $myrow['curr_code'];
+                                                               $msg .= $txt . $url . "\n\n";
+                                                       }
                                                }
-                                       }
-                               $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->subject($subject);
-                               $mail->text($msg . $sender);
-                               $mail->attachment($fname);
-                               if ($mail->send()) $sent++;
+                                       $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->subject($subject);
+                                       $mail->text($msg . $sender);
+                                       $mail->attachment($fname);
+                                       if ($mail->send()) $sent++;
                                        } // foreach contact
                                        unlink($fname);
                                        $this->SetLang(user_language());
index 33455a1948c4e0bb51b51a4873fac8fc6bb696d8..1f081ee2204be4cbf17923a039d7a069750b0b10 100644 (file)
@@ -219,11 +219,6 @@ function print_invoices()
                        if ($email == 1)
                        {
                                $myrow['dimension_id'] = $paylink; // helper for pmt link
-                               if ($myrow['email'] == '')
-                               {
-                                       $myrow['email'] = $branch['email'];
-                                       $myrow['DebtorName'] = $branch['br_name'];
-                               }
                                $rep->End($email, $doc_Invoice_no . " " . $myrow['reference'], $myrow, $j);
                        }
                }
index 26ffb53a2a7c7828f47d21ba34dd67852b01461d..b6077b6e9838fdeafe3b3bec4a35548bae542a1c 100644 (file)
@@ -217,15 +217,7 @@ function print_sales_orders()
                $rep->Font();
                if ($email == 1)
                {
-                       $res = get_branch_contacts(branch_code, 'order', customer_id);
-                       if ($myrow['contact_email'] == '')
-                       {
-                               $myrow['contact_email'] = $branch['email'];
-                               if ($myrow['contact_email'] == '')
-                                       $myrow['contact_email'] = $myrow['master_email'];
-                               $myrow['DebtorName'] = $branch['br_name'];
-                       }
-                       //$myrow['reference'] = $i;
+                       $res = get_branch_contacts($branch['branch_code'], 'order', $branch['customer_id']);
                        $rep->End($email, $doc_Invoice_no . " " . $i, $myrow);
                }
        }
index 1c9cf7436037078fb9ed26a20a9ac4ecea95ee50..6b392cd0ab3fe987d107348586c74b7d8726c636 100644 (file)
@@ -215,11 +215,6 @@ function print_deliveries()
                        }       
                        if ($email == 1)
                        {
-                               if ($myrow['email'] == '')
-                               {
-                                       $myrow['email'] = $branch['email'];
-                                       $myrow['DebtorName'] = $branch['br_name'];
-                               }
                                $rep->End($email, $doc_Delivery_no . " " . $myrow['reference'], $myrow, ST_CUSTDELIVERY);
                        }
        }
index 00e0dcb79631894899518fc11c591a17af2fc152..02285fca2452857bf62adac6119761a67dfd3a39 100644 (file)
@@ -152,13 +152,6 @@ function print_sales_quotations()
                $rep->Font();
                if ($email == 1)
                {
-                       if ($myrow['contact_email'] == '')
-                       {
-                               $myrow['contact_email'] = $branch['email'];
-                               if ($myrow['contact_email'] == '')
-                                       $myrow['contact_email'] = $myrow['master_email'];
-                               $myrow['DebtorName'] = $branch['br_name'];
-                       }
                        if ($print_invoice_no == 1)
                                $myrow['reference'] = $i;
                        $rep->End($email, $doc_Invoice_no . " " . $myrow['reference'], $myrow);
index f0a42fff0418b1435fccb0c92d623a9740d86a11..1d297de54d503f21c47c780e9e1cbeb6a853fef9 100644 (file)
@@ -219,7 +219,6 @@ function print_po()
                $rep->Font();
                if ($email == 1)
                {
-//                     $myrow['contact_email'] = $myrow['email'];
                        $myrow['DebtorName'] = $myrow['supp_name'];
 
                        if ($myrow['reference'] == "")
index eb928396fa09841dd62a459d1f07c100285df4ba..7f6b53b65e20c5e23e3b65faec3a36a629b20af7 100644 (file)
@@ -174,9 +174,7 @@ function print_remittances()
                        $rep->Font();
                        if ($email == 1)
                        {
-//                             $myrow['contact_email'] = $myrow['email'];
                                $myrow['DebtorName'] = $myrow['supp_name'];
-//                             if ($myrow['contact'] != '') $myrow['DebtorName'] = $myrow['contact'];
                                $rep->End($email, $doc_Order_no . " " . $myrow['reference'], $myrow);
                        }
                }       
index 4b65d59f81f314b79a04a9181eb57251a6d27acd..60f58b049be4341e66ab62dfea0c80068254afe7 100644 (file)
@@ -142,7 +142,6 @@ function print_workorders()
                }
                if ($email == 1)
                {
-//                     $myrow['contact_email'] = $myrow['email'];
                        $myrow['DebtorName'] = $myrow['contact'];
                        $myrow['reference'] = $myrow['wo_ref'];
                        $rep->End($email, _("Work Order No.") . " " . $myrow['wo_ref'], $myrow);