- // getGroupedRecordsForInterval - returns time records for a user for a given interval of dates grouped in an array of dates.
- // Example: for a week view we want one row representing the same attributes to have 7 values for each day of week.
- // We identify simlar records by a combination of client, billable, project, task, and custom field values.
- //
- // "cl:546,bl:0,pr:23456,ts:27464,cf_1:example text"
- // The above means client 546, billable, project 23456, task 27464, custom field value: example text.
- //
- // "cl:546,bl:1,pr:23456,ts:27464,cf_1:7623"
- // The above means client 546, not billable, project 23456, task 27464, custom field option value 7623.
- // This will allow us to extend the feature when more custom fields are added.
- 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);
- foreach ($records as $record) {
- $record_identifier = ttTimeHelper::makeRecordIdentifier($record);
- }
-
- return null; // Work in progress, not implemented.
- }
-
- // 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"
- // "cl:546,bl:1,pr:23456,ts:27464,cf_1:7623"
- // See comment for getGroupedRecordsForInterval.
- static function makeRecordIdentifier($record) {
- global $user;
- // Start with client.
- if ($user->isPluginEnabled('cl')) {
- $record_identifier = 'cl:';
- $record_identifier .= $record['client_id'] ? $record['client_id'] : '0';
- }
- // Add billable flag.
- if (!empty($record_identifier)) $record_identifier .= ',';
- $record_identifier .= 'bl:'.$record['billable'];
- // Add project.
- $record_identifier .= ',pr:';
- $record_identifier .= $record['project_id'] ? $record['project_id'] : '0';
- // Add task.
- $record_identifier .= ',ts:';
- $record_identifier .= $record['task_id'] ? $record['task_id'] : '0';
- // Add custom field 1. This requires modifying the query to get the data we need.
-
- return $record_identifier;