From 9df2c85d1cd3337978dcb72d5f12c602f2588cb7 Mon Sep 17 00:00:00 2001 From: anuko Date: Tue, 26 Dec 2017 14:37:56 +0000 Subject: [PATCH] Added a helper function to build an array of day headears for week view. --- WEB-INF/lib/ttTimeHelper.class.php | 47 ++++++++++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index f5edc5fa..d186696d 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -766,6 +766,32 @@ class ttTimeHelper { return $groupedRecords; } + /* This is work in progress, not working properly. + static function getDurationsForWeek($user_id, $start_date, $end_date) { + // Start by obtaining all records in interval. + // Then, iterate through them to build an array. + $records = ttTimeHelper::getRecordsForInterval($user_id, $start_date, $end_date); + $durations_with_labels = array(); + + foreach ($records as $record) { + $record_id_no_suffix = ttTimeHelper::makeRecordIdentifier($record); + // Handle potential multiple records with the same attributes by using a numerical suffix. + $suffix = 0; + $record_id = $record_id_no_suffix.'_'.$suffix; + while (!empty($durations_with_labels[$record_id][$record['date']])) { + $suffix++; + $record_id = $record_id_no_suffix.'_'.$suffix; + } + $groupedRecords[$record_identifier][$record['date']] = array('id'=>$record['id'], 'duration'=>$record['duration']); + $groupedRecords[$record_identifier]['client'] = $record['client']; + $groupedRecords[$record_identifier]['cf_1_value'] = $record['cf_1_value']; + $groupedRecords[$record_identifier]['project'] = $record['project']; + $groupedRecords[$record_identifier]['task'] = $record['task']; + $groupedRecords[$record_identifier]['billable'] = $record['billable']; + } + } + */ + // makeRecordIdentifier - builds a string identifying a record for a grouped display (such as a week view). // For example: // "cl:546,bl:0,pr:23456,ts:27464,cf_1:example text" @@ -812,4 +838,25 @@ class ttTimeHelper { return $groupedRecordsTotals; } + + // getDayHeadersForWeek - obtains day column headers for week view, which are simply day numbers in month. + static function getDayHeadersForWeek($start_date) { + $dayHeaders = array(); + $objDate = new DateAndTime(DB_DATEFORMAT, $start_date); + $dayHeaders['day_header_0'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_1'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_2'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_3'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_4'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_5'] = $objDate->getDate(); + $objDate->incDay(); + $dayHeaders['day_header_6'] = $objDate->getDate(); + unset($objDate); + return $dayHeaders; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 7c5de958..7f933a09 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.12.3.3691 | Copyright © Anuko | +  Anuko Time Tracker 1.12.3.3692 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1