public function executeVotazioni() { $c = new Criteria(); $c->addJoin(OppVotazionePeer::ID, OppVotazioneHasEmendamentoPeer::VOTAZIONE_ID); $c->add(OppVotazioneHasEmendamentoPeer::EMENDAMENTO_ID, $this->emendamento->getId()); $this->votazioni = OppVotazionePeer::doSelect($c); $this->limit = 2; $this->limit_count = 0; $this->votazioni_count = count($this->votazioni); }
public function executeWidgetVotiMaggioranza() { $c = new Criteria(); $c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID); $c->add(OppVotazionePeer::IS_MAGGIORANZA_SOTTO_SALVA, 1); $c->addDescendingOrderByColumn(OppSedutaPeer::DATA); $this->sotto = OppVotazionePeer::doSelect($c); $c = new Criteria(); $c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID); $c->add(OppVotazionePeer::IS_MAGGIORANZA_SOTTO_SALVA, 2); $c->addDescendingOrderByColumn(OppSedutaPeer::DATA); $this->salva = OppVotazionePeer::doSelect($c); }
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(); $c = new Criteria(); $c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID); $c->add(OppSedutaPeer::LEGISLATURA, $argv[1]); if ($argv[2] == 1) { $c->add(OppSedutaPeer::RAMO, 'C'); } if ($argv[2] == 2) { $c->add(OppSedutaPeer::RAMO, 'S'); } //$c->setLimit(1000); $votazioni = OppVotazionePeer::doSelect($c); foreach ($votazioni as $votazione) { print "elaborazione votazione: " . $votazione->getId() . "...\n"; $c = new Criteria(); $c->add(OppLegislaturaHasGruppoPeer::LEGISLATURA, $argv[1], Criteria::EQUAL); $c->add(OppLegislaturaHasGruppoPeer::RAMO, $votazione->getOppSeduta()->getRamo(), Criteria::EQUAL); $gruppi_votazione = OppLegislaturaHasGruppoPeer::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);
/** * API (protetta da una API key) * torna flusso xml con i voti in cui la maggioranza è stata battuta * progetto op_kw * * <opkw xmlns="http://www.openpolis.it/2010/opkw" * xmlns:op="http://www.openpolis.it/2010/op" * xmlns:op_location="http://www.openpolis.it/2010/op_location" * xmlns:op_politician="http://www.openpolis.it/2010/op_politician" * xmlns:xlink="http://www.w3.org/1999/xlink"> * <op:content> * <voti_maggioranza_sotto n_voti="50"> * <voto xlink:href="/votazioni/32288.xml"> * <titolo>Titolo</titolo> * <data>28/04/2010</data> * <ramo>Camera</ramo> * <num_seduta>313</num_seduta> * <esito>respinto</esito> * <voto_maggioranza>contrario</voto_maggioranza> * <n_ribelli>34</n_ribelli> * </voto> * ... * </voti_maggioranza_sotto> * </op:content> * </opkw> * * * Return error in case something's wrong * <opkw xlmns="http://www.openpolis.it/2010/opkw" * xmlns:op="http://www.openpolis.it/2010/op" * xlmns:op_location="http://www.openpolis.it/2010/op_location" * xmlns:op_politician="http://www.openpolis.it/2010/op_politician"> * <op:error>Messaggio di errore</op:error> * </opkw> * @return String * @author Guglielmo Celata **/ public function executeElencoVotiMaggioranzaSotto() { $key = $this->getRequestParameter('key'); $is_valid_key = deppApiKeysPeer::isValidKey($key); //$is_valid_key=true; $resp_node = new SimpleXMLElement('<opkw xmlns="' . $this->opkw_ns . '" ' . ' xmlns:op="' . $this->op_ns . '" ' . ' xmlns:xlink="' . $this->xlink_ns . '" >' . '</opkw>'); if ($is_valid_key) { // start producing xml $content_node = $resp_node->addChild('op:content', null, $this->op_ns); $c = new Criteria(); $c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID); $c->add(OppSedutaPeer::LEGISLATURA, 16); $c->add(OppVotazionePeer::IS_MAGGIORANZA_SOTTO_SALVA, 1); $c->addDescendingOrderByColumn(OppSedutaPeer::DATA); $votazioni = OppVotazionePeer::doSelect($c); // voti con maggioranza sotto $voti_node = $content_node->addChild('voti_maggioranza_sotto', null, $this->opkw_ns); $voti_node->addAttribute('n_voti', count($votazioni)); foreach ($votazioni as $votazione) { $data = $votazione->getOppSeduta()->getData('d/m/Y'); $ramo = $votazione->getOppSeduta()->getRamo() == 'C' ? 'Camera' : 'Senato'; $n_seduta = $votazione->getOppSeduta()->getNumero(); $href = sprintf("/votazioni/%s.xml", $votazione->getId()); $titulo = $votazione->getTitoloAggiuntivo() ? $votazione->getTitoloAggiuntivo() : $votazione->getTitolo(); $esito = $votazione->getEsito(); $n_ribelli = $votazione->getRibelli(); $voto_node = $voti_node->addChild('voto', null, $this->opkw_ns); $voto_node->addAttribute('xlink:href', $href, $this->xlink_ns); $voto_node->addAttribute('id', $votazione->getId()); $voto_node->addChild('data', $data); $voto_node->addChild('ramo', $ramo); $voto_node->addChild('n_seduta', $n_seduta); $voto_node->addChild('titolo', $titulo); $voto_node->addChild('esito', ucfirst(strtolower($esito))); $voto_node->addChild('n_ribelli', $n_ribelli); } } else { $resp_node->addChild('op:error', 'Chiave di accesso non valida', $this->op_ns); } $xmlContent = $resp_node->asXML(); $this->_send_output($xmlContent); return sfView::NONE; }
sfContext::getInstance(); $t = new lime_test(16, new lime_output_color()); $t->diag('unit test to verify the mechanisms of wiki descriptions automatic creation and removal'); $t->diag('Tests beginning'); // clean the database $t->diag('Cleaning previously created test records'); $c = new Criteria(); $c->add(OppAttoPeer::PARLAMENTO_ID, 999999); $existing_records = OppAttoPeer::doSelect($c); foreach ($existing_records as $rec) { $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")"); $rec->delete(); } $c = new Criteria(); $c->add(OppVotazionePeer::NUMERO_VOTAZIONE, 999999); $existing_records = OppVotazionePeer::doSelect($c); foreach ($existing_records as $rec) { $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")"); $rec->delete(); } $t->diag('Create the act object'); $obj_atto = new OppAtto(); $obj_atto->setTipoAttoId(1); $obj_atto->setParlamentoId(999999); $obj_atto->setDataPres('2008-11-01'); $obj_atto->setDescrizione("Un'atto di test"); $obj_atto->save(); $prefix = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_prefix', get_class($obj_atto))); $t->ok($prefix == 'atto', 'The prefix was correctly read from the behavior configuration'); $wiki_page = nahoWikiPagePeer::retrieveByName($prefix . "_" . $obj_atto->getId()); $t->ok($wiki_page instanceof nahoWikiPage, 'a wiki page was just created for this object');
public static function getKeyVotes($limit = 0, $namespace = 'key') { $c = new Criteria(); $c->addJoin(OppVotazionePeer::ID, sfLaunchingPeer::OBJECT_ID); $c->addJoin(OppVotazionePeer::SEDUTA_ID, OppSedutaPeer::ID); $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppVotazione'); if ($namespace == 'key') { $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'key_vote'); } if ($namespace == 'relevant') { $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'relevant_vote'); } $c->addDescendingOrderByColumn(OppSedutaPeer::DATA); if ($limit != 0) { $c->setLimit($limit); } return OppVotazionePeer::doSelect($c); }
<?php /* Controlla le votazioni, e mette 1 al campo ìs_maggioranza_sotto nel caso nella votazione la maggioranza sia stata battuta. in input: - numero della legislatuta - 0 ctrl tutte le votazioni, id_votazione ctrl solo una votazione */ 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(); $votazioni = OppVotazionePeer::doSelect(OppVotazionePeer::maggioranzaSottoCriteria($argv[1], $argv[2])); if (count($votazioni) > 0) { foreach ($votazioni as $v) { //if (OppVotazionePeer::isMaggioranzaUnitaSuVotazione($v->getId())) //{ $v->setIsMaggioranzaSottoSalva(1); $v->save(); echo $v->getId() . "\n"; //} } } mail("*****@*****.**", "UP MAGG. SOTTO", "controllo magg sotto", "From: 1_lista_ddl_new");