- static function getGroupedRecordsForInterval($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);
- $groupedRecords = array();
- foreach ($records as $record) {
- $record_identifier_no_suffix = ttTimeHelper::makeRecordIdentifier($record);
- // Handle potential multiple records with the same attributes by using a numerical suffix.
- $suffix = 0;
- $record_identifier = $record_identifier_no_suffix.'_'.$suffix;
- while (!empty($groupedRecords[$record_identifier][$record['date']])) {
- $suffix++;
- $record_identifier = $record_identifier_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'];
- }
-
- return $groupedRecords;
- }
-
- // getDataForWeekView - builds an array to render a table of durations for week view.
+ //
+ // Description of $dataArray format that the function returns.
+ // $dataArray = array(
+ // array( // Row 0.
+ // 'id' => 'cl:546,bl:1,pr:23456,ts:27464,cf_1:7623', // Record identifier. See ttTimeHelper::makeRecordIdentifier().
+ // 'label' => 'Anuko - Time Tracker - Coding', // Human readable label for the row describing what this time entry is for.
+ // 'day_0' => array('id' => '0_0', 'duration' => '00:00'),
+ // 'day_1' => array('id' => '0_1', 'duration' => '01:00'),
+ // 'day_2' => array('id' => '0_2', 'duration' => '02:00'),
+ // 'day_3' => array('id' => '0_3', 'duration' => null),
+ // 'day_4' => array('id' => '0_4', 'duration' => '04:00')
+ // ),
+ // array( // Row 1.
+ // 'id' => 'bl:0',
+ // 'label' => '', // In this case the label is empty as we don't have anything to put in, only not billable flag.
+ // 'day_0' => array('id' => '1_0', 'duration' => '00:30'),
+ // 'day_1' => array('id' => '1_1', 'duration' => '01:30'),
+ // 'day_2' => array('id' => '1_2', 'duration' => '02:30'),
+ // )
+ // );