Changeset 235 for trunk/admin/modules/Elezioni/ele_voti.php
- Timestamp:
- May 31, 2015, 1:59:14 AM (9 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin
-
Property svn:ignore
set to
config.php
-
Property svn:ignore
set to
-
trunk/admin/modules/Elezioni/ele_voti.php
r227 r235 43 43 include("modules/Elezioni/funzionidata.php"); 44 44 include("modules/Elezioni/ele.php"); 45 global $votolista, $limite ;45 global $votolista, $limite, $dettnulli; 46 46 if(!isset($votolista)) $votolista=0; 47 47 $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi); … … 50 50 $res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi); 51 51 list($num_circ)=mysql_fetch_row($res); 52 $res = mysql_query("SELECT solo_gruppo FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ", $dbi); 53 list($dettnulli)=mysql_fetch_row($res); 52 54 if ($conscirc){ // or $num_circ==1 53 55 if (!$id_circ){ … … 533 535 function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){ 534 536 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc; 535 global $tipo_cons,$limite; 537 global $tipo_cons,$limite,$dettnulli; 538 536 539 $bgcolor1="#7777ff"; 537 540 $bgcolor2=$_SESSION['bgcolor2']; … … 578 581 $result = mysql_query("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",$dbi); 579 582 list($ctrvoticand)=mysql_fetch_row($result); 580 $result = mysql_query("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_rif",$dbi);583 $result = mysql_query("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",$dbi); 581 584 list($votisezcand)=mysql_fetch_row($result); 582 585 if(($fascia>$limite or !$id_conf) or $genere==4) 583 $result = mysql_query("SELECT sum(voti)from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);586 $result = mysql_query("SELECT voti,nulli_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi); 584 587 else{ 585 588 586 589 $result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'", $dbi); 587 590 list($id_gruppo)=mysql_fetch_row($result); 588 $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);591 $result = mysql_query("SELECT sum(voti),0,0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi); 589 592 } 590 list($votisezlis )=mysql_fetch_row($result);593 list($votisezlis,$sgpl,$vnpl)=mysql_fetch_row($result); 591 594 if($votisezcand>($votisezlis*$numprefs)) 592 595 {$segna="style=\"background-color: #dd0000;\"";} … … 611 614 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";} 612 615 if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) 613 $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,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",$dbi);616 $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,0,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",$dbi); 614 617 else 615 $result = mysql_query("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 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",$dbi); 616 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2) = mysql_fetch_row($result); 618 if($tab=="_ele_voti_lista") 619 $result = mysql_query("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,0,t1.nulli_lista 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",$dbi); 620 else 621 $result = mysql_query("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,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",$dbi); 622 623 // aggiunte le variabili $sgpl e $vnpl 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 624 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl,$vnpl) = mysql_fetch_row($result); 617 625 $valista=$validi2; 618 626 if(!$id_lista or $genere==3){ //controllo di congruenza … … 666 674 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>" 667 675 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>"; 676 if($dettnulli){ 677 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>"; 678 } 668 679 } 669 680 echo "</tr>\n"; … … 703 714 } 704 715 }else { 705 $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista 716 $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista,t2.nulli_lista 706 717 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2 707 718 where t1.id_cons='$id_cons' … … 715 726 order by t1.num_lista", $dbi); 716 727 } 717 while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista )=mysql_fetch_row($result1)){728 while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl)=mysql_fetch_row($result1)){ 718 729 echo "<tr bgcolor=\"$bgcolor2\">"; 719 730 // if ($genere<4 or $votoc){ … … 724 735 $cond_sele="and id_lista=$id_lista3"; 725 736 echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">"; 726 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n"; 737 738 if($dettnulli) echo "</td><td align=\"right\"><input name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\" style=\"text-align:right\"><input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>"; 739 else echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>"; 740 // echo "<td align=\"right\">$sgpl"; 741 echo "</tr>\n"; 727 742 $i++; 728 743 $tot_pref+=$pro['voti']; … … 780 795 781 796 function rec_voti() { 782 global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update; 797 global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update,$dettnulli; 798 783 799 $sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'"; 784 800 $res = mysql_query($sqlcomu); … … 815 831 816 832 }else{ 817 for($i=8,$y--;$i< $y;$i++) { 833 for($i=8,$y--;$i< $y;$i++) { 818 834 $voti = intval($arg[$i++]); 819 $id_cand = intval($arg[$i]); 835 if($dettnulli) {$vnpl = intval($arg[$i++]); $vnriga=",nulli_lista='$vnpl'"; $vnrigains=",'".$vnpl."'";} else {$vnriga=''; $vnrigains=",''";} 836 $id_cand = intval($arg[$i]); 820 837 $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi); 821 $ar=mysql_fetch_array($result); 838 $ar=mysql_fetch_array($result); 839 822 840 if ($ar){ 823 if ($ar['voti']!=$voti ) {824 mysql_query("update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);841 if ($ar['voti']!=$voti or (isset($vnpl) and $ar['nulli_lista']!=$vnpl)) { 842 mysql_query("update ".$prefix."$tab set voti='$voti'$vnriga where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi); 825 843 if ($fileout) fwrite($fp,"update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand';\n"); 826 844 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')", $dbi); 827 845 } 828 } else { 846 } else {//die ("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)"); 829 847 if ($voti) 830 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi); 831 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti' )", $dbi);848 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi); 849 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)", $dbi); 832 850 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n"); 833 851 } … … 1194 1212 1195 1213 function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){ 1196 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo ;1214 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli; 1197 1215 //////////////////////////////////////////// 1198 1216 // da qua va la sezione per le preferenze ai gruppi 1199 1217 /////////////////////////////////////////// 1200 1218 // Controllo immmissioni 1219 1201 1220 $bgcolor1="#7777ff"; 1202 1221 $bgcolor2=$_SESSION['bgcolor2']; … … 1277 1296 }else{ 1278 1297 echo "<td width=\"5%\"><b>"._VOTI."</b></td>"; 1298 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>"; 1279 1299 } 1280 1300 echo "</tr>"; … … 1326 1346 $pro= mysql_fetch_array($res, 3); 1327 1347 echo "</td><td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>"; 1348 if($dettnulli) echo "</td><td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\" style=\"text-align:right\"></td>"; 1328 1349 $tot_pref += $pro['voti']; 1329 1350 } … … 1367 1388 global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout; 1368 1389 if ($fileout) while (!$fp = fopen($fileout,"a")); 1390 1391 $detnulli=1; 1369 1392 $username="$aid"; 1370 1393 $log_data= date("Y/m/d"); … … 1416 1439 $voti = "'$si','$no','$val','$nul','$bia','$con'"; 1417 1440 $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con"; 1441 $sgriga=''; 1418 1442 } 1419 1443 break; 1420 1444 default: 1421 1445 $voti = intval($arg[$i++]); 1446 if($detnulli) { $sg=intval($arg[$i++]); $sgriga = ', solo_gruppo='.$sg;} else {$sgriga=''; $sg=0;} 1422 1447 if (!$voti) {$voti="0";} 1423 $riga="voti=$voti"; 1448 $riga="voti=$voti".$sgriga; 1449 $sgriga=",'$sg'"; 1424 1450 break; 1425 1451 } … … 1439 1465 break; 1440 1466 default: 1441 if ($ar['voti']!=$voti ) {1467 if ($ar['voti']!=$voti or $ar['solo_gruppo']!=$sg) { 1442 1468 $oldval="voti:".$ar['voti']; 1443 1469 $voti.=",null"; … … 1445 1471 if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo']; 1446 1472 break; 1447 } 1448 if ($oldval) { 1473 } 1474 if ($oldval) { 1449 1475 mysql_query("update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi); 1450 1476 if ($fileout) fwrite($fp,"update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo';\n"); … … 1453 1479 } else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)"); 1454 1480 mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','','num_gruppo:$num_gruppo $riga','$tab')", $dbi); 1455 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti )", $dbi);1456 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti );\n");1481 mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga)", $dbi); 1482 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga);\n"); 1457 1483 // 1458 1484 }
Note:
See TracChangeset
for help on using the changeset viewer.