From: Nik Okuntseff Date: Sun, 11 Nov 2018 15:09:54 +0000 (+0000) Subject: Added monthly quotas to new export-import. X-Git-Tag: timetracker_1.19-1~657 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a4298d704504e90da27dfdae71aaf6cc2faa9844;p=timetracker.git Added monthly quotas to new export-import. --- diff --git a/WEB-INF/lib/ttGroupExportHelper.class.php b/WEB-INF/lib/ttGroupExportHelper.class.php index e18f8c9f..b1aa35c0 100644 --- a/WEB-INF/lib/ttGroupExportHelper.class.php +++ b/WEB-INF/lib/ttGroupExportHelper.class.php @@ -445,6 +445,18 @@ class ttGroupExportHelper { fwrite($this->file, $this->indentation." \n"); unset($expense_items); + // Write monthly quotas. + $quotas = ttTeamHelper::getMonthlyQuotas($this->group_id); + fwrite($this->file, $this->indentation." \n"); + foreach ($quotas as $quota) { + $quota_part = $this->indentation.' '."file, $quota_part); + } + fwrite($this->file, $this->indentation." \n"); + // Call self recursively for all subgroups. foreach ($this->subgroups as $subgroup) { $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.' '); diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 89428c4c..cc632f18 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -388,6 +388,16 @@ class ttOrgImportHelper { 'status' => $attrs['STATUS'])); if (!$expense_item_id) $this->errors->add($i18n->get('error.db')); } + + if ($name == 'MONTHLY_QUOTA') { + if (!$this->insertMonthlyQuota($this->current_group_id, + // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table. + $attrs['YEAR'], + $attrs['MONTH'], + $attrs['MINUTES'])) { + $this->errors->add($i18n->get('error.db')); + } + } } } @@ -548,4 +558,12 @@ class ttOrgImportHelper { $group_id = $mdb2->lastInsertID('tt_groups', 'id'); return $group_id; } + + // insertMonthlyQuota - a helper function to insert a monthly quota. + private function insertMonthlyQuota($group_id, $year, $month, $minutes) { + $mdb2 = getConnection(); + $sql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index dbce25f8..338b37b4 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4415 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4416 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}