From: Nik Okuntseff Date: Sat, 10 Nov 2018 21:20:54 +0000 (+0000) Subject: Improved new export-import by adding invoices. X-Git-Tag: timetracker_1.19-1~663 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e88a31092d2dbcd535a1704ed4410e92ca3be914;p=timetracker.git Improved new export-import by adding invoices. --- diff --git a/WEB-INF/lib/ttGroupExportHelper.class.php b/WEB-INF/lib/ttGroupExportHelper.class.php index 125df0ff..91a36ce9 100644 --- a/WEB-INF/lib/ttGroupExportHelper.class.php +++ b/WEB-INF/lib/ttGroupExportHelper.class.php @@ -45,6 +45,7 @@ class ttGroupExportHelper { var $taskMap = array(); // Task ids. var $projectMap = array(); // Project ids. var $clientMap = array(); // Client ids. + var $invoiceMap = array(); // Invoice ids. // Constructor. function __construct($group_id, $file, $indentation) { @@ -224,6 +225,11 @@ class ttGroupExportHelper { foreach ($clients as $key=>$client_item) $this->clientMap[$client_item['id']] = $key + 1; + // Prepare invoice map. + $invoices = ttTeamHelper::getAllInvoices(); + foreach ($invoices as $key=>$invoice_item) + $this->invoiceMap[$invoice_item['id']] = $key + 1; + // Write roles. fwrite($this->file, $this->indentation." \n"); foreach ($roles as $role) { @@ -324,6 +330,19 @@ class ttGroupExportHelper { } fwrite($this->file, $this->indentation." \n"); + // Write invoices. + fwrite($this->file, $this->indentation." \n"); + foreach ($invoices as $invoice_item) { + $invoice_part = $this->indentation.' '."invoiceMap[$invoice_item['id']]."\""; + $invoice_part .= " name=\"".htmlentities($invoice_item['name'])."\""; + $invoice_part .= " date=\"".$invoice_item['date']."\""; + $invoice_part .= " client_id=\"".$this->clientMap[$invoice_item['client_id']]."\""; + $invoice_part .= " status=\"".$invoice_item['status']."\""; + $invoice_part .= ">\n"; + fwrite($this->file, $invoice_part); + } + fwrite($this->file, $this->indentation." \n"); + // 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/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index ea899821..7fa1e283 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -247,7 +247,6 @@ class ttImportHelper { 'name' => $this->currentElement['NAME'], 'date' => $this->currentElement['DATE'], 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']], - 'discount' => $this->currentElement['DISCOUNT'], 'status' => $this->currentElement['STATUS'])); } diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index ccdc05b2..01566880 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -31,6 +31,7 @@ import('ttRoleHelper'); import('ttTaskHelper'); import('ttProjectHelper'); import('ttClientHelper'); +import('ttInvoiceHelper'); // ttOrgImportHelper - this class is a future replacement for ttImportHelper. // Currently, it is work in progress. @@ -52,6 +53,7 @@ class ttOrgImportHelper { var $currentGroupProjectMap = array(); var $currentGroupClientMap = array(); var $currentGroupUserMap = array(); + var $currentGroupInvoiceMap = array(); // Constructor. function __construct(&$errors) { @@ -255,6 +257,28 @@ class ttOrgImportHelper { $this->errors->add($i18n->get('error.db')); } } + + if ($name == 'INVOICES') { + // If we get here, we have to recycle $currentGroupInvoiceMap. + unset($this->currentGroupInvoiceMap); + $this->currentGroupInvoiceMap = array(); + // Invoice map is reconstructed after processing elements in XML. See below. + } + + if ($name == 'INVOICE') { + // We get here when processing tags for the current group. + $invoice_id = ttInvoiceHelper::insert(array( + 'group_id' => $this->current_group_id, + 'org_id' => $this->org_id, + 'name' => $attrs['NAME'], + 'date' => $attrs['DATE'], + 'client_id' => $this->currentGroupClientMap[$attrs['CLIENT_ID']], + 'status' => $attrs['STATUS'])); + if ($invoice_id) { + // Add a mapping. + $this->currentGroupInvoiceMap[$attrs['ID']] = $invoice_id; + } else $this->errors->add($i18n->get('error.db')); + } } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index cff88227..8995b12b 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4409 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4410 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}