Fixed Email Receipt to customer.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 1 May 2019 08:00:31 +0000 (10:00 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 1 May 2019 08:00:31 +0000 (10:00 +0200)
reporting/includes/reporting.inc
reporting/rep112.php
reporting/reports_main.php
sales/customer_payments.php

index 80632db211e2b2645413846bbad7ec37ef0d746d..6062ddca554ef024ca0ead27085e815041a3e31a 100644 (file)
@@ -92,8 +92,9 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no,
                                'PARAM_0' => $doc_no, 
                                'PARAM_1' => $doc_no, 
                                'PARAM_2' => '', 
-                               'PARAM_3' => '',
-                               'PARAM_4' => $def_orientation);
+                               'PARAM_3' => $email,
+                               'PARAM_4' => '',
+                               'PARAM_5' => $def_orientation);
                        break;
                case ST_SUPPAYMENT :
                        $rep = 210;
index a70b78cb112b47d8fbf33a72b1a53a11fb62e72d..aaaf783cea0ff576ed75f33dbb021b8cf4c805c6 100644 (file)
@@ -60,8 +60,9 @@ function print_receipts()
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
        $currency = $_POST['PARAM_2'];
-       $comments = $_POST['PARAM_3'];
-       $orientation = $_POST['PARAM_4'];
+    $email = $_POST['PARAM_3'];
+       $comments = $_POST['PARAM_4'];
+       $orientation = $_POST['PARAM_5'];
 
        if (!$from || !$to) return;
 
@@ -82,12 +83,10 @@ function print_receipts()
 
        $cur = get_company_Pref('curr_default');
 
-       $rep = new FrontReport(_('RECEIPT'), "ReceiptBulk", user_pagesize(), 9, $orientation);
+       if ($email == 0)
+               $rep = new FrontReport(_('RECEIPT'), "ReceiptBulk", user_pagesize(), 9, $orientation);
        if ($orientation == 'L')
        recalculate_cols($cols);
-       $rep->currency = $cur;
-       $rep->Font();
-       $rep->Info($params, $cols, null, $aligns);
 
        for ($i = $from; $i <= $to; $i++)
        {
@@ -107,6 +106,16 @@ function print_receipts()
                        $baccount = db_fetch($res);
                        $params['bankaccount'] = $baccount['bank_act'];
 
+                       if ($email == 1)
+                       {
+                               $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
+                               $rep->title = _('RECEIPT');
+                               $rep->filename = "Receipt" . $i . ".pdf";
+                       }
+                       $rep->currency = $cur;
+                       $rep->Font();
+                       $rep->Info($params, $cols, null, $aligns);
+
                        $contacts = get_branch_contacts($myrow['branch_code'], 'invoice', $myrow['debtor_no']);
                        $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT, $contacts);
                        $rep->SetHeaderType('Header2');
@@ -180,8 +189,13 @@ function print_receipts()
                        $rep->TextCol(4, 5, _("Branch"), - 2);
                        $rep->TextCol(5, 6, "__________________", - 2);
                        $rep->TextCol(6, 7, "__________________");
+                       if ($email == 1)
+                       {
+                               $rep->End($email);
+                       }
                }
        }
-       $rep->End();
+    if ($email == 0)
+               $rep->End();
 }
 
index 85c2612f1c32063341e096edfd7b268d62462b6f..92bf3d921f2e6263526ddec0fafe6115f9751b8f 100644 (file)
@@ -156,6 +156,7 @@ $reports->addReport(RC_CUSTOMER, 112, _('Print Receipts'),
        array(  _('From') => 'RECEIPT',
                        _('To') => 'RECEIPT',
                        _('Currency Filter') => 'CURRENCY',
+            _('Email Customers') => 'YES_NO',
                        _('Comments') => 'TEXTBOX',
                        _('Orientation') => 'ORIENTATION'));
 
index f314b9889b250f05289022009bdeaa913de51644..907f789eca8499fd7dd1e9014fe0be406779c6b4 100644 (file)
@@ -102,6 +102,7 @@ if (isset($_GET['AddedID'])) {
        display_notification_centered(_("The customer payment has been successfully entered."));
 
        submenu_print(_("&Print This Receipt"), ST_CUSTPAYMENT, $payment_no."-".ST_CUSTPAYMENT, 'prtopt');
+       submenu_print(_("&Email This Receipt"), ST_CUSTPAYMENT, $payment_no."-".ST_CUSTPAYMENT, null, 1);
 
        submenu_view(_("&View this Customer Payment"), ST_CUSTPAYMENT, $payment_no);