Removed unneeded subtotal row on reports, fixed printing of 0 subtotals.
[timetracker.git] / quotas.php
index 19e70e5..1f37619 100644 (file)
 require_once('initialize.php');
 require_once('plugins/MonthlyQuota.class.php');
 import('form.Form');
-import('ttTeamHelper');
 import('ttTimeHelper');
 
-// Access check.
-if (!ttAccessAllowed('manage_advanced_settings') || !$user->isPluginEnabled('mq')) {
+// Access checks.
+if (!ttAccessAllowed('manage_advanced_settings')) {
   header('Location: access_denied.php');
   exit();
 }
+if (!$user->isPluginEnabled('mq')) {
+  header('Location: feature_disabled.php');
+  exit();
+}
 
 // Start and end fallback values for the Year dropdown.
 $yearStart = 2015;
@@ -85,8 +88,8 @@ if ($request->isPost()){
 
     // Handle workday 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)))
+    if ($workday_minutes != $user->getWorkdayMinutes()) {
+      if (!$user->updateGroup(array('workday_minutes'=>$workday_minutes)))
         $err->add($i18n->get('error.db'));
     }
 
@@ -108,7 +111,7 @@ if ($request->isPost()){
 
 // Get monthly quotas for the entire year.
 $monthsData = $quota->get($selectedYear);
-$workdayHours = ttTimeHelper::toAbsDuration($user->workday_minutes, true);
+$workdayHours = ttTimeHelper::toAbsDuration($user->getWorkdayMinutes(), true);
 
 $form = new Form('monthlyQuotasForm');
 $form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$workdayHours, 'style'=>'width:60px'));