private function _analyze_raw_hours() { if (!array_key_exists('raw_results', $this->_request_data) || !array_key_exists('hr', $this->_request_data['raw_results']) || !is_array($this->_request_data['raw_results']['hr'])) { debug_add('Hour reports array not found', MIDCOM_LOG_WARN); return false; } org_openpsa_reports_handler_projects_report::_verify_cache('hours', $this->_request_data); reset($this->_request_data['raw_results']['hr']); foreach ($this->_request_data['raw_results']['hr'] as $hour) { debug_add('processing hour id: ' . $hour->id); //Put the mangled hour to caches $this->_request_data['object_cache'][$hour->guid] = $hour; $this->_request_data['object_cache']['hours'][$hour->id] =& $this->_request_data['object_cache'][$hour->guid]; $row = array(); $row['is_group'] = false; $row['hour'] =& $this->_request_data['object_cache'][$hour->guid]; $row['task'] =& org_openpsa_reports_handler_projects_report::_get_cache('tasks', $this->_request_data['object_cache'][$hour->guid]->task, $this->_request_data); $row['person'] =& org_openpsa_reports_handler_projects_report::_get_cache('users', $this->_request_data['object_cache'][$hour->guid]->person, $this->_request_data); // Default (should work for almost every grouping) is to sort rows by the hour report date $row['sort'] = $row['hour']->date; //Determine our group debug_add("grouping is {$this->_grouping}"); switch ($this->_grouping) { case 'date': $group =& $this->_get_report_group('date:' . date('Ymd', $row['hour']->date), date('Ymd', $row['hour']->date), strftime('%x', $row['hour']->date)); break; case 'person': $group =& $this->_get_report_group('person:' . $row['person']->guid, $row['person']->rname, $row['person']->rname); break; } //Place data to group $group['rows'][] = $row; $group['total_hours'] += $hour->hours; //Place data to report $this->_request_data['report']['total_hours'] += $hour->hours; } return true; }
<?php $hour =& $data['current_row']['hour']; $task =& $data['current_row']['task']; $report =& $data['report']; $person =& $data['current_row']['person']; $query_data =& $data['query_data']; $group =& $data['current_group']; $weekly_data =& $report['raw_results']['weekly_report_data']; $weekly_data_group =& $group['weekly_report_data']; $data['current_row']['customer'] = false; if ($task->customer) { $data['current_row']['customer'] =& org_openpsa_reports_handler_projects_report::_get_cache('groups', $task->customer, $data); } if ($hour->invoiceable) { $total =& $weekly_data['invoiceable_total']; $customers =& $weekly_data['invoiceable_customers']; $total_by_customer =& $weekly_data['invoiceable_total_by_customer']; $group_total =& $weekly_data_group['invoiceable_total']; $group_customers =& $weekly_data_group['invoiceable_customers']; $group_total_by_customer =& $weekly_data_group['invoiceable_total_by_customer']; } else { $total =& $weekly_data['uninvoiceable_total']; $customers =& $weekly_data['uninvoiceable_customers']; $total_by_customer =& $weekly_data['uninvoiceable_total_by_customer']; $group_total =& $weekly_data_group['uninvoiceable_total']; $group_customers =& $weekly_data_group['uninvoiceable_customers']; $group_total_by_customer =& $weekly_data_group['uninvoiceable_total_by_customer']; } $total += $hour->hours; $group_total += $hour->hours;