예제 #1
0
 public function dataverificationAction()
 {
     $method = $this->getRequest()->getParam('method', 'html');
     $start = $this->getRequest()->getParam('start');
     $locaion = (int) $this->getRequest()->getParam('locaion');
     $end = false;
     if (strstr($start, '~')) {
         $dates = explode("~", $start);
         $start = $dates[0];
         $end = $dates[1];
         $this->view->end = $end;
     }
     $this->view->start = $start;
     $this->view->method = $method;
     $recordsModel = new Records();
     $employeesModel = new Employees();
     if ($this->_me->admin == 1) {
         if ($locaion == 0) {
             $employees = $employeesModel->getAll();
         } else {
             $employees = $employeesModel->getAllByLocation($locaion);
         }
     } else {
         $employees = $employeesModel->getAllByLocation($this->_me->location);
     }
     $totalData = array();
     $i = 0;
     foreach ($employees as $employee) {
         $totalData[$i]['employee'] = $employee;
         $totalData[$i]['records'] = $recordsModel->getAllByEmployeeDate($employee->id, $start, $end);
         $i++;
     }
     $this->view->totalData = $totalData;
     if ($method == 'pdf') {
         error_reporting(0);
         ini_set('memory_limit', '-1');
         $this->_helper->viewRenderer->setNoRender(true);
         $html = $this->view->render('user/dataverification.phtml');
         $this->_helper->layout->disableLayout();
         require_once APPLICATION_PATH . "/../data/dompdf/dompdf_config.inc.php";
         $dompdf = new DOMPDF();
         $dompdf->load_html($html);
         $dompdf->render();
         $dompdf->stream("Data-Verification-" . date('M-Y', strtotime($start)) . "-" . date('Y-m-d') . "." . $method);
     }
     if ($method == 'csv') {
         //$this->_helper->viewRenderer->setNoRender(true);
         $this->_helper->layout->disableLayout();
     }
 }