More progress on storing group_id on new inserts.
authorNik Okuntseff <support@anuko.com>
Sat, 28 Jul 2018 18:50:15 +0000 (18:50 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 28 Jul 2018 18:50:15 +0000 (18:50 +0000)
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttImportHelper.class.php
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/lib/ttWeekViewHelper.class.php
WEB-INF/templates/footer.tpl
expense_edit.php
expenses.php
mobile/expense_edit.php
mobile/expenses.php
time_edit.php

index 8a4b171..6d3128f 100644 (file)
@@ -36,6 +36,7 @@ class ttExpenseHelper {
 
     $date = $fields['date'];
     $user_id = (int) $fields['user_id'];
+    $group_id = (int) $fields['group_id'];
     $client_id = $fields['client_id'];
     $project_id = $fields['project_id'];
     $name = $fields['name'];
@@ -45,8 +46,8 @@ class ttExpenseHelper {
     $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, created, created_ip, created_by, status) ".
-      "values (".$mdb2->quote($date).", $user_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id).
+    $sql = "insert into tt_expense_items (date, user_id, group_id, client_id, project_id, name, cost, invoice_id, paid, created, created_ip, created_by, status) ".
+      "values (".$mdb2->quote($date).", $user_id, $group_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id).
       ", ".$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'))
index 7b68ba7..8be7a83 100644 (file)
@@ -248,6 +248,7 @@ class ttImportHelper {
       $this->logMap[$this->currentElement['ID']] =
         ttTimeHelper::insert(array(
           'user_id' => $this->userMap[$this->currentElement['USER_ID']],
+          'group_id' => $this->group_id,
           'date' => $this->currentElement['DATE'],
           'start' => $this->currentElement['START'],
           'finish' => $this->currentElement['FINISH'],
@@ -292,6 +293,7 @@ class ttImportHelper {
       ttExpenseHelper::insert(array(
         'date' => $this->currentElement['DATE'],
         'user_id' => $this->userMap[$this->currentElement['USER_ID']],
+        'group_id' => $this->group_id,
         'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']],
         'project_id' => $this->projectMap[$this->currentElement['PROJECT_ID']],
         'name' => $this->currentElement['NAME'],
index 5ad07e1..e302035 100644 (file)
@@ -389,8 +389,8 @@ class ttTimeHelper {
     global $user;
     $mdb2 = getConnection();
 
-    $user_id = $fields['user_id'];
-    $group_id = $fields['group_id'];
+    $user_id = (int) $fields['user_id'];
+    $group_id = (int) $fields['group_id'];
     $date = $fields['date'];
     $start = $fields['start'];
     $finish = $fields['finish'];
@@ -424,7 +424,7 @@ class ttTimeHelper {
 
     if ($duration) {
       $sql = "insert into tt_log (user_id, group_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
-        "values ($user_id, ".$mdb2->quote($group_id).", ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+        "values ($user_id, $group_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -434,7 +434,7 @@ class ttTimeHelper {
       if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false;
 
       $sql = "insert into tt_log (user_id, group_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
-        "values ($user_id, ".$mdb2->quote($group_id).", ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+        "values ($user_id, $group_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
index 27a1bbc..dcb39af 100644 (file)
@@ -493,6 +493,7 @@ class ttWeekViewHelper {
     // Prepare an array of fields for regular insert function.
     $fields4insert = array();
     $fields4insert['user_id'] = $user->getActiveUser();
+    $fields4insert['group_id'] = $user->getActiveGroup();
     $fields4insert['date'] = $entry_date;
     $fields4insert['duration'] = $fields['duration'];
     $fields4insert['client'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'cl');
index e20ac62..df6d91d 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.96.4297 | 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.96.4298 | 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>
index 26cf3bb..353f5ce 100644 (file)
@@ -205,7 +205,7 @@ if ($request->isPost()) {
 
     // Now, a new insert.
     if ($err->no()) {
-      if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),
+      if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(),
         'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) {
         header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT));
         exit();
index 7d7295d..fa45ad4 100644 (file)
@@ -188,7 +188,7 @@ if ($request->isPost()) {
 
     // Insert record.
     if ($err->no()) {
-      if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),
+      if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(),
         'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) {
         header('Location: expenses.php');
         exit();
index f560f55..338e6c7 100644 (file)
@@ -200,7 +200,7 @@ if ($request->isPost()) {
 
     // Now, a new insert.
     if ($err->no()) {
-      if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),
+      if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(),
         'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) {
         header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT));
         exit();
index c853a2c..25a1c60 100644 (file)
@@ -192,7 +192,7 @@ if ($request->isPost()) {
 
     // Insert record.
     if ($err->no()) {
-      if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),
+      if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(),
         'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) {
         header('Location: expenses.php');
         exit();
index fd1851d..5f40688 100644 (file)
@@ -365,6 +365,7 @@ if ($request->isPost()) {
       $id = ttTimeHelper::insert(array(
         'date'=>$new_date->toString(DB_DATEFORMAT),
         'user_id'=>$user->getActiveUser(),
+        'group_id'=>$user->getActiveGroup(),
         'client'=>$cl_client,
         'project'=>$cl_project,
         'task'=>$cl_task,