public function indexAction() { $mainLayout = $this->initializeAdminArea(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $id = $this->params()->fromRoute('id'); $lang = $this->params()->fromRoute('lang'); $moduleCode = $this->params()->fromRoute('module'); try { switch ($moduleCode) { default: throw new NullException("Codice modulo non valido"); break; case "albo-pretorio": $recordsGetter = new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)); $recordsGetter->setInput(array('id' => $id, 'limit' => 1)); $recordsGetter->setupQueryBuilder(); $moduleName = 'Albo pretorio'; $record = $recordsGetter->getRecords(); $titolo = $record[0]['titolo']; break; case "stato-civile": $recordsGetter = new StatoCivileGetterWrapper(new StatoCivileGetter($em)); $recordsGetter->setInput(array("id" => $id, 'limit' => 1)); $recordsGetter->setupQueryBuilder(); $moduleName = 'Stato civile'; $record = $recordsGetter->getRecords(); $titolo = $record[0]['titolo']; break; } $wrapper = new EntiTerziGetterWrapper(new EntiTerziGetter($em)); $wrapper->setupQueryBuilder(); $entiTerziRecords = $wrapper->getRecords(); $form = new InvioEnteTerzoForm(); $form->addContatti($entiTerziRecords); $this->layout()->setVariables(array('formDataCommonPath' => 'backend/templates/common/', 'form' => $form, 'formAction' => $this->url()->fromRoute('admin/invio-ente-terzo-inviomail', array('lang' => $lang, 'modulename' => $moduleCode, 'id' => $record[0]['id'])), 'moduleName' => $moduleName, 'moduleCode' => $moduleCode, 'titolo' => $titolo, 'rubricaEntiTerzi' => $entiTerziRecords, 'templatePartial' => 'invio-ente-terzo/invio-ente-terzo.phtml')); $this->layout()->setTemplate($mainLayout); } catch (\Exception $e) { } }
/** * @param StatoCivileGetterWrapper $wrapper * @param array $input * @return array */ public function setupYears(StatoCivileGetterWrapper $wrapper, $input = array()) { $wrapper->setInput($input); $wrapper->setupQueryBuilder(); return $wrapper->formatYears($wrapper->getRecords()); }
/** * TXT action * * @return \Zend\Http\Response|\Zend\Stdlib\ResponseInterface * @throws \ModelModule\Model\NullException */ public function txtAction() { if ($this->getRequest()->isPost()) { $this->initializeFrontendWebsite(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $wrapper = new StatoCivileGetterWrapper(new StatoCivileGetter($em)); $wrapper->setInput(array('numero' => isset($post['numero']) ? $post['numero'] : null, 'anno' => isset($post['anno']) ? $post['anno'] : null, 'sezioneId' => isset($post['sezione']) ? $post['sezione'] : null, 'noScaduti' => isset($post['expired']) ? $post['expired'] : null, 'textSearch' => isset($post['testo']) ? $post['testo'] : null, 'orderBy' => 'sca.id DESC', 'limit' => 1500)); $wrapper->setupQueryBuilder(); $records = $wrapper->getRecords(); $content = ''; $content .= $this->layout()->getVariable('sitename') . "\n"; $content .= "Stato civile \n"; $content .= "---------------------------------------------------------------- \n"; foreach ($records as $record) { $content .= $record['titolo'] . "\n"; $content .= 'Sezione: ' . $record['nomeSezione'] . "\n"; $content .= "Inserito il: " . $record['data']->format("d-m-Y") . "\n"; $content .= "Scadenza: " . $record['scadenza']->format("d-m-Y") . "\n"; $content .= "---------------------------------------------------------------- \n"; } $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Content-Type', 'text/plain')->addHeaderLine('Content-Disposition', 'attachment; filename="stato_civile_' . date("dmYHis") . '.txt"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content)); $response->setContent($content); return $response; } return $this->redirectForUnvalidAccess(); }
public function testFormatYears() { $years = $this->objectWrapper->formatYears(array('anno' => 2014), array('anno' => 2015)); $this->assertTrue(is_array($years)); }