A bit more progress on new export.
authorNik Okuntseff <support@anuko.com>
Mon, 5 Nov 2018 15:40:55 +0000 (15:40 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 5 Nov 2018 15:40:55 +0000 (15:40 +0000)
WEB-INF/lib/ttGroupExportHelper.class.php
WEB-INF/templates/footer.tpl

index 3313854..59a19be 100644 (file)
 // When done, it should handle export of organizations containing multiple groups.
 class ttGroupExportHelper {
 
-  var $group_id = null;    // Group we are exporting.
-  var $file     = null;    // File to write to.
-  var $indentation = null; // A string consisting of a number of spaces.
+  var $group_id = null;     // Group we are exporting.
+  var $file     = null;     // File to write to.
+  var $indentation = null;  // A string consisting of a number of spaces.
+  var $subgroups = array(); // Immediate subgroups.
 
   // Constructor.
   function __construct($group_id, $file, $indentation) {
+    global $user;
 
     $this->group_id = $group_id;
     $this->file = $file;
     $this->indentation = $indentation;
 
-    // TODO: Build a list of subgroups here.
+    // Build a list of subgroups.
+    $mdb2 = getConnection();
+    $sql =  "select id from tt_groups".
+            " where status = 1 and parent_id = $this->group_id and org_id = $user->org_id order by id desc";
+    $res = $mdb2->query($sql);
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $this->subgroups[] = $val;
+      }
+    }
   }
 
   // writeData writes group data into file.
@@ -53,9 +64,13 @@ class ttGroupExportHelper {
 
     // Write group info. Something dummy for now to test...
     fwrite($this->file, $this->indentation."<group>\n");
-    fwrite($this->file, $this->indentation."</group>\n");
-    //
-    //
+
     // Call itself recursively for all subgroups.
+    foreach ($this->subgroups as $subgroup) {
+      $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.'  ');
+      $subgroup_helper->writeData();
+    }
+
+    fwrite($this->file, $this->indentation."</group>\n");
   }
 }
index af3f176..5b27516 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.07.4366 | 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.07.4367 | 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>