Integrated expense items in new export-import.
authorNik Okuntseff <support@anuko.com>
Sun, 11 Nov 2018 14:39:41 +0000 (14:39 +0000)
committerNik Okuntseff <support@anuko.com>
Sun, 11 Nov 2018 14:39:41 +0000 (14:39 +0000)
WEB-INF/lib/ttGroupExportHelper.class.php
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/templates/footer.tpl

index aba161f..e18f8c9 100644 (file)
@@ -426,6 +426,25 @@ class ttGroupExportHelper {
     fwrite($this->file, $this->indentation."  </custom_field_log>\n");
     unset($custom_field_log);
 
+    // Write expense items.
+    $expense_items = ttTeamHelper::getExpenseItems($this->group_id);
+    fwrite($this->file, $this->indentation."  <expense_items>\n");
+    foreach ($expense_items as $expense_item) {
+      $expense_item_part = $this->indentation.'    '."<expense_item date=\"".$expense_item['date']."\"";
+      $expense_item_part .= " user_id=\"".$this->userMap[$expense_item['user_id']]."\"";
+      $expense_item_part .= " client_id=\"".$this->clientMap[$expense_item['client_id']]."\"";
+      $expense_item_part .= " project_id=\"".$this->projectMap[$expense_item['project_id']]."\"";
+      $expense_item_part .= " name=\"".htmlentities($expense_item['name'])."\"";
+      $expense_item_part .= " cost=\"".$expense_item['cost']."\"";
+      $expense_item_part .= " invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\"";
+      $expense_item_part .= " paid=\"".$expense_item['paid']."\"";
+      $expense_item_part .= " status=\"".$expense_item['status']."\"";
+      $expense_item_part .= "></expense_item>\n";
+      fwrite($this->file, $expense_item_part);
+    }
+    fwrite($this->file, $this->indentation."  </expense_items>\n");
+    unset($expense_items);
+
     // Call self recursively for all subgroups.
     foreach ($this->subgroups as $subgroup) {
       $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.'  ');
index 1782798..89428c4 100644 (file)
@@ -33,6 +33,7 @@ import('ttProjectHelper');
 import('ttClientHelper');
 import('ttInvoiceHelper');
 import('ttCustomFieldHelper');
+import('ttExpenseHelper');
 
 // ttOrgImportHelper - this class is a future replacement for ttImportHelper.
 // Currently, it is work in progress.
@@ -370,6 +371,23 @@ class ttOrgImportHelper {
           $this->errors->add($i18n->get('error.db'));
         }
       }
+
+      if ($name == 'EXPENSE_ITEM') {
+        // We get here when processing <expense_item> tags for the current group.
+        $expense_item_id = ttExpenseHelper::insert(array(
+          'date' => $attrs['DATE'],
+          'user_id' => $this->currentGroupUserMap[$attrs['USER_ID']],
+          'group_id' => $this->current_group_id,
+          // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table.
+          'client_id' => $this->currentGroupClientMap[$attrs['CLIENT_ID']],
+          'project_id' => $this->currentGroupProjectMap[$attrs['PROJECT_ID']],
+          'name' => $attrs['NAME'],
+          'cost' => $attrs['COST'],
+          'invoice_id' => $this->currentGroupInvoiceMap[$attrs['INVOICE_ID']],
+          'paid' => $attrs['PAID'],
+          'status' => $attrs['STATUS']));
+        if (!$expense_item_id) $this->errors->add($i18n->get('error.db'));
+      }
     }
   }
 
index b8cedad..dbce25f 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.12.4414 | 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.12.4415 | 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>