public function executeGetNumeroVotazioni()
 {
     $c = new Criteria();
     $c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID);
     $c->add(OppSedutaPeer::LEGISLATURA, 17, Criteria::GREATER_EQUAL);
     $number = OppVotazionePeer::doCount($c);
     $resp_node = new SimpleXMLElement('<openparlamento_response></openparlamento_response>');
     $number_node = $resp_node->addChild('numero_voti', $number);
     $this->xmlContent = $resp_node->asXML();
     $this->response->setContentType('text/xml; charset=utf-8');
     $this->response->setHttpHeader('Content-Length: ', strlen($this->xmlContent));
     $this->setLayout(false);
 }
 public static function doSelectCountVotazioniPerPeriodo($data_inizio, $data_fine, $legislatura, $ramo)
 {
     $c = new Criteria();
     $c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID, Criteria::LEFT_JOIN);
     //$c->add(OppSedutaPeer::DATA, $data_inizio, Criteria::GREATER_EQUAL);
     $c->add(OppSedutaPeer::RAMO, $ramo, Criteria::EQUAL);
     $c->add(OppSedutaPeer::LEGISLATURA, $legislatura, Criteria::EQUAL);
     if ($data_inizio != '') {
         $c->add(OppSedutaPeer::DATA, $data_inizio, Criteria::GREATER_EQUAL);
     }
     if ($data_fine != '') {
         $c->add(OppSedutaPeer::DATA, $data_fine, Criteria::LESS_EQUAL);
     }
     return $count = OppVotazionePeer::doCount($c);
 }
$voto['Favorevole'] = 'FAV';
$voto['Contrario'] = 'CON';
$voto['Astenuto'] = 'AST';
$voto['Assente'] = 'NA';
$voto['In missione'] = 'NA';
$voto['Presidente di turno'] = 'NA';
$voto['Richiedente la votazione e non votante'] = 'NA';
$voto['Voto segreto'] = 'SKIP';
$voto['Partecipante votazione non valida'] = 'SKIP';
//calcola il numro totale di votazioni per ramp per escludere i parl. con poche votazioni
$c = new Criteria();
$c->addJoin(OppSedutaPeer::ID, OppVotazionePeer::SEDUTA_ID);
$c->add(OppSedutaPeer::LEGISLATURA, $legislatura);
//$c->add(OppCaricaPeer::IS_IMPORTED,1);
$c->add(OppSedutaPeer::RAMO, $ramo);
$num_votazioni = OppVotazionePeer::doCount($c);
$min_presenze = intval($num_votazioni * 50 / 100);
// estrae le cariche (attuali) per ramo e legislatura,
$c = new Criteria();
$c->add(OppCaricaPeer::LEGISLATURA, $legislatura);
$c->add(OppCaricaPeer::DATA_FINE, null, Criteria::ISNULL);
if ($ramo == 'C') {
    $c->add(OppCaricaPeer::TIPO_CARICA_ID, 1);
} else {
    $c->add(OppCaricaPeer::TIPO_CARICA_ID, array(4, 5), Criteria::IN);
}
//selezione dei parlamentari con il 50% minimo di presenze al voto
$c->add(OppCaricaPeer::PRESENZE, $min_presenze, Criteria::GREATER_THAN);
$cariche = OppCaricaPeer::doSelect($c);
unset($c);
$ncariche = count($cariche);