Another small iteration for new export.
authorNik Okuntseff <support@anuko.com>
Mon, 5 Nov 2018 16:53:55 +0000 (16:53 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 5 Nov 2018 16:53:55 +0000 (16:53 +0000)
WEB-INF/lib/ttGroupExportHelper.class.php
WEB-INF/templates/footer.tpl

index 59a19be..364f984 100644 (file)
@@ -49,7 +49,7 @@ class ttGroupExportHelper {
     // 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";
+            " where status = 1 and parent_id = $this->group_id and org_id = $user->org_id";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
       while ($val = $res->fetchRow()) {
@@ -58,14 +58,35 @@ class ttGroupExportHelper {
     }
   }
 
+  // getGroupData obtains group attributes for export.
+  function getGroupData() {
+    global $user;
+
+    $mdb2 = getConnection();
+    $sql =  "select name, currency, lang from tt_groups".
+            " where status = 1 and id = $this->group_id and org_id = $user->org_id";
+    $res = $mdb2->query($sql);
+    if (!is_a($res, 'PEAR_Error')) {
+      $val = $res->fetchRow();
+    }
+    return $val;
+  }
+
   // writeData writes group data into file.
   function writeData() {
-    // TODO: write code here.
 
-    // Write group info. Something dummy for now to test...
-    fwrite($this->file, $this->indentation."<group>\n");
+    // Write group info.
+    $group = $this->getGroupData();
+    $group_part = "<group name=\"".htmlentities($group['name'])."\"";
+    $group_part .= " currency=\"".htmlentities($group['currency'])."\"";
+    $group_part .= " lang=\"".$group['lang']."\"";
+    // TODO: add other group attributes here.
+    $group_part .= ">\n";
+
+    // Write group info.
+    fwrite($this->file, $this->indentation.$group_part);
 
-    // Call itself recursively for all subgroups.
+    // Call self recursively for all subgroups.
     foreach ($this->subgroups as $subgroup) {
       $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.'  ');
       $subgroup_helper->writeData();
index 5b27516..058c96f 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.4367 | 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.4368 | 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>