コード例 #1
0
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perpage');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $helper = new AlboPretorioControllerHelper();
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(AlboPretorioSearchController::sessionIdentifier);
     try {
         $arraySearch = $helper->recoverArrayQuerySearch($sessionSearch);
         $sezioniRecords = $helper->recoverWrapperRecords(new AlboPretorioSezioniGetterWrapper(new AlboPretorioSezioniGetter($em)), array('orderBy' => 'aps.nome ASC'));
         $helper->checkRecords($sezioniRecords, 'Nessuna sezione presente');
         $alboArticoliWrapper = $helper->recoverWrapperRecordsPaginator(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), $arraySearch, $page, $perPage);
         $formSearch = new AlboPretorioFormSearch();
         $formSearch->addYears();
         $formSearch->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
         $formSearch->addCheckExpired();
         $formSearch->addSubmitButton();
         $formSearch->addResetButton();
         $formSearch->addHomePage();
         if (!empty($sessionSearch)) {
             $formSearch->setData(array('numero_progressivo' => $sessionSearch['numero_progressivo'], 'numero_atto' => $sessionSearch['numero_atto'], 'mese' => $sessionSearch['mese'], 'anno' => $sessionSearch['anno'], 'sezione' => $sessionSearch['sezione'], 'testo' => $sessionSearch['testo'], 'home' => $sessionSearch['home'], 'expired' => $sessionSearch['expired']));
         }
         $alboArticoliRecords = $alboArticoliWrapper->setupRecords();
         $alboArticoliWrapper->setEntityManager($em);
         $alboArticoliWrapper->addAttachmentsFromRecords($alboArticoliRecords, array('moduleId' => ModulesContainer::albo_pretorio_id));
         $paginator = $alboArticoliWrapper->getPaginator();
         $paginatorCount = $paginator->getTotalItemCount();
         $tableDescription = $paginatorCount . " atti in archivio. ";
         if ($paginatorCount > 0) {
             $alboStatisticsRecords = $helper->recoverWrapperRecords(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array_merge($arraySearch, array('fields' => '
                         (SELECT COUNT(alboArt.id) FROM Application\\Entity\\ZfcmsComuniAlboArticoli alboArt WHERE alboArt.attivo = 0) AS disattivati,
                         (SELECT COUNT(aArt.id) FROM Application\\Entity\\ZfcmsComuniAlboArticoli aArt WHERE aArt.annullato = 1) AS annullati,
                         (SELECT COUNT(aa.id) FROM Application\\Entity\\ZfcmsComuniAlboArticoli aa WHERE aa.pubblicare = 0) AS nonPubblicati,
                         (SELECT COUNT(aHome.id) FROM Application\\Entity\\ZfcmsComuniAlboArticoli aHome WHERE aHome.pubblicare = 0) AS inHome
                     ', 'limit' => 1)));
             $tableDescription .= $alboStatisticsRecords[0]['disattivati'] . ' disattivati';
             $tableDescription .= ', ' . $alboStatisticsRecords[0]['annullati'] . ' annullati';
             $tableDescription .= ', ' . $alboStatisticsRecords[0]['nonPubblicati'] . ' non pubblicati';
             $tableDescription .= ', ' . $alboStatisticsRecords[0]['inHome'] . ' presenti in home page';
         }
         $this->layout()->setVariables(array('formSearch' => $formSearch, 'tableTitle' => 'Albo pretorio', 'tableDescription' => $tableDescription, 'columns' => array(array('label' => 'Num \\ Anno', 'width' => '10%'), array('label' => 'Titolo', 'width' => '20%'), 'Sezione', 'Date', 'Inserito da', ' ', ' ', ' ', ' ', ' ', ' '), 'sessionSearch' => $sessionSearch, 'paginator' => $paginator, 'records' => $this->formatArticoliRecords($alboArticoliRecords), 'templatePartial' => 'datatable/datatable_albo_pretorio.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageType' => 'warning', 'messageTitle' => 'Problema verificato', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
コード例 #2
0
 /**
  * Set search session
  *
  * @return \Zend\Http\Response
  */
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $inputFilter = new AlboPretorioFormSearchInputFilter();
         $formSearch = new AlboPretorioFormSearch();
         $formSearch->setBindOnValidate(false);
         $formSearch->addYears();
         $formSearch->addCheckExpired();
         $formSearch->addSubmitButton();
         $formSearch->addResetButton();
         $formSearch->setInputFilter($inputFilter->getInputFilter());
         $formSearch->addHomePage();
         $formSearch->setData($post);
         if ($formSearch->isValid()) {
             $inputFilter->exchangeArray($formSearch->getData());
             $formSearch->setData($post);
             $sessioContainer = new SessionContainer();
             $sessioContainer->offsetSet(self::sessionIdentifier, array('numero_progressivo' => $inputFilter->numero_progressivo != 0 ? $inputFilter->numero_progressivo : null, 'numero_atto' => $inputFilter->numero_atto != 0 ? $inputFilter->numero_atto : null, 'testo' => $inputFilter->testo, 'mese' => $inputFilter->mese, 'anno' => $inputFilter->anno, 'sezione' => $inputFilter->sezione, 'home' => $inputFilter->home, 'expired' => $inputFilter->expired));
             $referer = $this->getRequest()->getHeader('Referer');
             if (is_object($referer)) {
                 return $this->redirect()->toUrl($referer->getUri());
             }
         }
         $mainLayout = $this->initializeFrontendWebsite();
         $referer = $this->getRequest()->getHeader('Referer');
         $alboUrl = $this->url()->fromRoute('albo-pretorio');
         $refererUrl = is_object($referer) ? $referer->getUri() : $alboUrl;
         $this->layout()->setVariables(array('formMessages' => $formSearch->getMessages(), 'refererUrl' => $refererUrl, 'moduleUrl' => $alboUrl, 'moduleLabel' => "Albo pretorio", 'templatePartial' => 'form-message.phtml'));
         $this->layout()->setTemplate($mainLayout);
     } else {
         $referer = $this->getRequest()->getHeader('Referer');
         if (is_object($referer)) {
             return $this->redirect()->toUrl($referer->getUri());
         }
         return $this->redirect()->toRoute('main');
     }
 }