X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttImportHelper.class.php;h=99b35e4119605bad815879c85a6113428573bb7c;hb=e732e1dd5c8a5cfaa24f5690ede39be2a90d0e3d;hp=29c537f360289f849dba960f49220e53a044aa95;hpb=51d4d0c0575e14bf8cbfa81cfdef08361f075f71;p=timetracker.git diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 29c537f3..99b35e41 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,9 +116,9 @@ 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'], + 'workday_hours' => $this->teamData['WORKDAY_HOURS'], 'lang' => $this->teamData['LANG'], 'decimal_mark' => $this->teamData['DECIMAL_MARK'], 'date_format' => $this->teamData['DATE_FORMAT'], @@ -125,6 +126,7 @@ class ttImportHelper { 'week_start' => $this->teamData['WEEK_START'], 'plugins' => $this->teamData['PLUGINS'], 'tracking_mode' => $this->teamData['TRACKING_MODE'], + 'task_required' => $this->teamData['TASK_REQUIRED'], 'record_type' => $this->teamData['RECORD_TYPE'])); if ($team_id) { $this->team_id = $team_id; @@ -210,6 +212,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( @@ -308,9 +314,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 @@ -322,6 +326,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); @@ -336,13 +342,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; } } @@ -362,7 +368,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; } } @@ -396,4 +402,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')); + } }