X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=quotas.php;h=06fdbbe5a55769604f9f6d17f9880b2aa149c3d4;hb=2ccee198591bc2ad5d80b5e1076246449d9232c1;hp=d3e7912e7e28177ed0316808d4345141a65d7c4a;hpb=d27b08cc3e9c657bdb361379657d185f0ea47485;p=timetracker.git diff --git a/quotas.php b/quotas.php index d3e7912e..06fdbbe5 100644 --- a/quotas.php +++ b/quotas.php @@ -33,7 +33,7 @@ import('ttTeamHelper'); import('ttTimeHelper'); // Access check. -if (!ttAccessCheck(right_manage_team) || !$user->isPluginEnabled('mq')) { +if (!ttAccessAllowed('manage_advanced_settings') || !$user->isPluginEnabled('mq')) { header('Location: access_denied.php'); exit(); } @@ -71,12 +71,12 @@ $quota = new MonthlyQuota(); if ($request->isPost()){ // Validate user input. - if (!ttTimeHelper::isValidDuration($request->getParameter('workdayHours'))) + if (false === ttTimeHelper::postedDurationToMinutes($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)) + if (false === ttTimeHelper::postedDurationToMinutes($val, 44640/*24*60*31*/)) $err->add($i18n->getKey('error.field'), $months[$i]); } // Finished validating user input. @@ -84,16 +84,17 @@ if ($request->isPost()){ if ($err->no()) { // Handle workday hours. - $hours = $quota->quotaToFloat($request->getParameter('workdayHours')); - if ($hours != $user->workday_hours) { - if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_hours'=>$hours))) + $workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours')); + if ($workday_minutes != $user->workday_minutes) { + if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_minutes'=>$workday_minutes))) $err->add($i18n->getKey('error.db')); } // Handle monthly quotas for a selected year. $selectedYear = (int) $request->getParameter('year'); for ($i = 0; $i < count($months); $i++){ - if (!$quota->update($selectedYear, $i+1, $request->getParameter($months[$i]))) + $quota_in_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter($months[$i]), 44640/*24*60*31*/); + if (!$quota->update($selectedYear, $i+1, $quota_in_minutes)) $err->add($i18n->getKey('error.db')); } @@ -107,7 +108,7 @@ if ($request->isPost()){ // Get monthly quotas for the entire year. $monthsData = $quota->get($selectedYear); -$workdayHours = ttTimeHelper::toAbsDuration($user->workday_hours * 60, true); +$workdayHours = ttTimeHelper::toAbsDuration($user->workday_minutes, true); $form = new Form('monthlyQuotasForm'); $form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$workdayHours, 'style'=>'width:60px')); @@ -116,7 +117,7 @@ for ($i=0; $i < count($months); $i++) { $value = ""; if (array_key_exists($i+1, $monthsData)){ $value = $monthsData[$i+1]; - $value = ttTimeHelper::toAbsDuration($value * 60, true); + $value = ttTimeHelper::toAbsDuration($value, true); } $name = $months[$i]; $form->addInput(array('type'=>'text','name'=>$name,'maxlength'=>6,'value'=> $value,'style'=>'width:70px'));