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