Removed some warnings from reports.
/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
$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
$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'>";
//------------------------------------------------------------------------------------------------
-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;
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";
}
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'));
$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");
}
//----------------------------------------------------------------------------------------------------
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)
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);
$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')));
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';