From 1fe50194ffb6ae79e9b7af8e05a785c1f0f3ad7a Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 19 Mar 2018 13:20:44 +0000 Subject: [PATCH] Added handling of audit info for expenses. --- WEB-INF/lib/ttExpenseHelper.class.php | 9 ++++++--- WEB-INF/lib/ttReportHelper.class.php | 8 ++++---- WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/WEB-INF/lib/ttExpenseHelper.class.php b/WEB-INF/lib/ttExpenseHelper.class.php index 7d63ba41..8a4b1715 100644 --- a/WEB-INF/lib/ttExpenseHelper.class.php +++ b/WEB-INF/lib/ttExpenseHelper.class.php @@ -31,6 +31,7 @@ class ttExpenseHelper { // insert - inserts an entry into tt_expense_items table. static function insert($fields) { + global $user; $mdb2 = getConnection(); $date = $fields['date']; @@ -42,10 +43,11 @@ class ttExpenseHelper { $invoice_id = $fields['invoice_id']; $status = $fields['status']; $paid = (int) $fields['paid']; + $created = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); - $sql = "insert into tt_expense_items (date, user_id, client_id, project_id, name, cost, invoice_id, paid, status) ". + $sql = "insert into tt_expense_items (date, user_id, client_id, project_id, name, cost, invoice_id, paid, created, created_ip, created_by, status) ". "values (".$mdb2->quote($date).", $user_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id). - ", ".$mdb2->quote($name).", ".$mdb2->quote($cost).", ".$mdb2->quote($invoice_id).", $paid, ".$mdb2->quote($status).")"; + ", ".$mdb2->quote($name).", ".$mdb2->quote($cost).", ".$mdb2->quote($invoice_id).", $paid $created, ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -73,10 +75,11 @@ class ttExpenseHelper { if ($user->can('manage_invoices') && $user->isPluginEnabled('ps')) { $paid_part = $fields['paid'] ? ', paid = 1' : ', paid = 0'; } + $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); $sql = "UPDATE tt_expense_items set date = ".$mdb2->quote($date).", user_id = $user_id, client_id = ".$mdb2->quote($client_id). ", project_id = ".$mdb2->quote($project_id).", name = ".$mdb2->quote($name). - ", cost = ".$mdb2->quote($cost)."$paid_part, invoice_id = ".$mdb2->quote($invoice_id). + ", cost = ".$mdb2->quote($cost)."$paid_part $modified_part, invoice_id = ".$mdb2->quote($invoice_id). " WHERE id = $id"; $affected = $mdb2->exec($sql); diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index b5208bc7..ca7c83bd 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -370,10 +370,10 @@ class ttReportHelper { array_push($fields, 'ei.paid as paid'); // Add IP address. NULL for now for expenses. if ($canViewReports && $bean->getAttribute('chip')) { - array_push($fields, 'null as created'); - array_push($fields, 'null as created_ip'); - array_push($fields, 'null as modified'); - array_push($fields, 'null as modified_ip'); + array_push($fields, 'ei.created as created'); + array_push($fields, 'ei.created_ip as created_ip'); + array_push($fields, 'ei.modified as modified'); + array_push($fields, 'ei.modified_ip as modified_ip'); } // Add invoice name if it is selected. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 41ceedba..c1a6c321 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.59.4110 | Copyright © Anuko | +  Anuko Time Tracker 1.17.60.4111 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1