No display of shipping if there are no shipping costs on sales documents or views.
[fa-stable.git] / reporting / rep107.php
index 19f590ede16052e0eb9c7ac48153d4e0a045021a..58b1509fd7eaa54065c88147318892b6770649ed 100644 (file)
@@ -42,7 +42,8 @@ function print_invoices()
        $email = $_POST['PARAM_3'];
        $pay_service = $_POST['PARAM_4'];
        $comments = $_POST['PARAM_5'];
-       $orientation = $_POST['PARAM_6'];
+       $customer = $_POST['PARAM_6'];
+       $orientation = $_POST['PARAM_7'];
 
        if (!$from || !$to) return;
 
@@ -73,6 +74,13 @@ function print_invoices()
                                continue;
                        $sign = 1;
                        $myrow = get_customer_trans($i, ST_SALESINVOICE);
+
+                       if ($customer && $myrow['debtor_no'] != $customer) {
+                               continue;
+                       }
+                       if ($currency != ALL_TEXT && $myrow['curr_code'] != $currency) {
+                               continue;
+                       }
                        $baccount = get_default_bank_account($myrow['curr_code']);
                        $params['bankaccount'] = $baccount['id'];
 
@@ -89,7 +97,7 @@ function print_invoices()
                        $rep->Font();
                        $rep->Info($params, $cols, null, $aligns);
 
-                       $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], false);
+                       $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);
                        $baccount['payment_service'] = $pay_service;
                        $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
                        $rep->NewPage();
@@ -137,7 +145,6 @@ function print_invoices()
                        }
 
                        $DisplaySubTot = number_format2($SubTotal,$dec);
-                       $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
 
                $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
                        $doctype = ST_SALESINVOICE;
@@ -145,9 +152,13 @@ function print_invoices()
                        $rep->TextCol(3, 6, _("Sub-total"), -2);
                        $rep->TextCol(6, 7,     $DisplaySubTot, -2);
                        $rep->NewLine();
-                       $rep->TextCol(3, 6, _("Shipping"), -2);
-                       $rep->TextCol(6, 7,     $DisplayFreight, -2);
-                       $rep->NewLine();
+                       if ($myrow['ov_freight'] != 0.0)
+                       {
+                               $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
+                               $rep->TextCol(3, 6, _("Shipping"), -2);
+                               $rep->TextCol(6, 7,     $DisplayFreight, -2);
+                               $rep->NewLine();
+                       }       
                        $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i);
                        $first = true;
                while ($tax_item = db_fetch($tax_items))
@@ -208,4 +219,4 @@ function print_invoices()
                $rep->End();
 }
 
-?>
\ No newline at end of file
+?>