From: Janusz Dobrowolski Date: Sun, 7 Nov 2010 16:28:50 +0000 (+0000) Subject: Cleanup. X-Git-Tag: v2.4.2~19^2~509 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=52cb07f22b3c471b08339236ae5bcb9c07ee779e;p=fa-stable.git Cleanup. --- diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index a3713a24..6eb0b89e 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -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 . "¤cy_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 . "¤cy_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()); diff --git a/reporting/rep107.php b/reporting/rep107.php index 33455a19..1f081ee2 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -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); } } diff --git a/reporting/rep109.php b/reporting/rep109.php index 26ffb53a..b6077b6e 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -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); } } diff --git a/reporting/rep110.php b/reporting/rep110.php index 1c9cf743..6b392cd0 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -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); } } diff --git a/reporting/rep111.php b/reporting/rep111.php index 00e0dcb7..02285fca 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -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); diff --git a/reporting/rep209.php b/reporting/rep209.php index f0a42fff..1d297de5 100644 --- a/reporting/rep209.php +++ b/reporting/rep209.php @@ -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'] == "") diff --git a/reporting/rep210.php b/reporting/rep210.php index eb928396..7f6b53b6 100644 --- a/reporting/rep210.php +++ b/reporting/rep210.php @@ -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); } } diff --git a/reporting/rep409.php b/reporting/rep409.php index 4b65d59f..60f58b04 100644 --- a/reporting/rep409.php +++ b/reporting/rep409.php @@ -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);