public function indexAction()
 {
     $raportsModel = new Raports();
     $request = $this->getRequest();
     $hash = $request->getParam('hash');
     if (empty($hash)) {
         return;
     }
     $raport = $raportsModel->getRaportByHash($hash);
     if ($raport === null) {
         return;
     }
     $start = $raport->date_for;
     $end = $raport->date_to;
     $date = new Zend_Date();
     if (empty($start) || empty($end) || (!$date->setDate($start, "YYYY-MM-dd")->isDate($start, "YYYY-MM-dd") || !$date->setDate($end, "YYYY-MM-dd")->isDate($end, "YYYY-MM-dd"))) {
         return;
     }
     $logic = new Logic_Raports_Render($start, $end, $this->_helper->currentip());
     $logic->render();
 }
Beispiel #2
0
 public function render()
 {
     $raportModel = new Raports();
     $raportsData = $raportModel->getRaportByDate($this->_start, $this->_end);
     $rows = $this->_model->getRaportData($this->_start, $this->_end);
     $view = new Zend_View();
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts/raports');
     $output = array('start' => $this->_start, 'end' => $this->_end);
     while ($current = $rows->current()) {
         $last = true;
         $row = array();
         if ($rows->key() > 0) {
             $prev = $rows->getRow($rows->key() - 1);
             if ($prev->ws_service_id != $current->ws_service_id) {
                 $last = false;
                 if ($rows->key() == $rows->count() - 1) {
                     $last = true;
                 }
                 $serviceCount = $this->_model->getCounterByService($current->ws_service_id, $this->_start, $this->_end);
             } else {
                 $last = true;
             }
         } else {
             if ($rows->count() > 1 && $rows->getRow(1)->ws_service_id == $current->ws_service_id) {
                 $last = false;
             }
             $serviceCount = $this->_model->getCounterByService($current->ws_service_id, $this->_start, $this->_end);
         }
         $row['phone_number'] = $current->findParentRow('WsServiceSms')->phone_number;
         $row['mpk'] = $current->findParentRow('Wsclient')->mpk;
         $row['client_name'] = $current->findParentRow('Wsclient')->client_name;
         $row['count_value'] = $current->count_value;
         $row['part'] = round($current->count_value / $serviceCount->count_value * 100);
         $output['auto'][$current->ws_service_id][] = $row;
         if ($last) {
             $output['auto'][$current->ws_service_id]['total'] = $serviceCount->count_value;
         }
         $rows->next();
     }
     $rows = $this->_model->getRaportDataServiceSet($this->_start, $this->_end);
     while ($current = $rows->current()) {
         $last = true;
         $row = array();
         if ($rows->key() > 0) {
             $prev = $rows->getRow($rows->key() - 1);
             if ($prev->ws_service_id != $current->ws_service_id) {
                 $last = false;
                 if ($rows->key() == $rows->count() - 1) {
                     $last = true;
                 }
                 $serviceCount = $this->_model->getCounterByServiceSet($current->ws_service_id, $this->_start, $this->_end);
             } else {
                 $last = true;
             }
         } else {
             if ($rows->count() > 1 && $rows->getRow(1)->ws_service_id == $current->ws_service_id) {
                 $last = false;
             }
             $serviceCount = $this->_model->getCounterByServiceSet($current->ws_service_id, $this->_start, $this->_end);
         }
         $row['phone_number'] = $current->findParentRow('WsServiceSms')->phone_number;
         $row['mpk'] = $current->findParentRow('Wsclient')->mpk;
         $row['client_name'] = $current->findParentRow('WsServiceSet')->name;
         $row['count_value'] = $current->count_value;
         $row['part'] = round($current->count_value / $serviceCount->count_value * 100);
         $output['manual'][$current->ws_service_set_id][] = $row;
         if ($last) {
             $output['manual'][$current->ws_service_set_id]['total'] = $serviceCount->count_value;
         }
         $rows->next();
     }
     $this->saveDownload($raportsData);
     $view->output = $output;
     $this->renderPdf($view->render('raport.phtml'));
 }