From 4b203ad8b61fde986390ebc7d44727089d0595b4 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 28 Jan 2018 22:28:16 +0000 Subject: [PATCH] Usability improvement of the monthly quota config form. --- WEB-INF/resources/en.lang.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/quotas.tpl | 1 - quotas.php | 33 +++++++++++++++------------------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 37d9bedf..d682cc8f 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -440,6 +440,6 @@ $i18n_key_words = array( 'form.quota.year' => 'Year', 'form.quota.month' => 'Month', 'form.quota.quota' => 'Quota', -'form.quota.workday_hours' => 'Hours in a work day', +'form.quota.workday_hours' => 'Hours in work day', 'form.quota.hint' => 'If values are empty, quotas are calculated automatically based on workday hours and holidays.', ); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index a9a59c7a..814420ce 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- -
 Anuko Time Tracker 1.17.8.3815 | Copyright © Anuko | +  Anuko Time Tracker 1.17.9.3816 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/quotas.tpl b/WEB-INF/templates/quotas.tpl index 6ce26a91..67707d38 100644 --- a/WEB-INF/templates/quotas.tpl +++ b/WEB-INF/templates/quotas.tpl @@ -11,7 +11,6 @@
{$i18n.form.quota.workday_hours}: {$forms.monthlyQuotasForm.workdayHours.control}
diff --git a/quotas.php b/quotas.php index 0336d44c..375d8a78 100644 --- a/quotas.php +++ b/quotas.php @@ -80,27 +80,24 @@ if ($request->isPost()){ if ($err->no()) { - $res = false; - if ($_POST['btn_hours']){ - - // User changed workday hours for team. - $hours = (int)$request->getParameter('workdayHours'); - $res = ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_hours'=>$hours)); + // Handle workday hours. + $hours = (int)$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')); } - if ($_POST['btn_submit']){ - // User pressed the Save button under monthly quotas table. - $postedYear = $request->getParameter('year'); - $selectedYear = intval($postedYear); - for ($i = 0; $i < count($months); $i++){ - $res = $quota->update($postedYear, $i+1, $request->getParameter($months[$i])); - } + + // Handle monthly quotas for a selected year. + $selectedYear = intval($request->getParameter('year')); + for ($i = 0; $i < count($months); $i++){ + if (!$quota->update($selectedYear, $i+1, $request->getParameter($months[$i]))) + $err->add($i18n->getKey('error.db')); } - if ($res) { - // header('Location: profile_edit.php'); - header('Location: quotas.php'); // For debugging. + + if ($err->no()) { + // Redisplay the form. + header('Location: quotas.php?year='.$selectedYear); exit(); - } else { - $err->add($i18n->getKey('error.db')); } } } -- 2.20.1