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