public function executeIncarichiParlamentare()
 {
     // cariche attuali
     $c = new Criteria();
     $c->add(OppCaricaInternaPeer::CARICA_ID, $this->carica_id);
     $c->add(OppCaricaInternaPeer::DATA_FINE, NULL, Criteria::ISNULL);
     $c->addAscendingOrderByColumn(OppCaricaInternaPeer::SEDE_ID);
     $cariche = OppCaricaInternaPeer::doSelect($c);
     $this->cariche = $cariche;
     //cariche passate
     $c = new Criteria();
     $c->add(OppCaricaInternaPeer::CARICA_ID, $this->carica_id);
     $c->add(OppCaricaInternaPeer::DATA_FINE, NULL, Criteria::ISNOTNULL);
     $c->addDescendingOrderByColumn(OppCaricaInternaPeer::DATA_FINE);
     $pasts = OppCaricaInternaPeer::doSelect($c);
     $this->pasts = $pasts;
 }
 public function executeOrgani()
 {
     $c = new Criteria();
     if ($this->getRequestParameter('ramo') == 'camera') {
         $this->getResponse()->setTitle('Componenti e statistiche di commissioni e giunte della Camera - ' . sfConfig::get('app_main_title'));
         $this->response->addMeta('description', 'Il potere dei gruppi parlamentari in tutti gli organi della Camera dei Deputati', true);
         $c->add(OppSedePeer::RAMO, 'C');
     } else {
         $this->getResponse()->setTitle('Componenti e statistiche di commissioni e giunte del Senato - ' . sfConfig::get('app_main_title'));
         $this->response->addMeta('description', 'Il potere dei gruppi parlamentari in tutti gli organi del Senato', true);
         $c->add(OppSedePeer::RAMO, 'S');
     }
     $c->add(OppSedePeer::TIPOLOGIA, 'Presidenza');
     $this->comm = OppSedePeer::doSelectOne($c);
     $this->ramo = $this->getRequestParameter('ramo');
     $gruppi_all = array();
     $gruppi_p = array();
     $gruppi_q = array();
     $gruppi_vp = array();
     $gruppi_s = array();
     $gruppi_c = array();
     $membri_regione = array(21 => 0, 23 => 0, 25 => 0, 32 => 0, 34 => 0, 36 => 0, 42 => 0, 45 => 0, 52 => 0, 55 => 0, 57 => 0, 62 => 0, 65 => 0, 67 => 0, 72 => 0, 75 => 0, 77 => 0, 78 => 0, 82 => 0, 88 => 0);
     $c = new Criteria();
     $c->addJoin(OppCaricaInternaPeer::CARICA_ID, OppCaricaPeer::ID);
     $c->addJoin(OppCaricaInternaPeer::SEDE_ID, OppSedePeer::ID);
     if ($this->getRequestParameter('ramo') == 'camera') {
         $c->add(OppSedePeer::RAMO, array('C', 'CS'), Criteria::IN);
         $c->add(OppCaricaPeer::TIPO_CARICA_ID, 1);
     } else {
         $c->add(OppSedePeer::RAMO, array('S', 'CS'), Criteria::IN);
         $c->add(OppCaricaPeer::TIPO_CARICA_ID, 4);
     }
     $c->add(OppCaricaInternaPeer::DATA_FINE, NULL, Criteria::ISNULL);
     $membri = OppCaricaInternaPeer::doSelect($c);
     foreach ($membri as $membro) {
         $regione = strtolower(str_replace(array(" ", "'", "-"), "_", $membro->getOppCarica()->getCircoscrizione()));
         $codice_regione = sfConfig::get('app_circoscrizioni_' . $regione);
         if (array_key_exists($codice_regione, $membri_regione)) {
             $membri_regione[$codice_regione] = $membri_regione[$codice_regione] + 1;
         }
         $gruppo_id = OppCaricaHasGruppoPeer::getGruppoCorrentePerCarica($membro->getCaricaId())->getId();
         $tipo_carica = OppTipoCaricaPeer::retrieveByPk($membro->getTipoCaricaId())->getNome();
         if (array_key_exists($gruppo_id, $gruppi_all)) {
             $gruppi_all[$gruppo_id] = $gruppi_all[$gruppo_id] + 1;
         } else {
             $gruppi_all[$gruppo_id] = 1;
         }
         if ($tipo_carica == 'Presidente') {
             if (array_key_exists($gruppo_id, $gruppi_p)) {
                 $gruppi_p[$gruppo_id] = $gruppi_p[$gruppo_id] + 1;
             } else {
                 $gruppi_p[$gruppo_id] = 1;
             }
         }
         if ($tipo_carica == 'Questore') {
             if (array_key_exists($gruppo_id, $gruppi_q)) {
                 $gruppi_q[$gruppo_id] = $gruppi_q[$gruppo_id] + 1;
             } else {
                 $gruppi_q[$gruppo_id] = 1;
             }
         }
         if ($tipo_carica == 'Vicepresidente') {
             if (array_key_exists($gruppo_id, $gruppi_vp)) {
                 $gruppi_vp[$gruppo_id] = $gruppi_vp[$gruppo_id] + 1;
             } else {
                 $gruppi_vp[$gruppo_id] = 1;
             }
         }
         if ($tipo_carica == 'Segretario') {
             if (array_key_exists($gruppo_id, $gruppi_s)) {
                 $gruppi_s[$gruppo_id] = $gruppi_s[$gruppo_id] + 1;
             } else {
                 $gruppi_s[$gruppo_id] = 1;
             }
         }
         if ($tipo_carica == 'Componente') {
             if (array_key_exists($gruppo_id, $gruppi_c)) {
                 $gruppi_c[$gruppo_id] = $gruppi_c[$gruppo_id] + 1;
             } else {
                 $gruppi_c[$gruppo_id] = 1;
             }
         }
     }
     $this->gruppi_all = $gruppi_all;
     $this->gruppi_p = $gruppi_p;
     $this->gruppi_q = $gruppi_q;
     $this->gruppi_vp = $gruppi_vp;
     $this->gruppi_s = $gruppi_s;
     $this->gruppi_c = $gruppi_c;
     $this->membri_regione = $membri_regione;
 }
        echo image_tag(OppPoliticoPeer::getThumbUrl($politico['politico_id']), array('width' => '40', 'height' => '53'));
        ?>
                      <?php 
        $fullName = $politico['nome'] . " " . $politico['cognome'];
        echo link_to($fullName . " (" . $politico['acronimo'] . ")", '@parlamentare?id=' . $politico['politico_id'] . '&slug=' . slugify($fullName), array('class' => 'folk2'));
        ?>
                    </p>
                  </th>
                  <td>
                    <?php 
        echo $politico['circoscrizione'];
        ?>
                  </td>
                  <td>
                    <?php 
        foreach ($cariche_interne = OppCaricaInternaPeer::getPermanentiAttuali($carica_id) as $c => $carica_interna) {
            ?>
                      <?php 
            echo $tipo_carica = $carica_interna->getOppTipoCarica()->getNome() != 'Componente' ? $tipo_carica : '';
            ?>
                      <?php 
            echo $carica_interna->getOppSede()->getDenominazione();
            ?>
                      <?php 
            if ($c < count($cariche_interne) - 1) {
                ?>
,<?php 
            }
            ?>
                    <?php 
        }
<?php

$c = new Criteria();
$c->add(OppCaricaInternaPeer::SEDE_ID, $sede_id);
$c->add(OppCaricaInternaPeer::DATA_FINE, NULL, Criteria::ISNULL);
$result = OppCaricaInternaPeer::doSelectOne($c);
if ($result) {
    ?>
 <h3 class="subsection" id="#<?php 
    echo $sede_id;
    ?>
" style="font-size: 16px;">
   <a href="#<?php 
    echo $sede_id;
    ?>
" name="<?php 
    echo $sede_id;
    ?>
"><?php 
    echo OppSedePeer::retrieveByPk($sede_id)->getDenominazione();
    ?>
</a>
 </h3>
 
 <div class="clearfix">
    <div class="row">
    <div class="fivecol"><!-- START LEFT -->
        
        <table class="disegni-decreti column-table lazyload">
            <thead>
              <tr>