[2] | 1 | <?php
|
---|
| 2 | /************************************************************************/
|
---|
| 3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
| 4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
| 5 | /* http://www.eleonline.it */
|
---|
| 6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
| 7 | /************************************************************************/
|
---|
| 8 | /* Modulo Inserimento dati */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 |
|
---|
| 12 | if (!defined('ADMIN_FILE')) {
|
---|
| 13 | die ("You can't access this file directly...");
|
---|
| 14 | }
|
---|
| 15 | $aid=$_SESSION['aid'];
|
---|
| 16 | $dbi=$_SESSION['dbi'];
|
---|
| 17 | $prefix=$_SESSION['prefix'];
|
---|
| 18 | $currentlang=$_SESSION['lang'];
|
---|
| 19 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 20 | $vari= implode(',',$_GET);//param);
|
---|
| 21 | $id_comune=$_SESSION['id_comune'];
|
---|
| 22 | $id_cons_gen=intval($_GET['id_cons_gen']);
|
---|
| 23 | $perms=ChiSei($id_cons_gen);
|
---|
| 24 | if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 25 |
|
---|
| 26 | $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
|
---|
| 27 | list($tipo_cons) = mysql_fetch_row($res);
|
---|
| 28 | if ($tipo_cons!=3) $limite=0; #die ("limite: $limite");}
|
---|
| 29 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
| 30 | //if (isset($param['id_cons'])) $id_cons=intval($param['id_cons']); else $id_cons='';
|
---|
| 31 | if (isset($param['ops'])) $ops=intval($param['ops']); else $ops='';
|
---|
| 32 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
| 33 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
|
---|
| 34 | if (isset($param['ov'])) $ov=intval($param['ov']); else $ov='';
|
---|
| 35 | if (isset($param['mv'])) $mv=intval($param['mv']); else $mv='';
|
---|
| 36 | if (isset($param['gv'])) $gv=intval($param['gv']); else $gv='';
|
---|
| 37 | if (isset($param['msv'])) $msv=intval($param['msv']); else $msv='';
|
---|
| 38 | if (isset($param['av'])) $av=intval($param['av']); else $av='';
|
---|
| 39 | if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else
|
---|
| 40 | if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='';
|
---|
| 41 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
|
---|
| 42 | if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
|
---|
| 43 | if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
|
---|
| 44 | if (isset($param['prev_sez'])) $prev_sez=intval($param['prev_sez']); else $prev_sez='';
|
---|
| 45 | if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
|
---|
| 46 | include("modules/Elezioni/funzionidata.php");
|
---|
| 47 | include("modules/Elezioni/ele.php");
|
---|
| 48 | $res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
|
---|
| 49 | list($num_circ)=mysql_fetch_row($res);
|
---|
| 50 | if ($conscirc){ // or $num_circ==1
|
---|
| 51 | if (!$id_circ){
|
---|
| 52 | $res = mysql_query("SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1", $dbi);
|
---|
| 53 | if (!$res) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
|
---|
| 54 | list($id_circ)=mysql_fetch_row($res);
|
---|
| 55 | $_SESSION['id_circ']=$id_circ;
|
---|
| 56 | }
|
---|
| 57 | $result = mysql_query("select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'", $dbi);
|
---|
| 58 | $i=0;
|
---|
| 59 | while(list($tmp) = mysql_fetch_row($result)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
|
---|
| 60 | unset($idsedi);$i=0;$idsezi=array();unset($result);
|
---|
| 61 | $result = mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)", $dbi);
|
---|
| 62 | unset($tmp);
|
---|
| 63 | while(list($tmp) = mysql_fetch_row($result)) $idsezi[$i++]=$tmp;
|
---|
| 64 | $tmp=implode (",",$idsezi);
|
---|
| 65 | $sezi = "and id_sez in ($tmp)";
|
---|
| 66 | $circo = "and id_circ='$id_circ'";
|
---|
| 67 | }else{
|
---|
| 68 | $sezi='';
|
---|
| 69 | $circo='';
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[62] | 72 | function stato_rilevazione($id_sez,$solosede){
|
---|
| 73 | global $id_cons, $prefix, $dbi, $id_cons_gen;
|
---|
| 74 | $ops=0;
|
---|
| 75 | $status=0;
|
---|
| 76 | if($ops==0){
|
---|
| 77 | #controllo congruenza affluenze
|
---|
| 78 | $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc", $dbi);
|
---|
| 79 | if($res)
|
---|
| 80 | while (list($ora,$giorno) = mysql_fetch_row($res)){
|
---|
| 81 | $query="SELECT sum(voti_complessivi) FROM ".$prefix."_ele_voti_parziale as t1 where t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
| 82 | $res2 = mysql_query("$query", $dbi);
|
---|
| 83 | list($voti)=mysql_fetch_row($res2);
|
---|
| 84 | if($voti) {
|
---|
| 85 | if(isset($ora)){
|
---|
| 86 | $query="SELECT count(voti_complessivi) FROM ".$prefix."_ele_voti_parziale as t1 where t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
| 87 | $res3 = mysql_query("$query", $dbi);
|
---|
| 88 | list($numscru)=mysql_fetch_row($res3);
|
---|
| 89 | $res3= mysql_query("SELECT count(num_sez) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
|
---|
| 90 | list($numtot) = mysql_fetch_row($res3);
|
---|
| 91 | $res3= mysql_query("SELECT maschi+femmine+autorizzati_m+autorizzati_f FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
| 92 | list($iscritti) = mysql_fetch_row($res3);
|
---|
[2] | 93 |
|
---|
[62] | 94 |
|
---|
| 95 | $query="SELECT voti_complessivi, voti_uomini, voti_donne FROM ".$prefix."_ele_voti_parziale as t1 where t1.id_sez='$id_sez' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
| 96 | $res3 = mysql_query("$query", $dbi);
|
---|
| 97 | list($voti, $uomini, $donne)=mysql_fetch_row($res3);
|
---|
| 98 | if($voti>0) {#echo $query;
|
---|
| 99 | if ((($uomini+$donne)==0 or ($uomini+$donne)==$voti) and ($voti)<=$iscritti)
|
---|
| 100 | if($numscru<$numtot and $numscru>0)
|
---|
| 101 | {$status=1;break;}
|
---|
| 102 | else
|
---|
| 103 | {$status=0;break;}
|
---|
| 104 | else return 1;
|
---|
| 105 | } #else return 0;
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
| 109 | # return 0;
|
---|
| 110 | #controllo congruenza voti espressi
|
---|
| 111 | $res2= mysql_query("SELECT sum(validi) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
|
---|
| 112 | if($res2){
|
---|
| 113 | list($validi) = mysql_fetch_row($res2);
|
---|
| 114 | if($validi) {
|
---|
| 115 | $status=0;
|
---|
| 116 | $query="SELECT validi,nulli,bianchi,contestati,voti_nulli,solo_gruppo,voti_nulli,validi_lista,contestati_lista,voti_nulli_lista FROM ".$prefix."_ele_sezioni as t1 where t1.id_sez='$id_sez'";
|
---|
| 117 | $res4 = mysql_query("$query", $dbi);
|
---|
| 118 | list($validi, $nulli, $bianchi,$contestati,$votinulli,$sologruppo,$votinulli,$validilista,$contestatilista,$votinullilista)=mysql_fetch_row($res4);
|
---|
| 119 | if($validi>0) {
|
---|
| 120 | if (($validi+$nulli+$bianchi+$contestati+$votinulli)==$voti)
|
---|
| 121 | {$status=1;}
|
---|
| 122 | else return 4;
|
---|
| 123 | } #else return 0;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | #controllo congruenza voti di gruppo
|
---|
| 127 | $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons'", $dbi);
|
---|
| 128 | if($res3){
|
---|
| 129 | list($votig) = mysql_fetch_row($res3);
|
---|
| 130 | if($votig) {
|
---|
| 131 | $status=0;
|
---|
| 132 | $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
|
---|
| 133 | $res4 = mysql_query("$query", $dbi);
|
---|
| 134 | list($votigs)=mysql_fetch_row($res4);
|
---|
| 135 | if($votigs>0) {
|
---|
| 136 | if (($votigs)==$validi)
|
---|
| 137 | {$status=1;}
|
---|
| 138 | else return 4;
|
---|
| 139 | } #else return 0;
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 | #controllo congruenza voti di lista
|
---|
| 143 | $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons'", $dbi);
|
---|
| 144 | if($res3){
|
---|
| 145 | list($votil) = mysql_fetch_row($res3);
|
---|
| 146 | if($votil) {
|
---|
| 147 | $status=0;
|
---|
| 148 | $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
|
---|
| 149 | $res4 = mysql_query("$query", $dbi);
|
---|
| 150 | list($votils)=mysql_fetch_row($res4);
|
---|
| 151 | if($votils>0) {
|
---|
| 152 | if (($votils+$sologruppo+$votinulli+$contestatilista+$votinullilista)==($validi+$contestati))
|
---|
| 153 | {$status=1;}
|
---|
| 154 | else return 3;
|
---|
| 155 | } #else return 0;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
[2] | 158 |
|
---|
[62] | 159 |
|
---|
| 160 |
|
---|
| 161 | if($status==1) return (-1);
|
---|
| 162 | else return 0;
|
---|
| 163 |
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[2] | 168 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 169 | $offset=2;
|
---|
| 170 | if (!isset($min)) $min=0;
|
---|
| 171 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
| 172 |
|
---|
[56] | 173 | function numeri_sezione($nums) {
|
---|
[2] | 174 | // tabella visualizzazione sezioni per numero
|
---|
| 175 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$id_cons,$id_lista,$ops, $perms,$id_sez;
|
---|
| 176 | // $ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where aid='$aid'",$dbi);
|
---|
| 177 | // list ($perms)=mysql_fetch_row($ressup);
|
---|
[56] | 178 | $solosede='';
|
---|
| 179 | if ($perms<32) {
|
---|
| 180 | $res = mysql_query("SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons", $dbi);
|
---|
| 181 | if ($res) {
|
---|
| 182 | list($solouna)=mysql_fetch_row($res);
|
---|
[62] | 183 | if ($solouna>0) $solosede="and id_sede='$solouna'";
|
---|
[56] | 184 | }
|
---|
| 185 | }
|
---|
| 186 | $res = mysql_query("SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez", $dbi);
|
---|
[2] | 187 | $max = mysql_num_rows($res);
|
---|
| 188 | //if ($max>=64){
|
---|
| 189 | $i=0;
|
---|
| 190 | while(list($sez_num, $sez_id ,$sede_id) = mysql_fetch_row($res)) {
|
---|
| 191 | $i++;
|
---|
| 192 | $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ", $dbi);
|
---|
| 193 | list($circ_id) = mysql_fetch_row($result);
|
---|
[62] | 194 | //colora la sezione
|
---|
| 195 | $sezstat=0; #die($ops);
|
---|
| 196 | $sezstat=stato_rilevazione($sez_id,$solosede);
|
---|
| 197 | if ($sezstat==(-1)) $bgsez="#99CC33"; #verde
|
---|
| 198 | elseif ($sezstat>0) {
|
---|
| 199 | $bgsez="#FF3300";#rosso;
|
---|
| 200 | $ops=$sezstat;
|
---|
| 201 | }
|
---|
| 202 | else{$bgsez="";}
|
---|
[2] | 203 | $res2= mysql_query("SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
| 204 | list($numero_sez) = mysql_fetch_row($res2);
|
---|
[62] | 205 | if ($sez_num==$numero_sez) {$bgsez="#FFFF00";}
|
---|
[2] | 206 | echo "\n<td align=\"center\" width=\"5%\" bgcolor=\"$bgsez\"><b><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$circ_id&id_sede=$sede_id&id_sez=$sez_id&ops=$ops&do=spoglio&id_lista=$id_lista\">$sez_num</a></b></td>\n";
|
---|
[56] | 207 | if (($i%$nums) ==0) echo "</tr>\n<tr bgcolor=\"$bgcolor1\">";
|
---|
[2] | 208 | }
|
---|
| 209 | //}
|
---|
| 210 |
|
---|
[56] | 211 | # echo"</td></tr></table>";
|
---|
[2] | 212 | //}// fine tabella per numero sezioni
|
---|
| 213 | // inizio tabella centrale
|
---|
[56] | 214 | # echo "\n</td><td valign=\"top\" align=\"left\">";
|
---|
[2] | 215 | }
|
---|
| 216 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
| 217 |
|
---|
| 218 |
|
---|
| 219 | function voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
|
---|
| 220 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc;
|
---|
| 221 |
|
---|
[56] | 222 | echo "<table border=\"0\" width=\"770\" align=\"left\"><tr>";
|
---|
[2] | 223 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
|
---|
| 224 | //echo "<h6>";
|
---|
[56] | 225 | echo "\n<table align=\"left\" width=\"700\" border=\"0\"><tr bgcolor=\"$bgcolor1\">";
|
---|
[62] | 226 | numeri_sezione(22);
|
---|
[56] | 227 | echo "<td></td></tr></table>\n";
|
---|
| 228 | echo "\n</td></tr><tr><td>\n";
|
---|
| 229 |
|
---|
| 230 |
|
---|
[2] | 231 | ///////////////////////
|
---|
| 232 | // Circoscrizione : scelta
|
---|
| 233 | ///////////////////////
|
---|
| 234 |
|
---|
| 235 | $resoper=mysql_query("SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
|
---|
| 236 | ".$prefix."_ele_sede as t2
|
---|
| 237 | where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'", $dbi);
|
---|
| 238 | list($id_sede2,$id_circ2) = mysql_fetch_row($resoper);
|
---|
| 239 | if ($id_sede2 and !($id_sede==$id_sede2)) {
|
---|
| 240 | $id_sede=$id_sede2;
|
---|
| 241 | $id_circ=$id_circ2;
|
---|
| 242 | $do="spoglio";
|
---|
| 243 | $res= mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede=$id_sede order by num_sez limit 0,1", $dbi);
|
---|
| 244 | list($id_sez) = mysql_fetch_row($res);
|
---|
| 245 | }
|
---|
| 246 | if ($do == "circo") {
|
---|
| 247 | OpenTable();
|
---|
| 248 | echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
|
---|
| 249 | ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
| 250 | ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
|
---|
| 251 | // Circoscrizione: lista
|
---|
| 252 | //**************************************
|
---|
| 253 | .""._CIRCO.": "
|
---|
| 254 | ."<select name=\"id_circ\">";
|
---|
| 255 | $res= mysql_query("SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ", $dbi);
|
---|
| 256 | while(list($id,$descr) = mysql_fetch_row($res)) {
|
---|
| 257 | if ($descr!="Tutte"){
|
---|
| 258 | if ($id == $id_circ) {
|
---|
| 259 | $sel = "selected";
|
---|
| 260 | } else {
|
---|
| 261 | $sel = "";
|
---|
| 262 | }
|
---|
| 263 | echo "<option value=\"$id\" $sel>$descr";
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 | echo "</select>"
|
---|
| 267 | //***********************************
|
---|
| 268 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 269 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
| 270 | ."</form></td></tr>";
|
---|
| 271 | CloseTable();
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | ///////////////////////
|
---|
| 275 | // sede : scelta
|
---|
| 276 | ///////////////////////
|
---|
| 277 |
|
---|
| 278 |
|
---|
| 279 | if ($do == "sede") {
|
---|
| 280 | OpenTable();
|
---|
| 281 | echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
|
---|
| 282 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
| 283 | list( $descr_circ) = mysql_fetch_row($res);
|
---|
| 284 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->";
|
---|
| 285 | echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
| 286 | ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
| 287 |
|
---|
| 288 | // Indirizzo: lista
|
---|
| 289 | //**************************************
|
---|
| 290 | .""._INDIRIZZO.": "
|
---|
| 291 | ."<select name=\"id_sede\">";
|
---|
| 292 | $res= mysql_query("SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo", $dbi);
|
---|
| 293 | // echo "$id_circ - $id_cons";
|
---|
| 294 | while(list($id,$indir) = mysql_fetch_row($res)) {
|
---|
| 295 | if ($id == $id_sede) {
|
---|
| 296 | $sel = "selected";
|
---|
| 297 | } else {
|
---|
| 298 | $sel = "";
|
---|
| 299 | }
|
---|
| 300 | echo "<option value=\"$id\" $sel>$indir";
|
---|
| 301 | }
|
---|
| 302 | echo "</select>"
|
---|
| 303 | //*************************************
|
---|
| 304 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 305 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 306 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
| 307 | ."</form></td></tr>\n";
|
---|
| 308 | CloseTable();
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | ///////////////////////
|
---|
| 312 | // sezione : scelta
|
---|
| 313 | ///////////////////////
|
---|
| 314 | if ($do == "spoglio") {
|
---|
| 315 | echo "\n<form name=\"sezione\" action=\"admin.php\">";
|
---|
| 316 | OpenTable();
|
---|
| 317 | echo "<tr><td>";
|
---|
| 318 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
| 319 | list($descr_circ) = mysql_fetch_row($res);
|
---|
| 320 | $res= mysql_query("SELECT indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' AND id_sede='$id_sede' order by indirizzo", $dbi);
|
---|
| 321 | list($indir) = mysql_fetch_row($res);
|
---|
| 322 | echo "<input type=\"hidden\" name=\"pag_sez\" value=\"admin.php?op=voti&do=spoglio&ops=$ops&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_lista=$id_lista&id_sez=\">";
|
---|
| 323 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->
|
---|
| 324 | <a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&do=sede\">"._INDIRIZZO."</a> $indir ->
|
---|
| 325 | <input type=\"hidden\" name=\"op\" value=\"voti\">
|
---|
| 326 | <input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
| 327 | // Sezioni:lista
|
---|
| 328 | //**************************************
|
---|
| 329 | ."<b>"._SEZIONE."</b>: "
|
---|
| 330 | ."<select name=\"id_sez\" onChange=\"top.location.href=this.form.pag_sez.value+this.form.id_sez.options[this.form.id_sez.selectedIndex].value;return false\">";
|
---|
| 331 | $res= mysql_query("SELECT id_sez,num_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede='$id_sede' order by num_sez", $dbi);
|
---|
| 332 | $rif_sez=0;
|
---|
| 333 | $next_sez=0;
|
---|
| 334 | unset($prev_sez);
|
---|
| 335 | while(list($id,$num) = mysql_fetch_row($res)) {
|
---|
| 336 | if (!($id_sez>0)) {$id_sez=$id;}
|
---|
| 337 | if ($id == $id_sez) {
|
---|
| 338 | $sel = "selected";
|
---|
| 339 | $prev_sez=$rif_sez;
|
---|
| 340 | } else {
|
---|
| 341 | $sel = "";
|
---|
| 342 | if (isset($prev_sez) and ($next_sez==0)) { $next_sez=$id;}
|
---|
| 343 | $rif_sez=$id;
|
---|
| 344 | }
|
---|
| 345 | echo "<option value=\"$id\" $sel>$num";
|
---|
| 346 | }
|
---|
| 347 | echo "</select>"
|
---|
| 348 | //*************************************
|
---|
| 349 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">\n"
|
---|
| 350 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">\n"
|
---|
| 351 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">\n"
|
---|
| 352 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">\n"
|
---|
| 353 | ." <input type=\"submit\" name=\"update\" value=\""._OK."\">\n";
|
---|
| 354 | if ($prev_sez) {
|
---|
| 355 | echo " <a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=spoglio&id_circ=$id_circ&id_sede=$id_sede&id_sez=$prev_sez&ops=$ops&id_lista=$id_lista\">"._PREV."</a> \n";
|
---|
| 356 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._PREV."</span> ";}
|
---|
| 357 | if ($next_sez) {
|
---|
| 358 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=spoglio&id_circ=$id_circ&id_sede=$id_sede&id_sez=$next_sez&ops=$ops&id_lista=$id_lista\">"._NEXT."</a>\n";
|
---|
| 359 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._NEXT."</span>\n";}
|
---|
| 360 | echo "\n</td></tr>";
|
---|
| 361 | CloseTable();
|
---|
| 362 |
|
---|
| 363 | echo "</form>\n";
|
---|
| 364 | echo "\n</td></tr><tr><td>\n";
|
---|
| 365 | // echo "\n</td></tr></table>\n";
|
---|
| 366 |
|
---|
| 367 |
|
---|
| 368 | //************************************
|
---|
| 369 | // Menu spoglio
|
---|
| 370 | //************************************
|
---|
| 371 | $result = mysql_query("select id_cons,id_sez,id_sede,num_sez, maschi, femmine from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
| 372 | list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = mysql_fetch_row($result);
|
---|
| 373 |
|
---|
| 374 | //$bgcolor1="#b0b0b0";
|
---|
[56] | 375 | echo "<hr><table border=\"0\" width=\"60%\" align=\"center\"><tr>";
|
---|
[2] | 376 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=$id_sez&id_circ=$id_circ&id_sede=$id_sede&do=spoglio&ops=1\">"._AFFLUENZE."</a></b></td>\n";
|
---|
| 377 | if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
|
---|
| 378 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=$id_sez&id_circ=$id_circ&id_sede=$id_sede&do=spoglio&ops=4\">"._GRUPPO."</a></b></td>\n";
|
---|
| 379 | }
|
---|
| 380 | if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
|
---|
| 381 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=$id_sez&id_circ=$id_circ&id_sede=$id_sede&do=spoglio&ops=3\">"._PREFLISTA."</a></b></td>\n";
|
---|
| 382 | }
|
---|
[56] | 383 | echo "</tr></table><hr>\n";
|
---|
[2] | 384 | // echo "\n</td></tr></table>\n";
|
---|
[56] | 385 | #############
|
---|
| 386 | # posizionamento in mancanza di scelta
|
---|
| 387 | #############
|
---|
| 388 | if (!$ops){
|
---|
| 389 | if (!$id_sez) { echo"";#import( pagina di help );
|
---|
| 390 | } else{
|
---|
| 391 | $res= mysql_query("SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
|
---|
| 392 | list($data,$orario)=mysql_fetch_row($res);
|
---|
| 393 | $res= mysql_query("SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'", $dbi);
|
---|
| 394 | list($voti) = mysql_fetch_row($res);
|
---|
| 395 | if (!$voti) $ops=1;
|
---|
| 396 | else {
|
---|
| 397 | # $res= mysql_query("SELECT validi from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
| 398 | # list($voti) = mysql_fetch_row($res);
|
---|
| 399 | if($genere<4){
|
---|
| 400 | $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'", $dbi);
|
---|
| 401 | list($voti) = mysql_fetch_row($res);
|
---|
| 402 | if ($voti==0 or $genere<3) $ops=4;
|
---|
| 403 | }
|
---|
| 404 | if(!$ops) $ops=3;
|
---|
| 405 | }
|
---|
[2] | 406 |
|
---|
[56] | 407 | }
|
---|
| 408 | }
|
---|
| 409 | ############ fine posizionamento
|
---|
[2] | 410 |
|
---|
| 411 | ///////////////////////////////////////////
|
---|
| 412 | // opzioni per le funzioni di immissione
|
---|
| 413 |
|
---|
| 414 | if ($ops == 1) {
|
---|
| 415 | votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
|
---|
| 416 | }
|
---|
| 417 | /*
|
---|
| 418 | if ($ops == 2) {
|
---|
| 419 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
| 420 | }
|
---|
| 421 | */
|
---|
| 422 | if ($ops == 3) {
|
---|
| 423 | preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
| 424 | }
|
---|
| 425 | if ($ops == 4) {
|
---|
| 426 | preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
| 427 |
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | }
|
---|
| 431 | CloseTable();
|
---|
| 432 |
|
---|
| 433 | }
|
---|
| 434 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 435 | // FUNZIONI DI IMMISSIONE
|
---|
| 436 | // - preferenze (candidati consiglieri)
|
---|
| 437 | // - preferenze_gruppi
|
---|
| 438 | // - votanti
|
---|
| 439 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 440 |
|
---|
| 441 | //////////////////////////////////////////////////////////////////////
|
---|
| 442 | // da qui va la sezione per le preferenze candidati consiglieri
|
---|
| 443 | //////////////////////////////////////////////////////////////////////
|
---|
| 444 | function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
| 445 | global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
|
---|
| 446 | global $tipo_cons,$fascia,$limite;
|
---|
| 447 | $bgcolor1="#7777ff";
|
---|
| 448 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
| 449 | //controlla se sono stati inseriti i votanti
|
---|
| 450 | if(!$votog and ($genere==3 or $genere==5))
|
---|
| 451 | $result = mysql_query("select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 452 | else
|
---|
| 453 | $result = mysql_query("select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 454 | #e
|
---|
| 455 | list($validi,$nulli,$bianchi,$contestati,$votinulli) = mysql_fetch_row($result);
|
---|
| 456 | # if ($validi+$nulli+$bianchi) die("entra($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)");
|
---|
| 457 | echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr>";
|
---|
| 458 | $res_lis = mysql_query("SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista",$dbi);
|
---|
| 459 | $num_liste = mysql_num_rows($res_lis);
|
---|
| 460 | $ele_lista='';
|
---|
| 461 | if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
|
---|
| 462 | if($fascia<=$limite and !$id_lista) {
|
---|
| 463 | $result = mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1",$dbi);
|
---|
| 464 | list($id_lista)=mysql_fetch_row($result);
|
---|
| 465 | }
|
---|
| 466 | echo "<td> </td></tr><tr><td style=\"vertical-align: top;\">";
|
---|
| 467 | echo "<form name=\"liste\" action=\"admin.php\">";
|
---|
| 468 | echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_sez=$id_sez&id_circ=$id_circ&id_sede=$id_sede&do=spoglio&ops=3&id_lista=\">";
|
---|
| 469 | echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
|
---|
| 470 | if ($id_lista){
|
---|
| 471 | echo "<option value=\"0\">"._VOTI_LISTA;
|
---|
| 472 | $ele_lista=" and t1.id_lista='$id_lista' ";
|
---|
| 473 | }else{
|
---|
| 474 | echo "<option value=\"0\" selected>"._VOTI_LISTA;
|
---|
| 475 | $ele_lista=" group by t1.id_lista ";
|
---|
| 476 |
|
---|
| 477 | }
|
---|
| 478 | while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
|
---|
| 479 | $sel = ($id_rif == $id_lista) ? "selected" : "";
|
---|
| 480 | echo "<option value=\"$id_rif\" $sel>";
|
---|
| 481 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
| 482 | echo $num_lis.") ".substr($descrizione,0,30);
|
---|
| 483 | }
|
---|
| 484 | echo "</select></form></td>\n";
|
---|
| 485 | }else {
|
---|
| 486 | $id_lista=0;
|
---|
| 487 | }
|
---|
| 488 | echo "<td style=\"vertical-align: top;\">";
|
---|
| 489 |
|
---|
| 490 | if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
|
---|
| 491 | ###############prova
|
---|
| 492 | if($genere==4 and !$id_lista)
|
---|
| 493 | $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,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);
|
---|
| 494 | else
|
---|
| 495 | $result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,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);
|
---|
| 496 | list( $voti_sez, $validi2, $sg,$cont2,$vnulli2) = mysql_fetch_row($result);
|
---|
| 497 | if(!$id_lista or $genere==3){ //controllo di congruenza
|
---|
| 498 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
| 499 | list($tot) = mysql_fetch_row($res2);
|
---|
| 500 | if ($validi+$nulli+$bianchi+$contestati+$votinulli+$sg!=$tot and $validi+$sg>0){
|
---|
| 501 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0); 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+$sg)."</b><br></td></table>";
|
---|
| 502 | }
|
---|
| 503 |
|
---|
| 504 | if((($voti_sez)!=$validi2) and ($voti_sez>0)){
|
---|
| 505 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 |
|
---|
| 510 |
|
---|
| 511 | echo "\n<form name=\"sezioni\" action=\"admin.php\">"
|
---|
| 512 | ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
|
---|
| 513 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 514 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
| 515 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 516 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
| 517 | ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
|
---|
| 518 | ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n";
|
---|
| 519 | echo "<table border=\"0\" width=\"90%\" align=\"center\">";
|
---|
| 520 | echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
|
---|
| 521 | if ($genere<4){
|
---|
| 522 | // echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
|
---|
| 523 | }
|
---|
| 524 | echo "<b>"._NUM."</b></td>";
|
---|
| 525 | if($id_lista){
|
---|
| 526 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
|
---|
| 527 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
| 528 | }else{
|
---|
| 529 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
|
---|
| 530 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
| 531 | }
|
---|
| 532 | echo "</tr>\n";
|
---|
| 533 |
|
---|
| 534 |
|
---|
| 535 |
|
---|
| 536 |
|
---|
| 537 |
|
---|
| 538 | $result = mysql_query("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 ORDER BY t2.num_lista,t1.num_cand", $dbi);
|
---|
| 539 | $max = mysql_num_rows($result);
|
---|
| 540 | $tot_pref=0;
|
---|
| 541 | $i=1;
|
---|
| 542 |
|
---|
| 543 | if($id_lista) {
|
---|
| 544 | while(list($id_cand,$id_cons2,$id_lista2, $cognome, $nome, $note, $simbolo, $num_cand) = mysql_fetch_row($result)){
|
---|
| 545 | // dati lista
|
---|
| 546 | $result1 = mysql_query("select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'", $dbi);
|
---|
| 547 | list($id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1);
|
---|
| 548 | // dati gruppo
|
---|
| 549 | $result2 = mysql_query("select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
| 550 | list($descr_gruppo,$simb_gruppo)=mysql_fetch_row($result2);
|
---|
| 551 |
|
---|
| 552 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
| 553 | if ($genere<4){
|
---|
| 554 | echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
|
---|
| 555 | }
|
---|
| 556 | echo "<td align=\"center\"><b> $num_cand </b></td>"
|
---|
| 557 | ."<td align=\"left\"><b>$cognome $nome</b></td>";
|
---|
| 558 | $cond_sele="and id_cand=$id_cand";
|
---|
| 559 | $res = mysql_query("SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele", $dbi);
|
---|
| 560 | $pro= mysql_fetch_array($res, 3);
|
---|
| 561 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" >";
|
---|
| 562 | echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
|
---|
| 563 | $i++;
|
---|
| 564 | $tot_pref+=$pro['voti'];
|
---|
| 565 | }
|
---|
| 566 | }else {
|
---|
| 567 | $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista
|
---|
| 568 | from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
|
---|
| 569 | where t1.id_cons='$id_cons'
|
---|
| 570 | and t1.id_lista=t2.id_lista
|
---|
| 571 | and t2.id_sez=$id_sez
|
---|
| 572 | order by t1.num_lista", $dbi);
|
---|
| 573 | $num_lista=mysql_num_rows($result1);
|
---|
| 574 | if (!$num_lista){
|
---|
| 575 | $result1 = mysql_query("select '',t1.id_lista, descrizione,simbolo,num_lista
|
---|
| 576 | from ".$prefix."_ele_lista as t1 where t1.id_cons='$id_cons' $circo
|
---|
| 577 | order by t1.num_lista", $dbi);
|
---|
| 578 | }
|
---|
| 579 | while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1)){
|
---|
| 580 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
| 581 | // if ($genere<4 or $votoc){
|
---|
| 582 | // }
|
---|
| 583 |
|
---|
| 584 | echo "<td align=\"center\"><b> $num_lista </b></td>"
|
---|
| 585 | ."<td align=\"left\"><b> $descr_lista</b></td>";
|
---|
| 586 | $cond_sele="and id_lista=$id_lista3";
|
---|
| 587 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" >";
|
---|
| 588 | echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n";
|
---|
| 589 | $i++;
|
---|
| 590 | $tot_pref+=$pro['voti'];
|
---|
| 591 | }
|
---|
| 592 | }
|
---|
| 593 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
|
---|
| 594 | // toglie ai candidati la visual... del solo_gruppo
|
---|
| 595 | if(!$votog) {
|
---|
| 596 | if (($genere==3 OR $genere==5) and (!$id_lista) and ($fascia>$limite)) { //gruppo e liste
|
---|
| 597 | echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"><input name=\"sg\" value=\"$sg\" size=\"5\"></td></tr>";
|
---|
| 598 | echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._NULLI_LISTE."</b></td><td align=\"center\"><input name=\"votinulli\" value=\"$votinulli\" size=\"5\">"
|
---|
| 599 | ."</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._CONTESTATI_LISTE."</b></td><td align=\"center\"><input name=\"contestati\" value=\"$contestati\" size=\"5\"></td></tr>";
|
---|
| 600 |
|
---|
| 601 | }elseif (($genere==3 OR $genere==5) and !$votoc and $fascia>$limite){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
|
---|
| 602 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
|
---|
| 603 | }
|
---|
| 604 | ######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
|
---|
| 605 | elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite)) {
|
---|
| 606 | $resvg = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
|
---|
| 607 | list($id_gruppo) = mysql_fetch_row($resvg);
|
---|
| 608 | $resvg = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'", $dbi);
|
---|
| 609 | list($voti_sind) = mysql_fetch_row($resvg);
|
---|
| 610 |
|
---|
| 611 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
|
---|
| 612 | }
|
---|
| 613 | ###### fine modifica del 16-04-2009
|
---|
| 614 |
|
---|
| 615 | }
|
---|
| 616 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" value=\" "._OK. "\"></td>";
|
---|
| 617 | echo "</tr></table></form></tr></table>";
|
---|
| 618 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
| 619 | ."document.sezioni.voti1.focus()\n"
|
---|
| 620 | ."document.sezioni.voti1.select()\n"
|
---|
| 621 | ."//-->\n";
|
---|
| 622 | echo "function vai_lista() {\n";
|
---|
| 623 | echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
|
---|
| 624 | echo "}\n";
|
---|
| 625 | echo "</script>\n";
|
---|
| 626 | # }
|
---|
| 627 | if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
|
---|
| 628 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
| 629 | }
|
---|
| 630 |
|
---|
| 631 | /////////////////////////////////////////////
|
---|
| 632 | // registra le preferenze ai candidati
|
---|
| 633 | /////////////////////////////////////////////
|
---|
| 634 |
|
---|
| 635 | function rec_voti() {
|
---|
| 636 | global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite;
|
---|
| 637 | $sqlcomu="select fascia from ".$prefix."_ele_comuni where id_comune='$id_comune'";
|
---|
| 638 | $res = mysql_query($sqlcomu);
|
---|
| 639 | list($fascia)=mysql_fetch_row($res);
|
---|
| 640 |
|
---|
| 641 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
| 642 | $username=$aid;
|
---|
| 643 | $log_data= date("Y/m/d");
|
---|
| 644 | $log_ora=getdate(time());
|
---|
| 645 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
| 646 | $arg2 = func_get_args();
|
---|
| 647 | $arg = split(",",$arg2[0]);
|
---|
| 648 | $id_cons_gen=intval($arg[1]);
|
---|
| 649 | $id_sez = intval($arg[2]);
|
---|
| 650 | $id_circ = intval($arg[3]);
|
---|
| 651 | $id_sede = intval($arg[4]);
|
---|
| 652 | $tab = $arg[5];
|
---|
| 653 | $id_lista = intval($arg[6]);
|
---|
| 654 | if ($tab=="_ele_voti_candidati") {
|
---|
| 655 | $condizione="id_cand";
|
---|
| 656 | }else{
|
---|
| 657 | $condizione="id_lista";
|
---|
| 658 | }
|
---|
| 659 | if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ($fascia>$limite)) $y = (count($arg)-4);
|
---|
| 660 | else $y=count($arg);
|
---|
| 661 | for($i=7,$y--;$i< $y;$i++) {
|
---|
| 662 | $voti = intval($arg[$i++]);
|
---|
| 663 | $id_cand = intval($arg[$i]);
|
---|
| 664 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
| 665 | $ar=mysql_fetch_array($result);
|
---|
| 666 | if ($ar){
|
---|
| 667 | if ($ar['voti']!=$voti) {
|
---|
| 668 | mysql_query("update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
| 669 | 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");
|
---|
| 670 | 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);
|
---|
| 671 | }
|
---|
| 672 | } else {
|
---|
| 673 | if ($voti)
|
---|
| 674 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi);
|
---|
| 675 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti')", $dbi);
|
---|
| 676 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
|
---|
| 677 | }
|
---|
| 678 | }
|
---|
| 679 | // foreach ($arg as $vval) echo $vval." - ";
|
---|
| 680 | // solo gruppo e preferenze alle liste
|
---|
| 681 | if(!$votog) {
|
---|
| 682 | if ((($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)) {
|
---|
| 683 | $result = mysql_query("update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'",$dbi);
|
---|
| 684 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
|
---|
| 685 | if ($condizione=="id_lista"){
|
---|
| 686 | $result = mysql_query("select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
| 687 | $ar=mysql_fetch_array($result);
|
---|
| 688 | ++$i;
|
---|
| 689 | mysql_query("update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'", $dbi);
|
---|
| 690 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
|
---|
| 691 | # if ($ar['validi'] and !$ar['validi_lista']){
|
---|
| 692 | if ($ar['validi']){
|
---|
| 693 | # $result = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez'", $dbi);
|
---|
| 694 | # list($val)=mysql_fetch_row($result);
|
---|
| 695 | # mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$val' where id_sez='$id_sez'", $dbi);
|
---|
| 696 | mysql_query("update ".$prefix."_ele_sezioni set validi_lista=(`validi`+`contestati`+`voti_nulli`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'", $dbi);
|
---|
| 697 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi_lista=(`validi`+`contestati`+`voti_nulli`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez';\n");
|
---|
| 698 | }
|
---|
| 699 | }
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 |
|
---|
| 703 | // $ops = $arg[$argc];
|
---|
| 704 | if ($fileout)fclose($fp);
|
---|
| 705 | Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=3&id_lista=$id_lista");
|
---|
| 706 | }
|
---|
| 707 |
|
---|
| 708 |
|
---|
| 709 | ////////////////////////////////////////////
|
---|
| 710 | // da qua va la sezione per i votanti
|
---|
| 711 | ///////////////////////////////////////////
|
---|
| 712 |
|
---|
| 713 | function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
| 714 | //function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
| 715 | global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
|
---|
| 716 | $bgcolor1=$_SESSION['bgcolor2'];
|
---|
| 717 | OpenTable();
|
---|
| 718 | echo "<tr><td> </td></tr>";
|
---|
| 719 | $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ", $dbi);
|
---|
| 720 | $num = mysql_num_rows($res);
|
---|
| 721 | $ressez = mysql_query("SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez", $dbi);
|
---|
| 722 | list($maschi,$femmine)=mysql_fetch_row($ressez);
|
---|
| 723 | $y=0;
|
---|
| 724 | while (list($ora,$giorno)= mysql_fetch_row($res)){
|
---|
| 725 | $y++;
|
---|
| 726 | echo "\n<tr><td>";
|
---|
| 727 | echo "<form name=\"votanti$y\" action=\"admin.php\">";
|
---|
| 728 | echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr>";
|
---|
| 729 | if ($genere==0){ //e' un referendum
|
---|
| 730 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
|
---|
| 731 | }
|
---|
| 732 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
|
---|
| 733 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
|
---|
| 734 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
|
---|
| 735 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
|
---|
| 736 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
|
---|
| 737 | if ($genere==0){
|
---|
| 738 | $res2 = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
| 739 | $max = mysql_num_rows($res2);
|
---|
| 740 | }else{ $max=1;}
|
---|
| 741 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
|
---|
| 742 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 743 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
| 744 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 745 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
| 746 | echo "</td>"; //la riga viene chiusa nel ciclo for
|
---|
| 747 | for ($i=1;$i<=$max;$i++){
|
---|
| 748 | $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
|
---|
| 749 | on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
|
---|
| 750 | and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
| 751 | if ($genere==0){
|
---|
| 752 | $query.=" and t2.num_gruppo=$i";
|
---|
| 753 | }
|
---|
| 754 | $result = mysql_query($query, $dbi);
|
---|
| 755 | list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = mysql_fetch_row($result);
|
---|
| 756 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ", $dbi);
|
---|
| 757 | if ($res2)
|
---|
| 758 | list($gruppo)= mysql_fetch_row($res2);
|
---|
| 759 | else
|
---|
| 760 | $gruppo=0;
|
---|
| 761 | if (!$gruppo>0) {
|
---|
| 762 | $gruppo=$i;
|
---|
| 763 | $res3 = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons", $dbi);
|
---|
| 764 | if ($res3)
|
---|
| 765 | list($id_gruppo)=mysql_fetch_row($res3);
|
---|
| 766 | }
|
---|
| 767 | if ($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t){
|
---|
| 768 | echo "</tr><tr style=\"background-color: rgb(255, 0, 0); align=center\">";
|
---|
| 769 | }else{
|
---|
| 770 | echo "</tr><tr align=\"center\">";
|
---|
| 771 | }
|
---|
| 772 | if ($genere==0){ // e' un referendum
|
---|
| 773 | echo "<td align=\"center\">$gruppo</td>";
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | list ($anno,$mese,$di)=explode('-',$giorno);
|
---|
| 777 | echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
|
---|
| 778 | if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\"><input";
|
---|
| 779 | else echo "<td align=\"center\"><input";
|
---|
| 780 | if ($y<$num) { echo " type=\"hidden\"";}
|
---|
| 781 | echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
|
---|
| 782 | if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\"><input";
|
---|
| 783 | else echo "<td align=\"center\"><input";
|
---|
| 784 | if ($y<$num) { echo " type=\"hidden\"";}
|
---|
| 785 | echo " name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
|
---|
| 786 | if ($voti_t > ($maschi+$femmine)) echo "<td align=\"center\" bgcolor=\"red\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\">";
|
---|
| 787 | else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\">";
|
---|
| 788 | echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
|
---|
| 789 | ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
|
---|
| 790 | ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
|
---|
| 791 | ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
|
---|
| 792 | echo "</td>";
|
---|
| 793 | }
|
---|
| 794 | echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td></tr>";
|
---|
| 795 |
|
---|
| 796 |
|
---|
| 797 |
|
---|
[63] | 798 | # echo "</table></form></td></tr>";
|
---|
| 799 | echo "</table></form>";
|
---|
[2] | 800 | $compl= mysql_query("select voti_complessivi from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez", $dbi);
|
---|
| 801 | list ($complessivi)= mysql_fetch_row($compl);
|
---|
| 802 | if (!$complessivi)
|
---|
| 803 | {
|
---|
| 804 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
| 805 | if ($y==$num) {
|
---|
| 806 | echo "document.votanti$y.voti_u1.focus()\n";
|
---|
| 807 | echo "document.votanti$y.voti_u1.select()\n";
|
---|
| 808 | }else{
|
---|
| 809 | echo "document.votanti$y.voti_t1.focus()\n";
|
---|
| 810 | echo "document.votanti$y.voti_t1.select()\n";
|
---|
| 811 | }
|
---|
| 812 | echo "//-->\n"
|
---|
| 813 | ."</script>\n";
|
---|
| 814 | break;
|
---|
| 815 | }
|
---|
[63] | 816 | echo "</td></tr>";
|
---|
[2] | 817 | }
|
---|
| 818 | CloseTable();
|
---|
| 819 | }
|
---|
| 820 |
|
---|
| 821 |
|
---|
| 822 | ///////////////////////////
|
---|
| 823 | // registra i votanti
|
---|
| 824 | ///////////////////////////
|
---|
| 825 |
|
---|
| 826 | function rec_add_votanti() {
|
---|
| 827 | global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
|
---|
| 828 | //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
|
---|
| 829 | // 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
|
---|
| 830 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
| 831 |
|
---|
| 832 | $username="$aid";
|
---|
| 833 | $arg2 = func_get_args();
|
---|
| 834 | $arg = split(",",$arg2[0]);//foreach($arg as $key=>$val) echo "$key:$val<br>";die();
|
---|
| 835 | $arg = split(",",$arg2[0]);
|
---|
| 836 | $id_cons_gen=intval($arg[1]);
|
---|
| 837 | $id_sez=intval($arg[2]);
|
---|
| 838 | $id_circ=intval($arg[3]);
|
---|
| 839 | $id_sede=intval($arg[4]);
|
---|
| 840 | for($i=5;$i< count($arg)-1;) {
|
---|
| 841 | $voti_u = intval($arg[$i++]);
|
---|
| 842 | $voti_d = intval($arg[$i++]);
|
---|
| 843 | $voti_t = intval($arg[$i++]);
|
---|
| 844 | if($voti_t==0) $voti_t=$voti_d+$voti_u;
|
---|
| 845 | $id_parz = intval($arg[$i++]);
|
---|
| 846 | $giorno = $arg[$i++];
|
---|
| 847 | $ora = $arg[$i++];
|
---|
| 848 | $id_gruppo = intval($arg[$i++]);
|
---|
| 849 | $data=date("Y/m/d");
|
---|
| 850 | $tempo=date("H:i:s");
|
---|
| 851 | $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
|
---|
| 852 | if ($genere==0){
|
---|
| 853 | $query.=" and id_gruppo=$id_gruppo";
|
---|
| 854 | }
|
---|
| 855 | $res=mysql_query("$query",$dbi);
|
---|
| 856 | $righe=mysql_num_rows($res);
|
---|
| 857 | if (!$righe){
|
---|
| 858 | mysql_query("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')", $dbi);
|
---|
| 859 | mysql_query("insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo')", $dbi);
|
---|
| 860 | 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");
|
---|
| 861 | } else {
|
---|
| 862 | $res=mysql_query("select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz",$dbi);
|
---|
| 863 | $ar=mysql_fetch_array($res);
|
---|
| 864 | if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){
|
---|
| 865 | mysql_query("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')", $dbi);
|
---|
| 866 | $result = mysql_query("update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz'", $dbi);
|
---|
| 867 | 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");
|
---|
| 868 | }
|
---|
| 869 | }
|
---|
| 870 | }
|
---|
| 871 | if ($fileout)fclose($fp);
|
---|
| 872 | 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");
|
---|
| 873 | }
|
---|
| 874 |
|
---|
| 875 |
|
---|
| 876 |
|
---|
| 877 | function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
| 878 | global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
|
---|
| 879 | ////////////////////////////////////////////
|
---|
| 880 | // da qua va la sezione per i voti finali
|
---|
| 881 | ///////////////////////////////////////////
|
---|
| 882 | $bgcolor1="#7777ff";
|
---|
| 883 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
| 884 |
|
---|
| 885 |
|
---|
| 886 |
|
---|
| 887 | echo "<form name=\"spogliovoti\" action=\"admin.php\">"
|
---|
| 888 | ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
|
---|
| 889 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 890 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
| 891 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 892 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
| 893 |
|
---|
| 894 | echo "<table border=\"0\" width=\"80%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
|
---|
| 895 | /* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
| 896 | echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
|
---|
| 897 | else */
|
---|
| 898 | echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
|
---|
| 899 | echo "<td width=\"32\"><b>"._NULLI."</b></td>"
|
---|
| 900 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
| 901 | ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
|
---|
| 902 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
| 903 | ."<td><b>"._TOTNON."</b></td>"
|
---|
| 904 | ."<td><b>"._TOTALEVOTI."</b></td>"
|
---|
| 905 | ."<td bgcolor=\"#ffffff\"></td> </tr>";
|
---|
| 906 | /*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
| 907 | $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' ", $dbi);
|
---|
| 908 | else */
|
---|
| 909 | $result = mysql_query("select id_cons,id_sez,validi,nulli,bianchi,contestati,voti_nulli,'0','0','0' from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 910 | list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis) = mysql_fetch_row($result);
|
---|
| 911 | $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
|
---|
| 912 | $tot_voti=$validi+$tot_nulli+$sg+$conts+$nullis;
|
---|
| 913 |
|
---|
| 914 | echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\">";
|
---|
| 915 | /* if(($genere==3 or $genere==5) and !$votog and $ops==3){
|
---|
| 916 | echo "</td><td>$nulli"
|
---|
| 917 | ."</td><td>$bianchi";
|
---|
| 918 | echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
|
---|
| 919 | }else{ */
|
---|
| 920 | echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\">"
|
---|
| 921 | ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\">";
|
---|
| 922 | // }
|
---|
| 923 | echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\">"
|
---|
| 924 | ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\">"
|
---|
| 925 | ."</td><td>$tot_nulli"
|
---|
| 926 | ."</td><td>$tot_voti</td><td>"
|
---|
| 927 | // ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
|
---|
| 928 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
|
---|
| 929 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
| 930 | ."</td></tr></table></form>"; //</td></tr>";
|
---|
| 931 |
|
---|
| 932 |
|
---|
| 933 | // echo "</table>";
|
---|
| 934 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
| 935 | if (!$validi) {
|
---|
| 936 | echo "document.spogliovoti.validi.focus()\n";
|
---|
| 937 | echo "document.spogliovoti.validi.select()\n";
|
---|
| 938 | }
|
---|
| 939 | echo "//-->\n"
|
---|
| 940 | ."</script>\n";
|
---|
| 941 |
|
---|
| 942 |
|
---|
| 943 | }
|
---|
| 944 |
|
---|
| 945 |
|
---|
| 946 |
|
---|
| 947 |
|
---|
| 948 |
|
---|
| 949 |
|
---|
| 950 | ///////////////////////////
|
---|
| 951 | // registra voti finali
|
---|
| 952 | ///////////////////////////
|
---|
| 953 |
|
---|
| 954 | function rec_finale() {
|
---|
| 955 | global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
|
---|
| 956 |
|
---|
| 957 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
| 958 | $arg2 = func_get_args();
|
---|
| 959 | $arg = split(",",$arg2[0]);
|
---|
| 960 | $id_cons_gen=intval($arg[1]);
|
---|
| 961 | $id_sez = intval($arg[2]);
|
---|
| 962 | $id_circ = intval($arg[3]);
|
---|
| 963 | $id_sede = intval($arg[4]);
|
---|
| 964 | $validi = intval($arg[5]);
|
---|
| 965 | $nulli = intval($arg[6]);
|
---|
| 966 | $bianchi = intval($arg[7]);
|
---|
| 967 | $votinulli = intval($arg[8]);
|
---|
| 968 | $contestati = intval($arg[9]);
|
---|
| 969 | $ops = $arg[10];
|
---|
| 970 | $username="$aid";
|
---|
| 971 | $log_data= date("Y/m/d");
|
---|
| 972 | $log_ora=getdate(time());
|
---|
| 973 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
| 974 |
|
---|
| 975 | $result= mysql_query("select voti_complessivi from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' order by id_parz desc", $dbi);
|
---|
| 976 | list($voti_t) = mysql_fetch_row($result);
|
---|
| 977 | $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
|
---|
| 978 | $result= mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 979 | $ar=mysql_fetch_array($result);
|
---|
| 980 | #die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
|
---|
| 981 | if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
| 982 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] contestati_lista:$ar[15] voti_nulli_lista:$ar[16]','validi_lista=$validi, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')", $dbi);
|
---|
| 983 |
|
---|
| 984 | /* $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 985 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez';\n"); */
|
---|
| 986 | $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 987 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez';\n");
|
---|
| 988 | }else{
|
---|
| 989 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')", $dbi);
|
---|
| 990 | $valista="";
|
---|
| 991 | if ($ar['validi_lista']){
|
---|
| 992 | $tvalista=$validi+$contestati+$votinulli-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista'];
|
---|
| 993 | $valista=",validi_lista='$tvalista'";
|
---|
| 994 | }
|
---|
| 995 |
|
---|
| 996 | $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $valista where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 997 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $valista where id_cons='$id_cons' and id_sez='$id_sez';\n");
|
---|
| 998 | }
|
---|
| 999 | // }
|
---|
| 1000 | // Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
|
---|
| 1001 | if ($fileout) fclose($fp);
|
---|
| 1002 | Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops");
|
---|
| 1003 |
|
---|
| 1004 | /*}else{
|
---|
| 1005 |
|
---|
| 1006 | echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
|
---|
| 1007 | echo "<hr><a href=\"admin.php?op=voti&id_cons=$id_cons&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=$ops\">Torna e correggi i dati immessi</a></center>";
|
---|
| 1008 | }*/
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
| 1011 |
|
---|
| 1012 | function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
| 1013 | global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo;
|
---|
| 1014 | ////////////////////////////////////////////
|
---|
| 1015 | // da qua va la sezione per le preferenze ai gruppi
|
---|
| 1016 | ///////////////////////////////////////////
|
---|
| 1017 | // Controllo immmissioni
|
---|
| 1018 | $bgcolor1="#7777ff";
|
---|
| 1019 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
| 1020 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
| 1021 | $max = mysql_num_rows($res);
|
---|
| 1022 | $max = $max-1;
|
---|
| 1023 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
| 1024 | if ($genere==0) {
|
---|
| 1025 | echo "document.sezioni.si1.focus()\n";
|
---|
| 1026 | echo "document.sezioni.si1.select()\n";
|
---|
| 1027 | } else {
|
---|
| 1028 | echo "document.sezioni.voti1.focus()\n"
|
---|
| 1029 | ."document.sezioni.voti1.select()\n";
|
---|
| 1030 | }
|
---|
| 1031 | echo "//-->\n"
|
---|
| 1032 | ."</script>\n";
|
---|
| 1033 | // tabella votanti
|
---|
| 1034 | if ($genere!=0){
|
---|
| 1035 | $result = mysql_query("SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' and (voti_uomini > 0 or voti_donne > 0)", $dbi);
|
---|
| 1036 | list( $voti_u, $voti_d, $voti_t) = mysql_fetch_row($result);
|
---|
| 1037 | echo "<table border=\"0\" width=\"50%\" align=\"center\">"
|
---|
| 1038 | ."<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>"
|
---|
| 1039 | ."<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>";
|
---|
| 1040 | echo "</table>";
|
---|
| 1041 | }
|
---|
| 1042 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr>";
|
---|
| 1043 | if ($genere==0){
|
---|
| 1044 | $res = mysql_query("SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
| 1045 | while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = mysql_fetch_row($res)){
|
---|
| 1046 | if ($voti_parz!=$validi){
|
---|
| 1047 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
| 1048 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
| 1049 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
| 1050 | }
|
---|
| 1051 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
| 1052 | list($tot) = mysql_fetch_row($res2);
|
---|
| 1053 | if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
|
---|
| 1054 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
| 1055 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
| 1056 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
| 1057 | }
|
---|
| 1058 | }
|
---|
| 1059 | }else{
|
---|
| 1060 | $res = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
| 1061 | list($voti_parz) = mysql_fetch_row($res);
|
---|
| 1062 | $res = mysql_query("SELECT validi,nulli,bianchi,contestati,solo_gruppo,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
| 1063 | list($validi,$nulli,$bianchi,$contestati,$solo_gruppo,$votinulli) = mysql_fetch_row($res);
|
---|
| 1064 | if ($voti_parz!=$validi and $voti_parz>0){
|
---|
| 1065 | echo "<td style=\"background-color: rgb(255, 0, 0); align=center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".$validi."</b><br></td>";
|
---|
| 1066 | }
|
---|
| 1067 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
| 1068 | list($tot) = mysql_fetch_row($res2);
|
---|
| 1069 | if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
|
---|
| 1070 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
| 1071 | }
|
---|
| 1072 | }
|
---|
[56] | 1073 | if(!isset($votinulli)) $votinulli=0;
|
---|
[2] | 1074 | echo "<td></td></tr></table>";
|
---|
| 1075 | if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
|
---|
| 1076 | echo "<form name=\"sezioni\" action=\"admin.php\">";
|
---|
| 1077 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
|
---|
| 1078 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
| 1079 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
| 1080 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
| 1081 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
| 1082 | echo "<br><br> <table border=\"0\" width=\"60%\" align=\"center\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
|
---|
| 1083 | ."<td width=\"3%\"><b>"._NUM."</b></td>"
|
---|
| 1084 | ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
|
---|
| 1085 | if ($genere==0){
|
---|
| 1086 | echo "<td><b>"._SI."</b></td>"
|
---|
| 1087 | ."<td><b>"._NO."</b></td>"
|
---|
| 1088 | ."<td><b>"._VALIDI."</b></td>"
|
---|
| 1089 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
| 1090 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
| 1091 | ."<td><b>"._NULLI."</b></td>"
|
---|
| 1092 | ."<td><b>"._TOTNON."</b></td>";
|
---|
| 1093 | }else{
|
---|
| 1094 | echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
|
---|
| 1095 | }
|
---|
| 1096 | echo "</tr>";
|
---|
| 1097 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
|
---|
| 1098 | $max = mysql_num_rows($res);
|
---|
| 1099 | //echo "Massimo:$max - id=$id_cons - circo: $circo";
|
---|
| 1100 | $result = mysql_query("select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ", $dbi);
|
---|
| 1101 | $i=1;
|
---|
| 1102 | $tot_pref=0;
|
---|
| 1103 |
|
---|
| 1104 | while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = mysql_fetch_row($result)){
|
---|
| 1105 |
|
---|
| 1106 | //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
|
---|
| 1107 |
|
---|
| 1108 |
|
---|
| 1109 | if ($num_gruppo != ''){
|
---|
| 1110 | if ($genere==0){
|
---|
| 1111 | $res = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
| 1112 | list($tot) = mysql_fetch_row($res);
|
---|
| 1113 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
| 1114 | $pro= mysql_fetch_array($res, 3);
|
---|
| 1115 |
|
---|
| 1116 | 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)){
|
---|
| 1117 | echo "<tr style=\"background-color: rgb(255, 0, 0); align=center\">";
|
---|
| 1118 | }else{
|
---|
| 1119 | echo "<tr style=\"background-color: $bgcolor2; align=center\">";
|
---|
| 1120 | }
|
---|
| 1121 | $descr = explode('.',$descr_gruppo, 100);
|
---|
| 1122 | echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
| 1123 | ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
|
---|
| 1124 | $pro['si']=$pro['si']>0 ? $pro['si']:0;
|
---|
| 1125 | $pro['no']=$pro['no']>0 ? $pro['no']:0;
|
---|
| 1126 | $pro['validi']=$pro['validi']>0 ? $pro['validi']:0;
|
---|
| 1127 | $pro['bianchi']=$pro['bianchi']>0 ? $pro['bianchi']:0;
|
---|
| 1128 | $pro['contestati']=$pro['contestati']>0 ? $pro['contestati']:0;
|
---|
| 1129 | $pro['nulli']=$pro['nulli']>0 ? $pro['nulli']:0;
|
---|
| 1130 | $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
|
---|
| 1131 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" ></td>";
|
---|
| 1132 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" ></td>";
|
---|
| 1133 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" ></td>";
|
---|
| 1134 | echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" ></td>";
|
---|
| 1135 | echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" ></td>";
|
---|
| 1136 | echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" ></td>";
|
---|
| 1137 | echo "</td><td align=\"right\">$tot_nulli</td>";
|
---|
| 1138 | }else{
|
---|
| 1139 | echo "<tr style=\"background-color: $bgcolor2; align=center\"><td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
| 1140 | ."</td><td align=\"left\"><b> $descr_gruppo </b>";
|
---|
| 1141 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
| 1142 | $pro= mysql_fetch_array($res, 3);
|
---|
| 1143 | echo "</td><td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" ></td>";
|
---|
| 1144 | $tot_pref += $pro['voti'];
|
---|
| 1145 | }
|
---|
| 1146 |
|
---|
| 1147 | $i++;
|
---|
| 1148 | }
|
---|
| 1149 |
|
---|
| 1150 | }
|
---|
| 1151 | if ($genere!=0) {
|
---|
| 1152 | echo "<tr style=\"background-color: $bgcolor1; align=center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td></tr>";
|
---|
| 1153 | }
|
---|
| 1154 |
|
---|
| 1155 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" value=\" "._OK. "\"></td>";
|
---|
| 1156 |
|
---|
| 1157 | echo "</tr></table></form><br><br> ";
|
---|
| 1158 | }
|
---|
| 1159 | if ($genere!=0){
|
---|
| 1160 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
| 1161 | }
|
---|
| 1162 | }
|
---|
| 1163 |
|
---|
| 1164 |
|
---|
| 1165 |
|
---|
| 1166 |
|
---|
| 1167 |
|
---|
| 1168 |
|
---|
| 1169 | ///////////////////////////
|
---|
| 1170 | // registra le preferenze ai gruppi
|
---|
| 1171 | ///////////////////////////
|
---|
| 1172 |
|
---|
| 1173 | function rec_voti_gruppi() {
|
---|
| 1174 | global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout;
|
---|
| 1175 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
| 1176 | $username="$aid";
|
---|
| 1177 | $log_data= date("Y/m/d");
|
---|
| 1178 | $log_ora=getdate(time());
|
---|
| 1179 | $arg2 = func_get_args();
|
---|
| 1180 | $arg = split(",",$arg2[0]);
|
---|
| 1181 | $id_cons_gen=intval($arg[1]);
|
---|
| 1182 | $id_sez = intval($arg[2]);
|
---|
| 1183 | $id_circ = intval($arg[3]);
|
---|
| 1184 | $id_sede = intval($arg[4]);
|
---|
| 1185 | $y=count($arg)-1;
|
---|
| 1186 | if ($genere==0) {
|
---|
| 1187 | $tab="_ele_voti_ref";
|
---|
| 1188 | } else {
|
---|
| 1189 | $tab="_ele_voti_gruppo";
|
---|
| 1190 | $y--;
|
---|
| 1191 | }
|
---|
| 1192 |
|
---|
| 1193 | for($i=5;$i< $y;) {
|
---|
| 1194 | $id_gruppo = intval($arg[$i++]);
|
---|
| 1195 | switch ($genere){
|
---|
| 1196 | case (0):
|
---|
| 1197 | $si=intval($arg[$i++]);
|
---|
| 1198 | $no=intval($arg[$i++]);
|
---|
| 1199 | $val=intval($arg[$i++]);
|
---|
| 1200 | if ($val==0){$val=$si+$no;}
|
---|
| 1201 | $bia=intval($arg[$i++]);
|
---|
| 1202 | $con=intval($arg[$i++]);
|
---|
| 1203 | $nul=intval($arg[$i++]);
|
---|
| 1204 | $voti = "$si,$no,$val,$nul,$bia,$con";
|
---|
| 1205 | $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
|
---|
| 1206 | break;
|
---|
| 1207 | default:
|
---|
| 1208 | $voti = intval($arg[$i++]);
|
---|
| 1209 | if (!$voti) {$voti="0";}
|
---|
| 1210 | $riga="voti=$voti";
|
---|
| 1211 | break;
|
---|
| 1212 | }
|
---|
| 1213 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
| 1214 | $ar=mysql_fetch_array($result);
|
---|
| 1215 | $res = mysql_query("select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
| 1216 | list($num_gruppo)=mysql_fetch_array($res);
|
---|
| 1217 | $oldval='';
|
---|
| 1218 | if ($ar){
|
---|
| 1219 | switch ($genere){
|
---|
| 1220 | case (0):
|
---|
| 1221 | if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
|
---|
| 1222 | or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
|
---|
| 1223 | $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
|
---|
| 1224 | }
|
---|
| 1225 | break;
|
---|
| 1226 | default:
|
---|
| 1227 | if ($ar['voti']!=$voti) {
|
---|
| 1228 | $oldval="voti:".$ar['voti'];
|
---|
| 1229 | $voti.=",null";
|
---|
| 1230 | }
|
---|
| 1231 | if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
|
---|
| 1232 | break;
|
---|
| 1233 | }
|
---|
| 1234 | if ($oldval) {
|
---|
| 1235 | mysql_query("update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
| 1236 | 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");
|
---|
| 1237 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','$oldval','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
|
---|
| 1238 | }
|
---|
| 1239 | } else {
|
---|
| 1240 | 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);
|
---|
| 1241 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)", $dbi);
|
---|
| 1242 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti);\n");
|
---|
| 1243 | //
|
---|
| 1244 | }
|
---|
| 1245 |
|
---|
| 1246 | }
|
---|
| 1247 | //$ops = $arg[$argc];
|
---|
| 1248 | if ($fileout) fclose($fp);
|
---|
| 1249 | Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&do=spoglio&ops=4");
|
---|
| 1250 |
|
---|
| 1251 | }
|
---|
| 1252 |
|
---|
| 1253 |
|
---|
[23] | 1254 | if (!preg_match("/rec/",$op)) {
|
---|
[2] | 1255 | ele(); //menu
|
---|
[62] | 1256 | /* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
|
---|
[56] | 1257 | numeri_sezione(8);
|
---|
[62] | 1258 | echo "<td></td></tr></table>\n";*/
|
---|
[68] | 1259 | echo"</td></tr></table>";
|
---|
[2] | 1260 | }
|
---|
| 1261 |
|
---|
| 1262 | switch ($op){
|
---|
| 1263 | case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
|
---|
| 1264 | voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
| 1265 | break;
|
---|
| 1266 | default :
|
---|
| 1267 | $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
|
---|
| 1268 | }
|
---|
[56] | 1269 | echo"</td></tr></table></div>";
|
---|
[2] | 1270 | include ("footer.php");
|
---|
| 1271 | ?>
|
---|
| 1272 |
|
---|
| 1273 |
|
---|