X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep710.php;h=1c2e86ecfd2e62d57f292a1668b6abd6eac4f0a3;hb=11e485e4a7c5f12c9424713b7330815a9cc5e4ae;hp=9c1df5f16e6d39f8cdcec49fec743b7bea0a2bc9;hpb=b42adf7edd906956a0f9cf21c0ec2b66007b9585;p=fa-stable.git diff --git a/reporting/rep710.php b/reporting/rep710.php index 9c1df5f1..1c2e86ec 100644 --- a/reporting/rep710.php +++ b/reporting/rep710.php @@ -9,12 +9,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 15; +$page_security = 'SA_GLANALYTIC'; // ---------------------------------------------------------------- // $ Revision: 2.0 $ // Creator: Joe Hunt // date_: 2005-05-19 -// Title: List of Journal Entries +// Title: Audit Trail // ---------------------------------------------------------------- $path_to_root=".."; @@ -30,25 +30,25 @@ print_audit_trail(); 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 "; + $fromdate = date2sql($from) . " 00:00:00"; + $todate = date2sql($to). " 23:59.59"; + + $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 a.stamp >= '$fromdate' + AND 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);