Audit-Trail report (systypes selector should include all systypes, extra parameter...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 15 Jul 2009 08:48:24 +0000 (08:48 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 15 Jul 2009 08:48:24 +0000 (08:48 +0000)
Removed some warnings from reports.

CHANGELOG.txt
gl/includes/db/gl_db_accounts.inc
reporting/includes/reports_classes.inc
reporting/rep709.php
reporting/rep710.php
reporting/reports_main.php
sql/alter2.2.sql

index be91584ab484b0d3e9b11a6766e01a917e3d69ae..86fdad7c9b7a7cad83aa036bd927b37419a53e72 100644 (file)
@@ -29,6 +29,14 @@ $ /reporting/rep101.php
   /reporting/rep202.php
   /reporting/rep203.php
   /reporting/rep709.php
+  /sql/alter2.2.sql
+! Audit-Trail report (systypes selector should include all systypes, extra parameter to function dup_systypes_list.
+$ /reporting/rep710.php
+  /reporting/reports_main.php
+  /reporting/includes/reports_classes.inc
+# Removed warning from COA report
+$ /gl/includes/db/gl_db_accounts.inc 
+  /reporting/rep701.php
   
 13-Jul-2009 Joe Hunt
 + Added Audit Trail Report
index eb61b1c743c9e286d09af40d1df6777e0970a9db..474ea713b633cfdc151397eae39589b7f1ff02d6 100644 (file)
@@ -55,7 +55,8 @@ function get_gl_accounts_all($balance=-1)
                $where ="WHERE ctype>0 AND ctype<".CL_INCOME;
        elseif ($balance == 0)  
                $where ="WHERE ctype>".CL_EQUITY." OR ctype=0"; // backwards compatibility
-       $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType,
+       $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_code2, ".TB_PREF."chart_master.account_name, 
+               ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType,
                ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID, 
                ".TB_PREF."chart_class.ctype AS ClassType
                FROM ".TB_PREF."chart_types INNER JOIN ".TB_PREF."chart_class ON ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid
index 9a04b58ef56a8c17c910cd76a9d3ebc67972a6a7..62dcd582b8eef99fe2ddab4948e6d0ea9dd6f333 100644 (file)
@@ -197,7 +197,8 @@ class Report
                                        $st .= dup_simple_name_list("PARAM_$index", $sel);
                                        break;
                                case 'SYS_TYPES':
-                                       $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), true);
+                               case 'SYS_TYPES_ALL':
+                                       $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), ($param->param_type=='SYS_TYPES_ALL'));
                                        break;
                                case 'TEXT':
                                        $st .= "<input type='text' name='PARAM_$index'>";
@@ -421,7 +422,7 @@ function dup_simple_name_list($name, $selections)
 
 //------------------------------------------------------------------------------------------------
 
