X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/b06601362567c117bdc889277d554c8c58f0efdc..e88a31092d2dbcd535a1704ed4410e92ca3be914:/WEB-INF/lib/ttOrgImportHelper.class.php 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')); + } } }