Added handling of audit info for expenses.
authorNik Okuntseff <support@anuko.com>
Mon, 19 Mar 2018 13:20:44 +0000 (13:20 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 19 Mar 2018 13:20:44 +0000 (13:20 +0000)
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttReportHelper.class.php
WEB-INF/templates/footer.tpl

index 7d63ba4..8a4b171 100644 (file)
@@ -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);
index b5208bc..ca7c83b 100644 (file)
@@ -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.
index 41ceedb..c1a6c32 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.59.4110 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.60.4111 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>