function link_to_politicoNomeTipoFromCaricaId($carica_id, $relevance) { $carica = OppCaricaPeer::retrieveByPK($carica_id); if ($carica) { $politico = $carica->getOppPolitico(); $str = $politico->__toString(); } else { return "impossibile trovare carica per {$carica_id}"; } $c = new Criteria(); $c->add(OppCaricaHasGruppoPeer::CARICA_ID, $carica_id); $c->add(OppCaricaHasGruppoPeer::DATA_FINE, NULL); $gruppo_attuale = OppCaricaHasGruppoPeer::doSelectOne($c); $str = $str . " (" . $gruppo_attuale->getOppGruppo()->getAcronimo() . ")"; // Visualizzazione dell'indice di rilevanza $punteggio = $relevance['punteggio']; return link_to($str, '@parlamentare?' . $politico->getUrlParams(), array('class' => 'folk2', 'title' => "punteggio: " . $punteggio)); }
/** * estrae l'elenco di cariche di un parlamentare, per la legislatura corrente * se il parlamentare è un senatore a vita, vengono estratte solo le cariche attuali (la legislatura non conta) * * @return void * @author Guglielmo Celata */ public function getCaricheCorrentiIds() { $c = new Criteria(); $cton = $c->getNewCriterion(OppCaricaPeer::POLITICO_ID, $this->getId()); $cton->addAnd($c->getNewCriterion(OppCaricaPeer::LEGISLATURA, sfConfig::get('app_legislatura_corrente'))); $cton_vita = $c->getNewCriterion(OppCaricaPeer::POLITICO_ID, $this->getId()); $cton_vita->addAnd($c->getNewCriterion(OppCaricaPeer::TIPO_CARICA_ID, 5)); $cton_vita->addAnd($c->getNewCriterion(OppCaricaPeer::DATA_FINE, null, Criteria::ISNULL)); $cton->addOr($cton_vita); $c->add($cton); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::ID); $rs = OppCaricaPeer::doSelectRS($c); $cariche = array(); while ($rs->next()) { $cariche[] = $rs->getInt(1); } return $cariche; }
public function executeBoxparlamentari() { $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::ID); $c->addSelectColumn(OppPoliticoPeer::ID); $c->addSelectColumn(OppPoliticoPeer::COGNOME); $c->addSelectColumn(OppPoliticoPeer::NOME); $c->addSelectColumn(OppPoliticoPeer::N_MONITORING_USERS); $c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID, Criteria::INNER_JOIN); $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::ISNULL); // deputati + monitorati if ($this->type == 'deputati') { $c->add(OppCaricaPeer::TIPO_CARICA_ID, 1); } else { // senatori + monitorati $c->add(OppCaricaPeer::TIPO_CARICA_ID, 4); } $c->addDescendingOrderByColumn(OppPoliticoPeer::N_MONITORING_USERS); $c->setLimit(3); $this->parlamentari = OppCaricaPeer::doSelectRS($c); }
public function executeGetParlamentoIdParlamentariInCarica() { $ramo = $this->getRequestParameter('ramo'); $resp_node = new SimpleXMLExtended('<opp xmlns="' . $this->opp_ns . '" ' . ' xmlns:opp="' . $this->op_ns . '" ' . ' xmlns:xlink="' . $this->xlink_ns . '" >' . '</opp>'); // start producing xml $content_node = $resp_node->addChild('opp:content', null, $this->op_ns); $c = new Criteria(); if ($ramo == 'C') { $arr_tipo_id = array(1); } else { $arr_tipo_id = array(4, 5); } $c->add(OppCaricaPeer::TIPO_CARICA_ID, $arr_tipo_id, Criteria::IN); $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::ISNULL); $parlamentari = OppCaricaPeer::doSelect($c); foreach ($parlamentari as $p) { $p_node = $content_node->addChild('parlamentare', $p->getId()); $p_node->addAttribute('parlamento_id', $p->getParliamentId()); } $xmlContent = $resp_node->asXML(); $this->_send_output($xmlContent); return sfView::NONE; }
echo $tr_class; ?> "> <?php $tr_class = $tr_class == 'even' ? 'odd' : 'even'; ?> <th scope="row"> <p class="politician-id"> <?php echo image_tag(OppPoliticoPeer::getThumbUrl($k), array('width' => '40', 'height' => '53')); ?> <?php $politico = OppPoliticoPeer::retrieveByPk($k); ?> <?php echo (OppCaricaPeer::retrieveByPk($c[1])->getTipoCaricaId() == 1 ? 'On. ' : 'Sen. ') . link_to($politico->getCognome() . " " . $politico->getNome(), "@parlamentare?" . $politico->getUrlParams()); ?> (<?php echo OppCaricaHasGruppoPeer::getGruppoCorrentePerCarica($c[1])->getAcronimo(); ?> ) </p> </th> <td><?php echo $c[0]; ?> </td> </tr> <?php } ?>
public function executeListClassificaActionAid() { $this->ramo = $this->getRequestParameter('ramo'); $this->argomentis = array('aiuti umanitari' => 6729, 'cooperazione allo sviluppo' => 4653); $this->forward404Unless(in_array($this->ramo, array('C', 'S'))); if ($this->ramo == 'C') { $this->tipo_politici = 'dep'; } else { $this->tipo_politici = 'sen'; } if ($this->hasRequestParameter('limit')) { $limit = $this->getRequestParameter('limit'); } // la data è passata come parametro o viene estratta l'ultima nella cache (per dati di tipo 'A', singoli atti) if ($this->hasRequestParameter('data')) { $data = $this->getRequestParameter('data'); } else { $data = OppActHistoryCachePeer::fetchLastData(); } $this->politici = OppCaricaPeer::getClassificaPoliticiSiOccupanoDiArgomenti(array_values($this->argomentis), $this->ramo, $data); }
/** * restituisce i componenti del Governo (PresDelCons e Ministri) che appartengono ad un gruppo, se data_fine è zero (default, restituisce i componenti attuali, se 1 quelli di tutta la legislatura) * * @param integer $gruppo_id * @return void * @author Ettore Di Cesare */ public static function getCaricheGovernoPerGruppo($gruppo_id, $data_fine = 0, $leg = 16) { $c = new Criteria(); $c->add(OppCaricaPeer::LEGISLATURA, $leg, Criteria::EQUAL); $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(2, 3), Criteria::IN); $ministri = OppCaricaPeer::doSelect($c); foreach ($ministri as $ministro) { $c = new Criteria(); $c->add(OppCaricaPeer::POLITICO_ID, $ministro->getPoliticoId()); $c->add(OppCaricaPeer::LEGISLATURA, $leg); $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(1, 4, 5), Criteria::IN); $deputato = OppCaricaPeer::doSelectOne($c); if ($deputato) { $gruppi = self::doSelectTuttiGruppiPerCarica($deputato->getId()); foreach ($gruppi as $gruppo) { if ($gruppo['gruppo_id'] == $gruppo_id) { $rs[] = $ministro->getId(); break; } } } } if (count($rs) > 0) { return $rs; } else { return NULL; } }
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); print "Fetching data... \n"; $c = new Criteria(); $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::EQUAL); $c->add(OppCaricaPeer::LEGISLATURA, 16, Criteria::EQUAL); $cariche = OppCaricaPeer::doSelect($c); foreach ($cariche as $carica) { $parlamentare = OppPoliticoPeer::RetrieveByPk($carica->getPoliticoId()); $report = $carica->getReport(); $presenze = $report['Astenuto'] + $report['Contrario'] + $report['Favorevole'] + $report['Partecipante votazione non valida'] + $report['Presidente di turno'] + $report['Richiedente la votazione e non votante'] + $report['Voto segreto']; $numero_votazioni = $report['Astenuto'] + $report['Contrario'] + $report['Favorevole'] + $report['Partecipante votazione non valida'] + $report['Presidente di turno'] + $report['Richiedente la votazione e non votante'] + $report['Voto segreto'] + $report['Assente'] + $report['In missione']; $gruppi = OppCaricaHasGruppoPeer::doSelectGruppiPerCarica($carica->getId()); foreach ($gruppi as $nome => $gruppo) { $data_inizio = split("/", $gruppo['data_inizio']); $di = "20" . $data_inizio[2] . "-" . $data_inizio[0] . "-" . $data_inizio[1]; if ($data_fine != '') { $data_fine = split("/", $gruppo['data_fine']); $df = "20" . $data_fine[2] . "-" . $data_fine[0] . "-" . $data_fine[1]; } else { $df = ''; } $ribelle_count = $parlamentare->getRibelleReport($carica->getId(), $report['carica'] == 'Deputato' ? 'C' : 'S', $nome, $di, $df); } print "id carica:" . $carica->getId() . " presenze:" . $presenze . " assenze:" . $report['Assente'] . " missioni:" . $report['In missione'] . "\n";
<th scope="col">missioni:</th> <th scope="col">ribellioni:</th> </tr> </thead> <tbody> <?php $tr_class = 'even'; ?> <?php foreach ($pager->getResults() as $record) { ?> <?php $parlamentare = OppCaricaPeer::retrieveByPK($record->getChiId()); ?> <tr class="<?php echo $tr_class; ?> "> <?php $tr_class = $tr_class == 'even' ? 'odd' : 'even'; ?> <th scope="row"> <?php if (!is_null($parlamentare)) { ?> <p><?php echo link_to($parlamentare->getOppPolitico() . " (" . ($parlamentare->getGruppo($date) ? $parlamentare->getGruppo($date)->getAcronimo() : '') . ") ", 'http://' . sfConfig::get('sf_site_url', 'op_openparlamento') . "@parlamentare?" . $parlamentare->getOppPolitico()->getUrlParams(), true);
public function executePosizioneDettaglio() { $carica_id = $this->getRequestParameter('carica_id'); $tags_ids = explode(",", trim(strip_tags($this->getRequestParameter('tags_ids', '')), " ,")); $user_id = $this->getUser()->getId(); $this->messaggi_dettaglio = OppCaricaPeer::getPosizionePoliticoOggettiVotatiPerArgomenti($carica_id, $tags_ids, $user_id, false, true); }
verifica l'esattezza del numero delle firme nei ddl di ogni singolo parlamentare Prende in input - il numero della legislatura */ define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); include "../parser/simple_html_dom.php"; //Controllo per i senatori $c = new Criteria(); $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(1, 4), Criteria::IN); $c->add(OppCaricaPeer::LEGISLATURA, $argv[1]); $results = OppCaricaPeer::doSelect($c); foreach ($results as $result) { if ($result->getTipoCaricaId() == 1) { $c = new Criteria(); $c->add(OppAppoggioPeer::CARICA_ID, $result->getId()); $c->add(OppAppoggioPeer::TIPOLOGIA, 2); $c->add(OppAppoggioPeer::LEGISLATURA, $argv[1]); $aka = OppAppoggioPeer::doSelectOne($c); if ($aka) { $url = "http://www.senato.it/ricerche/sDDLa/risultati.ricerca?searchID=null&parms.output=&parms.statoDiv=0%2C0%2C0%2C1%2C0%2C0%2C0&parms.statoIcone=0%2C0%2C0%2C1%2C0%2C0%2C0&parms.sel=&parms.des=&parms.selmode=&parms.legislatura=" . $argv[1] . "&parms.ramo=+&parms.numeroFase=&parms.specification=&parms.testoScheda=&parms.natura=+&parms.lettura=+&parms.presentatoDal=&parms.presentatoAl=&parms.numeroDecretoLegge=&parms.decretoLeggeDel=&parms.numeroGazzettaDecreto=&parms.gazzettaDecretoDel=&parms.numeroLegge=&parms.leggeDel=&parms.numeroGazzettaLegge=&parms.gazzettaLeggeDel=&parms.statoDal=&parms.statoAl=&parms.tuttiTermini=T&parms.teseo=&parms.livelloTeseo=+&parms.naturaParlamentare=on&parms.deputatoIniziativa=" . $aka->getAka() . "&parms.iniziativa=&parms.tipoFirmatari=+&parms.assegnazione=&parms.ultimaAssegnazione=on&parms.assegnatoDal=&parms.assegnatoAl=&parms.pareri=&parms.criterioPareriAssegnazione=OR&parms.trattazione=&parms.trattatoDal=&parms.trattatoAl=&parms.fattoProprio=&parms.relatori=&parms.options.resultsPerPage=10&parms.ordinamento=DESC&parms.ordinaPerData=true&button-cerca=Cerca"; } else { echo "??? non trovo AKA per " . $result->getId() . "\n"; $url = ""; } } else { $parl_id = $result->getParliamentId();
public function executeInteressiDettaglio() { $carica_id = $this->getRequestParameter('carica_id'); $tags_ids = explode(",", trim(strip_tags($this->getRequestParameter('tags_ids', '')), " ,")); // la data è passata come parametro o viene estratta l'ultima nella cache (per dati di tipo 'A', singoli atti) if ($this->hasRequestParameter('data')) { $data = $this->getRequestParameter('data'); } else { $data = OppActHistoryCachePeer::fetchLastData(); } $dettaglio = OppCaricaPeer::getDettaglioInteresseArgomenti($carica_id, $tags_ids, $data); $this->firme_p = $dettaglio['firme_p']; $this->totale_firme_p = $dettaglio['totale_firme_p']; $this->firme_r = $dettaglio['firme_r']; $this->totale_firme_r = $dettaglio['totale_firme_r']; $this->firme_c = $dettaglio['firme_c']; $this->totale_firme_c = $dettaglio['totale_firme_c']; $this->interventi = $dettaglio['interventi']; $this->totale_interventi = $dettaglio['totale_interventi']; }
public function executeSenatorisioccupanodi() { $options = array('limit' => 10, 'sort_by_relevance' => true); //$options = array('sort_by_relevance' => true); // estrazione cariche, tipo firma, tipo atto $c = new Criteria(); $c->addJoin(OppCaricaPeer::ID, OppCaricaHasAttoPeer::CARICA_ID); $c->addJoin(OppCaricaHasAttoPeer::ATTO_ID, OppAttoPeer::ID); $c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID); $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(4, 5), Criteria::IN); $c->add(OppCaricaPeer::DATA_FINE, NULL); $c->add(TaggingPeer::TAG_ID, $this->tag->getId()); $c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto'); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::ID); $c->addSelectColumn(OppCaricaHasAttoPeer::TIPO); $c->addSelectColumn(OppAttoPeer::TIPO_ATTO_ID); // costruzione array associativo dei politici $politici = array(); $rs = OppCaricaPeer::doSelectRS($c); while ($rs->next()) { $carica_id = $rs->getInt(1); $tipo = $rs->getString(2); $tipo_atto_id = $rs->getInt(3); if (!array_key_exists($carica_id, $politici)) { $politici[$carica_id] = 0; } $politici[$carica_id] += OppCaricaHasAttoPeer::get_nuovo_fattore_firma($tipo) * OppAttoPeer::get_fattore_tipo_atto($tipo_atto_id); } // ordinamento per rilevanza, prima dello slice arsort($politici); // slice dell'array, se specificata l'opzione limit $this->n_remaining_politici = 0; if (isset($options['limit']) && count($politici) > $options['limit']) { $this->n_remaining_politici = count($politici) - $options['limit']; $politici = array_slice($politici, 0, $options['limit'], true); } // ordinamento per triple_value, in caso sort_by_relevance non sia specificato if (!isset($options['sort_by_relevance']) || true !== $options['sort_by_relevance']) { krsort($politici); } $this->politici = $politici; }
echo image_tag(OppPoliticoPeer::getThumbUrl($politico->getId()), array('width' => '40', 'height' => '53')); ?> <?php echo link_to((OppSedePeer::retrieveByPk($sede_id)->getRamo() == 'CS' ? OppCaricaPeer::retrieveByPk($k[0])->getTipoCaricaId() == 1 ? 'On. ' : 'Sen. ' : '') . $politico->getNome() . " " . $politico->getCognome(), '@parlamentare?' . $politico->getUrlParams()); ?> <?php echo $k[1] != "componente" ? " (" . ucfirst($k[1]) . ")" : ""; ?> </p> </th> <td> <?php echo OppGruppoPeer::retrieveByPk($g)->getAcronimo(); ?> </td> <td> <?php echo OppCaricaPeer::retrieveByPk($k[0])->getCircoscrizione(); ?> </td> <?php } ?> <?php } } ?> </tbody> </table>
public function executeAttivitaPoliticoArgomento() { $dettaglio = OppCaricaPeer::getDettaglioInteresseArgomenti($this->carica_id, array($this->argomento_id), $this->data, false); $this->politico['firme_p'] = $dettaglio['firme_p']; $this->politico['firme_r'] = $dettaglio['firme_r']; $this->n_firme_pr = count($this->politico['firme_p']) + count($this->poitico['firme_r']); }
public static function doSelectVotoGruppo($votazione_id, $gruppo) { $c = new Criteria(); $c->add(OppVotazionePeer::ID, $votazione_id); $votazione = OppVotazionePeer::doSelectOne($c); $data_votazione = $votazione->getOppSeduta()->getData(); $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTO); $c->addAsColumn('CONT', 'COUNT(*)'); $c->addJoin(OppVotazioneHasCaricaPeer::CARICA_ID, OppCaricaPeer::ID, Criteria::INNER_JOIN); $c->addJoin(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, OppVotazionePeer::ID, Criteria::INNER_JOIN); //$c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID, Criteria::INNER_JOIN); $c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID, Criteria::INNER_JOIN); $c->addJoin(OppCaricaHasGruppoPeer::GRUPPO_ID, OppGruppoPeer::ID, Criteria::INNER_JOIN); $c->add(OppVotazioneHasCaricaPeer::VOTO, 'Assente', Criteria::NOT_EQUAL); $cton1 = $c->getNewCriterion(OppVotazioneHasCaricaPeer::VOTO, 'Favorevole', Criteria::EQUAL); $cton2 = $c->getNewCriterion(OppVotazioneHasCaricaPeer::VOTO, 'Contrario', Criteria::EQUAL); $cton1->addOr($cton2); $cton3 = $c->getNewCriterion(OppVotazioneHasCaricaPeer::VOTO, 'Astenuto', Criteria::EQUAL); $cton1->addOr($cton3); $c->add($cton1); $c->add(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, $votazione_id, Criteria::EQUAL); $c->add(OppGruppoPeer::NOME, $gruppo, Criteria::EQUAL); $c->add(OppCaricaHasGruppoPeer::DATA_INIZIO, $data_votazione, Criteria::LESS_EQUAL); $cton4 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, $data_votazione, Criteria::GREATER_EQUAL); $cton5 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, null, Criteria::ISNULL); $cton4->addOr($cton5); $c->add($cton4); $c->addGroupByColumn(OppVotazioneHasCaricaPeer::VOTO); $c->addDescendingOrderByColumn('CONT'); $c->setLimit(2); $rs = OppCaricaPeer::doSelectRS($c); $voto = 'nv'; $voti = array(); $i = 0; while ($rs->next()) { $voti[$i] = array('voto' => $rs->getString(1), 'numero' => $rs->getInt(2)); $i++; } if (count($voti) > 1 && $voti[0]['numero'] != $voti[1]['numero'] || count($voti) == 1) { $voto = $voti[0]['voto']; } return $voto; }
public static function getActiveMPs($ramo, $limit = 0, $leg = 16) { if (!in_array($ramo, array('C', 'S'))) { throw new Exception("Ramo must be 'C' or 'S'"); } $c = new Criteria(); if ($ramo == 'C') { $c->add(self::TIPO_CARICA_ID, 1); $c->add(OppCaricaPeer::TIPO_CARICA_ID, '1', Criteria::EQUAL); } else { $c->add(self::TIPO_CARICA_ID, array(4, 5), Criteria::IN); $cton = $c->getNewCriterion(OppCaricaPeer::TIPO_CARICA_ID, '4', Criteria::EQUAL); $cton1 = $c->getNewCriterion(OppCaricaPeer::TIPO_CARICA_ID, '5', Criteria::EQUAL); $cton->addOr($cton1); $c->add($cton); } $c->add(OppCaricaPeer::LEGISLATURA, $leg, Criteria::EQUAL); $c->add(self::DATA_FINE, null, Criteria::ISNULL); $c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID, Criteria::INNER_JOIN); if ($limit > 0) { $c->setLimit($limit); } return OppCaricaPeer::doSelect($c); }
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); $c = new Criteria(); $c->add(OppCaricaPeer::LEGISLATURA, 16); $c->add(OppCaricaPeer::TIPO_CARICA_ID, 1); $c->add(OppCaricaPeer::DATA_INIZIO, '2008-04-29'); $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::EQUAL); $deps = OppCaricaPeer::doSelect($c); foreach ($deps as $dep) { $c = new Criteria(); $c->add(OppVotazioneHasCaricaPeer::CARICA_ID, $dep->getId()); //$c->add(OppVotazioneHasCaricaPeer::VOTO,'Votazione annullata',Criteria::NOT_EQUAL); $count = OppVotazioneHasCaricaPeer::doCount($c); if ($count != 4825) { echo $dep->getId() . " " . $count . "\n"; } }
public function executePolitician() { $this->politician_id = $this->getRequestParameter('id'); $this->politician = OppPoliticoPeer::retrieveByPK($this->politician_id); $this->n_news = oppNewsPeer::countNewsForItem('OppPolitico', $this->politician_id); $this->getResponse()->setTitle('tutte le notizie sul parlamentare ' . $this->politician->getNome() . ' ' . $this->politician->getCognome() . ' - ' . sfConfig::get('app_main_title')); $this->response->addMeta('description', 'Tutte le notizie aggiornate quotidianamente su cosa fa in Parlamento ' . $this->politician->getNome() . ' ' . $this->politician->getCognome(), true); $c = new Criteria(); $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(1, 4, 5), Criteria::IN); $c->add(OppCaricaPeer::DATA_FINE, null, Criteria::ISNULL); $c->add(OppCaricaPeer::POLITICO_ID, $this->politician_id); $this->carica = OppCaricaPeer::doSelectOne($c); $c = oppNewsPeer::getNewsForItemCriteria('OppPolitico', $this->politician_id); $c->addDescendingOrderByColumn(NewsPeer::DATE); if ($this->hasRequestParameter('itemsperpage')) { $this->getUser()->setAttribute('itemsperpage', $this->getRequestParameter('itemsperpage')); } $itemsperpage = $this->getUser()->getAttribute('itemsperpage', sfConfig::get('app_pagination_limit')); $pager = new deppNewsPager('News', $itemsperpage); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; }
public function getRibelliList($voto_gruppi = null) { if (is_null($voto_gruppi)) { $voto_gruppi = OppVotazioneHasCaricaPeer::doSelectGroupByGruppo($this->getId()); } $ribelli_id = array(); $ribelli = array(); foreach ($voto_gruppi as $gruppo => $risultato) { if ($gruppo != 'Gruppo Misto') { $c = new Criteria(); $c->add(OppGruppoPeer::NOME, $gruppo); $gruppo_id = $risultato['id']; $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $this->getId()); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $gruppo_id); $voto_gruppo = OppVotazioneHasGruppoPeer::doSelectOne($c); if ($voto_gruppo) { if ($voto_gruppo->getVoto() != 'nv') { unset($risultato['Assente']); unset($risultato['In missione']); arsort($risultato); array_shift($risultato); $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::POLITICO_ID); $c->addSelectColumn(OppGruppoPeer::NOME); $c->addSelectColumn(OppCaricaPeer::CIRCOSCRIZIONE); $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTO); $c->addJoin(OppCaricaPeer::ID, OppVotazioneHasCaricaPeer::CARICA_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(OppGruppoPeer::NOME, $gruppo, Criteria::EQUAL); $c->add(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, $this->getId(), Criteria::EQUAL); $c->add(OppVotazioneHasCaricaPeer::VOTO, array_keys($risultato), Criteria::IN); $c->add(OppCaricaHasGruppoPeer::DATA_INIZIO, $this->getOppSeduta()->getData(), Criteria::LESS_EQUAL); $cton1 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, $this->getOppSeduta()->getData(), Criteria::GREATER_EQUAL); $cton2 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, null, Criteria::ISNULL); $cton1->addOr($cton2); $c->add($cton1); $rs = OppCaricaPeer::doSelectRS($c); while ($rs->next()) { $ribelli1[$rs->getInt(1)] = array('id' => $rs->getInt(1), 'gruppo' => $rs->getString(2), 'circoscrizione' => $rs->getString(3), 'voto_gruppo' => $voto_gruppo->getVoto(), 'voto' => $rs->getString(4)); array_push($ribelli_id, $rs->getInt(1)); } } } } } $c = new Criteria(); $c->add(OppPoliticoPeer::ID, $ribelli_id, Criteria::IN); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $rs1 = OppPoliticoPeer::doSelectRS($c); while ($rs1->next()) { $ribelli[$rs1->getString(3) . ' ' . $rs1->getString(2)] = $ribelli1[$rs1->getInt(1)]; } return $ribelli; }
<?php if ($opp_politician_history_cache->getChiTipo() == 'P' || $opp_politician_history_cache->getChiTipo() == 'N') { ?> <?php $parlamentare = OppCaricaPeer::retrieveByPK($opp_politician_history_cache->getChiId()); ?> <a href="/xml/indici/politici/<?php echo $parlamentare->getId(); ?> .xml" target="_blank"> <?php echo $parlamentare->getOppPolitico(); ?> </a> - <?php echo link_to($parlamentare->getPoliticoId(), 'http://' . sfConfig::get('sf_site_url', 'op_openpolis') . "/parlamentare/" . $parlamentare->getPoliticoId(), true); ?> (<?php echo $parlamentare->getId(); ?> ) <?php }
/** * get all distinct available presenters for emendamenti of a given atto * * @param OppAtto $atto * @return hash of type {id => presenter} * @author Guglielmo Celata */ public static function getAvailablePresenters(OppAtto $atto) { $atto_id = $atto->getId(); $sql = "select distinct ce.carica_id " . "from opp_emendamento e left join opp_carica_has_emendamento ce on ce.emendamento_id = e.id " . "join opp_carica c on (c.id=ce.carica_id || ce.carica_id is null) " . "join opp_atto_has_emendamento ae on ae.emendamento_id=e.id " . "where (ce.tipo = 'P' or ce.tipo is null) and ae.atto_id={$atto_id};"; $con = Propel::getConnection(BaseOppEmendamentoPeer::DATABASE_NAME); $stm = $con->createStatement(); $rs = $stm->executeQuery($sql, ResultSet::FETCHMODE_NUM); $items = array(); while ($rs->next()) { if (is_null($rs->getInt(1))) { $items['999999999'] = "Governo, Comm. ..."; } else { $c = OppCaricaPeer::retrieveByPK($rs->getInt(1)); $p = $c->getOppPolitico(); $items[$rs->getInt(1)] = $p->getNome() . " " . strtoupper($p->getCognome()); } } return $items; }
define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); print "Fetching data... \n"; $c = new Criteria(); $c->setOffset(3013213); $c->setLimit(600000); $votazioni = OppVotazioneHasPoliticoPeer::doSelect($c); foreach ($votazioni as $votazione) { echo "votazione: " . $votazione->getVotazioneId() . " politico: " . $votazione->getPoliticoId() . "\n"; $c1 = new Criteria(); $c1->add(OppVotazionePeer::ID, $votazione->getVotazioneId(), Criteria::EQUAL); $vot = OppVotazionePeer::doSelectOne($c1); $c2 = new Criteria(); $c2->add(OppSedutaPeer::ID, $vot->getSedutaId(), Criteria::EQUAL); $seduta = OppSedutaPeer::doSelectOne($c2); $senatori_a_vita = array("1529", "1606", "1719", "1519", "1682", "1456", "1524"); $c3 = new Criteria(); $c3->add(OppCaricaPeer::POLITICO_ID, $votazione->getPoliticoId()); if (!in_array($votazione->getPoliticoId(), $senatori_a_vita)) { $c3->add(OppCaricaPeer::LEGISLATURA, $seduta->getLegislatura()); } $carica = OppCaricaPeer::doSelectOne($c3); $votazioneCarica = new OppVotazioneHasCarica(); $votazioneCarica->setVotazioneId($votazione->getVotazioneId()); $votazioneCarica->setCaricaId($carica->getId()); $votazioneCarica->setVoto($votazione->getVoto()); $votazioneCarica->save(); echo "OK\n"; } print "done.\n";
public function executeComparaQuesto() { if ($this->ramo == 1) { $this->tipo_carica = 1; } else { $this->tipo_carica = 4; } $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppPoliticoPeer::ID); $c->addSelectColumn(OppPoliticoPeer::COGNOME); $c->addSelectColumn(OppPoliticoPeer::NOME); $c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID); $c->add(OppCaricaPeer::LEGISLATURA, '17', Criteria::EQUAL); $c->add(OppCaricaPeer::TIPO_CARICA_ID, $this->tipo_carica, Criteria::EQUAL); $c->add(OppCaricaPeer::DATA_FINE, null, Criteria::EQUAL); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->parlamentari = OppCaricaPeer::doSelectRS($c); }
} ?> </td> <td><?php echo $carica['circoscrizione']; ?> </td> <td> <?php $presenze_totali = 0; ?> <?php foreach ($gruppi as $nome => $gruppo) { ?> <?php $presenze = OppCaricaPeer::doSelectPresenzePerGruppo($id, format_date($gruppo['data_inizio'], 'yyyy-MM-dd'), format_date($gruppo['data_fine'], 'yyyy-MM-dd')); ?> <?php if ($presenze != 0) { ?> <?php printf('%d volte su %d voti (%01.2f %%)', $gruppo['ribelle'], $presenze, number_format($gruppo['ribelle'] / $presenze * 100, 2)); ?> <br /> <?php } else { ?> <?php print '0 volte su 0 voti (0%)'; ?> <br />
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'dev'); define('SF_DEBUG', true); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; sfContext::getInstance(); print "Fetching data... \n"; $cariche = OppCaricaPeer::doSelect(new Criteria()); foreach ($cariche as $carica) { $c = new Criteria(); $c->add(OppGruppoPeer::NOME, $carica->getGruppo(), Criteria::EQUAL); $gruppo = OppGruppoPeer::doSelectOne($c); if ($gruppo != null) { $carica_gruppo = new OppCaricaHasGruppo(); $carica_gruppo->setCaricaId($carica->getId()); $carica_gruppo->setGruppoId($gruppo->getId()); $carica_gruppo->setDataInizio($carica->getDataInizio()); $carica_gruppo->setDataFine($carica->getDataFine()); $carica_gruppo->save(); } else { echo "carica {$carica->getId}() gruppo non trovato\n"; } } print "done.\n";
public function executeClassifiche() { // box rotazione politici // random del ramo if ($this->ramo == 0) { if (rand(1, 2) == 1) { $tipo_carica = 1; $this->nome_carica = 'deputati'; } else { $tipo_carica = 4; $this->nome_carica = 'senatori'; } } if ($this->ramo == 1) { $tipo_carica = 1; $this->nome_carica = 'deputati'; } if ($this->ramo == 2) { $tipo_carica = 4; $this->nome_carica = 'senatori'; } $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::ID); $c->addSelectColumn(OppPoliticoPeer::ID); $c->addSelectColumn(OppPoliticoPeer::COGNOME); $c->addSelectColumn(OppPoliticoPeer::NOME); $c->addSelectColumn(OppCaricaPeer::CIRCOSCRIZIONE); $c->addSelectColumn(OppCaricaPeer::PRESENZE); $c->addSelectColumn(OppCaricaPeer::ASSENZE); $c->addSelectColumn(OppCaricaPeer::MISSIONI); $c->addSelectColumn(OppCaricaPeer::INDICE); $c->addSelectColumn(OppCaricaPeer::POSIZIONE); $c->addSelectColumn(OppCaricaPeer::MEDIA); $c->addSelectColumn(OppCaricaPeer::RIBELLE); $c->addSelectColumn(OppPoliticoPeer::N_MONITORING_USERS); $c->addJoin(OppCaricaPeer::POLITICO_ID, OppPoliticoPeer::ID, Criteria::INNER_JOIN); $c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::ISNULL); $c->add(OppCaricaPeer::TIPO_CARICA_ID, $tipo_carica); // escludere boldrini e grasso $c->add(OppPoliticoPeer::ID, array(686427, 687024), Criteria::NOT_IN); $this->quale_pagina = $this->classifica; // random sul cosa if ($this->classifica == 0) { $random = rand(1, 4); } else { $random = $this->classifica; } switch ($random) { case 1: $c->addDescendingOrderByColumn(OppCaricaPeer::PRESENZE); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->color = 'green'; $this->string = 'più presenti'; $this->cosa = 1; break; case 2: $c->addDescendingOrderByColumn(OppCaricaPeer::ASSENZE); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->color = 'red'; $this->string = 'più assenti'; $this->cosa = 2; break; case 5: $c->addDescendingOrderByColumn(OppCaricaPeer::INDICE); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->color = 'blue'; $this->string = 'più produttivi <span style="margin-left:5px;"><a href="http://indice.openpolis.it/info.html" style="font-size:11px;">come sono calcolati?</a></span>'; $this->cosa = 3; break; case 3: $c->addDescendingOrderByColumn(OppPoliticoPeer::N_MONITORING_USERS); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->color = 'orange'; $this->string = 'più monitorati dagli utenti'; $this->cosa = 4; break; case 4: $c->addDescendingOrderByColumn(OppCaricaPeer::RIBELLE); $c->addAscendingOrderByColumn(OppPoliticoPeer::COGNOME); $this->color = 'violet'; $this->string = 'più ribelli al proprio gruppo'; $this->cosa = 5; break; /* case 6: $c->addAscendingOrderByColumn(OppCaricaPeer::INDICE); $this->color='violet'; $this->string='meno attivi'; $this->cosa=6; break; */ } $c->setLimit($this->limit); $this->parlamentari = OppCaricaPeer::doSelectRS($c); }
/** * Calcola o ri-calcola gli indici di posizionamento per: * - presenze, assenze, missioni * - indice di attività (nuovo) * - ribellioni * Si può specificare: * - il ramo (camera, senato, governo, parlamento, tutti*) * - la data (da inizio legislatura a quella data) */ function run_opp_build_pos_cache_politici($task, $args, $options) { static $loaded; // load application context if (!$loaded) { task_loader(); $loaded = true; } echo "memory usage: " . memory_get_usage() . "\n"; $msg = sprintf("start time: %s\n", date('H:i:s')); echo $msg; $data = ''; $ramo = ''; $tipo = 'P'; if (array_key_exists('data', $options)) { $data = $options['data']; } if (array_key_exists('ramo', $options)) { $ramo = substr(strtolower($options['ramo']), 0, 1); } if ($ramo != 'c' && $ramo != 's') { throw new Exception("I valori per il ramo possono essere: camera o senato"); } // definisce la data fino alla quale vanno fatti i calcoli // data_lookup serve per controllare se i record già esistono if ($data != '') { $legislatura_corrente = OppLegislaturaPeer::getCurrent($data); $data_lookup = $data; } else { $legislatura_corrente = OppLegislaturaPeer::getCurrent(); $data = date('Y-m-d'); if ($ramo == 'tutti') { $data_lookup = OppPoliticianHistoryCachePeer::fetchLastData($tipo); } else { $data_lookup = OppPoliticianHistoryCachePeer::fetchLastData($tipo, $ramo); } } $msg = sprintf("calcolo indici posizionamento per politici data: %10s, ramo: %10s\n", $data ? $data : '-', $ramo); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); $parlamentari_rs = OppCaricaPeer::getParlamentariRamoDataRS($ramo, $legislatura_corrente, $data); echo "memory usage: " . memory_get_usage() . "\n"; $start_time = time(); $cnt = 0; $indice_ar = array(); $presenze_ar = array(); $assenze_ar = array(); $missioni_ar = array(); $ribellioni_ar = array(); while ($parlamentari_rs->next()) { $cnt++; $p = $parlamentari_rs->getRow(); $id = $p['id']; // inserimento o aggiornamento del valore in opp_politician_history_cache $cache_record = OppPoliticianHistoryCachePeer::retrieveByDataChiTipoChiIdRamo($data_lookup, $tipo, $id, $ramo); if (!$cache_record) { throw new Exception("Record {$id} mancante: data: {$data_lookup}, tipo: {$tipo}, ramo: {$ramo}!"); } $record_id = $cache_record->getId(); $indice_ar[$record_id] = $cache_record->getIndice(); $presenze_ar[$record_id] = $cache_record->getPresenze(); $assenze_ar[$record_id] = $cache_record->getAssenze(); $missioni_ar[$record_id] = $cache_record->getMissioni(); $ribellioni_ar[$record_id] = $cache_record->getRibellioni(); unset($cache_record); $msg = sprintf("%d) i: %7.2f p:%4d a:%4d m:%4d, r:%4d", $cnt, $indice_ar[$record_id], $presenze_ar[$record_id], $assenze_ar[$record_id], $missioni_ar[$record_id], $ribellioni_ar[$record_id]); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage()); echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false)); } # update positions arsort($indice_ar); compute_posizioni($indice_ar, 'indice'); arsort($presenze_ar); compute_posizioni($presenze_ar, 'presenze'); arsort($assenze_ar); compute_posizioni($assenze_ar, 'assenze'); arsort($missioni_ar); compute_posizioni($missioni_ar, 'missioni'); arsort($ribellioni_ar); compute_posizioni($ribellioni_ar, 'ribellioni'); $msg = sprintf("id: indexing positions generated\n"); echo pakeColor::colorize($msg, array('fg' => 'green', 'bold' => true)); $msg = sprintf("end time: %s\n", date('H:i:s')); echo $msg; $msg = sprintf("memory usage: %10d\n", memory_get_usage()); echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false)); $msg = sprintf("%d parlamentari elaborati\n", $cnt); echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true)); }
public function executeIndex() { $this->getResponse()->setTitle('Monitora i tuoi rappresentanti - ' . sfConfig::get('app_main_title')); $this->getResponse()->addMeta('description', 'Cosa fanno i tuoi rappresentanti? Tutte le attività parlamentari aggiornate quotidianamente.', true); deppFiltersAndSortVariablesManager::resetVars($this->getUser(), 'module', 'module', array('acts_filter', 'sf_admin/opp_atto/sort', 'votes_filter', 'sf_admin/opp_votazione/sort', 'pol_camera_filter', 'pol_senato_filter', 'sf_admin/opp_carica/sort', 'argomento/atti_filter', 'argomento_leggi/sort', 'argomento_nonleg/sort', 'monitoring_filter')); // ultime attivita' della community $this->latest_activities = CommunityNewsPeer::getLatestActivities(4); // ultime news dal parlamento $c = oppNewsPeer::getHomeNewsCriteria(); $c->addDescendingOrderByColumn(NewsPeer::DATE); $itemsperpage = 4; $pager = new deppNewsPager('News', $itemsperpage); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; // atti in evidenza $this->lanci = array(); $c = new Criteria(); $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'home'); $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppAtto'); $c->setLimit(8); $c->addDescendingOrderByColumn(sfLaunchingPeer::PRIORITY); $evidences = sfLaunchingPeer::doSelect($c); foreach ($evidences as $evidence) { $atto = OppAttoPeer::retrieveByPk($evidence->getObjectId()); $this->lanci[] = $atto->getId(); } // post del blog $this->post_pager = sfSimpleBlogPostPeer::getTaggedPager('in evidenza', sfConfig::get('app_sfSimpleBlog_post_max_per_page', 10), $this->getRequestParameter('page', 1)); // estrae le circoscrizioni, compreso il valore 0 $this->senato_constituencies = OppCaricaPeer::getAllConstituencies('senato', false); $this->camera_constituencies = OppCaricaPeer::getAllConstituencies('camera', false); }
public function getReport() { $risultato = array('Assente' => 0, 'Astenuto' => 0, 'Contrario' => 0, 'Favorevole' => 0, 'In missione' => 0, 'Partecipante votazione non valida' => 0, 'Presidente di turno' => 0, 'Richiedente la votazione e non votante' => 0, 'Voto segreto' => 0); $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppCaricaPeer::ID); $c->addSelectColumn(OppCaricaPeer::DATA_INIZIO); $c->addSelectColumn(OppCaricaPeer::DATA_FINE); $c->addSelectColumn(OppCaricaPeer::CARICA); $c->addSelectColumn(OppCaricaPeer::CIRCOSCRIZIONE); $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTO); $c->addAsColumn('CONT', 'COUNT(*)'); $c->addJoin(OppVotazioneHasCaricaPeer::CARICA_ID, OppCaricaPeer::ID, Criteria::LEFT_JOIN); $c->addGroupByColumn(OppCaricaPeer::ID); $c->addGroupByColumn(OppVotazioneHasCaricaPeer::VOTO); $c->add(OppCaricaPeer::ID, $this->getId(), Criteria::EQUAL); $c->addDescendingOrderByColumn(OppCaricaPeer::DATA_INIZIO); $c->addDescendingOrderByColumn(OppCaricaPeer::DATA_FINE); $rs = OppCaricaPeer::doSelectRS($c); while ($rs->next()) { if (!isset($risultato['carica'])) { $risultato['carica'] = $rs->getString(4); } $risultato[$rs->getString(6)] = $rs->getInt(7); } return $risultato; }