Пример #1
0
 public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $page = $this->params()->fromRoute('page');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(AlboPretorioSearchController::sessionIdentifier);
     try {
         $helper = new AlboPretorioControllerHelper();
         $sezioniRecords = $helper->recoverWrapperRecords(new AlboPretorioSezioniGetterWrapper(new AlboPretorioSezioniGetter($em)), array());
         $articoliWrapper = $helper->recoverWrapperRecordsPaginator(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'sezioneId' => isset($sessionSearch['sezine']) ? $sessionSearch['sezine'] : null, 'numeroProgressivo' => isset($sessionSearch['numero_progressivo']) ? $sessionSearch['numero_progressivo'] : null, 'numeroAtto' => isset($sessionSearch['numero_atto']) ? $sessionSearch['numero_atto'] : null, 'mese' => isset($sessionSearch['mese']) ? $sessionSearch['mese'] : null, 'anno' => isset($sessionSearch['anno']) ? $sessionSearch['anno'] : null, 'noScaduti' => 1, 'orderBy' => 'alboArticoli.id DESC', 'pubblicare' => 1), $page, null);
         $articoliWrapper->setEntityManager($em);
         $mainRecords = $articoliWrapper->addAttachmentsToPaginatorRecords($articoliWrapper->setupRecords(), array('moduleId' => ModulesContainer::albo_pretorio_id, 'noScaduti' => 1, 'orderBy' => 'a.position'));
         $formSearch = new AlboPretorioFormSearch();
         $formSearch->addYears();
         $formSearch->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
         $formSearch->addCheckExpired();
         $formSearch->addSubmitButton();
         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'], 'expired' => $sessionSearch['expired']));
         }
         $this->layout()->setVariables(array('sessionSearch' => $sessionSearch, 'form' => $formSearch, 'paginator' => $articoliWrapper->getPaginator(), 'emptyRecords' => count($mainRecords), 'records' => $mainRecords, 'templatePartial' => 'albo-pretorio/albo-pretorio.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageTitle' => 'Si è verificato un problema:', 'messageText' => $e->getMessage(), 'moduleLabel' => 'Albo pretorio', 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $mainLayout = $this->initializeAdminArea();
         $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
         $lang = $this->params()->fromRoute('lang');
         $id = $this->params()->fromPost('revisionId');
         try {
             $helper = new AlboPretorioControllerHelper();
             $articoloRecord = $helper->recoverWrapperRecordsById(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('id' => $id, 'limit' => 1), $id);
             $helper->checkRecords($articoloRecord, 'Atto albo pretorio non trovato');
             $sezioniRecords = $helper->recoverWrapperRecords(new AlboPretorioSezioniGetterWrapper(new AlboPretorioSezioniGetter($em)), array());
             $articoloRecord[0]['checkRettifica'] = 1;
             $form = new AlboPretorioArticoliForm();
             $form->addNote();
             $form->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
             $form->addTitolo();
             $form->addMainFields();
             $form->addScadenze();
             $form->setData($articoloRecord[0]);
             $this->layout()->setVariables(array('form' => $form, 'formAction' => $this->url()->fromRoute('admin/albo-pretorio-update', array('lang' => $lang)), 'formTitle' => $articoloRecord[0]['titolo'], 'formDescription' => "Compila i dati relativi all'atto da inserire sull'albo pretorio", 'templatePartial' => self::formTemplate, 'formBreadCrumbCategory' => array(array('label' => 'Albo pretorio', 'href' => $this->url()->fromRoute('admin/albo-pretorio-summary', array('lang' => $lang)), 'title' => "'Torna all'elenco atti albo pretorio")), 'alboRevisionWarning' => 1, 'alboNumeroAtto' => $articoloRecord[0]['numeroAtto'], 'alboAnnoAtto' => $articoloRecord[0]['anno']));
             $this->layout()->setTemplate($mainLayout);
         } catch (\Exception $e) {
             $this->layout()->setVariables(array('messageType' => 'warning', 'messageTitle' => 'Errore verificato', 'messageText' => $e->getMessage(), 'showBreadCrumb' => 1, 'formBreadCrumbCategory' => array(array('label' => 'Albo pretorio', 'href' => $this->url()->fromRoute('admin/albo-pretorio-operations', array('lang' => $this->params()->fromRoute('lang'), 'action' => 'publish')), 'title' => "Vai all'elenco atti albo pretorio")), 'dataTableActiveTitle' => 'Rettifica atto', 'templatePartial' => 'message.phtml'));
         }
     } else {
         return $this->redirect()->toRoute('admin/albo-pretorio-summary', array('lang' => $this->params()->fromRoute('lang')));
     }
 }
 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);
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $id = $this->params()->fromRoute('id');
     $lang = $this->params()->fromRoute('lang');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $helper = new AlboPretorioControllerHelper();
     try {
         $sezioniRecords = $helper->recoverWrapperRecords(new AlboPretorioSezioniGetterWrapper(new AlboPretorioSezioniGetter($em)), array('fields' => 'aps.id, aps.nome', 'orderBy' => 'aps.nome ASC'));
         $helper->checkRecords($sezioniRecords, 'Sezioni non presenti o non rilevate dal sistema. Verificare i dati delle sezioni o inserirne una nuova');
         $articoliRecords = $helper->recoverWrapperRecordsById(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('id' => $id, 'limit' => 1), $id);
         $helper->checkArticoloIsNotAnnulled($articoliRecords);
         $numeroProgressivo = $helper->recoverNumeroProgressivo(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), date("Y"));
         $form = new AlboPretorioArticoliForm();
         $form->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
         $form->addTitolo();
         $form->addNumero();
         $form->addAnno();
         $form->addMainFields();
         $form->addScadenze();
         $form->addHomePage();
         if (!empty($articoliRecords)) {
             $form->setData($articoliRecords[0]);
             $formAction = $this->url()->fromRoute('admin/albo-pretorio-update', array('lang' => $lang));
             $formTitle = $articoliRecords[0]['titolo'];
             $submitButtonValue = 'Modifica';
         } else {
             $form->addFacebook();
             $form->setData(array('anno' => date("Y"), 'numeroAtto' => $numeroProgressivo));
             $formAction = $this->url()->fromRoute('admin/albo-pretorio-insert', array('lang' => $lang));
             $formTitle = 'Nuovo atto';
             $submitButtonValue = 'Inserisci';
         }
         $this->layout()->setVariables(array('form' => $form, 'formAction' => $formAction, 'formTitle' => $formTitle, 'formDescription' => "Compila i dati relativi all'atto da inserire sull'albo pretorio", 'submitButtonValue' => $submitButtonValue, 'templatePartial' => self::formTemplate, 'formBreadCrumbCategory' => array(array('label' => 'Albo pretorio', 'href' => $this->url()->fromRoute('admin/albo-pretorio-summary', array('lang' => $lang)), 'title' => "'Torna all'elenco atti albo pretorio"))));
     } catch (NullException $e) {
         $message = $e->getParams();
         $this->layout()->setVariables(array('messageType' => $message['type'] ? $message['type'] : 'warning', 'messageTitle' => $message['title'] ? $message['title'] : 'Problema verificato', 'messageText' => $message['text'] ? $message['text'] : $e->getMessage(), 'showBreadCrumb' => 1, 'formBreadCrumbCategory' => 'Albo pretorio', 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }