Cleanup Sales Summary Report
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 6 Apr 2011 21:57:45 +0000 (23:57 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 6 Apr 2011 21:57:45 +0000 (23:57 +0200)
reporting/rep114.php
reporting/reports_main.php

index 6839a45919fefc5d6d05083f3e93f1193f610fc1..96f743e76834c5920f3bfcac8b6b83513070d847 100644 (file)
@@ -28,7 +28,7 @@ include_once($path_to_root . "/gl/includes/gl_db.inc");
 
 print_sales_summary_report();
 
-function getTaxTransactions($from, $to)
+function getTaxTransactions($from, $to, $tax_id)
 {
        $fromdate = date2sql($from);
        $todate = date2sql($to);
@@ -42,8 +42,10 @@ function getTaxTransactions($from, $to)
                FROM ".TB_PREF."debtor_trans dt\r
                        LEFT JOIN ".TB_PREF."debtors_master d ON d.debtor_no=dt.debtor_no\r
                        LEFT JOIN ".TB_PREF."trans_tax_details t ON (t.trans_type=dt.type AND t.trans_no=dt.trans_no)\r
-               WHERE (dt.type=".ST_SALESINVOICE." OR dt.type=".ST_CUSTCREDIT.")\r
-               AND dt.tran_date >=".db_escape($fromdate)." AND dt.tran_date<=".db_escape($todate)."\r
+               WHERE (dt.type=".ST_SALESINVOICE." OR dt.type=".ST_CUSTCREDIT.") ";\r
+       if ($tax_id)\r
+               $sql .= "AND tax_id<>'' ";\r
+       $sql .= "AND dt.tran_date >=".db_escape($fromdate)." AND dt.tran_date<=".db_escape($todate)."\r
                GROUP BY d.debtor_no, d.name, d.tax_id ORDER BY d.name"; \r
     return db_query($sql,"No transactions were returned");
 }
@@ -56,8 +58,14 @@ function print_sales_summary_report()
        
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
-       $comments = $_POST['PARAM_2'];
-       $destination = $_POST['PARAM_3'];
+       $tax_id = $_POST['PARAM_2'];\r
+       $comments = $_POST['PARAM_3'];
+       $destination = $_POST['PARAM_4'];
+       if ($tax_id == 0)\r
+               $tid = _('No');\r
+       else\r
+               $tid = _('Yes');\r
+\r
 
        if ($destination)
                include_once($path_to_root . "/reporting/includes/excel_report.inc");
@@ -69,7 +77,8 @@ function print_sales_summary_report()
        $rep = new FrontReport(_('Sales Summary Report'), "SalesSummaryReport", user_pagesize());
 
        $params =   array(      0 => $comments,
-                                               1 => array('text' => _('Period'), 'from' => $from, 'to' => $to));
+                                               1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
+                                               2 => array(  'text' => _('Tax Id Only'),'from' => $tid,'to' => ''));
 
        $cols = array(0, 130, 180, 270, 350, 500);\r
 
@@ -81,7 +90,7 @@ function print_sales_summary_report()
        
        $totalnet = 0.0;
        $totaltax = 0.0;
-       $transactions = getTaxTransactions($from, $to);
+       $transactions = getTaxTransactions($from, $to, $tax_id);
 \r
        $rep->TextCol(0, 4, _("Values in domestic currency"));\r
        $rep->NewLine(2);\r
index 74ace3c96612225f439e95b44f0e5abeecbf4b0f..84becd523c9f10d0ae0097ee71d9482ebb06c966 100644 (file)
@@ -58,6 +58,7 @@ $reports->addReport(RC_CUSTOMER, 103, _('Customer &Detail Listing'),
 $reports->addReport(RC_CUSTOMER, 114, _('Sales &Summary Report'),
        array(  _('Start Date') => 'DATEBEGINTAX',
                        _('End Date') => 'DATEENDTAX',
+                       _('Tax Id Only') => 'YES_NO',
                        _('Comments') => 'TEXTBOX',
                        _('Destination') => 'DESTINATION'));
 $reports->addReport(RC_CUSTOMER, 104, _('&Price Listing'),