-function dup_systypes_list($name, &$selected_id, $all_option=false, $all_option_name=null)
+function dup_systypes_list($name, &$selected_id, $all_option=false, $all_option_name=null, $all_types=false)
 {
        global $systypes_array;
 
@@ -439,7 +440,7 @@ function dup_systypes_list($name, &$selected_id, $all_option=false, $all_option_
 
        foreach ($systypes_array as $i => $value)
        {
-               if ($i == 16 || $i == 18 || $i == 25 || ($i >= 28 && $i <= 30) || $i >= 40)
+               if (!$all_types && ($i == 16 || $i == 18 || $i == 25 || ($i >= 28 && $i <= 30) || $i >= 40))
                        continue;
        $st .= "<option" . ($selected_id == $i ? " selected" : "") . " value='$i'>" . $value['name'] . "</option>\n";
        }
index 6b1f1e40eaf05ab683d788be63012f246c9f0845..e4598f01ea32635173249cf2f1b17273684d5f86 100644 (file)
@@ -98,7 +98,7 @@ function print_tax_report()
                                                1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
                                                2 => array('text' => _('Type'), 'from' => $summary, 'to' => ''));
 
-       $cols = array(0, 100, 130, 180, 290, 370, 455, 505, 555);
+       $cols = array(0, 100, 130, 180, 290, 370, 420, 470, 520);
 
        $headers = array(_('Trans Type'), _('Ref'), _('Date'), _('Name'), _('Branch Name'),
                _('Net'), _('Rate'), _('Tax'));
index 9c1df5f16e6d39f8cdcec49fec743b7bea0a2bc9..76f232b71d4fc67d1b8e020002ef6bb66a611aa1 100644 (file)
@@ -33,22 +33,22 @@ function getTransactions($from, $to, $type, $user)
        $fromdate = date2sql($from);
        $todate = date2sql($to);
 
-       $sql = "SELECT ".TB_PREF."audit_trail.*, ".TB_PREF."gl_trans.tran_date
-               SUM(IF(".TB_PREF."gl_trans.amount > 0, ".TB_PREF."gl_trans.amount, 0)) AS amount,
-               ".TB_PREF."users.user_id,
-               UNIX_TIMESTAMP(".TB_PREF."audit_trail.stamp) as unix_stamp
-               FROM ".TB_PREF."audit_trail, ".TB_PREF."gl_trans, ".TB_PREF."users
-               WHERE ".TB_PREF."audit_trail.type = ".TB_PREF."gl_trans.type
-                       AND ".TB_PREF."audit_trail.trans_no = ".TB_PREF."gl_trans.type_no 
-                       AND ".TB_PREF."audit_trail.user = ".TB_PREF."users.id ";
+       $sql = "SELECT a.*
+               SUM(IF(ISNULL(g.amount), NULL, IF(g.amount > 0, g.amount, 0))) AS amount,
+               u.user_id,
+               UNIX_TIMESTAMP(a.stamp) as unix_stamp
+               FROM ".TB_PREF."audit_trail AS a JOIN ".TB_PREF."users AS u
+               LEFT JOIN ".TB_PREF."gl_trans AS g ON (g.type_no=a.trans_no
+                       AND g.type=a.type)
+               WHERE a.user = u.id ";
        if ($type != -1)
-               $sql .= "AND ".TB_PREF."gl_trans.type=$type ";
+               $sql .= "AND a.type=$type ";
        if ($user != -1)        
-               $sql .= "AND ".TB_PREF."audit_trail.user='$user' ";
-       $sql .= "AND DATE(".TB_PREF."audit_trail.stamp) >= '$fromdate'
-                       AND DATE(".TB_PREF."audit_trail.stamp) <= '$todate'
-               GROUP BY ".TB_PREF."gl_trans.type_no,".TB_PREF."audit_trail.gl_seq,".TB_PREF."audit_trail.stamp 
-               ORDER BY ".TB_PREF."audit_trail.stamp,".TB_PREF."audit_trail.gl_seq";
+               $sql .= "AND a.user='$user' ";
+       $sql .= "AND DATE(a.stamp) >= '$fromdate'
+                       AND DATE(a.stamp) <= '$todate'
+               GROUP BY a.trans_no,a.gl_seq,a.stamp    
+               ORDER BY a.stamp,a.gl_seq";
     return db_query($sql,"No transactions were returned");
 }
 //----------------------------------------------------------------------------------------------------
@@ -100,7 +100,7 @@ function print_audit_trail()
         else   
                $rep->TextCol(1, 2, date("H:i:s", $myrow['unix_stamp']));
         $rep->TextCol(2, 3, $myrow['user_id']);
-        $rep->TextCol(3, 4, sql2date($myrow['tran_date']));
+        $rep->TextCol(3, 4, sql2date($myrow['gl_date']));
         $rep->TextCol(4, 5, systypes::name($myrow['type']));
         $rep->TextCol(5, 6, $myrow['trans_no']);
         if ($myrow['gl_seq'] == null)
@@ -108,7 +108,8 @@ function print_audit_trail()
         else
                $action = _('Closed');
         $rep->TextCol(6, 7, $action);
-        $rep->AmountCol(7, 8, $myrow['amount'], $dec);
+        if ($myrow['amount'] != null)
+               $rep->AmountCol(7, 8, $myrow['amount'], $dec);
         $rep->NewLine(1, 2);
     }
     $rep->Line($rep->row  + 4);
index bb5ea791221ff174c4c22bdb81b9ec4968d0173b..df7019f57d664657ee6b25395e1abbfe33739297 100644 (file)
@@ -339,7 +339,7 @@ $reports->addReport(_('General Ledger'),709,_('Ta&x Report'),
 $reports->addReport(_('General Ledger'),710,_('Audit Trail'),
        array(  new ReportParam(_('Start Date'),'DATEBEGINM'),
                        new ReportParam(_('End Date'),'DATEENDM'),
-                       new ReportParam(_('Type'),'SYS_TYPES'),
+                       new ReportParam(_('Type'),'SYS_TYPES_ALL'),
                        new ReportParam(_('User'),'USERS'),
                        new ReportParam(_('Comments'),'TEXTBOX'),
                        new ReportParam(_('Destination'),'DESTINATION')));
index f99abc0bc42ab979372937077b99c5d701c4a7f4..1327bd688b2673b49f05c6c0359b0edda48aaaaa 100644 (file)
@@ -38,6 +38,7 @@ ALTER TABLE `0_users` ADD COLUMN `sticky_doc_date` TINYINT(1) DEFAULT '0';
 ALTER TABLE `0_debtors_master` MODIFY COLUMN `name` varchar(100) NOT NULL default '';
 ALTER TABLE `0_cust_branch` ADD COLUMN `inactive` tinyint(1) NOT NULL default '0';
 
+ALTER TABLE `0_sys_types` DROP COLUMN `type_name`;
 ALTER TABLE `0_chart_class` DROP COLUMN `sign_convert`;
 ALTER TABLE `0_chart_class` CHANGE `balance_sheet` `ctype` TINYINT(1) NOT NULL DEFAULT '0';