public static function getVotoGruppoVotazione($gruppo_id, $votazione_id) { $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $gruppo_id); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $votazione_id); $voto = OppVotazioneHasGruppoPeer::doSelectOne($c); if ($voto) { return $voto->getVoto(); } else { return null; } }
/** * Executes index action * */ public function executeIndex() { $votazione_id = $this->getRequestParameter('id'); $this->votazione = OppVotazionePeer::retrieveByPK($votazione_id); $this->forward404Unless($this->votazione); $this->ramo = $this->votazione->getOppSeduta()->getRamo() == 'C' ? 'Camera' : 'Senato'; $data = $this->votazione->getOppSeduta()->getData('Y-m-d'); $this->risultati = $this->votazione->getVotoGruppi($data); $this->ribelli = $this->votazione->getVotoRibelli($data); $this->getResponse()->setTitle('Votazione ' . $this->ramo . ' ' . $this->votazione->getTitolo() . ' - ' . sfConfig::get('app_main_title')); $this->response->addMeta('description', 'Come hanno votato i gruppi, che voto hanno espresso i singoli parlamentari e quali sono stati ribelli al proprio gruppo parlamentare per la votazione ' . $this->ramo . ' ' . $this->votazione->getTitolo(), true); $this->processSort(); $this->votanti = OppVotazioneHasCaricaPeer::getRSAllVotanti($votazione_id, $data); $this->votantiComponent = OppVotazioneHasCaricaPeer::getRSAllVotanti($votazione_id, $data); $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $votazione_id); $this->voto_gruppi = OppVotazioneHasGruppoPeer::doSelect($c); $c = new Criteria(); $c->add(OppVotazioneHasAttoPeer::VOTAZIONE_ID, $votazione_id); $this->voto_atti = OppVotazioneHasAttoPeer::doSelect($c); $c = new Criteria(); $c->add(OppVotazioneHasEmendamentoPeer::VOTAZIONE_ID, $votazione_id); $this->voto_ems = OppVotazioneHasEmendamentoPeer::doSelect($c); }
$crit0 = $c->getNewCriterion(OppGruppoRamoPeer::RAMO, $seduta->getRamo()); $crit1 = $c->getNewCriterion(OppGruppoRamoPeer::DATA_INIZIO, $seduta->getData(), Criteria::LESS_EQUAL); $crit2 = $c->getNewCriterion(OppGruppoRamoPeer::DATA_FINE, $seduta->getData(), Criteria::GREATER_THAN); $crit3 = $c->getNewCriterion(OppGruppoRamoPeer::DATA_FINE, NULL, Criteria::ISNULL); $crit2->addOr($crit3); $crit0->addAnd($crit1); $crit0->addAnd($crit2); $c->add($crit0); $gruppi_votazione = OppGruppoRamoPeer::doSelect($c); foreach ($gruppi_votazione as $gruppo) { $gr = OppGruppoPeer::retrieveByPk($gruppo->getGruppoId()); $voto_gruppo = OppVotazionePeer::doSelectVotoGruppo($votazione->getId(), $gr->getNome()); $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $votazione->getId()); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $gr->getId()); $result = OppVotazioneHasGruppoPeer::doSelectOne($c); if ($result) { $result->setVoto($voto_gruppo); $result->save(); print $gr->getNome() . ": " . $voto_gruppo . "\n"; } else { $insert = new OppVotazioneHasGruppo(); $insert->setVotazioneId($votazione->getId()); $insert->setGruppoId($gr->getId()); $insert->setVoto($voto_gruppo); $insert->save(); print "++++++++++++++++ " . $gr->getNome() . ": " . $voto_gruppo . "\n"; } print $gr->getNome() . ": " . $voto_gruppo . "\n"; } } else {
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; }
} else { $ramo = 'senato'; } $arr_opposizione = array(); $c = new Criteria(); $c->addJoin(OppGruppoPeer::ID, OppGruppoRamoPeer::GRUPPO_ID); $c->add(OppGruppoRamoPeer::DATA_INIZIO, $votazione->getOppSeduta()->getData(), Criteria::LESS_EQUAL); $crit0 = $c->getNewCriterion(OppGruppoRamoPeer::DATA_FINE, NULL, Criteria::ISNULL); $crit1 = $c->getNewCriterion(OppGruppoRamoPeer::DATA_FINE, $votazione->getOppSeduta()->getData(), Criteria::GREATER_EQUAL); $crit0->addOr($crit1); $c->add($crit0); $c->add(OppGruppoRamoPeer::RAMO, $votazione->getOppSeduta()->getRamo()); $gruppi = OppGruppoPeer::doSelect($c); foreach ($gruppi as $g) { if (!OppGruppoIsMaggioranzaPeer::isGruppoMaggioranza($g->getId(), $votazione->getOppSeduta()->getData()) and $g->getNome() != 'Gruppo Misto') { $voto_gruppo = OppVotazioneHasGruppoPeer::getVotoGruppoVotazione($g->getId(), $votazione->getId()); if ($votazione->getEsito() == 'APPROVATA' && $voto_gruppo == 'Contrario' && $ramo == 'camera' || $votazione->getEsito() == 'RESPINTA' && $voto_gruppo == 'Favorevole' && $ramo == 'camera' || $votazione->getEsito() == 'APPROVATA' && ($voto_gruppo == 'Contrario' || $voto_gruppo == 'Astenuto') && $ramo == 'senato' || $votazione->getEsito() == 'RESPINTA' && $voto_gruppo == 'Favorevole' && $ramo == 'senato') { $c = new Criteria(); $c->add(OppCaricaHasGruppoPeer::GRUPPO_ID, $g->getId()); $c->add(OppCaricaHasGruppoPeer::DATA_INIZIO, $votazione->getOppSeduta()->getData(), Criteria::LESS_EQUAL); $crit0 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, NULL, Criteria::ISNULL); $crit1 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_FINE, $votazione->getOppSeduta()->getData(), Criteria::GREATER_EQUAL); $crit0->addOr($crit1); $c->add($crit0); $parlamentari = OppCaricaHasGruppoPeer::doSelect($c); //$parlamentari = OppCaricaHasGruppoPeer::getParlamentariGruppoData($g->getId(),$votazione->getOppSeduta()->getData()); foreach ($parlamentari as $p) { $arr_opposizione[] = $p->getCaricaId(); } } }
$c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppVotazioneHasGruppoPeer::VOTAZIONE_ID); $c->addSelectColumn(OppVotazioneHasGruppoPeer::VOTO); $c->addJoin(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, OppVotazionePeer::ID, Criteria::LEFT_JOIN); $c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID, Criteria::LEFT_JOIN); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $gruppo['gruppo_id'], Criteria::EQUAL); if ($df != '') { $cton1 = $c->getNewCriterion(OppSedutaPeer::DATA, $di, Criteria::GREATER_EQUAL); $cton2 = $c->getNewCriterion(OppSedutaPeer::DATA, $df, Criteria::LESS_EQUAL); $cton1->addAnd($cton2); $c->add($cton1); } else { $c->add(OppSedutaPeer::DATA, $di, Criteria::GREATER_EQUAL); } $rs = OppVotazioneHasGruppoPeer::doSelectRS($c); $voto_gruppo = array(); while ($rs->next()) { $voto_gruppo[$rs->getInt(1)] = $rs->getString(2); } //CALCOLO VOTO CARICA $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTAZIONE_ID); $c->addSelectColumn(OppVotazioneHasCaricaPeer::VOTO); $c->addJoin(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, OppVotazionePeer::ID, Criteria::LEFT_JOIN); $c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID, Criteria::LEFT_JOIN); $c->add(OppVotazioneHasCaricaPeer::CARICA_ID, $argv[1], Criteria::EQUAL); if ($df != '') { $cton1 = $c->getNewCriterion(OppSedutaPeer::DATA, $di, Criteria::GREATER_EQUAL); $cton2 = $c->getNewCriterion(OppSedutaPeer::DATA, $df, Criteria::LESS_EQUAL);
public static function isMaggioranzaUnitaSuVotazione($votazione_id) { $votazione = OppVotazionePeer::retrieveByPk($votazione_id); $gruppi = OppGruppoRamoPeer::getGruppiRamo($votazione->getOppSeduta()->getRamo(), $votazione->getOppSeduta()->getData()); $array_gruppi = array(); foreach ($gruppi as $gruppo) { // controlla se il gruppo alla data faceva parte della maggioranza if (OppGruppoIsMaggioranzaPeer::isGruppoMaggioranza($gruppo->getGruppoId(), $votazione->getOppSeduta()->getData())) { $array_gruppi[] = $gruppo->getGruppoId(); } } $voto_magg = ""; foreach ($array_gruppi as $k => $g) { $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, $g); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $votazione_id); $voto_gruppo = OppVotazioneHasGruppoPeer::doSelectOne($c); if ($voto_magg == "" && $voto_gruppo->getVoto() != 'nv') { $voto_magg = $voto_gruppo->getVoto(); } elseif ($voto_gruppo->getVoto() != 'nv') { if ($voto_gruppo->getVoto() != $voto_magg) { return false; } } } return true; }
$votazioni = OppVotazionePeer::doSelect(OppVotazionePeer::getVotazioniMaggioranzaSotto($argv[1])); } else { $c = new Criteria(); $c->add(OppVotazionePeer::ID, $argv[2]); $c->add(OppVotazionePeer::IS_MAGGIORANZA_SOTTO_SALVA, 1); $votazioni = OppVotazionePeer::doSelect($c); } echo count($votazioni) . "\n\n"; if (count($votazioni) > 0) { foreach ($votazioni as $v) { echo $v->getOppSeduta()->getRamo() . $v->getOppSeduta()->getData() . "\n\n"; //controlla come ha votato la PD (gruppo id=71) $c = new Criteria(); $c->add(OppVotazioneHasGruppoPeer::GRUPPO_ID, 71); $c->add(OppVotazioneHasGruppoPeer::VOTAZIONE_ID, $v->getId()); $voto_magg = OppVotazioneHasGruppoPeer::doSelectOne($c); //prendi i gruppi attivi alla data della votazione nel ramo della votazione $gruppi_ramo = OppGruppoRamoPeer::getGruppiRamo($v->getOppSeduta()->getRamo(), $v->getOppSeduta()->getData()); foreach ($gruppi_ramo as $gruppo) { echo $gruppo->getGruppoId() . "\n"; // controlla se il gruppo alla data faceva parte della maggioranza if (OppGruppoIsMaggioranzaPeer::isGruppoMaggioranza($gruppo->getGruppoId(), $v->getOppSeduta()->getData())) { //ctrl i voti dei componenti i gruppi di maggioranza $c = new Criteria(); $c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID); $c->addJoin(OppCaricaPeer::ID, OppVotazioneHasCaricaPeer::CARICA_ID); $c->addJoin(OppVotazionePeer::ID, OppVotazioneHasCaricaPeer::VOTAZIONE_ID); $c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID); //ctrl se fa parte del gruppo alla data della votazione $crit0 = $c->getNewCriterion(OppCaricaHasGruppoPeer::GRUPPO_ID, $gruppo->getGruppoId()); $crit1 = $c->getNewCriterion(OppCaricaHasGruppoPeer::DATA_INIZIO, $v->getOppSeduta()->getData(), Criteria::LESS_EQUAL);
/* * This file is part of the Openpolis project * * (c) 2008 Guglielmo Celata <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * Add created_at informations to the sf_tagging table * the field takes a value equal to a random timestamp between 3 and 9 hours after * the creation of the tagged object's creation date * */ define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'fe'); define('SF_ENVIRONMENT', 'prod'); 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(); $c = new Criteria(); $c->addJoin(OppVotazionePeer::ID, OppVotazioneHasAttoPeer::VOTAZIONE_ID); $c->addJoin(OppVotazionePeer::ID, OppVotazioneHasGruppoPeer::VOTAZIONE_ID); $c->addJoin(OppAttoPeer::ID, OppAttoHasIterPeer::ATTO_ID); $c->add(OppAttoHasIterPeer::ITER_ID, 16); $c->add(OppVotazionePeer::FINALE, 1); $c->add(OppAttoPeer::TIPO_ATTO_ID, 1); $results = OppVotazioneHasGruppoPeer::doSelect($c); foreach ($results as $r) { echo $r->getGruppoId() . "-" . $r->getVoto() . "\n"; //.$r->getOppVotazione()->$r->getOppVotazioneHasAtto()->getOppAtto()->getId(); }