From cdd2e058776a3d0dc9b6f32a2d5d33e4f9388491 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 22 Apr 2019 17:45:08 +0000 Subject: [PATCH] A bit of refactoring. --- WEB-INF/lib/ttTimeHelper.class.php | 6 ++++-- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/week.tpl | 10 ++++++++++ mobile/time.php | 2 +- mobile/timer.php | 2 +- time.php | 2 +- week.php | 3 +++ 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 44d96785..0d5863ed 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -807,11 +807,12 @@ class ttTimeHelper { } // getRecords - returns time records for a user for a given date. - static function getRecords($user_id, $date) { + static function getRecords($date) { // TODO: merge getRecords and getRecordsWithFiles into one function. global $user; $mdb2 = getConnection(); + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id; @@ -869,10 +870,11 @@ class ttTimeHelper { // getRecordsWithFiles - returns time records for a user for a given date // with information whether they have attached files (has_files property). // A separate fiunction from getRecords because sql here is more complex. - static function getRecordsWithFiles($user_id, $date) { + static function getRecordsWithFiles($date) { global $user; $mdb2 = getConnection(); + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 6e00cf34..62a5cf42 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- + {if $show_files} + + {/if} @@ -138,6 +141,13 @@ function fillDropdowns() { {/if} + {if $show_files} + {if $record.has_files} + + {else} + + {/if} + {/if}
 Anuko Time Tracker 1.19.1.4969 | Copyright © Anuko | +  Anuko Time Tracker 1.19.1.4970 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/week.tpl b/WEB-INF/templates/week.tpl index 6fc08b8a..33a218a3 100644 --- a/WEB-INF/templates/week.tpl +++ b/WEB-INF/templates/week.tpl @@ -117,6 +117,9 @@ function fillDropdowns() { {/if} {$i18n.label.duration} {$i18n.label.note}
{if ($record.duration == '0:00' && $record.start <> '')}{$i18n.form.time.uncompleted}{else}{$record.duration}{/if} {if $record.comment}{$record.comment|escape}{else} {/if}{$i18n.label.files}{$i18n.label.files} {if $record.approved || $record.timesheet_id || $record.invoice_id}   diff --git a/mobile/time.php b/mobile/time.php index 15069db2..30c7a402 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -347,7 +347,7 @@ if ($request->isPost()) { $smarty->assign('next_date', $next_date); $smarty->assign('prev_date', $prev_date); -$smarty->assign('time_records', ttTimeHelper::getRecords($user_id, $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($cl_date)); $smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); diff --git a/mobile/timer.php b/mobile/timer.php index d3a0d0fb..a8f708a8 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -290,7 +290,7 @@ $smarty->assign('uncompleted', $uncompleted); -$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date)); +$smarty->assign('time_records', ttTimeHelper::getRecords($cl_date)); $smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date)); $smarty->assign('client_list', $client_list); $smarty->assign('project_list', $project_list); diff --git a/time.php b/time.php index f6c84759..2a2c616b 100644 --- a/time.php +++ b/time.php @@ -442,7 +442,7 @@ if ($request->isPost()) { } // isPost $week_total = ttTimeHelper::getTimeForWeek($selected_date); -$timeRecords = $showFiles? ttTimeHelper::getRecordsWithFiles($user_id, $cl_date) : ttTimeHelper::getRecords($user_id, $cl_date); +$timeRecords = $showFiles? ttTimeHelper::getRecordsWithFiles($cl_date) : ttTimeHelper::getRecords($cl_date); $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total); diff --git a/week.php b/week.php index f18817d7..b4a9176e 100644 --- a/week.php +++ b/week.php @@ -507,6 +507,9 @@ $smarty->assign('onload', 'onLoad="fillDropdowns()"'); $smarty->assign('timestring', $startDate->toString($user->date_format).' - '.$endDate->toString($user->date_format)); $smarty->assign('time_records', $records); +//$showFiles = $user->isPluginEnabled('at'); +//$smarty->assign('show_files', $showFiles); + $smarty->assign('title', $i18n->get('title.time')); $smarty->assign('content_page_name', 'week.tpl'); $smarty->display('index.tpl'); -- 2.20.1