Ignore:
Timestamp:
Mar 14, 2022, 5:13:56 PM (2 years ago)
Author:
roby
Message:

ATTENZIONE: con questa rev viene cambiato il charset che da ora viene impostato su utf8. Fate tutte le vostre verifiche prima di installarla.
Seconda fase di rivisitazione e completamento delle funzioni necessarie per l'accesso al servizio tramite cellulare.
Effettuate alcune sistemazioni per gli avvisi di incongruenza.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/modules/Elezioni/ele_voti.php

    r358 r360  
    4343include("modules/Elezioni/funzionidata.php");
    4444include("modules/Elezioni/ele.php");
     45include_once("modules/Elezioni/ele_spoglio.php");
    4546global $votolista, $limite, $dettnulli,$disgiunto;
    4647if(!isset($votolista)) $votolista=0;
     
    302303        $result->execute();
    303304        list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
     305        $sql="select tipo from ".$prefix."_ele_controlli where id_sez='$id_sez' group by tipo";
     306$rese = $dbi->prepare("$sql");
     307$rese->execute();
     308$id_comune=$_SESSION['id_comune'];
     309$bordoa='';
     310$bordog='';
     311$bordol='';
     312while (list($tipo)=$rese->fetch(PDO::FETCH_NUM)) {
     313        if ($tipo=='affluenze') $bordoa="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
     314        if ($tipo=='gruppo' or $tipo=='referendum') $bordog="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
     315        if ($tipo=='lista') $bordol="style=\"border: 6px solid; border-color: rgb(255, 0, 0);\"";
     316}
     317echo "<SCRIPT type=\"text/javascript\">\n";
     318echo "function vai_scelta(idrif){\n";
     319echo "window.document.location.href=idrif\n";
     320echo "}\n";
     321echo "</script>\n";
     322if($rese->rowCount()) $segna="style=\"background-color: #dd0000;\""; else $segna='';
     323if($ops=="4" ) {$bgcolorg="yellow"; $tcolorg='blue';} else {$bgcolorg="grey"; $tcolorg='white';} #$active_gruppo=" class=\"ui-btn-active\""; else $active_gruppo='';
     324if($ops=="3") {$bgcolorl="yellow"; $tcolorl='blue';} else {$bgcolorl="grey"; $tcolorl='white';} # $active_lista=" class=\"ui-btn-active\""; else $active_lista='';
     325if($ops=="1") {$bgcolora="yellow"; $tcolora='blue';} else {$bgcolora="grey"; $tcolora='white';} # $active_aff=" class=\"ui-btn-active\""; else $active_aff='';
     326echo "<div data-role=\"content\" data-theme=\"a\"><hr><table style=\"margin-left:auto; margin-right:auto;\"><tr>";
     327#<a href=\"admin.php?id_comune=$id_comune&amp;id_cons_gen=$id_cons_gen&amp;ops=1\"></a>
     328echo "\n<td bgcolor=\"$bgcolora\" align=\"center\" $bordoa onClick=\"vai_scelta('admin.php?op=voti&amp;id_comune=$id_comune&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;ops=1');\"><p style=\"margin-left:10px;margin-right:10px;\"><font color=\"$tcolora\"><b>"._AFFLUENZE."</font></b></p></td>\n";
     329if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
     330        echo "<td bgcolor=\"$bgcolorg\" align=\"center\" $bordog onClick=\"vai_scelta('admin.php?op=voti&amp;id_comune=$id_comune&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;ops=4');\"><p style=\"margin-left:10px;margin-right:10px;\"><b><font color=\"$tcolorg\">"._GRUPPO."</font></b></p></td>\n";
     331}
     332if($genere==2 and $votog)
     333        echo "<td bgcolor=\"$bgcolorg\" align=\"center\" $bordog onClick=\"vai_scelta('admin.php?op=voti&amp;id_comune=$id_comune&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;ops=4');\"><p style=\"margin-left:10px;margin-right:10px;\"><b><font color=\"$tcolorg\">"._GRUPPO."</font></b></p></td>\n";
     334elseif(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
     335        echo "<td bgcolor=\"$bgcolorl\" align=\"center\"$bordol onClick=\"vai_scelta('admin.php?op=voti&amp;id_comune=$id_comune&amp;id_sez=$id_sez&amp;id_cons_gen=$id_cons_gen&amp;do=spoglio&amp;ops=3');\"><p style=\"margin-left:10px;margin-right:10px;\"><b><font color=\"$tcolorl\">"._LISTA."</font></b></p></td>\n";
     336}
     337echo "</tr></table><hr></div>\n";
     338/*
    304339        echo "<hr><table><tr><td  width=\"200\"><font size =\"4\" color=\"black\" align=\"left\"><b>Sezione N. $num_sez</b></font></td><td><table><tr>";
    305340        echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=1\">"._AFFLUENZE."</a></b></p></td>\n";
     
    313348        }
    314349        echo "</tr></table></td></tr></table><hr>\n";
    315 
     350*/
    316351#############
    317352# posizionamento in mancanza di scelta
     
    376411
    377412}
    378 ////////////////////////////////////////////////////////////////////////////////
    379 //   FUNZIONI DI IMMISSIONE
    380 //   - preferenze (candidati consiglieri)
    381 //   - preferenze_gruppi
    382 //   - votanti
    383 ////////////////////////////////////////////////////////////////////////////////
    384 
    385 //////////////////////////////////////////////////////////////////////
    386 // da qui va la sezione per le preferenze candidati consiglieri
    387 //////////////////////////////////////////////////////////////////////
    388 function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
    389         global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
    390 global $tipo_cons,$limite,$dettnulli,$disgiunto;
    391 $bgcolor1="#7777ff";
    392 $bgcolor2=$_SESSION['bgcolor2'];
    393 
    394 if ($genere==4){
    395         $sql="SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' order by data desc,orario desc limit 0,1";
    396         $result = $dbi->prepare("$sql");
    397         $result->execute();
    398 
    399 
    400         list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
    401         echo "<table  class=\"table-menu\" style=\"width: 50%; color: black;\">"
    402         ."<tr><td></td><td align=\"center\"></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIU."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTID."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIT."</td></tr>"
    403         ."<tr><td></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._TOT_ULT."</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_u</td><td align=\"center\" bgcolor=\"$bgcolor2\">$voti_d</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_t</td></tr>";
    404         echo "</table>";
    405 }
    406 $sql="select validi,nulli,bianchi,contestati from ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
    407 $result = $dbi->prepare("$sql");
    408 $result->execute();
    409 list($v1,$v2,$v3,$v4)=$result->fetch(PDO::FETCH_NUM);
    410 if($v1+$v2+$v3+$v4>0){
    411     //controlla se sono stati inseriti i votanti
    412 $sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    413 $result = $dbi->prepare("$sql");
    414 $result->execute();
    415 
    416 
    417 list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
    418 
    419 ####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
    420 if ($circo and $id_lista){
    421         $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
    422         $res_lis = $dbi->prepare("$sql");
    423         $res_lis->execute();
    424         list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
    425 }
    426 
    427 if(!$votog and ($genere==3 or $genere==5)){
    428         $sql="select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
    429 $result = $dbi->prepare("$sql");
    430 $result->execute();
    431 
    432 
    433 }else{
    434         $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
    435 $result = $dbi->prepare("$sql");
    436 $result->execute();
    437 }
    438 
    439     list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
    440                 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
    441                 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
    442 $res_lis = $dbi->prepare("$sql");
    443 $res_lis->execute();
    444 
    445 
    446                 $num_liste = $res_lis->rowCount();
    447                 $ele_lista='';
    448                 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
    449                         if(($genere==5 and $id_conf and $fascia<=$limite and !$disgiunto) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
    450                                 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo limit 0,1";
    451 $result = $dbi->prepare("$sql");
    452 $result->execute();
    453 
    454 
    455                                 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
    456                         }
    457                         echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
    458                         echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
    459                         echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3&amp;id_lista=\">";
    460                         echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
    461                         if ($id_lista){
    462                                 echo "<option value=\"0\">"._VOTI_LISTA;
    463                                 $ele_lista=" and t1.id_lista='$id_lista' ";
    464                         }else{
    465                                 echo "<option value=\"0\" selected>"._VOTI_LISTA;
    466                                 $ele_lista=" group by t1.id_lista ";
    467 if(!isset($votolista)) $votolista=0;
    468 
    469                         }
    470                         while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
    471                         $segna='';
    472                         $sql="SELECT count(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif";
    473 $result = $dbi->prepare("$sql");
    474 $result->execute();
    475 
    476 
    477                         list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
    478                         $sql="SELECT sum(t1.voti),0,0 from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_rif";
    479 $result = $dbi->prepare("$sql");
    480 $result->execute();
    481 
    482 
    483                         list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
    484                         if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
    485                 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
    486 $result = $dbi->prepare("$sql");
    487 $result->execute();
    488             }else{
    489                                 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
    490 $result = $dbi->prepare("$sql");
    491 $result->execute();
    492                                 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
    493                                 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    494 $result = $dbi->prepare("$sql");
    495 $result->execute();
    496             }
    497                         list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
    498                         if($votisezcand>($votisezlis*$numprefs))
    499                                 {$segna="style=\"background-color: #dd0000;\"";}
    500                         elseif($ctrvoticand)
    501                                 $segna="style=\"background-color: #99CC33;\"";
    502                         $sql="SELECT t1.voti,t2.num_cand FROM ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on t1.id_cand=t2.id_cand where t1.id_cons='$id_cons' and  t1.id_sez='$id_sez' and t2.id_lista='$id_rif'";
    503 $res4 = $dbi->prepare("$sql");
    504 $res4->execute();
    505 
    506 
    507                         $errcand[$id_rif]=array();
    508                         while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
    509                                 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
    510                        
    511                         $sel = ($id_rif == $id_lista) ? "selected" : "";
    512                                 echo "<option $segna value=\"$id_rif\" $sel>";
    513                                 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
    514                                 echo $num_lis.") ".substr($descrizione,0,30);
    515                         }
    516                         echo "</select></form></td>\n";
    517                 }else {
    518                         $id_lista=0;
    519                 }
    520                 echo "<td style=\"vertical-align: top;\">";
    521 
    522                 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
    523 if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)      {
    524                 $sql="SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,t2.contestati,0,0 from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez";
    525 $result = $dbi->prepare("$sql");
    526 $result->execute();
    527 
    528 
    529 }else{
    530                 $sql="SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,t2.solo_gruppo,t1.id_sez from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez='$id_sez' group by t1.id_sez,t2.validi_lista, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli_lista,t2.bianchi,t2.nulli,t2.contestati,t2.voti_nulli,t2.solo_gruppo";
    531 $result = $dbi->prepare("$sql");
    532 $result->execute();
    533 }
    534 
    535 // aggiunte le variabili $sgpl e $vnulli2 per la gestione dei voti 1) al solo presidente per singola lista - 2) al solo presidente per singola lista perché nullo o contestato quello di lista         
    536                 $isscr= $result->rowCount();
    537                 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
    538                 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
    539                         $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
    540 $resg = $dbi->prepare("$sql");
    541 $resg->execute();
    542 
    543 
    544                         list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
    545                         if ($sg != $sgpl) echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></table>";
    546                 }
    547                 $valista=$validi2;
    548                 if(!$id_lista or $genere==3){   //controllo di congruenza
    549                         $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
    550 $res2 = $dbi->prepare("$sql");
    551 $res2->execute();
    552 
    553 
    554                         list($tot) = $res2->fetch(PDO::FETCH_NUM);
    555 #######    controlli
    556         $sql="select * from ".$prefix."_ele_controlli where id_cons='$id_cons' and id_sez='$id_sez' ";
    557         $resc = $dbi->prepare("$sql");
    558         $resc->execute();
    559 if($resc->rowCount()){                  if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
    560                                 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2)."</b><br></td></table>";
    561                         }
    562 
    563                         if((($voti_sez)!=$validi2) and ($voti_sez>0)){
    564                                 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".($voti_sez)." "._NO_VAL_VOTI." ".$validi2."</b><br></td></tr></table>";
    565                         }
    566                 }elseif($genere==5){
    567                         $sql="SELECT sum(t1.voti) from ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on (t1.id_cand=t2.id_cand) where t1.id_sez=$id_sez and t2.id_lista=$id_lista";
    568 $result = $dbi->prepare("$sql");
    569 $result->execute();
    570 
    571 
    572                         list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
    573                         if(($fascia>$limite or $disgiunto) or !$id_conf){
    574                  $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
    575 $result = $dbi->prepare("$sql");
    576 $result->execute();
    577 
    578 
    579             }else{
    580 
    581                                 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
    582 $result = $dbi->prepare("$sql");
    583 $result->execute();
    584 
    585 
    586                                 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
    587                                 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    588 $result = $dbi->prepare("$sql");
    589 $result->execute();
    590 
    591 
    592             }
    593                         list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
    594                         if($votisezcand>($votisezlis*$numprefs))
    595                                 {
    596                                 echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti di preferenza $votisezcand <br/>superano i voti di lista $votisezlis</b><br></td></tr></table>";
    597                                 }
    598                 }
    599 #controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
    600         $errgrulis=array();
    601         if($genere==5 and !$disgiunto  and ($tipo_cons==18 or $tipo_cons==19)){
    602                 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
    603 $resref = $dbi->prepare("$sql");
    604 $resref->execute();
    605 
    606 
    607                 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
    608 $res4 = $dbi->prepare("$sql");
    609 $res4->execute();
    610 
    611 
    612                 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
    613                 if ($sezscrl)
    614                                
    615                 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
    616                     {
    617                     $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    618 $res3 = $dbi->prepare("$sql");
    619 $res3->execute();
    620 
    621 
    622                     $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and  id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
    623 $res4 = $dbi->prepare("$sql");
    624 $res4->execute();
    625 
    626 
    627                     list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
    628                     list($vliste)=$res4->fetch(PDO::FETCH_NUM);
    629                     if($vliste>$vgruppo)
    630                         {
    631                          $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    632 $result = $dbi->prepare("$sql");
    633 $result->execute();
    634 
    635 
    636                          list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
    637                         echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate<br/> superano i voti assegnati al gruppo $dgruppo </b><br></td></tr></table>";
    638                         $errgrulis[$id_gruppo]=1;
    639                         }
    640                     elseif($vliste<$vgruppo)
    641                         {
    642                          $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    643 $result = $dbi->prepare("$sql");
    644 $result->execute();
    645 
    646 
    647                          list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
    648                         echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr></table>";
    649                         $errgrulis[$id_gruppo]=1;
    650                         }
    651                     }
    652                 }
    653 }
    654 
    655 
    656                 echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
    657                 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
    658                 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
    659                 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    660                 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
    661                 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    662                 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
    663                 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
    664                 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
    665                 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
    666                 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
    667                 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
    668                 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
    669                 if ($genere<4){
    670 //                      echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
    671                 }
    672                 echo "<b>"._NUM."</b></td>";
    673                 if($id_lista){
    674                         echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
    675                         ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
    676                 }else{
    677                         echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
    678                         ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
    679 #                       if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
    680 #                       echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
    681                         if($disgiunto){
    682                         echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
    683                         }
    684                 }
    685                 echo "</tr>\n";
    686 
    687 
    688 
    689 
    690 
    691 if($id_lista)           $sql="select t1.* from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on (t1.id_lista=t2.id_lista) WHERE t1.id_cons=$id_cons and t1.id_cons=t2.id_cons $ele_lista $circo ORDER BY t2.num_lista,t1.num_cand";
    692 else $sql="select 0,'$id_cons',t1.id_lista,'','','','','',0 from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on (t1.id_lista=t2.id_lista) WHERE t1.id_cons=$id_cons and t1.id_cons=t2.id_cons $ele_lista $circo ORDER BY t2.num_lista";
    693 $result = $dbi->prepare("$sql");
    694 $result->execute();
    695 
    696 
    697                 $max = $result->rowCount();
    698                 $tot_pref=0;
    699                 $i=1;
    700 
    701                 if($id_lista) {
    702                         while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
    703                                 // dati lista
    704                                 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
    705 $result1 = $dbi->prepare("$sql");
    706 $result1->execute();
    707 
    708 
    709                                 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
    710                         // dati gruppo
    711                                 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    712 $result2 = $dbi->prepare("$sql");
    713 $result2->execute();
    714 
    715 
    716                                 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
    717                                
    718                                 echo "<tr bgcolor=\"$bgcolor2\">";
    719                                 if ($genere<4){
    720                                         echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
    721                                 }
    722                                 echo "<td align=\"center\"><b> $num_cand </b></td>"
    723                                 ."<td align=\"left\"><b>$cognome $nome</b></td>";
    724                                 $cond_sele="and id_cand=$id_cand";
    725                                 $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
    726 $res = $dbi->prepare("$sql");
    727 $res->execute();
    728 
    729 
    730                                 list($voti)= $res->fetch(PDO::FETCH_NUM);
    731                                 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
    732                                 echo "<td align=\"right\" $errcolor><input  name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\"  style=\"text-align:right\">";
    733                                 echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
    734                                 $i++;
    735                                 $tot_pref+=$voti;
    736                         }
    737                 }else {
    738                         if($circo) $circot1=" and t1.id_circ=$id_circ"; else $circot1='';
    739                         $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
    740                         from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
    741                         where t1.id_cons='$id_cons'
    742                         and t1.id_lista=t2.id_lista
    743                         and t2.id_sez=$id_sez
    744                         $circot1
    745                         order by t1.num_lista";
    746 
    747         try {
    748                 $result1 = $dbi->prepare("$sql");
    749                 $result1->execute();
    750 
    751         }
    752                 catch(PDOException $e)
    753                 {
    754                         echo $sql . "<br>" . $e->getMessage();
    755                 }                 
    756 
    757                         $num_lista=$result1->rowCount();
    758                         if (!$num_lista){
    759                                 $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
    760                                 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
    761                                 order by num_lista";
    762                                 $result1 = $dbi->prepare("$sql");
    763                                 $result1->execute();
    764                         }
    765                         $tvnpl=0;
    766                         $tslpl=0;
    767                         while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
    768                                 echo "<tr bgcolor=\"$bgcolor2\">";
    769 //                              if ($genere<4 or $votoc){
    770 //                              }
    771                                 $errcolor='';
    772                                 if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
    773                                 echo "<td align=\"center\"><b> $num_lista </b></td>"
    774                                 ."<td align=\"left\"><b> $descr_lista</b></td>";
    775                                 $cond_sele="and id_lista=$id_lista3";
    776                                 echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$voti."\" size=\"7\"  style=\"text-align:right\">";
    777 #                               if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19) { echo "</td><td align=\"right\"><input  name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\"  style=\"text-align:right\">"; $tvnpl+=$vnpl;}
    778                                 if($disgiunto) {echo "</td><td align=\"right\"><input  name=\"slpl$i\" value=\"".$slpl."\" size=\"7\"  style=\"text-align:right\">"; $tslpl+=$slpl;}
    779                                 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
    780 //                              echo "<td align=\"right\">$sgpl";
    781                                 echo "</tr>\n";
    782                                 $i++;
    783                                 $tot_pref+=$voti;
    784                         }
    785                 }
    786                 if(!$id_lista) {
    787                         echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><font size=\"3\">"._TOT._VOTI_LISTA."</font></td><td align=\"center\"><font size=\"3\">$tot_pref</font></td>";
    788 #                       if($dettnulli && !$disgiunto  && $tipo_cons!=18 && $tipo_cons!=19)
    789 #                               echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tvnpl."</font></td>";
    790                         if($disgiunto)
    791                                 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><font size=\"3\">".$tslpl."</font></td>";
    792                         echo "</tr>";
    793                 }
    794                 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
    795                 // toglie ai candidati la visual... del solo_gruppo
    796                 if(!$votog) {
    797                    if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
    798                         echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._VALIDI_LISTA."</b></td><td align=\"center\"><input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"><input name=\"valista\" value=\"$valista\" size=\"5\" style=\"text-align:right\"></td></tr>";
    799                         echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input name=\"sg\" value=\"$sg\" size=\"5\" style=\"text-align:right\">";
    800                         if(defined('_NULLISTA'))
    801                                 echo "<input type=\"hidden\" name=\"votinulli\" value=\"$votinulli\"><input  type=\"hidden\" name=\"contestati\" value=\"$contestati\"></td></tr>";
    802                         else
    803                                 echo "</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._NULLI_LISTE."</b></td><td align=\"center\"><input  name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
    804         ."</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._CONTESTATI_LISTE."</b></td><td align=\"center\"><input  name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\"></td></tr>";
    805                        
    806                    }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
    807                         echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
    808                    }
    809 ######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
    810 elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
    811 $sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
    812 $resvg = $dbi->prepare("$sql");
    813 $resvg->execute();
    814 
    815 
    816 list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
    817 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
    818 $resvg = $dbi->prepare("$sql");
    819 $resvg->execute();
    820 
    821 
    822         list($voti_sind) = $resvg->fetch(PDO::FETCH_NUM);
    823 
    824 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
    825 }
    826 ###### fine modifica del 16-04-2009
    827 
    828         }
    829                 echo "<tr>";
    830                 echo "<td></td><td></td>";
    831                 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
    832                 echo "</tr></table>";
    833                 if(chisei($id_cons_gen)>=64){
    834                         echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
    835                 } # onclick=\"javascript:del_dati()\"
    836                 echo "</form></tr></table>";
    837                 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
    838                 ."document.sezioni.voti1.focus()\n"
    839                 ."document.sezioni.voti1.select()\n"
    840                 ."//-->\n";
    841                 echo "function vai_lista() {\n";
    842                 echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
    843                 echo "}\n";
    844                 echo "</script>\n";
    845 }
    846 #if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
    847         finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
    848  }
    849 
    850 
    851 ////////////////////////////////////////////
    852 // da qua va la sezione per i votanti
    853 ///////////////////////////////////////////
    854 
    855 function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
    856 //function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
    857  global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
    858 $bgcolor1=$_SESSION['bgcolor2'];
    859 
    860 #OpenTable();
    861 $sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    862 $res = $dbi->prepare("$sql");
    863 $res->execute();
    864 
    865 
    866 if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
    867 $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
    868 $res = $dbi->prepare("$sql");
    869 $res->execute();
    870 
    871 echo "<table><tr><td>";
    872 $num = $res->rowCount();
    873 $sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
    874 $ressez = $dbi->prepare("$sql");
    875 $ressez->execute();
    876 ##################
    877 echo "<style>";
    878 echo "DIV.table";
    879 echo "{
    880     display:table;
    881 }
    882 FORM.tr
    883 {
    884     display:table-row;
    885         text-align: center;
    886 }
    887 DIV.tr
    888 {
    889     display:table-row;
    890         background-color: #D3D3D3;
    891         text-align: center;
    892 }
    893 SPAN.tdm
    894 {
    895     display:table-cell;
    896         border: 1px solid black;
    897         padding: 5px;
    898 }
    899 SPAN.td
    900 {
    901     display:table-cell;
    902 }";
    903 echo "</style>";
    904 
    905 /*
    906     echo "<form class=\"tr\"  name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
    907         echo "<span class=\"td\"><input type=\"text\"/></span>";
    908         <span class="td"><input type="text"/></span>
    909     </form>
    910     <div class="tr">
    911         <span class="td">(cell data)</span>
    912         <span class="td">(cell data)</span>
    913     </div>
    914     ...
    915 </div>
    916 */
    917 ##################
    918 
    919 list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
    920 $y=0;
    921 echo "<div class=\"table\">";
    922 #echo "<tr><td>&nbsp;</td></tr>";
    923 $riga=array();
    924 $rigat=array();
    925 while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
    926         $y++;
    927         $rigat[$y]='';
    928         $riga[$y]='';
    929 #       echo "\n<tr><td>";
    930 #       echo "<form name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
    931 #       echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
    932 $rigat[$y]= "<div class=\"tr\">";
    933         if ($genere==0){ //e' un referendum
    934 #               echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
    935                 $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
    936         }
    937         $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
    938         ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
    939         $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
    940         $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
    941         ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
    942         if ($genere==0){
    943                 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'  ";
    944 $res2 = $dbi->prepare("$sql");
    945 $res2->execute();
    946 
    947 
    948                 $max = $res2->rowCount();
    949         }else{ $max=1;}
    950         $op="rec_add_votanti";
    951         $rigat[$y].= "</div>";
    952 
    953         for ($i=1;$i<=$max;$i++){
    954                 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
    955                 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
    956                 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
    957                 if ($genere==0){
    958                         $query.=" and t2.num_gruppo=$i";
    959                 }
    960                 $sql=$query;
    961 $result = $dbi->prepare("$sql");
    962 $result->execute();
    963 
    964 
    965                 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
    966                 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
    967 $res2 = $dbi->prepare("$sql");
    968 $res2->execute();
    969 
    970 
    971         $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    972 $resril = $dbi->prepare("$sql");
    973 $resril->execute();
    974 
    975 
    976         list($numril)=$resril->fetch(PDO::FETCH_NUM);
    977                 if ($res2)
    978                         list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
    979                 else
    980                         $gruppo=0;
    981                 if (!$gruppo>0) {
    982                         $gruppo=$i;
    983                         $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
    984 $res3 = $dbi->prepare("$sql");
    985 $res3->execute();
    986 
    987 
    988                         if ($res3)
    989                         list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
    990                 }
    991                 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
    992                 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
    993                 $precede[$id_gruppo]=$voti_t;
    994                 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
    995 #                       echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
    996                         $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
    997                 }else{
    998                         $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
    999                 }
    1000                 if ($genere==0){ // e' un referendum
    1001                         $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
    1002                 }
    1003        
    1004 
    1005         $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
    1006         $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
    1007         ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
    1008         ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
    1009         ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
    1010         ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
    1011 #$riga[$y].= "</span>";                     
    1012         list ($anno,$mese,$di)=explode('-',$giorno);
    1013                 $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
    1014                 if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
    1015                 else $riga[$y].= "<span class=\"td\" align=\"center\">";
    1016                 if ($y<$num and $vismf==0 and $voti_u==0) { $riga[$y].= "<input type=\"hidden\" id=\"voti_u$y$i\" name=\"voti_u\" value=\"'$voti_u'\"";}else $riga[$y].= "<input type=\"text\" style=\"text-align:right\" id=\"voti_u$y$i\" name=\"voti_u\" value=\"$voti_u\"";
    1017                 $riga[$y].= " size=\"5\"/></span>";
    1018                 if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
    1019                 else $riga[$y].= "<span class=\"td\" align=\"center\">";
    1020                 if ($y<$num and $vismf==0 and $voti_d==0) { $riga[$y].= "<input type=\"hidden\" id=\"voti_d$y$i\" name=\"voti_d\" value=\"'$voti_d'\"";}else $riga[$y].= "<input type=\"text\" style=\"text-align:right\" id=\"voti_d$y$i\" name=\"voti_d\" value=\"$voti_d\"";
    1021                 $riga[$y].= "  size=\"5\"/></span>";
    1022                 if ($voti_t > ($maschi+$femmine)) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\" ><input type=\"text\" id=\"voti_t$y$i\" name=\"voti_t\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\"/>";
    1023                 else $riga[$y].= "<span class=\"td\" align=\"center\"><input id=\"voti_t$y$i\" name=\"voti_t\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\"/>";
    1024                 $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
    1025                 ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
    1026                 ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
    1027                 ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
    1028                 ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
    1029                 $riga[$y].= "</span>";
    1030 
    1031                 if (chisei($id_cons_gen)>=64 and $y==$numril)   $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"/></span>";
    1032                 else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
    1033                 $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
    1034                 $riga[$y].= "</form>";
    1035 
    1036         }
    1037 #          echo "</table></form>";
    1038            echo "</div>";
    1039 
    1040 
    1041         $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
    1042 $compl = $dbi->prepare("$sql");
    1043 $compl->execute();
    1044 
    1045 
    1046         list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
    1047         if (!$complessivi)
    1048         {
    1049                 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
    1050                 $numy=$y.'1';
    1051                 if ($y==$num) {
    1052                         echo "document.votanti$y.voti_u$numy.focus()\n";
    1053                         echo "document.votanti$y.voti_u$numy.select()\n";
    1054                 }else{
    1055                         echo "this.voti_t$numy.focus()\n";
    1056                         echo "this.voti_t$numy.select()\n";
    1057                 }
    1058                 echo "//-->\n"
    1059                 ."</script>\n";
    1060                 break;
    1061         }
    1062 #       echo "</td></tr>";
    1063         }
    1064 #CloseTable();
    1065 foreach($riga as $key=>$val){
    1066         echo $rigat[$key];
    1067         echo $riga[$key];
    1068 }
    1069 echo "</div></td></tr></table>";
    1070 }
    1071 
    1072 
    1073 
    1074 function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
    1075  global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
    1076 ////////////////////////////////////////////
    1077 // da qua va la sezione per i voti finali
    1078 ///////////////////////////////////////////
    1079 $bgcolor1="#7777ff";
    1080 $bgcolor2=$_SESSION['bgcolor2'];
    1081 
    1082 
    1083 
    1084         echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
    1085         ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
    1086         echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
    1087         ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    1088         ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    1089         ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
    1090         ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
    1091 
    1092         echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
    1093 /*      if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
    1094                 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
    1095         else */
    1096                 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
    1097         echo "<td width=\"82\"><b>"._NULLI."</b></td>"
    1098     ."<td><b>"._BIANCHI."</b></td>"
    1099         ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
    1100         ."<td><b>"._CONTESTATI."</b></td>"
    1101     ."<td><b>"._TOTNON."</b></td>"
    1102         ."<td><b>"._TOTALEVOTI."</b></td>"
    1103         ."<td bgcolor=\"#ffffff\"></td> </tr>";
    1104 /*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
    1105     $result = mysql_query("select id_cons,id_sez,validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista,solo_gruppo,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
    1106 $res = $dbi->prepare("$sql");
    1107 $res->execute();
    1108 
    1109 
    1110 else */
    1111     $sql = "select id_cons,id_sez,validi,nulli,bianchi,contestati,voti_nulli,'0','0','0',solo_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
    1112 $result = $dbi->prepare("$sql");
    1113 $result->execute();
    1114 
    1115 
    1116     list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
    1117     $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
    1118     $tot_voti=$validi+$tot_nulli+$conts+$nullis;
    1119 //      ."</td><td><input  name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" ---     ."<td><b>"._SOLOLIS."</b></td>"
    1120 
    1121 
    1122         echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input  name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
    1123 /*      if(($genere==3 or $genere==5) and !$votog and $ops==3){
    1124         echo "</td><td>$nulli"
    1125         ."</td><td>$bianchi";
    1126         echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
    1127         }else{ */
    1128         echo "</td><td><input  name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
    1129         ."</td><td><input  name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
    1130 //      }
    1131         echo "</td><td><input  name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
    1132         ."</td><td><input  name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
    1133         ."</td><td>$tot_nulli"
    1134         ."</td><td>$tot_voti</td><td>"
    1135         ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
    1136         ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
    1137         ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
    1138         ."</td></tr></table></form>"; //</td></tr>";
    1139 
    1140 
    1141 //    echo "</table>";
    1142         echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
    1143         if (!$validi) {
    1144                 echo "document.spogliovoti.validi.focus()\n";
    1145                 echo "document.spogliovoti.validi.select()\n";
    1146         }
    1147         echo "//-->\n"
    1148         ."</script>\n";
    1149 
    1150 
    1151     }
    1152 
    1153 
    1154 function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
    1155  global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
    1156 ////////////////////////////////////////////
    1157 // da qua va la sezione per le preferenze ai gruppi
    1158 ///////////////////////////////////////////
    1159 // Controllo immmissioni
    1160 
    1161 $bgcolor1="#7777ff";
    1162 $bgcolor2=$_SESSION['bgcolor2'];
    1163 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
    1164 $res = $dbi->prepare("$sql");
    1165 $res->execute();
    1166 
    1167 
    1168     $max = $res->rowCount();
    1169     $max = $max-1;
    1170          echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
    1171         if ($genere==0) {
    1172                 echo "document.sezioni.si1.focus()\n";
    1173                 echo "document.sezioni.si1.select()\n";
    1174         } else {
    1175                 echo "document.sezioni.voti1.focus()\n"
    1176                 ."document.sezioni.voti1.select()\n";
    1177         }
    1178         echo "//-->\n"
    1179         ."</script>\n";
    1180 // tabella votanti
    1181         echo "<center>";
    1182     if ($genere!=0){
    1183         $sql="SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' order by data desc,orario desc limit 0,1";
    1184 $result = $dbi->prepare("$sql");
    1185 $result->execute();
    1186 
    1187 
    1188     list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
    1189         echo "<table  class=\"table-menu\" style=\"width: 50%; color: black;\">"
    1190         ."<tr><td></td><td align=\"center\"></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIU."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTID."</td><td bgcolor=\"$bgcolor1\" align=\"center\">"._VOTIT."</td></tr>"
    1191         ."<tr><td></td><td bgcolor=\"$bgcolor1\" align=\"center\">"._TOT_ULT."</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_u</td><td align=\"center\" bgcolor=\"$bgcolor2\">$voti_d</td><td bgcolor=\"$bgcolor2\" align=\"center\">$voti_t</td></tr>";
    1192         echo "</table>";
    1193     }
    1194         echo "<table  class=\"table-menu\" style=\"width: 50%; color: black\">";
    1195     if ($genere==0){
    1196         $sql="SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez'  ";
    1197 $res = $dbi->prepare("$sql");
    1198 $res->execute();
    1199 
    1200 
    1201                 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
    1202                         if ($voti_parz!=$validi){
    1203                                 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'  ";
    1204 $res2 = $dbi->prepare("$sql");
    1205 $res2->execute();
    1206 
    1207 
    1208                                 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
    1209                                 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI_REF." $num_gruppo: ".$voti_parz." "._NO_VAL_VOTI.": ".$validi."</b><br></td></tr>";
    1210                         }
    1211                         $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
    1212 $res2 = $dbi->prepare("$sql");
    1213 $res2->execute();
    1214 
    1215 
    1216                         list($tot) = $res2->fetch(PDO::FETCH_NUM);
    1217                         if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
    1218                                 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
    1219 $res2 = $dbi->prepare("$sql");
    1220 $res2->execute();
    1221 
    1222 
    1223                                 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
    1224                                 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI_REF." $num_gruppo: ".$tot." "._NO_SOMMA." ".($validi+$nulli+$bianchi+$contestati)."</b><br></td></tr>";
    1225                         }
    1226                 }
    1227     }else{
    1228         $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
    1229 $result = $dbi->prepare("$sql");
    1230 $result->execute();
    1231 
    1232 
    1233         list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
    1234         $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
    1235 $res = $dbi->prepare("$sql");
    1236 $res->execute();
    1237 
    1238 
    1239         list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
    1240         $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
    1241 $res = $dbi->prepare("$sql");
    1242 $res->execute();
    1243 
    1244 
    1245         list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
    1246                 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
    1247                         echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".($validi-$solo_lista)."</b><br></td><tr>";
    1248         }
    1249                 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
    1250 $res2 = $dbi->prepare("$sql");
    1251 $res2->execute();
    1252 
    1253 
    1254                 list($tot) = $res2->fetch(PDO::FETCH_NUM);
    1255                 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
    1256                         echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi+$nulli+$bianchi+$contestati+$votinulli)."</b><br></td></tr>";
    1257         }
    1258                 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
    1259                 $resg = $dbi->prepare("$sql");
    1260                 $resg->execute();
    1261 
    1262 
    1263                 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
    1264                 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
    1265 
    1266                         $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
    1267                         $resg = $dbi->prepare("$sql");
    1268                         $resg->execute();
    1269 
    1270 
    1271                         list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
    1272                         $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
    1273                         $resg = $dbi->prepare("$sql");
    1274                         $resg->execute();
    1275 
    1276 
    1277                         list($sg)=$resg->fetch(PDO::FETCH_NUM);
    1278                         if ($sg != $sgpl) echo "<tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></tr>";
    1279                 }
    1280 #controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
    1281 if($genere==5 and !$disgiunto and $flagsg  and ($tipo_cons==18 or $tipo_cons==19)){
    1282 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo";
    1283 $resref = $dbi->prepare("$sql");
    1284 $resref->execute();
    1285 
    1286 
    1287                 $errgrulis=array();
    1288                 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
    1289                 $res4 = $dbi->prepare("$sql");
    1290                 $res4->execute();
    1291 
    1292 
    1293                 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
    1294                 if ($sezscrl)
    1295                 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
    1296                 {
    1297                                         if($disgiunto || $flagsg){     
    1298                                                 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    1299                                                 $res3 = $dbi->prepare("$sql");
    1300                                                 $res3->execute();
    1301                                                 if($flagsg){
    1302                                                         $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and  id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";
    1303                                                         $res4 = $dbi->prepare("$sql");
    1304                                                         $res4->execute();
    1305                                                 }else{
    1306                                                         $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and  id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";                                             
    1307                                                         $res4 = $dbi->prepare("$sql");
    1308                                                         $res4->execute();                                                       
    1309                                                 }
    1310                                         }else{
    1311                                                 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    1312                                                 $res3 = $dbi->prepare("$sql");
    1313                                                 $res3->execute();
    1314                                                 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and  id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";                                             
    1315                                                 $res4 = $dbi->prepare("$sql");
    1316                                                 $res4->execute();
    1317                                         }
    1318                     list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
    1319                     list($vliste)=$res4->fetch(PDO::FETCH_NUM);
    1320                     if($vliste>$vgruppo and !$disgiunto )
    1321                         {
    1322                         $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    1323                                                 $result = $dbi->prepare("$sql");
    1324                                                 $result->execute();
    1325                                                 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
    1326                         echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti delle liste collegate $vliste<br/> superano i voti assegnati al gruppo $dgruppo $vgruppo</b><br></td></tr></table>";
    1327                         $errgrulis[$id_gruppo]=1;
    1328                         }
    1329                     elseif($vliste<$vgruppo and $disgiunto )
    1330                         {
    1331                         $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
    1332                                                 $result = $dbi->prepare("$sql");
    1333                                                 $result->execute();
    1334                         list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
    1335                         echo "<table class=\"table-menu\" style=\"width: 50%;\"><tr><td style=\"background-color: rgb(255, 0, 0); color: black; text-align: center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br/><b> ATTENZIONE!<BR/>I voti assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr></table>";
    1336                         $errgrulis[$id_gruppo]=1;
    1337                         }
    1338                 }
    1339                 }
    1340 
    1341     }
    1342     if(!isset($votinulli)) $votinulli=0;
    1343         echo "<tr><td></td></tr></table>";
    1344         if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
    1345  if($genere==0)   echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_ref.php\">";
    1346    else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
    1347         echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
    1348     ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
    1349     ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    1350     ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    1351     ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
    1352     ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
    1353     ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
    1354     ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
    1355     ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
    1356         echo "<br><br> <table  class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
    1357         ."<td width=\"3%\"><b>"._NUM."</b></td>"
    1358     ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
    1359         if ($genere==0){
    1360                 echo "<td><b>"._SI."</b></td>"
    1361                 ."<td><b>"._NO."</b></td>"
    1362                 ."<td><b>"._VALIDI."</b></td>"
    1363                 ."<td><b>"._BIANCHI."</b></td>"
    1364                 ."<td><b>"._CONTESTATI."</b></td>"
    1365                 ."<td><b>"._NULLI."</b></td>"
    1366                 ."<td><b>"._TOTNON."</b></td>"
    1367                 ."<td><b>"._TOTALEVOTI."</b></td>"
    1368                 ."<td><b>"._VOTANTI."</b></td>";
    1369         }else{
    1370                 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
    1371                 if($dettnulli)          echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
    1372         }
    1373     echo "</tr>";
    1374     $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
    1375 $res = $dbi->prepare("$sql");
    1376 $res->execute();
    1377 
    1378 
    1379     $max = $res->rowCount();
    1380     //echo "Massimo:$max - id=$id_cons - circo: $circo";
    1381     $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo  ";
    1382 $result = $dbi->prepare("$sql");
    1383 $result->execute();
    1384 
    1385 
    1386     $i=1;
    1387         $tot_pref=0;
    1388        $totsg=0;
    1389     while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
    1390  
    1391       //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
    1392                 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
    1393                
    1394                 ."//-->\n";
    1395                 echo "function controlloref$i() {\n";
    1396                 echo "var a=Number(window.document.sezioni.si$i.value); var b=Number(window.document.sezioni.no$i.value); if(a=='NaN') {a=0} if(b=='NaN') {b=0} var c=a + b; window.document.sezioni.val$i.value=c\n";
    1397                 echo "}\n";
    1398                 echo "</script>\n";   
    1399 
    1400      if ($num_gruppo != ''){
    1401         if ($genere==0){
    1402                 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
    1403 $res = $dbi->prepare("$sql");
    1404 $res->execute();
    1405 
    1406 
    1407                 list($tot) = $res->fetch(PDO::FETCH_NUM);
    1408                 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
    1409 $res = $dbi->prepare("$sql");
    1410 $res->execute();
    1411 
    1412 
    1413                 $pro= $res->fetch(PDO::FETCH_BOTH);
    1414        
    1415                 if ($pro['si']+$pro['no']!=$pro['validi'] or ($pro['validi']+$pro['nulli']+$pro['bianchi']+$pro['contestati']!=$tot and $pro['validi']+$pro['nulli']+$pro['bianchi']+$pro['contestati']!=0)){
    1416                         echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
    1417                 }else{
    1418                         echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
    1419                 }
    1420                 $descr = explode('.',$descr_gruppo, 100);
    1421                 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
    1422                 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
    1423         $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
    1424         $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
    1425         $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
    1426         $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
    1427         $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
    1428         $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
    1429                 $tot_nulli=intval($pro['nulli'])+intval($pro['bianchi'])+intval($pro['contestati']);
    1430                 $tot_voti=intval($pro['validi'])+$tot_nulli;
    1431                 echo "</td><td align=\"right\" width=\"3%\"><input  name=\"si$i\" value=\"".$pro['si']."\" size=\"7\"  style=\"text-align:right\" onchange=controlloref$i()></td>";
    1432                 echo "</td><td align=\"right\" width=\"3%\"><input  name=\"no$i\" value=\"".$pro['no']."\" size=\"7\"  style=\"text-align:right\" onchange=controlloref$i()></td>";
    1433                 echo "</td><td align=\"right\" width=\"3%\"><input  name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
    1434                 echo "</td><td align=\"right\"><input  name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\"  style=\"text-align:right\"></td>";
    1435                 echo "</td><td align=\"right\"><input  name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\"  style=\"text-align:right\"></td>";
    1436                 echo "</td><td align=\"right\"><input  name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\"  style=\"text-align:right\"></td>";
    1437                 echo "</td><td align=\"right\">$tot_nulli</td>";
    1438                 echo "</td><td align=\"right\">$tot_voti</td>";
    1439                 echo "</td><td align=\"right\">$tot</td>";
    1440         }else{
    1441                 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td align=\"center\"><input type=\"hidden\" name=\"num_gruppo$i\" value=\"$num_gruppo\"><b>$num_gruppo</b>"
    1442                 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
    1443                 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
    1444                 $res = $dbi->prepare("$sql");
    1445                 $res->execute();
    1446 
    1447                 $pro= $res->fetch(PDO::FETCH_BOTH);
    1448                 if(!$res->rowCount()) {$pro['voti']=''; $pro['solo_gruppo']='';}
    1449                 $errcolor='';
    1450                 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
    1451                 echo "</td><td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\"  style=\"text-align:right\"></td>";
    1452 
    1453                 if($dettnulli) {echo "<td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\"  style=\"text-align:right\"></td>"; $totsg+=intval($pro['solo_gruppo']);}
    1454                 $tot_pref += intval($pro['voti']);
    1455                 echo "</tr>";
    1456         }
    1457        
    1458         $i++;
    1459     }
    1460 
    1461    }
    1462         if ($genere!=0) {
    1463                 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
    1464 $res = $dbi->prepare("$sql");
    1465 $res->execute();
    1466 
    1467 
    1468                 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
    1469                 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
    1470 $res = $dbi->prepare("$sql");
    1471 $res->execute();
    1472 
    1473 
    1474                 list($sololis)=$res->fetch(PDO::FETCH_NUM);
    1475                 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
    1476                 if($dettnulli) echo "<td>$totsg</td>";
    1477                 echo "</tr>";
    1478                 if($disgiunto)
    1479                         echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._SOLOLIS."</td><td><input  name=\"sololista\" value=\"".$sololis."\" size=\"7\"  style=\"text-align:right\"></td></tr>";
    1480         }
    1481 
    1482    echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
    1483 
    1484     echo "</tr></table></form></td></tr>";
    1485                 if(chisei($id_cons_gen)>=64){
    1486                         echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
    1487                 }
    1488 
    1489         echo "</td></tr></table></center>";
    1490         }
    1491     if ($genere!=0){
    1492         finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
    1493     }
    1494 }
    1495413
    1496414
Note: See TracChangeset for help on using the changeset viewer.