Ongoing refactoring - renamed a variable.
[timetracker.git] / WEB-INF / lib / ttImportHelper.class.php
index 67d60df..26cdfac 100644 (file)
@@ -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'
@@ -118,7 +119,7 @@ class ttImportHelper {
           'address' => $this->teamData['ADDRESS'],
           'currency' => $this->teamData['CURRENCY'],
           'lock_spec' => $this->teamData['LOCK_SPEC'],
-          'lock_interval' => $this->teamData['LOCK_INTERVAL'],
+          'workday_hours' => $this->teamData['WORKDAY_HOURS'],
           'lang' => $this->teamData['LANG'],
           'decimal_mark' => $this->teamData['DECIMAL_MARK'],
           'date_format' => $this->teamData['DATE_FORMAT'],
@@ -211,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(
@@ -397,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'));
+  }
 }