From: Nik Okuntseff Date: Sat, 10 Nov 2018 15:17:30 +0000 (+0000) Subject: Improved new import with integrating clients. X-Git-Tag: timetracker_1.19-1~667 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a9354220ac7de34e59172d112884acab96f37538;p=timetracker.git Improved new import with integrating clients. --- diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index f8dbc523..7c00f254 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -30,6 +30,7 @@ import('ttUserHelper'); import('ttRoleHelper'); import('ttTaskHelper'); import('ttProjectHelper'); +import('ttClientHelper'); // ttOrgImportHelper - this class is a future replacement for ttImportHelper. // Currently, it is work in progress. @@ -51,11 +52,7 @@ class ttOrgImportHelper { var $currentGroupRoleMap = array(); var $currentGroupTaskMap = array(); var $currentGroupProjectMap = array(); - //var $userMap = array(); // User ids. - //var $projectMap = array(); // Project ids. - //var $taskMap = array(); // Task ids. - //var $clientMap = array(); // Client ids. - //var $invoiceMap = array(); // Invoice ids. + var $currentGroupClientMap = array(); // Constructor. function __construct(&$errors) { @@ -173,6 +170,35 @@ class ttOrgImportHelper { $this->currentGroupProjectMap[$attrs['ID']] = $project_id; } else $this->errors->add($i18n->get('error.db')); } + + if ($name == 'CLIENTS') { + // If we get here, we have to recycle $currentGroupClientMap. + unset($this->currentGroupClientMap); + $this->currentGroupClientMap = array(); + // Client map is reconstructed after processing elements in XML. See below. + } + + if ($name == 'CLIENT') { + // We get here when processing tags for the current group. + + // Prepare a list of project ids. + $projects = explode(',', $attrs['PROJECTS']); + foreach ($projects as $id) + $mapped_projects[] = $this->currentGroupProjectMap[$id]; + + $client_id = ttClientHelper::insert(array( + 'group_id' => $this->current_group_id, + 'org_id' => $this->org_id, + 'name' => $attrs['NAME'], + 'address' => $attrs['ADDRESS'], + 'tax' => $attrs['TAX'], + 'projects' => $mapped_projects, + 'status' => $attrs['STATUS'])); + if ($client_id) { + // Add a mapping. + $this->currentGroupClientMap[$attrs['ID']] = $client_id; + } else $this->errors->add($i18n->get('error.db')); + } } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4d6e74da..d4275c18 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4405 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4406 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}