From 7d4e0805bf2f55c97c750021ebdd0ff0a1b44b0b Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 28 Nov 2018 14:26:34 +0000 Subject: [PATCH] A bit of refactoring in time.php. --- WEB-INF/templates/footer.tpl | 2 +- group_edit.php | 1 + time.php | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 70225624..312131d2 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4532 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4533 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/group_edit.php b/group_edit.php index 08c1db59..6a16dc1f 100644 --- a/group_edit.php +++ b/group_edit.php @@ -112,6 +112,7 @@ if (count($groups) > 1) { 'data'=>$groups, 'datakeys'=>array('id','name'))); $form->addInput(array('type'=>'hidden','name'=>'group_changed')); + $smarty->assign('group_dropdown', 1); } $form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'group_name','value'=>$cl_group,'enable'=>$advanced_settings)); $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); diff --git a/time.php b/time.php index 89f7389f..ce622b23 100644 --- a/time.php +++ b/time.php @@ -89,7 +89,7 @@ $_SESSION['date'] = $cl_date; // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->getGroup()); + $custom_fields = new CustomFields($group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -97,7 +97,7 @@ if ($user->isPluginEnabled('mq')){ require_once('plugins/MonthlyQuota.class.php'); $quota = new MonthlyQuota(); $month_quota_minutes = $quota->get($selected_date->mYear, $selected_date->mMonth); - $month_total = ttTimeHelper::getTimeForMonth($user->getUser(), $selected_date); + $month_total = ttTimeHelper::getTimeForMonth($user_id, $selected_date); $minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total); $smarty->assign('month_total', $month_total); @@ -170,7 +170,7 @@ if ($user->can('track_time')) { // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->getTrackingMode() && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->getGroup(), true); + $active_clients = ttTeamHelper::getActiveClients($group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -196,7 +196,7 @@ if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $use // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->getGroup(), true); + $active_clients = ttTeamHelper::getActiveClients($group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -224,7 +224,7 @@ if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $use } if (MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { - $task_list = ttTeamHelper::getActiveTasks($user->getGroup()); + $task_list = ttTeamHelper::getActiveTasks($group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', @@ -323,13 +323,13 @@ if ($request->isPost()) { // Prohibit creating another uncompleted record. if ($err->no()) { - if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getUser())) && (($cl_finish == '') && ($cl_duration == ''))) + if (($not_completed_rec = ttTimeHelper::getUncompleted($user_id)) && (($cl_finish == '') && ($cl_duration == ''))) $err->add($i18n->get('error.uncompleted_exists')." ".$i18n->get('error.goto_uncompleted').""); } // Prohibit creating an overlapping record. if ($err->no()) { - if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish)) + if (ttTimeHelper::overlaps($user_id, $cl_date, $cl_start, $cl_finish)) $err->add($i18n->get('error.overlap')); } @@ -337,8 +337,8 @@ if ($request->isPost()) { if ($err->no()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, - 'user_id' => $user->getUser(), - 'group_id' => $user->getGroup(), + 'user_id' => $user_id, + 'group_id' => $group_id, 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, @@ -366,18 +366,18 @@ if ($request->isPost()) { } elseif ($request->getParameter('btn_stop')) { // Stop button pressed to finish an uncompleted record. $record_id = $request->getParameter('record_id'); - $record = ttTimeHelper::getRecord($record_id, $user->getUser()); + $record = ttTimeHelper::getRecord($record_id, $user_id); $browser_date = $request->getParameter('browser_date'); $browser_time = $request->getParameter('browser_time'); // Can we complete this record? if ($record['date'] == $browser_date // closing today's record && ttTimeHelper::isValidInterval($record['start'], $browser_time) // finish time is greater than start time - && !ttTimeHelper::overlaps($user->getUser(), $browser_date, $record['start'], $browser_time)) { // no overlap + && !ttTimeHelper::overlaps($user_id, $browser_date, $record['start'], $browser_time)) { // no overlap $res = ttTimeHelper::update(array( 'id'=>$record['id'], 'date'=>$record['date'], - 'user_id'=>$user->getUser(), + 'user_id'=>$user_id, 'client'=>$record['client_id'], 'project'=>$record['project_id'], 'task'=>$record['task_id'], @@ -395,12 +395,12 @@ if ($request->isPost()) { } } // isPost -$week_total = ttTimeHelper::getTimeForWeek($user->getUser(), $selected_date); +$week_total = ttTimeHelper::getTimeForWeek($user_id, $selected_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total); -$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date)); -$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date)); +$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user_id, $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($user_id, $cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); -- 2.20.1