Changeset 260 for trunk/admin/modules/Elezioni/ele_voti.php
- Timestamp:
- Apr 6, 2019, 6:32:47 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_voti.php
r258 r260 111 111 } 112 112 113 function stato_rilevazione($id_sez,$solosede){114 global $id_cons, $prefix, $dbi, $id_cons_gen,$status,$genere,$votol, $votog, $votoc,$idrefgruppo,$num_ril,$circo,$dettnulli,$tipo_cons;115 116 if($idrefgruppo and $genere==0) $perref= "and id_gruppo='$idrefgruppo'";117 else $perref="";118 $ops=0;119 $status=0;120 $stret=0; $contains=0;121 ###########122 $sql="SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data asc,orario asc";123 $res = $dbi->prepare("$sql");124 $res->execute();125 126 127 $num_ril=$res->rowCount();128 $sql="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'";129 $res3 = $dbi->prepare("$sql");130 $res3->execute();131 132 133 134 if($res3->rowCount()){135 list($aff,$val,$gru,$lis,$can,$status)=$res3->fetch(PDO::FETCH_NUM);136 if ($can) {$ops=-5;}137 elseif ($lis) {$ops=-3;}138 elseif($gru) {$ops=-4;}139 elseif ($val) {$ops=-2;}140 elseif($aff) {$ops=-1;}141 # if($can==1) $status=1;142 }else{143 $aff=0;$lis=0;$val=0;$gru=0;$can=0;$stret=0;$status=0;144 ##########################145 if($ops==0){146 #controllo congruenza affluenze147 $sql="SELECT count(num_sez) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";148 $res3 = $dbi->prepare("$sql");149 $res3->execute();150 151 152 list($numtot) = $res3->fetch(PDO::FETCH_NUM);153 $test_ril=0;$pre_rilc=0;$pre_rilm=0;$pre_rilf=0;154 if($res->rowCount())155 while (list($giorno,$ora) = $res->fetch(PDO::FETCH_NUM)){156 $test_ril++;157 $query="SELECT voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";158 $sql="$query";159 $res2 = $dbi->prepare("$sql");160 $res2->execute();161 162 163 $numscru=$res2->rowCount();164 $query="SELECT sum(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";165 $sql="$query";166 $res2 = $dbi->prepare("$sql");167 $res2->execute();168 169 170 list($voti)=$res2->fetch(PDO::FETCH_NUM);171 if($numscru) {172 if(isset($ora)){173 $query="SELECT count(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' $perref and orario='$ora' and data='$giorno'";174 # $res3 = mysql_query("$query";175 # list($numscru)=mysql_fetch_row($res3);176 $sql="SELECT maschi+autorizzati_m,femmine+autorizzati_f FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";177 $res3 = $dbi->prepare("$sql");178 $res3->execute();179 180 181 list($iscrittim,$iscrittif) = $res3->fetch(PDO::FETCH_NUM);182 $iscritti=$iscrittim+$iscrittif;183 184 $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'";185 $sql="$query";186 $res3 = $dbi->prepare("$sql");187 $res3->execute();188 189 190 list($voti, $uomini, $donne)=$res3->fetch(PDO::FETCH_NUM);191 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)192 {193 $ops=-1;$aff=1; $status=$test_ril;194 }elseif($numscru) {$aff=-1;$stret=1;break;}195 else {$status=0;$ops=-1;break;}196 }197 } else {$stret=-1;$aff=0;}198 $pre_rilc=$voti; $pre_rilm=$uomini;$pre_rilf=$donne;199 }200 #if(isset($num_ril) and $num_ril==$test_ril) $status=1;201 202 #controllo congruenza voti espressi203 #per referendum204 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";205 $resref = $dbi->prepare("$sql");206 $resref->execute();207 208 209 if($genere==0){210 $numscru=$resref->rowCount(); $rifscru=0;211 while(list($idrefgruppo)=$resref->fetch(PDO::FETCH_NUM)) {212 $sql="SELECT si,no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_sez='$id_sez' and id_gruppo='$idrefgruppo'";213 $res2 = $dbi->prepare("$sql");214 $res2->execute();215 216 217 $refscru=$res2->rowCount();218 if($refscru){219 $query="SELECT voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$idrefgruppo' order by data desc, orario desc";220 $sql="$query";221 $res3 = $dbi->prepare("$sql");222 $res3->execute();223 224 225 list($voti)=$res3->fetch(PDO::FETCH_NUM);226 227 $rifscru++;228 list($si,$no,$validi,$nulli,$bianchi,$contestati)=$res2->fetch(PDO::FETCH_NUM);229 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);}230 else {$val=-1;$stret=4;break;} #return (4);231 } else { $stret=4;break;}232 }233 }else{234 #per le altre consultazione235 $sql="SELECT validi FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' and id_cons='$id_cons' ";236 $res2 = $dbi->prepare("$sql");237 $res2->execute();238 239 240 if($res2){241 list($validi) = $res2->fetch(PDO::FETCH_NUM);242 if($validi) {243 $status=0;244 $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'";245 $sql="$query";246 $res4 = $dbi->prepare("$sql");247 $res4->execute();248 249 250 list($validi, $nulli, $bianchi,$contestati,$votinulli,$sologruppo,$validilista,$contestatilista,$votinullilista,$sololista)=$res4->fetch(PDO::FETCH_NUM);251 if($validi>0) {252 if (($validi+$nulli+$bianchi+$contestati+$votinulli)==$voti)253 {$status=2;$ops=(-4+$votog);$val=1;}254 else {$val=-1;$stret=(4-$votog);}255 } #else return 0;256 }257 }258 #controllo congruenza voti di gruppo259 if($genere!=4){260 $sql="SELECT sum(voti),sum(solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_cons='$id_cons'";261 $res3 = $dbi->prepare("$sql");262 $res3->execute();263 264 265 if($res3->rowCount() and !$votog){#$status=0;$ops=-4;266 list($votigs,$votisolog) = $res3->fetch(PDO::FETCH_NUM);267 if($votigs and $genere!=2) {268 # $status=0;269 # $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";270 # $res4 = mysql_query("$query";271 # list($votigs)=mysql_fetch_row($res4);272 if($votigs>0||$sololista==$validi) {273 if (($votigs+$sololista)==$validi && (!$sologruppo || $votisolog==($sologruppo*$dettnulli) || ($sologruppo<$validi and $validilista+$contestatilista+$votinullilista==0)))274 {$status=3;$ops=-3;$gru=1;}275 else {$gru=-1; $stret=4;}276 } #else return 0;277 }278 }279 }#else {$gru=1;echo "--$votigs -- $votog";}280 if(($genere>1 and !$votol)){#$status=0;281 $sql="SELECT t1.preferenze,t1.id_fascia,t2.limite,t1.disgiunto 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'";282 $res4 = $dbi->prepare("$sql");283 $res4->execute();284 285 286 if($res4) list($testpref,$fascia,$limite,$disgiunto)=$res4->fetch(PDO::FETCH_NUM); else {$testpref=0;$fascia=0;$limite=0;}287 288 #controllo congruenza voti di lista289 # $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons'";290 # list($votil) = mysql_fetch_row($res3);291 $tablg=($fascia<=$limite && !$disgiunto) ? "gruppo":"lista";292 $query="SELECT sum(voti),sum(solo_".$tablg.") FROM ".$prefix."_ele_voti_$tablg where id_sez='$id_sez' and id_cons='$id_cons'";293 $sql=$query;294 $res4 = $dbi->prepare("$sql");295 $res4->execute();296 297 298 list($votils,$votisolols)=$res4->fetch(PDO::FETCH_NUM);299 $query="SELECT voti FROM ".$prefix."_ele_voti_$tablg where id_sez='$id_sez' and id_cons='$id_cons'";300 $sql=$query;301 $res4 = $dbi->prepare("$sql");302 $res4->execute();303 304 305 $sezscru=$res4->rowCount();306 if($sezscru) {307 if($genere==4 or $votog) {$contrlis= ($votisolols==$sololista || $votisolols==0) ? 1:0; }308 #################309 else {310 $contrlis=($sologruppo+$validilista+$contestatilista+$votinullilista)==$validi ? 1:0;311 if($contrlis and $disgiunto and ($sologruppo+$validilista+$contestatilista+$votinullilista)==0)312 $contrlis=($votisolols==$sololista || $votisolols==0) ? 1:0;313 if($contrlis and $tipo_cons==18 or $tipo_cons==19)314 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))315 {316 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";317 $res3 = $dbi->prepare("$sql");318 $res3->execute();319 320 321 $sql="SELECT sum(voti+nulli_lista) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista in (select id_lista from ".$prefix."_ele_lista where id_gruppo='$id_gruppo')";322 $res4 = $dbi->prepare("$sql");323 $res4->execute();324 325 326 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);327 list($vliste)=$res4->fetch(PDO::FETCH_NUM);328 if($vliste>$vgruppo) {$contrlis=0 ;}329 if($vliste<$vgruppo) {$contrlis=0 ;}330 }331 }332 #################333 334 if((($contrlis) and $validilista==$votils) or ($fascia<=$limite and $fascia)) {$status=4;$lis=1;$ops=-4;}335 elseif($sezscru) {$stret=3;$lis=-1;}336 337 # if($votils>0) {338 if($res4->rowCount()>0) {339 # $res4= mysql_query("SELECT count(0) FROM ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez' ";340 # list($contains)=mysql_fetch_row($res4);341 # if($contains==0) $tutte=1; else $tutte=0;342 343 $query="SELECT id_lista FROM ".$prefix."_ele_lista where id_cons='$id_cons' $circo";344 $sql="$query";345 $res3 = $dbi->prepare("$sql");346 $res3->execute();347 348 349 $contaliste=$res3->rowCount();350 $sql="SELECT preferenze FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons'";351 $res4 = $dbi->prepare("$sql");352 $res4->execute();353 354 355 if($res4->rowCount()) list($testpref)=$res4->fetch(PDO::FETCH_NUM); else $testpref=0;356 while(list($testlista)=$res3->fetch(PDO::FETCH_NUM)){357 if($fascia<=$limite and !$disgiunto and !$dettnulli)358 {359 $sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_cons='$id_cons' and id_lista='$testlista'";360 $res4 = $dbi->prepare("$sql");361 $res4->execute();362 363 364 list($idgruppo)=$res4->fetch(PDO::FETCH_NUM);365 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$idgruppo'";366 $res4 = $dbi->prepare("$sql");367 $res4->execute();368 369 370 371 }else{372 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and id_lista='$testlista'";373 $res4 = $dbi->prepare("$sql");374 $res4->execute();375 376 377 }378 if($res4) list($testvotil)=$res4->fetch(PDO::FETCH_NUM); else $testvotil=0;379 $sql="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'";380 $res4 = $dbi->prepare("$sql");381 $res4->execute();382 383 384 if($res4) list($testvotic)=$res4->fetch(PDO::FETCH_NUM); else $testvotic=0;385 $sql="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'";386 $res4 = $dbi->prepare("$sql");387 $res4->execute();388 389 390 if($res4->rowCount()) $contains++;391 $totvotic=0;392 while(list($testvotic)=$res4->fetch(PDO::FETCH_NUM))393 {394 $totvotic+=$testvotic;395 if($testvotil<$testvotic) { $can=-1;break;}396 }397 if(($testvotil*$testpref)<$totvotic) { $can=-1;break;}398 }399 if($contains==$contaliste and $can==0) {$status=5;$can=1;$ops=-3;}400 elseif($can==-1) {$stret=3;}401 }402 }403 }elseif($ops==-3){ $ops=-4;}404 }405 if(isset($can)){406 $sql="insert into ".$prefix."_ele_controllosez values('$id_sez','$id_cons','$aff','$val','$gru','$lis','$can','$status')";407 $res4 = $dbi->prepare("$sql");408 $res4->execute();409 410 411 }412 }413 }414 if($aff==-1) {$stret=1;}415 elseif($val==-1) {$stret=(4-$votog);}416 elseif($gru==-1) {$stret=4;}417 elseif($lis==-1) {$stret=3;}418 elseif($can==-1) {$stret=3;}419 elseif($can==1) {$stret=-3;}420 elseif($lis==1) {$stret=-3;}421 elseif($gru==1) {$stret=-4;}422 elseif($val==1) {$stret=-(4-$votog);}423 else ($stret=-1);424 if($stret) return($stret);425 return ($ops);426 427 428 }429 430 113 // Offset - visualizza il numero di elementi per pagina 431 114 $offset=2; … … 461 144 462 145 echo "<div id=\"navmenu\"> <ul>"; 463 while(list($sez_num, $sez_id ,$sede_id,$c ursez) = $res->fetch(PDO::FETCH_NUM)) {146 while(list($sez_num, $sez_id ,$sede_id,$colore) = $res->fetch(PDO::FETCH_NUM)) { 464 147 $ops=''; 465 148 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;} … … 471 154 472 155 list($circ_id) = $result->fetch(PDO::FETCH_NUM); 473 /* 474 //colora la sezione 475 $sezstat=0; #die($ops); 476 $sezstat=stato_rilevazione($sez_id,$solosede); 477 $cursez="style=\" background: #bbbbbb;"; 478 $bgsez=""; 479 if ($sezstat>0) { 480 $cursez="style=\" background: #FF3300;";#rosso; 481 }else{ 482 if($sezstat==-5 or ($sezstat==-3 and $votoc)) 483 if($status<$num_ril or ($votoc and $status==0) or ($genere==5 and $status==2)) {$cursez="style=\" background: #ADFF2F;";}#verde-giallo 484 else $cursez="style=\" background: #99CC33;"; #verde 485 elseif($sezstat==-3){ 486 if($status==0) {$cursez="style=\" background: #B0E0E6;";}#powder-blue 487 elseif(($genere==4 and $status==5) or $votoc or $status==5 or ($genere==3 and $status==4)) $cursez="style=\" background: #99CC33;"; #verde 488 else $cursez="style=\" background: #00BFFF;"; #deepsky-blue 489 } 490 elseif($sezstat==-4){ 491 if($status==2) {$cursez="style=\" background: #F5F5F5;";}#whitesmoke 492 elseif ($genere>1 or ($genere==0 and $status<5)) $cursez="style=\" background: #98FB98;"; #palegreen 493 elseif ($genere==0 and $status==0) {$cursez="style=\" background: #DAA520;";} #gold 494 else $cursez="style=\" background: #99CC33;"; #verde 495 } 496 elseif($sezstat==-2){ 497 if($status==0) {$cursez="style=\" background: #B0E0E6;";}#powder-blue 498 else $cursez="style=\" background: #00BFFF;"; #deepsky-blue 499 } 500 elseif($sezstat==-1){ 501 if($status==0 and $status<$num_ril) {$cursez="style=\" background: #F5F5DC;";}#beige 502 elseif($status==1 and $status<$num_ril) {$cursez="style=\" background: #D3D3D3;";}#lightgray 503 elseif($status==2 and $status<$num_ril) {$cursez="style=\" background: #E0FFFF;";}#lightcyan 504 elseif($status==3 and $status<$num_ril) {$cursez="style=\" background: #F0E68C;";}#kaki 505 else {$sezstat=-4;$cursez="style=\" background: #DAA520;";} #gold 506 } 507 } 508 509 if ($sezstat) $ops=abs($sezstat); else $ops=1; 510 */ 156 511 157 if(!$ops) $ops=1; 512 158 $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'"; … … 516 162 517 163 list($numero_sez) = $res2->fetch(PDO::FETCH_NUM); 518 if ($sez_num==$numero_sez) {$cursez.= " border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";} else $cursez.=" \""; 164 if ($sez_num==$numero_sez) { 165 $cursez= "style=\" background: $colore; border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";} 166 else $cursez="style=\" background: $colore; \""; 519 167 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"; 520 168 } … … 998 646 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">" 999 647 ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">" 648 ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">" 1000 649 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">" 1001 650 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
Note:
See TracChangeset
for help on using the changeset viewer.