]> wagnertech.de Git - timetracker.git/commitdiff
Started to populate group_id on new time entry inserts.
authorNik Okuntseff <support@anuko.com>
Sat, 28 Jul 2018 18:15:05 +0000 (18:15 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 28 Jul 2018 18:15:05 +0000 (18:15 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
mobile/time.php
mobile/timer.php
time.php

index bfb81cc32d538d816fda53832e0bb3dee305bc79..5ad07e18f6202efb8f256270e8168b32fc9f8083 100644 (file)
@@ -383,13 +383,14 @@ class ttTimeHelper {
     return false;
   }
 
-  // insert - inserts a time record into log table. Does not deal with custom fields.
+  // insert - inserts a time record into tt_log table. Does not deal with custom fields.
   static function insert($fields)
   {
     global $user;
     $mdb2 = getConnection();
 
     $user_id = $fields['user_id'];
+    $group_id = $fields['group_id'];
     $date = $fields['date'];
     $start = $fields['start'];
     $finish = $fields['finish'];
@@ -422,8 +423,8 @@ class ttTimeHelper {
     if (!$paid) $paid = 0;
 
     if ($duration) {
-      $sql = "insert into tt_log (user_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($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+      $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)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -432,8 +433,8 @@ class ttTimeHelper {
       if ($duration === false) $duration = 0;
       if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false;
 
-      $sql = "insert into tt_log (user_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($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+      $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)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
index e498cde0e822302559ec427d678d71c0287aeddc..65a1f5962ee81c381c55ae4880cf38bd9a599734 100644 (file)
@@ -38,7 +38,9 @@ class ttUser {
   var $rank = null;             // User role rank.
   var $client_id = null;        // Client id for client user role.
   var $behalf_id = null;        // User id, on behalf of whom we are working.
+  var $behalf_group_id = null;  // Group id, on behalf of which we are working.
   var $behalf_name = null;      // User name, on behalf of whom we are working.
+  var $behalf_group = null;     // Group name, on behalf of which we are working.
   var $email = null;            // User email.
   var $lang = null;             // Language.
   var $decimal_mark = null;     // Decimal separator.
@@ -143,11 +145,16 @@ class ttUser {
         $this->unit_totals_only = $config->getDefinedValue('unit_totals_only');
       }
       
-      // Set "on behalf" id and name.
+      // Set "on behalf" id and name (user).
       if (isset($_SESSION['behalf_id'])) {
           $this->behalf_id = $_SESSION['behalf_id'];
           $this->behalf_name = $_SESSION['behalf_name'];
       }
+      // Set "on behalf" id and name (group).
+      if (isset($_SESSION['behalf_group_id'])) {
+          $this->behalf_group_id = $_SESSION['behalf_group_id'];
+          $this->behalf_group = $_SESSION['behalf_group'];
+      }
     }
   }
 
@@ -156,6 +163,11 @@ class ttUser {
     return ($this->behalf_id ? $this->behalf_id : $this->id);
   }
 
+  // The getActiveGroup returns group id on behalf of which the current user is operating.
+  function getActiveGroup() {
+    return ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id);
+  }
+
   // can - determines whether user has a right to do something.
   function can($do_something) {
     return in_array($do_something, $this->rights);
index c0fe9a67d8bfcfb093bef89d5899c3f477460ee2..e20ac62dfb42d01ca11087d0ceba33d971041597 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.4296 | 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.4297 | 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 2649ff279d0317261c0174a3933ee59c6eecc2a6..76296f64be5d07c93a339d598ab6095f98e961d0 100644 (file)
@@ -252,6 +252,7 @@ if ($request->isPost()) {
       $id = ttTimeHelper::insert(array(
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
+        'group_id' => $user->getActiveGroup(),
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,
index e547c256d7e4491f46f5673ffcdb45e91ad4913f..09500bd22b4b21305e9c9c29ac6147c3e93f2dbc 100644 (file)
@@ -225,6 +225,7 @@ if ($request->isPost()) {
       $id = ttTimeHelper::insert(array(
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
+        'group_id' => $user->getActiveGroup(),
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,
index d4caad2b171ff96a1389077daa0feda6426e568f..98f6bbaf6e1623b4d7428b4fc4a543fa4ed83903 100644 (file)
--- a/time.php
+++ b/time.php
@@ -293,6 +293,7 @@ if ($request->isPost()) {
       $id = ttTimeHelper::insert(array(
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
+        'group_id' => $user->getActiveGroup(),
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,