Exemplo n.º 1
0
 public function listAction()
 {
     if ($this->getRequest()->isXmlHttpRequest()) {
         if ($this->sSessionNameSpace != '') {
             $container = new \Zend\Session\Container($this->sSessionNameSpace);
             $this->getReadTable()->createWhere($container);
             if ($container->offsetExists('orderby')) {
                 $this->getReadTable()->createOrder($container->offsetGet('orderby'), $container->offsetGet('direction'));
             }
         }
         $paginator = $this->getReadTable()->fetchAllPaginator();
         $iCount = (int) $this->params()->fromQuery('count', 20);
         $iStart = (int) $this->params()->fromQuery('posStart', 0);
         $iPage = round($iStart / $iCount, 0, PHP_ROUND_HALF_UP) + 1;
         $paginator->setCurrentPageNumber($iPage);
         if (!$this->bPaginator) {
             $iCount = $paginator->getTotalItemCount();
         }
         $paginator->setItemCountPerPage($iCount);
         $adapter = $paginator->getAdapter();
         $results = $adapter->getItems($iStart, $iCount);
         $oMyGrid = new Grid($results->toArray(), 'id');
         $oMyGrid->setPagingGrid($iStart, $paginator->getTotalItemCount());
         $xml = $oMyGrid->createXml();
         $this->getResponse()->getHeaders()->addHeaders(array('Content-type' => 'text/xml'));
         return $this->getResponse()->setContent($xml);
     }
 }
Exemplo n.º 2
0
 public function pdfAction()
 {
     require_once ROOT_DIR . '/vendor/My/grid-pdf-php/gridPdfGenerator.php';
     require_once ROOT_DIR . '/vendor/My/grid-pdf-php/tcpdf/tcpdf.php';
     require_once ROOT_DIR . '/vendor/My/grid-pdf-php/gridPdfWrapper.php';
     if ($this->sSessionNameSpace != '') {
         $container = new \Zend\Session\Container($this->sSessionNameSpace);
         $this->getReadTable()->createWhere($container);
         if ($container->offsetExists('orderby')) {
             $this->getReadTable()->createOrder($container->offsetGet('orderby'), $container->offsetGet('direction'));
         }
     }
     $paginator = $this->getReadTable()->fetchAllPaginator();
     $iCount = (int) $this->params()->fromQuery('count', 20);
     $iStart = (int) $this->params()->fromQuery('posStart', 0);
     $iPage = round($iStart / $iCount, 0, PHP_ROUND_HALF_UP) + 1;
     $paginator->setCurrentPageNumber($iPage);
     $iCount = $paginator->getTotalItemCount();
     $paginator->setItemCountPerPage($iCount);
     $adapter = $paginator->getAdapter();
     $results = $adapter->getItems($iStart, $iCount);
     $aHead = $this->prepareHeadGrid();
     $sFooter = implode(',', $this->getReadTable()->getColumnViewList());
     $oMyGrid = new Grid($results->toArray(), 'id', '', array_merge($aHead, array('footer' => $this->getReadTable()->getColumnViewList())));
     $oMyGrid->setPagingGrid($iStart, $paginator->getTotalItemCount());
     $xml = $oMyGrid->createXml();
     ob_clean();
     $pdf = new \gridPdfGenerator();
     $xmlPDF = simplexml_load_string($xml);
     $pdf->printGrid($xmlPDF);
     exit;
 }