コード例 #1
0
 public function getreportAction()
 {
     $user = $this->session->getCurrentUser();
     $data = array();
     $data['date_from'] = addslashes(trim(strip_tags($this->request->getPost('date_from'))));
     $data['date_to'] = addslashes(trim(strip_tags($this->request->getPost('date_to'))));
     $data['users_id'] = (int) $user->id;
     $data['ids'] = array();
     if (!is_null($this->request->getPost('ids')) && is_array($this->request->getPost('ids'))) {
         foreach ($this->request->getPost('ids') as $id) {
             $data['ids'][] = (int) $id;
         }
     }
     $projectsModel = new Projects();
     $reports = $projectsModel->getReports($data);
     $totalTime = 0;
     foreach ($reports as $key => &$item) {
         if ($item['t_sum'] === null) {
             unset($reports[$key]);
         } else {
             $totalTime += $item['t_sum'];
             $hours = floor($item['t_sum'] / 3600);
             $mins = floor(($item['t_sum'] - $hours * 3600) / 60);
             $item['t_sum'] = $hours . ' часов ' . $mins . ' минут';
         }
     }
     $this->view->reports = array_values($reports);
     $hours = floor($totalTime / 3600);
     $mins = floor(($totalTime - $hours * 3600) / 60);
     $this->view->totalTime = $hours . ' часов ' . $mins . ' минут';
     $dateFrom = new \DateTime($data['date_from']);
     $dateTo = new \DateTime($data['date_to']);
     $this->view->dateFrom = $dateFrom->format('d.m.Y');
     $this->view->dateTo = $dateTo->format('d.m.Y');
 }