Ignore:
Timestamp:
Apr 4, 2019, 11:16:00 PM (5 years ago)
Author:
roby
Message:
 
File:
1 edited

Legend:

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

    r257 r258  
    264264
    265265                if($res3->rowCount() and !$votog){#$status=0;$ops=-4;
    266                         list($votigs,$votisolog) = m$res3->fetch(PDO::FETCH_NUM);
     266                        list($votigs,$votisolog) = $res3->fetch(PDO::FETCH_NUM);
    267267                        if($votigs  and $genere!=2) { 
    268268                                #       $status=0;
     
    319319
    320320
    321                                                                 $res4= mysql_query("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')";
     321                                                                $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')";
    322322$res4 = $dbi->prepare("$sql");
    323323$res4->execute();
     
    449449                        }
    450450                }
    451                 $sql="SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
     451                $sql="SELECT num_sez, id_sez ,id_sede,colore FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
    452452$res = $dbi->prepare("$sql");
    453453$res->execute();
     
    461461
    462462                echo "<div id=\"navmenu\"> <ul>";
    463                 while(list($sez_num, $sez_id ,$sede_id) = $res->fetch(PDO::FETCH_NUM)) {
     463                while(list($sez_num, $sez_id ,$sede_id,$cursez) = $res->fetch(PDO::FETCH_NUM)) {
    464464                        $ops='';
    465465                        if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
    466466                        $i++;
    467                         $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
     467                        $sql="SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
    468468$result = $dbi->prepare("$sql");
    469469$result->execute();
     
    471471
    472472                        list($circ_id) = $result->fetch(PDO::FETCH_NUM);
     473                        /*
    473474                        //colora la sezione
    474475                        $sezstat=0; #die($ops);
     
    507508                                                       
    508509                        if ($sezstat) $ops=abs($sezstat); else $ops=1;
    509                        
     510                        */
    510511                        if(!$ops) $ops=1;
    511512                        $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";
     
    515516
    516517                        list($numero_sez) = $res2->fetch(PDO::FETCH_NUM);
    517                         if ($sez_num==$numero_sez) {$cursez.= " border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px;\"";} else $cursez.="\"";
     518                        if ($sez_num==$numero_sez) {$cursez.= " border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";} else $cursez.=" \"";
    518519                        echo "\n<li $cursez><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$circ_id&amp;id_sede=$sede_id&amp;id_sez=$sez_id&amp;ops=$ops&amp;do=spoglio&amp;id_lista=$id_lista\">$sez_num</a></b></li>\n";
    519520                }
     
    650651                list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
    651652
    652                 echo "<hr><table><tr><td  width=\"200\"><font size =\"4\" color=\"black\" align=\"left\"><b>Sezione N. $num_sez</b></font size></td><td><table><tr>";
     653                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>";
    653654                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";
    654655                if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
     
    768769}
    769770#######   
    770 if(!$votog and ($genere==3 or $genere==5))
     771if(!$votog and ($genere==3 or $genere==5)){
    771772        $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' ";
    772773$result = $dbi->prepare("$sql");
     
    774775
    775776
    776 else
     777}else{
    777778        $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
    778779$result = $dbi->prepare("$sql");
    779780$result->execute();
    780 
     781}
    781782
    782783    list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
     
    799800                        }
    800801                        echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
    801                         echo "<form name=\"liste\" action=\"admin.php\">";
     802                        echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
    802803                        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=\">";
    803804                        echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
     
    825826
    826827                        list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
    827                         if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4)
     828                        if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
    828829                $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
    829830$result = $dbi->prepare("$sql");
    830831$result->execute();
    831 
    832 
    833             else{
    834 
     832            }else{
    835833                                $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
    836834$result = $dbi->prepare("$sql");
    837835$result->execute();
    838 
    839 
    840836                                list($id_gruppo)=$result;
    841837                                $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    842838$result = $dbi->prepare("$sql");
    843839$result->execute();
    844 
    845 
    846840            }
    847841                        list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
     
    871865
    872866                if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
    873 if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)     
     867if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)      {
    874868                $sql="SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,0,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";
    875869$result = $dbi->prepare("$sql");
     
    877871
    878872
    879 else
     873}else{
    880874                $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 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";
    881875$result = $dbi->prepare("$sql");
    882876$result->execute();
    883 
     877}
    884878
    885879// 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         
     
    917911
    918912                        list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
    919                         if(($fascia>$limite or $disgiunto) or !$id_conf)
     913                        if(($fascia>$limite or $disgiunto) or !$id_conf){
    920914                 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
    921915$result = $dbi->prepare("$sql");
     
    923917
    924918
    925             else{
     919            }else{
    926920
    927921                                $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
     
    951945
    952946
    953                 $res4= mysql_query("SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
     947                $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
    954948$res4 = $dbi->prepare("$sql");
    955949$res4->execute();
     
    1000994
    1001995
    1002                 echo "\n<form name=\"sezioni\" action=\"admin.php\">"
     996                echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
    1003997                ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
    1004998                ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
     999                ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    10051000                ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    10061001                ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
     
    10661061                                ."<td align=\"left\"><b>$cognome $nome</b></td>";
    10671062                                $cond_sele="and id_cand=$id_cand";
    1068                                 $sql="SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
    1069 $res = $dbi->prepare("$sql");
    1070 $res->execute();
    1071 
    1072 
    1073                                 $pro= $res->fetch(PDO::FETCH_BOTH);
     1063                                $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
     1064$res = $dbi->prepare("$sql");
     1065$res->execute();
     1066
     1067
     1068                                list($voti)= $res->fetch(PDO::FETCH_NUM);
    10741069                                if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
    1075                                 echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\"  style=\"text-align:right\">";
     1070                                echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$voti."\" size=\"7\"  style=\"text-align:right\">";
    10761071                                echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
    10771072                                $i++;
    1078                                 $tot_pref+=$pro['voti'];
     1073                                $tot_pref+=$voti;
    10791074                        }
    10801075                }else {
    1081                         $sql="select t2.voti,t1.id_lista, descrizione,simbolo,num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
     1076                        $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
    10821077                        from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
    10831078                        where t1.id_cons='$id_cons'
     
    10851080                        and t2.id_sez=$id_sez
    10861081                        order by t1.num_lista";
    1087 $result1 = $dbi->prepare("$sql");
    1088 $result1->execute();
    1089 
     1082
     1083        try {
     1084                $result1 = $dbi->prepare("$sql");
     1085                $result1->execute();
     1086
     1087        }
     1088                catch(PDOException $e)
     1089                {
     1090                        echo $sql . "<br>" . $e->getMessage();
     1091                }                 
    10901092
    10911093                        $num_lista=$result1->rowCount();
    10921094                        if (!$num_lista){
    1093                                 $sql="select '',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
     1095                                $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
    10941096                                from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
    10951097                                order by num_lista";
     
    10991101
    11001102                        }
    1101                         while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
     1103                        while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
    11021104                                echo "<tr bgcolor=\"$bgcolor2\">";
    11031105//                              if ($genere<4 or $votoc){
     
    11081110                                ."<td align=\"left\"><b> $descr_lista</b></td>";
    11091111                                $cond_sele="and id_lista=$id_lista3";
    1110                                 echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\"  style=\"text-align:right\">";
     1112                                echo "<td align=\"right\" $errcolor><input  name=\"voti$i\" value=\"".$voti."\" size=\"7\"  style=\"text-align:right\">";
    11111113                                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\">";
    11121114                                if($disgiunto) echo "</td><td align=\"right\"><input  name=\"slpl$i\" value=\"".$slpl."\" size=\"7\"  style=\"text-align:right\">";
     
    11151117                                echo "</tr>\n";
    11161118                                $i++;
    1117                                 $tot_pref+=$pro['voti'];
     1119                                $tot_pref+=$voti;
    11181120                        }
    11191121                }
     
    11541156                echo "<td></td><td></td>";
    11551157                echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
    1156                 echo "</tr></table></form></tr>";
     1158                echo "</tr></table>";
    11571159                if(chisei($id_cons_gen)>=64){
    1158                         echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."</td>";
    1159                 }
    1160                 echo "</table>";
     1160                        echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
     1161                } # onclick=\"javascript:del_dati()\"
     1162                echo "</form></tr></table>";
    11611163                echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
    11621164                ."document.sezioni.voti1.focus()\n"
     
    11791181        global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update,$dettnulli,$disgiunto,$tipo_cons;
    11801182       
    1181         $sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    1182         $sql=$sqlcomu);
     1183        $sql="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    11831184        if($res)
    11841185                list($fascia,$id_conf)=$res->fetch(PDO::FETCH_NUM);
     
    11901191        $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
    11911192        $arg2 = func_get_args();
    1192         $arg = split(",",$arg2[0]);
     1193        $arg = preg_split("/\,+/",$arg2[0]);
    11931194        $id_cons_gen=intval($arg[1]);
    11941195        $id_sez = intval($arg[2]);
     
    13021303
    13031304
    1304                                         if($valista)
     1305                                        if($valista) {
    13051306                                                $sql="update  ".$prefix."_ele_sezioni set validi_lista='$valista' where id_sez='$id_sez'";
    13061307$res = $dbi->prepare("$sql");
     
    13081309
    13091310
    1310                                         else
     1311                                        }else{
    13111312                                                $sql="update  ".$prefix."_ele_sezioni set validi_lista=(`validi`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'";
    13121313$res = $dbi->prepare("$sql");
    1313 $res->execute();
     1314                                        $res->execute();}
    13141315
    13151316
     
    13331334function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
    13341335//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
    1335  global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
     1336 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
    13361337$bgcolor1=$_SESSION['bgcolor2'];
    1337 OpenTable();
     1338
     1339#OpenTable();
    13381340$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    13391341$res = $dbi->prepare("$sql");
     
    13461348$res->execute();
    13471349
    1348 
     1350echo "<table><tr><td>";
    13491351$num = $res->rowCount();
    13501352$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
    13511353$ressez = $dbi->prepare("$sql");
    13521354$ressez->execute();
    1353 
     1355##################
     1356echo "<style>";
     1357echo "DIV.table";
     1358echo "{
     1359    display:table;
     1360}
     1361FORM.tr
     1362{
     1363    display:table-row;
     1364        text-align: center;
     1365}
     1366DIV.tr
     1367{
     1368    display:table-row;
     1369        background-color: #D3D3D3;
     1370        text-align: center;
     1371}
     1372SPAN.tdm
     1373{
     1374    display:table-cell;
     1375        border: 1px solid black;
     1376        padding: 5px;
     1377}
     1378SPAN.td
     1379{
     1380    display:table-cell;
     1381}";
     1382echo "</style>";
     1383
     1384/*
     1385    echo "<form class=\"tr\"  name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
     1386        echo "<span class=\"td\"><input type=\"text\"/></span>";
     1387        <span class="td"><input type="text"/></span>
     1388    </form>
     1389    <div class="tr">
     1390        <span class="td">(cell data)</span>
     1391        <span class="td">(cell data)</span>
     1392    </div>
     1393    ...
     1394</div>
     1395*/
     1396##################
    13541397
    13551398list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
    13561399$y=0;
    1357 echo "<tr><td>&nbsp;</td></tr>";
     1400echo "<div class=\"table\">";
     1401#echo "<tr><td>&nbsp;</td></tr>";
     1402$riga=array();
     1403$rigat=array();
    13581404while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
    13591405        $y++;
    1360         echo "\n<tr><td>";
    1361         echo "<form name=\"votanti$y\" action=\"admin.php\">";
    1362         echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
    1363         if ($genere==0){ //e' un referendum
    1364                 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
    1365         }
    1366         echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
    1367         ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
    1368         echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
    1369         echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
    1370         ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
     1406        $rigat[$y]='';
     1407        $riga[$y]='';
     1408#       echo "\n<tr><td>";
     1409#       echo "<form name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
     1410#       echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
     1411$rigat[$y]= "<div class=\"tr\">";
     1412        if ($genere==0){ //e' un referendum
     1413#               echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
     1414                $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
     1415        }
     1416        $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
     1417        ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
     1418        $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
     1419        $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
     1420        ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
    13711421        if ($genere==0){
    13721422                $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'  ";
     
    13751425
    13761426
    1377                 $max = $res2_>rowCount();
    1378         }else{ $max=1;}
    1379         echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
    1380         echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
    1381         ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    1382         ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
    1383         ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
    1384         echo "</td>"; //la riga viene chiusa nel ciclo for   
     1427                $max = $res2->rowCount();
     1428        }else{ $max=1;} $op="rec_add_votanti";
     1429        $rigat[$y].= "</div>";
     1430
    13851431        for ($i=1;$i<=$max;$i++){
    13861432                $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
     
    13961442
    13971443                list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
    1398                 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ";
     1444                $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
    13991445$res2 = $dbi->prepare("$sql");
    14001446$res2->execute();
    14011447
    14021448
    1403         $resril = mysql_query("select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
     1449        $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
    14041450$resril = $dbi->prepare("$sql");
    14051451$resril->execute();
     
    14251471                $precede[$id_gruppo]=$voti_t;
    14261472                if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
    1427                         echo "</tr><tr style=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
     1473#                       echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
     1474                        $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
    14281475                }else{
    1429                         echo "</tr><tr class=\"tr-dx\">";
     1476                        $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
    14301477                }
    14311478                if ($genere==0){ // e' un referendum
    1432                         echo "<td align=\"center\">$gruppo</td>";
    1433                 }
    1434                
    1435                 list ($anno,$mese,$di)=explode('-',$giorno);
    1436                 echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
    1437                 if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\">";
    1438                 else echo "<td align=\"center\">";
    1439                 if ($y<$num and $vismf==0 and $voti_u==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
    1440                 echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
    1441                 if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\">";
    1442                 else echo "<td align=\"center\">";
    1443                 if ($y<$num and $vismf==0 and $voti_d==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
    1444                 echo "  name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
    1445                 if ($voti_t > ($maschi+$femmine)) echo "<td align=\"center\" bgcolor=\"red\"><input type=\"text\" name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
    1446                 else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
    1447                 echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
    1448                 ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
    1449                 ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
    1450                 ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
    1451                 echo "</td>";
    1452         }
    1453         if (chisei($id_cons_gen)>=64 and $y==$numril)   echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"></td>";
    1454         else echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"></td>";
    1455         echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td>";
    1456         echo "</tr>";
    1457 
    1458 
    1459 
    1460 #   echo "</table></form></td></tr>";
    1461    echo "</table></form>";
     1479                        $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
     1480                }
     1481       
     1482
     1483        $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
     1484        $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
     1485        ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
     1486        ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
     1487        ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
     1488#$riga[$y].= "</span>";                     
     1489        list ($anno,$mese,$di)=explode('-',$giorno);
     1490                $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
     1491                if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
     1492                else $riga[$y].= "<span class=\"td\" align=\"center\">";
     1493                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\"";
     1494                $riga[$y].= " size=\"5\"/></span>";
     1495                if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
     1496                else $riga[$y].= "<span class=\"td\" align=\"center\">";
     1497                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\"";
     1498                $riga[$y].= "  size=\"5\"/></span>";
     1499                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\"/>";
     1500                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\"/>";
     1501                $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
     1502                ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
     1503                ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
     1504                ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
     1505                ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
     1506                $riga[$y].= "</span>";
     1507
     1508                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>";
     1509                else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
     1510                $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
     1511                $riga[$y].= "</form>";
     1512
     1513        }
     1514#          echo "</table></form>";
     1515           echo "</div>";
     1516
     1517
    14621518        $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
    14631519$compl = $dbi->prepare("$sql");
     
    14691525        {
    14701526                echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
    1471                 if ($y==$num) {
    1472                         echo "document.votanti$y.voti_u1.focus()\n";
    1473                         echo "document.votanti$y.voti_u1.select()\n";
     1527                $numy=$y.'1';
     1528                if ($y==$num) {
     1529                        echo "document.votanti$y.voti_u$numy.focus()\n";
     1530                        echo "document.votanti$y.voti_u$numy.select()\n";
    14741531                }else{
    1475                         echo "document.votanti$y.voti_t1.focus()\n";
    1476                         echo "document.votanti$y.voti_t1.select()\n";
     1532                        echo "this.voti_t$numy.focus()\n";
     1533                        echo "this.voti_t$numy.select()\n";
    14771534                }
    14781535                echo "//-->\n"
     
    14801537                break;
    14811538        }
    1482         echo "</td></tr>";
    1483         }
    1484 CloseTable();
    1485 }
    1486 
    1487 
    1488 ///////////////////////////
    1489 // registra i votanti
    1490 ///////////////////////////
    1491 
    1492 function rec_add_votanti() {
    1493 global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
    1494 //ordine dei parametri: 0)op 1)voti_u 2) voti_d 3)voti_t 4)id_cons 5)id_sez 6)id_circ 7)id_sede
    1495 // 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
    1496 if ($fileout) while (!$fp = fopen($fileout,"a"));
    1497 
    1498 $username="$aid";
    1499 $arg2 = func_get_args();
    1500 $arg = split(",",$arg2[0]);
    1501 $id_cons_gen=intval($arg[1]);
    1502 $id_sez=intval($arg[2]);
    1503 $id_circ=intval($arg[3]);
    1504 $id_sede=intval($arg[4]);
    1505 $op=$arg[count($arg)-2];
    1506 for($i=5;$i< count($arg)-2;) {
    1507         $voti_u = intval($arg[$i++]);
    1508         $voti_d = intval($arg[$i++]);
    1509         $voti_t = intval($arg[$i++]);
    1510         if($voti_t==0) $voti_t=$voti_d+$voti_u;
    1511         $id_parz = intval($arg[$i++]);
    1512         $giorno = $arg[$i++];
    1513         $ora = $arg[$i++];
    1514         $id_gruppo = intval($arg[$i++]);
    1515     $data=date("Y/m/d");
    1516         $tempo=date("H:i:s");
    1517         $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
    1518 $res = $dbi->prepare("$sql");
    1519 $res->execute();
    1520 
    1521 
    1522         $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
    1523         if ($genere==0){
    1524                 $query.=" and id_gruppo=$id_gruppo";
    1525         }
    1526         $sql="$query";
    1527 $res = $dbi->prepare("$sql");
    1528 $res->execute();
    1529 
    1530 
    1531         $righe=$res->rowCount();
    1532     if (!$righe){
    1533         $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')";
    1534 $res = $dbi->prepare("$sql");
    1535 $res->execute();
    1536 
    1537 
    1538         $sql="insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo')";
    1539 $res = $dbi->prepare("$sql");
    1540 $res->execute();
    1541 
    1542 
    1543         if ($fileout) fwrite($fp,"insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo');\n");
    1544      } elseif($op=="true"){
    1545         $sql="delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'";
    1546 $res = $dbi->prepare("$sql");
    1547 $res->execute();
    1548 
    1549 
    1550         if ($fileout) fwrite($fp,"delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz';\n");
    1551          } else {
    1552         $sql="select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz";
    1553 $res = $dbi->prepare("$sql");
    1554 $res->execute();
    1555 
    1556 
    1557         $ar=$res->fetch(PDO::FETCH_BOTH);
    1558        
    1559         if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){     
    1560         $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','ora:$ar[3] data:$ar[4] voti uomini:$ar[5] donne:$ar[6] totali:$ar[7] gruppo:$ar[8]','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')";
    1561 $res = $dbi->prepare("$sql");
    1562 $res->execute();
    1563 
    1564        
    1565         $sql="update  ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz'";
    1566 $res = $dbi->prepare("$sql");
    1567 $res->execute();
    1568 
    1569 
    1570         if ($fileout) fwrite($fp,"update  ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz';\n");
    1571         }
    1572      }
    1573   }   
    1574 if ($fileout)fclose($fp);
    1575 Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&ops=1&do=spoglio");
     1539#       echo "</td></tr>";
     1540        }
     1541#CloseTable();
     1542foreach($riga as $key=>$val){
     1543        echo $rigat[$key];
     1544        echo $riga[$key];
     1545}
     1546echo "</div></td></tr></table>";
    15761547}
    15771548
     
    15881559
    15891560
    1590         echo "<form name=\"spogliovoti\" action=\"admin.php\">"
     1561        echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
    15911562        ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
    15921563        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
     1564        ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    15931565        ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    15941566        ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
     
    16381610        ."</td><td>$tot_nulli"
    16391611        ."</td><td>$tot_voti</td><td>"
    1640 //      ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
     1612        ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
    16411613        ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
    16421614        ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
     
    18001772
    18011773
    1802         list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM)
     1774    list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
    18031775        echo "<table  class=\"table-menu\" style=\"width: 50%; color: black;\">"
    18041776        ."<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>"
     
    19501922        echo "<tr><td></td></tr></table>";
    19511923        if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
    1952     echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"admin.php\">";
    1953         echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
     1924 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\">";
     1925   else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
     1926        echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
    19541927    ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
     1928    ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
    19551929    ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
    19561930    ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
    19571931    ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
     1932    ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
     1933    ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
    19581934    ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
    19591935        echo "<br><br> <table  class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
     
    20181994                echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
    20191995                ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
    2020         $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
    2021         $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
    2022         $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
    2023         $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
    2024         $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
    2025         $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
     1996        $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'0';
     1997        $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'0';
     1998        $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'0';
     1999        $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'0';
     2000        $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'0';
     2001        $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'0';
    20262002                $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
    20272003                $tot_voti=$pro['validi']+$tot_nulli;
     
    20362012                echo "</td><td align=\"right\">$tot</td>";
    20372013        }else{
    2038                 echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
     2014                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>"
    20392015                ."</td><td align=\"left\"><b> $descr_gruppo </b>";
    20402016                $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
     
    21082084$log_ora=getdate(time());
    21092085$arg2 = func_get_args();
    2110 $arg = split(",",$arg2[0]);
     2086$arg = preg_split("/\,+/",$arg2[0]);
    21112087$id_cons_gen=intval($arg[1]);
    21122088$id_sez = intval($arg[2]);
     
    22782254        voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
    22792255        break;
     2256        case "rec_add_votanti":
     2257                rec_add_votanti($vari);
     2258                break;
    22802259        default :
    22812260        $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
Note: See TracChangeset for help on using the changeset viewer.