]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttImportHelper.class.php
Some more work in progress on subgroups.
[timetracker.git] / WEB-INF / lib / ttImportHelper.class.php
index 8be7a831070352ce06da3e410d789fa94bdf6493..6686d40f6e7087174f51f17e191c335a78f473c3 100644 (file)
@@ -335,7 +335,9 @@ class ttImportHelper {
         'chnote' => (int) $this->currentElement['SHOW_NOTE'],
         'chcf_1' => (int) $this->currentElement['SHOW_CUSTOM_FIELD_1'],
         'chunits' => (int) $this->currentElement['SHOW_WORK_UNITS'],
-        'group_by' => $this->currentElement['GROUP_BY'],
+        'group_by1' => $this->currentElement['GROUP_BY1'],
+        'group_by2' => $this->currentElement['GROUP_BY2'],
+        'group_by3' => $this->currentElement['GROUP_BY3'],
         'chtotalsonly' => (int) $this->currentElement['SHOW_TOTALS_ONLY']));
     }
     $this->currentTag = '';
@@ -472,11 +474,18 @@ class ttImportHelper {
 
     $sql = 'insert into tt_groups '.$columns.$values;
     $affected = $mdb2->exec($sql);
-    if (!is_a($affected, 'PEAR_Error')) {
-      $group_id = $mdb2->lastInsertID('tt_groups', 'id');
-      return $group_id;
-    }
-    return false;
+    if (is_a($affected, 'PEAR_Error')) return false;
+
+    $group_id = $mdb2->lastInsertID('tt_groups', 'id');
+
+    // Update org_id with group_id.
+    // NOTE: Both export and import need an additional effort to properly operate on subgroups.
+    // Currently we are importing one group only, which becomes a top level group.
+    $sql = "update tt_groups set org_id = $group_id where org_id is NULL and id = $group_id";
+    $affected = $mdb2->exec($sql);
+    if (is_a($affected, 'PEAR_Error')) return false;
+
+    return $group_id;
   }
 
   // insertMonthlyQuota - a helper function to insert a monthly quota.