From b5c16658c0a91c98bb4e41bb6c0e1cc254222a68 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 11 Nov 2018 14:39:41 +0000 Subject: [PATCH] Integrated expense items in new export-import. --- WEB-INF/lib/ttGroupExportHelper.class.php | 19 +++++++++++++++++++ WEB-INF/lib/ttOrgImportHelper.class.php | 18 ++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/WEB-INF/lib/ttGroupExportHelper.class.php b/WEB-INF/lib/ttGroupExportHelper.class.php index aba161f6..e18f8c9f 100644 --- a/WEB-INF/lib/ttGroupExportHelper.class.php +++ b/WEB-INF/lib/ttGroupExportHelper.class.php @@ -426,6 +426,25 @@ class ttGroupExportHelper { fwrite($this->file, $this->indentation." \n"); unset($custom_field_log); + // Write expense items. + $expense_items = ttTeamHelper::getExpenseItems($this->group_id); + fwrite($this->file, $this->indentation." \n"); + foreach ($expense_items as $expense_item) { + $expense_item_part = $this->indentation.' '."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 .= ">\n"; + fwrite($this->file, $expense_item_part); + } + fwrite($this->file, $this->indentation." \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.' '); diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 17827986..89428c4c 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -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 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')); + } } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index b8cedad7..dbce25f8 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4414 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4415 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1