- if (!ttTimeHelper::isValidQuota($val))
- $err->add($i18n->getKey('error.field'), $months[$i]);
+ $monthMinutes = ttTimeHelper::postedDurationToMinutes($val, 44640/*24*60*31*/);
+ if (false === $monthMinutes || $monthMinutes < 0)
+ $err->add($i18n->get('error.field'), $months[$i]);
- $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'));
+ $workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours'));
+ if ($workday_minutes != $user->getWorkdayMinutes()) {
+ if (!$user->updateGroup(array('workday_minutes'=>$workday_minutes)))
+ $err->add($i18n->get('error.db'));
}
// Handle monthly quotas for a selected year.
$selectedYear = (int) $request->getParameter('year');
for ($i = 0; $i < count($months); $i++){
}
// 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])))
- $err->add($i18n->getKey('error.db'));
+ $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->get('error.db'));
-$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 = "";
if (array_key_exists($i+1, $monthsData)){
$value = $monthsData[$i+1];
$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 = "";
if (array_key_exists($i+1, $monthsData)){
$value = $monthsData[$i+1];
}
$name = $months[$i];
$form->addInput(array('type'=>'text','name'=>$name,'maxlength'=>6,'value'=> $value,'style'=>'width:70px'));
}
$name = $months[$i];
$form->addInput(array('type'=>'text','name'=>$name,'maxlength'=>6,'value'=> $value,'style'=>'width:70px'));
$smarty->assign('months', $months);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('months', $months);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('content_page_name', 'quotas.tpl');
$smarty->display('index.tpl');
$smarty->assign('content_page_name', 'quotas.tpl');
$smarty->display('index.tpl');