/**
  * Show single report
  *
  * @param void
  * @return null
  */
 function report()
 {
     if ($this->active_report->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_report->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $report_records = TimeReports::executeReport($this->logged_user, $this->active_report);
     $total_time = 0;
     if (is_foreachable($report_records)) {
         if ($this->active_report->getSumByUser()) {
             foreach ($report_records as $report_record) {
                 $total_time += $report_record['total_time'];
             }
             // foreach
         } else {
             foreach ($report_records as $report_record) {
                 $total_time += $report_record->getValue();
             }
             // foreach
         }
         // if
     }
     // if
     $this->smarty->assign(array('grouped_reports' => TimeReports::findGrouped(), 'report_records' => $report_records, 'total_time' => $total_time, 'show_project' => true));
 }
 /**
  * Execute report and prepare it for export
  *
  * @param User $user
  * @param TimeReport $report
  * @param Project $project
  * @return array
  */
 function executeReportForExport($user, $report, $project = null)
 {
     $report_records = TimeReports::executeReport($user, $report, $project);
     $csv_content = array();
     if ($report->getSumByUser()) {
         $csv_content[] = array('Person', 'Hours');
         if (is_foreachable($report_records)) {
             foreach ($report_records as $report_record) {
                 $csv_content[] = array($report_record['user']->getDisplayName(), (string) $report_record['total_time']);
             }
             // foreach
         }
         // if
     } else {
         $csv_content[] = array('Date', 'Person', 'Project ID', 'Project Name', 'Hours', 'Summary', 'Parent Summary', 'Billable', 'Billed', 'Billed Status');
         if (is_foreachable($report_records)) {
             foreach ($report_records as $time_record) {
                 if ($time_record->isBillable()) {
                     $billable = 'Yes';
                     $billed = $time_record->isBilled() ? 'Yes' : 'No';
                 } else {
                     $billable = 'No';
                     $billed = 'No';
                 }
                 // if
                 $date = $time_record->getRecordDate();
                 $person = $time_record->getUser();
                 $project = $time_record->getProject();
                 $parent = $time_record->getParent();
                 $csv_content[] = array($date->toMySql(), $person->getDisplayName(), $time_record->getProjectId(), $project->getName(), (string) $time_record->getValue(), $time_record->getBody(), instance_of($parent, 'ProjectObject') ? $parent->getName() : '', $billable, $billed, (int) $time_record->getBillableStatus());
             }
             // foreach
         }
         // if
     }
     // if
     return $csv_content;
 }
 /**
  * Show a single report
  *
  * @param void
  * @return null
  */
 function report()
 {
     if ($this->active_report->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_report->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $report_records = TimeReports::executeReport($this->logged_user, $this->active_report, $this->active_project);
     $total_time = 0;
     if (is_foreachable($report_records)) {
         if ($this->active_report->getSumByUser()) {
             foreach ($report_records as $report_record) {
                 $total_time += $report_record['total_time'];
             }
             // foreach
         } else {
             foreach ($report_records as $report_record) {
                 $total_time += $report_record->getValue();
             }
             // foreach
         }
         // if
     }
     // if
     $this->smarty->assign(array('grouped_reports' => TimeReports::findGrouped(), 'report_records' => $report_records, 'total_time' => $total_time, 'show_project' => false));
     $this->setTemplate(array('module' => TIMETRACKING_MODULE, 'controller' => 'global_timetracking', 'template' => 'report'));
 }