From: Nik Okuntseff Date: Mon, 29 Jan 2018 19:08:10 +0000 (+0000) Subject: Fixed monthly quotas for non-integer workday hours. X-Git-Tag: timetracker_1.19-1~1283 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d27b08cc3e9c657bdb361379657d185f0ea47485;p=timetracker.git Fixed monthly quotas for non-integer workday hours. --- diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ddcbe995..33aca876 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - - + +
 Anuko Time Tracker 1.17.9.3834 | Copyright © Anuko | +  Anuko Time Tracker 1.17.10.3835 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index e8c68848..00b9c382 100755 --- a/dbinstall.php +++ b/dbinstall.php @@ -709,13 +709,14 @@ if ($_POST) { setChange("ALTER TABLE `tt_log` ADD `paid` tinyint(4) NULL default '0' AFTER `billable`"); } - if ($_POST["convert11400to11707"]) { + if ($_POST["convert11400to11710"]) { setChange("ALTER TABLE `tt_teams` DROP `address`"); setChange("ALTER TABLE `tt_fav_reports` ADD `report_spec` text default NULL AFTER `user_id`"); setChange("ALTER TABLE `tt_fav_reports` ADD `paid_status` tinyint(4) default NULL AFTER `invoice`"); setChange("ALTER TABLE `tt_fav_reports` ADD `show_paid` tinyint(4) NOT NULL DEFAULT '0' AFTER `show_invoice`"); setChange("ALTER TABLE `tt_expense_items` ADD `paid` tinyint(4) NULL default '0' AFTER `invoice_id`"); setChange("ALTER TABLE `tt_monthly_quotas` MODIFY `quota` decimal(5,2) NOT NULL"); + setChange("ALTER TABLE `tt_teams` MODIFY `workday_hours` decimal(5,2) DEFAULT '8.00'"); } if ($_POST["cleanup"]) { @@ -760,7 +761,7 @@ if ($_POST) {

DB Install

-
Create database structure (v1.17.7) + Create database structure (v1.17.10)
(applies only to new installations, do not execute when updating)
@@ -796,8 +797,8 @@ if ($_POST) {

Update database structure (v1.14 to v1.17.7)
Update database structure (v1.14 to v1.17.10)
diff --git a/mysql.sql b/mysql.sql index 96e14924..d6e1d2d3 100644 --- a/mysql.sql +++ b/mysql.sql @@ -31,7 +31,7 @@ CREATE TABLE `tt_teams` ( `plugins` varchar(255) default NULL, # a list of enabled plugins for team `lock_spec` varchar(255) default NULL, # Cron specification for record locking, # for example: "0 10 * * 1" for "weekly on Mon at 10:00". - `workday_hours` smallint(6) DEFAULT '8', # number of work hours in a regular day + `workday_hours` decimal(5,2) DEFAULT '8.00', # number of work hours in a regular day `custom_logo` tinyint(4) default '0', # whether to use a custom logo or not `status` tinyint(4) default '1', # team status PRIMARY KEY (`id`) diff --git a/plugins/MonthlyQuota.class.php b/plugins/MonthlyQuota.class.php index 4fed3c90..4b036796 100644 --- a/plugins/MonthlyQuota.class.php +++ b/plugins/MonthlyQuota.class.php @@ -139,7 +139,7 @@ class MonthlyQuota { } // quotaToFloat converts a valid quota value to a float. - private function quotaToFloat($value) { + public function quotaToFloat($value) { if (preg_match('/^[0-9]{1,3}h?$/', $value )) { // 000 - 999 return (float) $value; diff --git a/quotas.php b/quotas.php index 10653893..d3e7912e 100644 --- a/quotas.php +++ b/quotas.php @@ -71,6 +71,9 @@ $quota = new MonthlyQuota(); if ($request->isPost()){ // Validate user input. + if (!ttTimeHelper::isValidDuration($request->getParameter('workdayHours'))) + $err->add($i18n->getKey('error.field'), $i18n->getKey('form.quota.workday_hours')); + for ($i = 0; $i < count($months); $i++){ $val = $request->getParameter($months[$i]); if (!$quota->isValidQuota($val)) @@ -81,7 +84,7 @@ if ($request->isPost()){ if ($err->no()) { // Handle workday hours. - $hours = (int)$request->getParameter('workdayHours'); + $hours = $quota->quotaToFloat($request->getParameter('workdayHours')); if ($hours != $user->workday_hours) { if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_hours'=>$hours))) $err->add($i18n->getKey('error.db')); @@ -104,9 +107,10 @@ if ($request->isPost()){ // Get monthly quotas for the entire year. $monthsData = $quota->get($selectedYear); +$workdayHours = ttTimeHelper::toAbsDuration($user->workday_hours * 60, true); $form = new Form('monthlyQuotasForm'); -$form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$user->workday_hours, 'style'=>'width:50px')); +$form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$workdayHours, 'style'=>'width:60px')); $form->addInput(array('type'=>'combobox','name'=>'year','data'=>$years,'datakeys'=>array('id','name'),'value'=>$selectedYear,'onchange'=>'yearChange(this.value);')); for ($i=0; $i < count($months); $i++) { $value = "";