Started to populate org_id in tt_log and tt_invoices tables.
authorNik Okuntseff <support@anuko.com>
Wed, 7 Nov 2018 23:38:00 +0000 (23:38 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 7 Nov 2018 23:38:00 +0000 (23:38 +0000)
WEB-INF/lib/ttImportHelper.class.php
WEB-INF/lib/ttInvoiceHelper.class.php
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/lib/ttWeekViewHelper.class.php
WEB-INF/templates/footer.tpl
dbinstall.php
mobile/time.php
mobile/timer.php
time.php
time_edit.php

index 350b0c1..64a32e0 100644 (file)
@@ -241,6 +241,7 @@ class ttImportHelper {
       $this->invoiceMap[$this->currentElement['ID']] =
         ttInvoiceHelper::insert(array(
           'group_id' => $this->group_id,
+          'org_id' => $this->org_id,
           'name' => $this->currentElement['NAME'],
           'date' => $this->currentElement['DATE'],
           'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']],
@@ -257,6 +258,7 @@ class ttImportHelper {
         ttTimeHelper::insert(array(
           'user_id' => $this->userMap[$this->currentElement['USER_ID']],
           'group_id' => $this->group_id,
+          'org_id' => $this->org_id,
           'date' => $this->currentElement['DATE'],
           'start' => $this->currentElement['START'],
           'finish' => $this->currentElement['FINISH'],
index 5c5d714..3a8dbe2 100644 (file)
@@ -38,6 +38,7 @@ class ttInvoiceHelper {
     $mdb2 = getConnection();
 
     $group_id = (int) $fields['group_id'];
+    $org_id = (int) $fields['org_id'];
     $name = $fields['name'];
     if (!$name) return false;
 
@@ -49,8 +50,8 @@ class ttInvoiceHelper {
     }
 
     // Insert a new invoice record.
-    $sql = "insert into tt_invoices (group_id, name, date, client_id $status_f)".
-      " values($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)";
+    $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id $status_f)".
+      " values($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)";
     $affected = $mdb2->exec($sql);
 
     if (is_a($affected, 'PEAR_Error')) return false;
@@ -330,8 +331,8 @@ class ttInvoiceHelper {
     if (isset($fields['project_id'])) $project_id = (int) $fields['project_id'];
 
     // Create a new invoice record.
-    $sql = "insert into tt_invoices (group_id, name, date, client_id) values(".
-            $user->getActiveGroup().", ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)";
+    $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id) values(".
+      $user->getActiveGroup().", $user->org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;
 
index e302035..2450678 100644 (file)
@@ -391,6 +391,7 @@ class ttTimeHelper {
 
     $user_id = (int) $fields['user_id'];
     $group_id = (int) $fields['group_id'];
+    $org_id = (int) $fields['org_id'];
     $date = $fields['date'];
     $start = $fields['start'];
     $finish = $fields['finish'];
@@ -423,8 +424,8 @@ class ttTimeHelper {
     if (!$paid) $paid = 0;
 
     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, $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)";
+      $sql = "insert into tt_log (user_id, group_id, org_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
+        "values ($user_id, $group_id, $org_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;
@@ -433,8 +434,8 @@ class ttTimeHelper {
       if ($duration === false) $duration = 0;
       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, $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)";
+      $sql = "insert into tt_log (user_id, group_id, org_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, $group_id, $org_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 dcb39af..53065d3 100644 (file)
@@ -494,6 +494,7 @@ class ttWeekViewHelper {
     $fields4insert = array();
     $fields4insert['user_id'] = $user->getActiveUser();
     $fields4insert['group_id'] = $user->getActiveGroup();
+    $fields4insert['org_id'] = $user->org_id;
     $fields4insert['date'] = $entry_date;
     $fields4insert['duration'] = $fields['duration'];
     $fields4insert['client'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'cl');
index 4f98ebc..98b2ad5 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.18.11.4385 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.11.4386 | 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 a2ff433..1c5fa90 100644 (file)
@@ -982,6 +982,8 @@ if ($_POST) {
     setChange("ALTER TABLE `tt_log` ADD `org_id` int(11) default NULL AFTER `group_id`");
     setChange("ALTER TABLE `tt_invoices` ADD `org_id` int(11) default NULL AFTER `group_id`");
     setChange("UPDATE `tt_site_config` SET param_value = '1.18.11', modified = now() where param_name = 'version_db' and param_value = '1.18.10'");
+    setChange("UPDATE `tt_log` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.11') set org_id = group_id where org_id is null");
+    setChange("UPDATE `tt_invoices` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.11') set org_id = group_id where org_id is null");
   }
 
   if ($_POST["cleanup"]) {
index 76296f6..a25cf90 100644 (file)
@@ -253,6 +253,7 @@ if ($request->isPost()) {
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
         'group_id' => $user->getActiveGroup(),
+        'org_id' => $user->org_id,
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,
index 09500bd..2f5dbad 100644 (file)
@@ -226,6 +226,7 @@ if ($request->isPost()) {
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
         'group_id' => $user->getActiveGroup(),
+        'org_id' => $user->org_id,
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,
index 258f15c..68aaf40 100644 (file)
--- a/time.php
+++ b/time.php
@@ -313,6 +313,7 @@ if ($request->isPost()) {
         'date' => $cl_date,
         'user_id' => $user->getActiveUser(),
         'group_id' => $user->getActiveGroup(),
+        'org_id' => $user->org_id,
         'client' => $cl_client,
         'project' => $cl_project,
         'task' => $cl_task,
index 5f40688..21c3eff 100644 (file)
@@ -366,6 +366,7 @@ if ($request->isPost()) {
         'date'=>$new_date->toString(DB_DATEFORMAT),
         'user_id'=>$user->getActiveUser(),
         'group_id'=>$user->getActiveGroup(),
+        'org_id' => $user->org_id,
         'client'=>$cl_client,
         'project'=>$cl_project,
         'task'=>$cl_task,