From: Nik Okuntseff Date: Sun, 24 Jul 2016 18:02:29 +0000 (+0000) Subject: Implemented import of monthly quotas. X-Git-Tag: timetracker_1.19-1~1664 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=23925086e3efb3a08402c619e1b800ca15b138d5;p=timetracker.git Implemented import of monthly quotas. --- diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 29c537f3..26cdfac1 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' @@ -118,6 +119,7 @@ class ttImportHelper { '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'], @@ -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( @@ -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')); + } } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index fa785903..4c1af14e 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -701,11 +701,20 @@ class ttTeamHelper { $record_type_v = ''; } - $sql = "insert into tt_teams (name, address, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f) + $workday_hours = $fields['workday_hours']; + if ($workday_hours !== null) { + $workday_hours_f = ', workday_hours'; + $workday_hours_v = ', ' . (int)$workday_hours; + } else { + $workday_hours_f = ''; + $workday_hours_v = ''; + } + + $sql = "insert into tt_teams (name, address, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f $workday_hours_f) values(".$mdb2->quote(trim($fields['name'])). ", ".$mdb2->quote(trim($fields['address'])). ", ".$mdb2->quote(trim($fields['currency']))." $lockspec_v, ".$mdb2->quote($lang). - "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v)"; + "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v $workday_hours_v)"; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) {