From 85910e4038e5f54d82a29ceafc32b8e14e18628e Mon Sep 17 00:00:00 2001 From: anuko Date: Sat, 6 Jan 2018 18:42:15 +0000 Subject: [PATCH] Enhanced week view ith a list of editable records. --- WEB-INF/lib/ttWeekViewHelper.class.php | 7 +-- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/week.tpl | 77 ++++++++++++++++++++++++-- week.php | 7 ++- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index ad21be00..5c03a373 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -72,7 +72,7 @@ class ttWeekViewHelper { from tt_log l $left_joins where l.date >= '$start_date' and l.date <= '$end_date' and l.user_id = $user_id and l.status = 1 - order by p.name, t.name, l.date, l.start, l.id"; + order by l.date, p.name, t.name, l.start, l.id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -132,12 +132,9 @@ class ttWeekViewHelper { // 'day_6' => array('control_id' => '2_day_6', 'tt_log_id' => null, 'duration' => null) // ) // ); - static function getDataForWeekView($user_id, $start_date, $end_date, $dayHeaders) { + static function getDataForWeekView($records, $dayHeaders) { global $i18n; - // Start by obtaining all records in interval. - $records = ttWeekViewHelper::getRecordsForInterval($user_id, $start_date, $end_date); - $dataArray = array(); // Construct the first row for a brand new entry. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index a18ab1e0..3d14fea2 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.13.7.3726 | Copyright © Anuko | +  Anuko Time Tracker 1.13.8.3727 | 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 34edf920..42f24f16 100644 --- a/WEB-INF/templates/week.tpl +++ b/WEB-INF/templates/week.tpl @@ -69,6 +69,77 @@ {$forms.weekTimeForm.week_durations.control}
+ + + + + + +
{$forms.weekTimeForm.btn_submit.control}
 
+ + + + + +
+{if $time_records} + + + + {if $user->isPluginEnabled('cl')} + + {/if} + {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} + + {/if} + {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} + + {/if} + {if (($smarty.const.TYPE_START_FINISH == $user->record_type) || ($smarty.const.TYPE_ALL == $user->record_type))} + + + {/if} + + + + + {foreach $time_records as $record} + + + {if $user->isPluginEnabled('cl')} + + {/if} + {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} + + {/if} + {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} + + {/if} + {if (($smarty.const.TYPE_START_FINISH == $user->record_type) || ($smarty.const.TYPE_ALL == $user->record_type))} + + + {/if} + + + + + {/foreach} +
{$i18n.label.date}{$i18n.label.client}{$i18n.label.project}{$i18n.label.task}{$i18n.label.start}{$i18n.label.finish}{$i18n.label.duration}{$i18n.label.note}{$i18n.label.edit}
{$record.date}{$record.client|escape}{$record.project|escape}{$record.task|escape}{if $record.start}{$record.start}{else} {/if}{if $record.finish}{$record.finish}{else} {/if}{if ($record.duration == '0:00' && $record.start <> '')}{$i18n.form.time.uncompleted}{else}{$record.duration}{/if}{if $record.comment}{$record.comment|escape}{else} {/if} + {if $record.invoice_id} +   + {else} + {$i18n.label.edit} + {if ($record.duration == '0:00' && $record.start <> '')} + + + + + {/if} + {/if} +
+{/if} +
+{if $time_records} @@ -85,9 +156,5 @@ {/if}
{$i18n.label.week_total}: {$week_total}
- - - - -
{$forms.weekTimeForm.btn_submit.control}
+{/if} {$forms.weekTimeForm.close} diff --git a/week.php b/week.php index 19476c8b..fb2dcaa6 100644 --- a/week.php +++ b/week.php @@ -113,8 +113,10 @@ $cl_note = trim($request->getParameter('note')); // Get column headers, which are day numbers in month. $dayHeaders = ttWeekViewHelper::getDayHeadersForWeek($startDate->toString(DB_DATEFORMAT)); $lockedDays = ttWeekViewHelper::getLockedDaysForWeek($startDate->toString(DB_DATEFORMAT)); -// Build data array for the table. Format is described in the function.. -$dataArray = ttWeekViewHelper::getDataForWeekView($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT), $dayHeaders); +// Get already existing records. +$records = ttWeekViewHelper::getRecordsForInterval($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT)); +// Build data array for the table. Format is described in the function. +$dataArray = ttWeekViewHelper::getDataForWeekView($records, $dayHeaders); // Build day totals (total durations for each day in week). $dayTotals = ttWeekViewHelper::getDayTotals($dataArray, $dayHeaders); @@ -410,6 +412,7 @@ $smarty->assign('task_list', $task_list); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="fillDropdowns()"'); $smarty->assign('timestring', $startDate->toString($user->date_format).' - '.$endDate->toString($user->date_format)); +$smarty->assign('time_records', $records); $smarty->assign('title', $i18n->getKey('title.time')); $smarty->assign('content_page_name', 'week.tpl'); -- 2.20.1