X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttImportHelper.class.php;h=753dc1654f1184118f763dee12ec92864383e59e;hb=294895b702e4c5cb5bfc87292c464bed201f296b;hp=67d60dff235b902d6f4427ad3b3ff4868ddf9020;hpb=9c676b689107fb18c634fb91ca016d3d56c76691;p=timetracker.git diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 67d60dff..753dc165 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -75,6 +75,7 @@ class ttImportHelper { || $name == 'PROJECT' || $name == 'CLIENT' || $name == 'INVOICE' + || $name == 'MONTHLY_QUOTA' || $name == 'LOG_ITEM' || $name == 'CUSTOM_FIELD' || $name == 'CUSTOM_FIELD_OPTION' @@ -115,18 +116,21 @@ class ttImportHelper { if ($this->canImport) { $team_id = ttTeamHelper::insert(array( 'name' => $this->teamData['NAME'], - 'address' => $this->teamData['ADDRESS'], 'currency' => $this->teamData['CURRENCY'], - 'lock_spec' => $this->teamData['LOCK_SPEC'], - 'lock_interval' => $this->teamData['LOCK_INTERVAL'], - 'lang' => $this->teamData['LANG'], 'decimal_mark' => $this->teamData['DECIMAL_MARK'], + 'lang' => $this->teamData['LANG'], 'date_format' => $this->teamData['DATE_FORMAT'], 'time_format' => $this->teamData['TIME_FORMAT'], 'week_start' => $this->teamData['WEEK_START'], - 'plugins' => $this->teamData['PLUGINS'], 'tracking_mode' => $this->teamData['TRACKING_MODE'], - 'record_type' => $this->teamData['RECORD_TYPE'])); + 'project_required' => $this->teamData['PROJECT_REQUIRED'], + 'task_required' => $this->teamData['TASK_REQUIRED'], + 'record_type' => $this->teamData['RECORD_TYPE'], + 'uncompleted_indicators' => $this->teamData['UNCOMPLETED_INDICATORS'], + 'bcc_email' => $this->teamData['BCC_EMAIL'], + 'plugins' => $this->teamData['PLUGINS'], + 'lock_spec' => $this->teamData['LOCK_SPEC'], + 'workday_hours' => $this->teamData['WORKDAY_HOURS'])); if ($team_id) { $this->team_id = $team_id; foreach ($this->users as $key=>$user_item) { @@ -211,6 +215,10 @@ class ttImportHelper { 'status' => $this->currentElement['STATUS'])); } + if ($name == 'MONTHLY_QUOTA' && $this->canImport) { + $this->insertMonthlyQuota($this->team_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['QUOTA']); + } + if ($name == 'LOG_ITEM' && $this->canImport) { $this->logMap[$this->currentElement['ID']] = ttTimeHelper::insert(array( @@ -226,6 +234,7 @@ class ttImportHelper { 'invoice' => $this->invoiceMap[$this->currentElement['INVOICE_ID']], 'note' => (isset($this->currentElement['COMMENT']) ? $this->currentElement['COMMENT'] : ''), 'billable' => $this->currentElement['BILLABLE'], + 'paid' => $this->currentElement['PAID'], 'status' => $this->currentElement['STATUS'])); } @@ -309,9 +318,7 @@ class ttImportHelper { || $this->currentTag == 'LABEL' || $this->currentTag == 'VALUE' || $this->currentTag == 'COMMENT' - || $this->currentTag == 'ADDRESS' - || $this->currentTag == 'CLIENT_NAME' - || $this->currentTag == 'CLIENT_ADDRESS') { + || $this->currentTag == 'ADDRESS') { if (isset($this->currentElement[$this->currentTag])) $this->currentElement[$this->currentTag] .= trim($data); else @@ -323,6 +330,8 @@ class ttImportHelper { // startElement, endElement, and dataElement functions are called as many times as necessary. // Actual import occurs in the endElement handler. function importXml() { + global $i18n; + // Do we have a compressed file? $compressed = false; $file_ext = substr($_FILES['xmlfile']['name'], strrpos($_FILES['xmlfile']['name'], '.') + 1); @@ -337,13 +346,13 @@ class ttImportHelper { // If the file is compressed - uncompress it. if ($compressed) { if (!$this->uncompress($_FILES['xmlfile']['tmp_name'], $filename)) { - $this->errors->add($GLOBALS['I18N']->getKey('error.sys')); + $this->errors->add($i18n->getKey('error.sys')); return; } unlink($_FILES['xmlfile']['tmp_name']); } else { if (!move_uploaded_file($_FILES['xmlfile']['tmp_name'], $filename)) { - $this->errors->add($GLOBALS['I18N']->getKey('error.upload')); + $this->errors->add($i18n->getKey('error.upload')); return; } } @@ -363,7 +372,7 @@ class ttImportHelper { xml_get_current_line_number($parser))); } if (!$this->canImport) { - $this->errors->add($GLOBALS['I18N']->getKey('error.user_exists')); + $this->errors->add($i18n->getKey('error.user_exists')); break; } } @@ -397,4 +406,12 @@ class ttImportHelper { fclose ($out_file); return true; } + + // insertMonthlyQuota - a helper function to insert a monthly quota. + private function insertMonthlyQuota($team_id, $year, $month, $quota) { + $mdb2 = getConnection(); + $sql = "INSERT INTO tt_monthly_quotas (team_id, year, month, quota) values ($team_id, $year, $month, $quota)"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } }