public function countSignedEmendamentiAtDate($date = null) { if (is_null($date)) { $date = date('Y-m-d'); } return OppCaricaHasEmendamentoPeer::countSignedByAtDate($this->getCaricaDepSenCorrente()->getId(), $date); }
public static function getRecordsetFirmatari($em_id, $tipo) { $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppPoliticoPeer::ID); $c->addSelectColumn(OppPoliticoPeer::NOME); $c->addSelectColumn(OppPoliticoPeer::COGNOME); $c->addSelectColumn(OppGruppoPeer::NOME); $c->addSelectColumn(OppCaricaHasEmendamentoPeer::DATA); $c->addSelectColumn(OppGruppoPeer::ACRONIMO); $c->add(OppCaricaHasEmendamentoPeer::EMENDAMENTO_ID, $em_id, Criteria::EQUAL); $c->addJoin(OppCaricaHasEmendamentoPeer::CARICA_ID, OppCaricaPeer::ID, Criteria::LEFT_JOIN); $c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID, Criteria::LEFT_JOIN); $c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID, Criteria::LEFT_JOIN); $c->addJoin(OppCaricaHasGruppoPeer::GRUPPO_ID, OppGruppoPeer::ID, Criteria::LEFT_JOIN); $c->add(OppCaricaHasEmendamentoPeer::TIPO, $tipo, Criteria::EQUAL); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $c->addDescendingOrderByColumn(OppCaricaHasGruppoPeer::DATA_INIZIO); $rs = OppCaricaHasEmendamentoPeer::doSelectRS($c); return $rs; }
/** * estrae tutte le firme fino a una certa data * * @param string $data * @return array di OppCaricaHasEmendamento * @author Guglielmo Celata */ public function getFirme($data) { return OppCaricaHasEmendamentoPeer::getFirme($this->getId(), $data); }
/** * estrae tutti gli atti presentati dal parlamentare nel corso della legislatura * sono considerate tutte le cariche ricoperte * * @return void * @author Guglielmo Celata */ public function executeAttiPresentati() { $cariche_ids = $this->parlamentare->getCaricheCorrentiIds(); if (count($cariche_ids) == 0) { $this->atti_presentati = array(); return; } $cariche_ids_as_string = join($cariche_ids, ","); /* select raw select ta.descrizione, ca.tipo, count(ta.id) from opp_carica_has_atto ca, opp_atto a, opp_tipo_atto ta where ca.atto_id=a.id and a.tipo_atto_id=ta.id and carica_id=$carica->getId() group by ta.id, ca.tipo order by ta.id; */ $connection = Propel::getConnection(); $query = "SELECT %s AS tipo, %s AS tipo_id, %s AS firma, count(%s) AS cnt " . "FROM %s, %s, %s " . "WHERE %s=%s and %s=%s and %s in ({$cariche_ids_as_string})" . "GROUP BY %s, %s " . "ORDER BY %s"; $query = sprintf($query, OppTipoAttoPeer::DESCRIZIONE, OppTipoAttoPeer::ID, OppCaricaHasAttoPeer::TIPO, OppTipoAttoPeer::ID, OppCaricaHasAttoPeer::TABLE_NAME, OppAttoPeer::TABLE_NAME, OppTipoAttoPeer::TABLE_NAME, OppCaricaHasAttoPeer::ATTO_ID, OppAttoPeer::ID, OppAttoPeer::TIPO_ATTO_ID, OppTipoAttoPeer::ID, OppCaricaHasAttoPeer::CARICA_ID, OppTipoAttoPeer::ID, OppCaricaHasAttoPeer::TIPO, OppTipoAttoPeer::ID); $statement = $connection->prepareStatement($query); $rs = $statement->executeQuery(); $atti = array(); while ($rs->next()) { $tipo = $rs->getString('tipo'); $tipo_id = $rs->getString('tipo_id'); if (!array_key_exists($tipo, $atti)) { $atti[$tipo] = array('id' => $tipo_id, 'C' => 0, 'P' => 0, 'R' => 0); } $firma = $rs->getString('firma'); $cnt = $rs->getInt('cnt'); $atti[$tipo][$firma] = $cnt; } $this->atti_presentati = $atti; for ($x = 0; $x < 2; $x++) { $c = new Criteria(); $c->add(OppCaricaHasEmendamentoPeer::CARICA_ID, $cariche_ids, Criteria::IN); if ($x == 0) { $c->add(OppCaricaHasEmendamentoPeer::TIPO, 'P'); $this->emen_primo = OppCaricaHasEmendamentoPeer::doCount($c); } else { $c->add(OppCaricaHasEmendamentoPeer::TIPO, 'C'); $this->emen_co = OppCaricaHasEmendamentoPeer::doCount($c); } } }
public function executeEmendamenti() { $this->_getAndCheckParlamentare(); $title = 'Emendamenti presentati in Parlamento da '; if ($this->carica) { if ($this->carica->getTipoCaricaId() == 1) { $ramo = 'C'; } if ($this->carica->getTipoCaricaId() == 4 || $this->carica->getTipoCaricaId() == 5) { $ramo = 'S'; } $this->ramo = $ramo == 'C' ? 'camera' : 'senato'; $title .= $this->ramo == 'camera' ? ' On. ' : ' Sen. '; } $this->getResponse()->setTitle($title . $this->parlamentare->getNome() . ' ' . $this->parlamentare->getCognome() . ' - ' . sfConfig::get('app_main_title')); $this->response->addMeta('description', 'La lista aggiornata quotidianamente di tutti gli emendamenti presentati da ' . $this->parlamentare->getNome() . ' ' . $this->parlamentare->getCognome(), true); $this->session = $this->getUser(); // reset dei filtri se richiesto esplicitamente if ($this->getRequestParameter('reset_filters', 'false') == 'true') { $this->getRequest()->getParameterHolder()->set('filter_ddls_collegati', '0'); $this->getRequest()->getParameterHolder()->set('filter_act_firma', '0'); // $this->getRequest()->getParameterHolder()->set('filter_act_ramo', '0'); // $this->getRequest()->getParameterHolder()->set('filter_act_stato', '0'); } $this->processEmendamentiFilters(array('ddls_collegati', 'act_firma')); // if all filters were reset, then restart if ($this->getRequestParameter('filter_ddls_collegati') == '0' && $this->getRequestParameter('filter_act_firma') == '0') { $this->redirect('@parlamentare_emendamenti?id=' . $this->getRequestParameter('id') . '&slug=' . $this->parlamentare->getSlug()); } //$this->processEmendamentiSort(); if ($this->hasRequestParameter('itemsperpage')) { $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage')); } $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit')); $this->pager = new sfPropelPager('OppCaricaHasEmendamento', $itemsperpage); // estrazione cariche parlamentare $cariche_ids = $this->parlamentare->getCaricheCorrentiIds(); /* // estrae tutti i ddl collegati $c=new Criteria(); $c->addJoin(OppEmendamentoPeer::ID, OppCaricaHasEmendamentoPeer::EMENDAMENTO_ID); $c->add(OppCaricaHasEmendamentoPeer::CARICA_ID, $cariche_ids, Criteria::IN); $emens=OppEmendamentoPeer::doSelect($c); $this->ddls_collegati=array(); foreach($emens as $em) { $ddls=$em->getOppAttoHasEmendamentos(); $ddl=$ddls[0]->getOppAtto(); if (!in_array( $ddl,$this->ddls_collegati)) $this->ddls_collegati[]=$ddl; } */ $this->ddls_collegati = empty($cariche_ids) ? $cariche_ids : OppCaricaHasEmendamentoPeer::getDDLCollegatiCariche($cariche_ids); $c = new Criteria(); $c->addJoin(OppEmendamentoPeer::ID, OppCaricaHasEmendamentoPeer::EMENDAMENTO_ID); $c->add(OppCaricaHasEmendamentoPeer::CARICA_ID, $cariche_ids, Criteria::IN); $this->addEmendamentiFiltersCriteria($c); //$this->addAttiSortCriteria($c); $c->addDescendingOrderByColumn(OppEmendamentoPeer::DATA_PRES); $this->pager->setCriteria($c); $this->pager->setPage($this->getRequestParameter('page', 1)); $this->pager->setPeerMethod('doSelectJoinOppEmendamento'); $this->pager->init(); }