source: trunk/admin/modules/Elezioni/ele_voti.php@ 257

Last change on this file since 257 was 257, checked in by roby, 6 years ago
File size: 94.3 KB
Line 
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
12if (!defined('ADMIN_FILE')) {
13 die ("You can't access this file directly...");
14}
15global $dbi;
16$aid=$_SESSION['aid'];
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);
24if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
25if (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='';
27if (isset($param['ops'])) $ops=intval($param['ops']); else $ops='';
28if (isset($param['min'])) $min=intval($param['min']); else $min=0;
29if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
30if (isset($param['ov'])) $ov=intval($param['ov']); else $ov='';
31if (isset($param['mv'])) $mv=intval($param['mv']); else $mv='';
32if (isset($param['gv'])) $gv=intval($param['gv']); else $gv='';
33if (isset($param['msv'])) $msv=intval($param['msv']); else $msv='';
34if (isset($param['av'])) $av=intval($param['av']); else $av='';
35if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else
36 if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='0';
37if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='0';
38if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
39if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='0';
40if (isset($param['prev_sez'])) $prev_sez=intval($param['prev_sez']); else $prev_sez='0';
41if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='0';
42if (isset($param['update'])) $update=intval($param['update']); else $update='';
43include("modules/Elezioni/funzionidata.php");
44include("modules/Elezioni/ele.php");
45global $votolista, $limite, $dettnulli,$disgiunto;
46if(!isset($votolista)) $votolista=0;
47$sql="SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" ;
48$res = $dbi->prepare("$sql");
49$res->execute();
50
51
52list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
53if ($tipo_cons!=3 or $votolista==1) $limite=0; #die ("limite: $limite");}
54$sql="SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ";
55$res = $dbi->prepare("$sql");
56$res->execute();
57
58
59list($num_circ)=$res->fetch(PDO::FETCH_NUM);
60$sql="SELECT solo_gruppo,disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
61$res = $dbi->prepare("$sql");
62$res->execute();
63
64
65list($dettnulli,$disgiunto)=$res->fetch(PDO::FETCH_NUM);
66if ($conscirc){ // or $num_circ==1
67 if (!$id_circ){
68 if (!$id_sez){
69 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='1'";
70$res = $dbi->prepare("$sql");
71$res->execute();
72
73
74 list($id_sez)=$res->fetch(PDO::FETCH_NUM);
75 }
76 $sql="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'";
77$res = $dbi->prepare("$sql");
78$res->execute();
79
80
81 #$sql="SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1";
82$res = $dbi->prepare("$sql");
83$res->execute();
84
85
86 if (!$res->rowCount()) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
87 list($id_circ)=$res->fetch(PDO::FETCH_NUM);
88 $_SESSION['id_circ']=$id_circ;
89 }
90 $sql="select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'";
91$result = $dbi->prepare("$sql");
92$result->execute();
93
94
95 $i=0;
96 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
97 unset($idsedi);$i=0;$idsezi=array();unset($result);
98 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)";
99$result = $dbi->prepare("$sql");
100$result->execute();
101
102
103 unset($tmp);
104 while(list($tmp) = $result->fetch(PDO::FETCH_NUM)) $idsezi[$i++]=$tmp;
105 $tmp=implode (",",$idsezi);
106 $sezi = "and id_sez in ($tmp)";
107 $circo = "and id_circ='$id_circ'";
108}else{
109 $sezi='';
110 $circo='';
111}
112
113function stato_rilevazione($id_sez,$solosede){
114global $id_cons, $prefix, $dbi, $id_cons_gen,$status,$genere,$votol, $votog, $votoc,$idrefgruppo,$num_ril,$circo,$dettnulli,$tipo_cons;
115
116if($idrefgruppo and $genere==0) $perref= "and id_gruppo='$idrefgruppo'";
117else $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
134if($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 affluenze
147 $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 espressi
203 #per referendum
204 $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 consultazione
235 $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 gruppo
259 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) = m$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 lista
289# $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 $res4= mysql_query("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}
414if($aff==-1) {$stret=1;}
415elseif($val==-1) {$stret=(4-$votog);}
416elseif($gru==-1) {$stret=4;}
417elseif($lis==-1) {$stret=3;}
418elseif($can==-1) {$stret=3;}
419elseif($can==1) {$stret=-3;}
420elseif($lis==1) {$stret=-3;}
421elseif($gru==1) {$stret=-4;}
422elseif($val==1) {$stret=-(4-$votog);}
423else ($stret=-1);
424if($stret) return($stret);
425return ($ops);
426
427
428}
429
430// Offset - visualizza il numero di elementi per pagina
431$offset=2;
432if (!isset($min)) $min=0;
433$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
434
435function numeri_sezione($nums) {
436// tabella visualizzazione sezioni per numero
437global $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;
438$idrefgruppo='';
439 $solosede='';
440 if ($perms<32) {
441 $sql="SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons";
442$res = $dbi->prepare("$sql");
443$res->execute();
444
445
446 if ($res) {
447 list($solouna)=$res->fetch(PDO::FETCH_NUM);
448 if ($solouna>0) $solosede="and id_sede='$solouna'";
449 }
450 }
451 $sql="SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
452$res = $dbi->prepare("$sql");
453$res->execute();
454
455
456 $max = $res->rowCount();
457 //if ($max>=64){
458 $i=0;
459 echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
460
461
462 echo "<div id=\"navmenu\"> <ul>";
463 while(list($sez_num, $sez_id ,$sede_id) = $res->fetch(PDO::FETCH_NUM)) {
464 $ops='';
465 if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
466 $i++;
467 $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
468$result = $dbi->prepare("$sql");
469$result->execute();
470
471
472 list($circ_id) = $result->fetch(PDO::FETCH_NUM);
473 //colora la sezione
474 $sezstat=0; #die($ops);
475 $sezstat=stato_rilevazione($sez_id,$solosede);
476 $cursez="style=\" background: #bbbbbb;";
477 $bgsez="";
478 if ($sezstat>0) {
479 $cursez="style=\" background: #FF3300;";#rosso;
480 }else{
481 if($sezstat==-5 or ($sezstat==-3 and $votoc))
482 if($status<$num_ril or ($votoc and $status==0) or ($genere==5 and $status==2)) {$cursez="style=\" background: #ADFF2F;";}#verde-giallo
483 else $cursez="style=\" background: #99CC33;"; #verde
484 elseif($sezstat==-3){
485 if($status==0) {$cursez="style=\" background: #B0E0E6;";}#powder-blue
486 elseif(($genere==4 and $status==5) or $votoc or $status==5 or ($genere==3 and $status==4)) $cursez="style=\" background: #99CC33;"; #verde
487 else $cursez="style=\" background: #00BFFF;"; #deepsky-blue
488 }
489 elseif($sezstat==-4){
490 if($status==2) {$cursez="style=\" background: #F5F5F5;";}#whitesmoke
491 elseif ($genere>1 or ($genere==0 and $status<5)) $cursez="style=\" background: #98FB98;"; #palegreen
492 elseif ($genere==0 and $status==0) {$cursez="style=\" background: #DAA520;";} #gold
493 else $cursez="style=\" background: #99CC33;"; #verde
494 }
495 elseif($sezstat==-2){
496 if($status==0) {$cursez="style=\" background: #B0E0E6;";}#powder-blue
497 else $cursez="style=\" background: #00BFFF;"; #deepsky-blue
498 }
499 elseif($sezstat==-1){
500 if($status==0 and $status<$num_ril) {$cursez="style=\" background: #F5F5DC;";}#beige
501 elseif($status==1 and $status<$num_ril) {$cursez="style=\" background: #D3D3D3;";}#lightgray
502 elseif($status==2 and $status<$num_ril) {$cursez="style=\" background: #E0FFFF;";}#lightcyan
503 elseif($status==3 and $status<$num_ril) {$cursez="style=\" background: #F0E68C;";}#kaki
504 else {$sezstat=-4;$cursez="style=\" background: #DAA520;";} #gold
505 }
506 }
507
508 if ($sezstat) $ops=abs($sezstat); else $ops=1;
509
510 if(!$ops) $ops=1;
511 $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";
512$res2 = $dbi->prepare("$sql");
513$res2->execute();
514
515
516 list($numero_sez) = $res2->fetch(PDO::FETCH_NUM);
517 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.="\"";
518 echo "\n<li $cursez><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_circ=$circ_id&amp;id_sede=$sede_id&amp;id_sez=$sez_id&amp;ops=$ops&amp;do=spoglio&amp;id_lista=$id_lista\">$sez_num</a></b></li>\n";
519 }
520 //}
521echo "</ul></div></td></tr></table>\n";
522 //}// fine tabella per numero sezioni
523}
524///////////////////////////////////////////////////////////////////////////////////
525
526
527function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
528 global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez;
529
530 echo "<table border=\"0\" width=\"760\" align=\"left\"><tr>";
531 echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
532 numeri_sezione(22);
533 echo "\n</td></tr><tr><td>\n";
534
535
536 ///////////////////////
537 // Circoscrizione : scelta
538 ///////////////////////
539
540 $sql="SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
541 ".$prefix."_ele_sede as t2
542 where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'";
543$resoper = $dbi->prepare("$sql");
544$resoper->execute();
545
546
547 list($id_sede2,$id_circ2) = $resoper->fetch(PDO::FETCH_NUM);
548 if ($id_sede2 and !($id_sede==$id_sede2)) {
549 $id_sede=$id_sede2;
550 $id_circ=$id_circ2;
551 $do="spoglio";
552 $sql="SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede=$id_sede order by num_sez limit 0,1";
553$res = $dbi->prepare("$sql");
554$res->execute();
555
556
557 list($id_sez) = $res->fetch(PDO::FETCH_NUM);
558 }
559 if ($do == "circo") {
560 OpenTable();
561 echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
562 ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
563 ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
564 // Circoscrizione: lista
565 //**************************************
566 .""._CIRCO.": "
567 ."<select name=\"id_circ\">";
568 $sql="SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ";
569$res = $dbi->prepare("$sql");
570$res->execute();
571
572
573 while(list($id,$descr) = $res->fetch(PDO::FETCH_NUM)) {
574 if ($descr!="Tutte"){
575 if ($id == $id_circ) {
576 $sel = "selected";
577 } else {
578 $sel = "";
579 }
580 echo "<option value=\"$id\" $sel>$descr";
581 }
582 }
583 echo "</select>"
584 //***********************************
585 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
586 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
587 ."</form></td></tr>";
588 CloseTable();
589 }
590
591 ///////////////////////
592 // sede : scelta
593 ///////////////////////
594
595
596 if ($do == "sede") {
597 OpenTable();
598 echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
599 $sql="SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ";
600$res = $dbi->prepare("$sql");
601$res->execute();
602
603
604 list( $descr_circ) = $res->fetch(PDO::FETCH_NUM);
605 echo "<a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;do=circo\">"._CIRCO."</a> $descr_circ ->";
606 echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
607 ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
608
609 // Indirizzo: lista
610 //**************************************
611 .""._INDIRIZZO.": "
612 ."<select name=\"id_sede\">";
613 $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo";
614$res = $dbi->prepare("$sql");
615$res->execute();
616
617
618// echo "$id_circ - $id_cons";
619 while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
620 if ($id == $id_sede) {
621 $sel = "selected";
622 } else {
623 $sel = "";
624 }
625 echo "<option value=\"$id\" $sel>$indir";
626 }
627 echo "</select>"
628 //*************************************
629 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
630 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
631 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
632 ."</form></td></tr>\n";
633 CloseTable();
634 }
635
636 ///////////////////////
637 // sezione : scelta
638 ///////////////////////
639 if ($do == "spoglio") {
640
641
642 //************************************
643 // Menu spoglio
644 //************************************
645 $sql="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'";
646$result = $dbi->prepare("$sql");
647$result->execute();
648
649
650 list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
651
652 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>";
653 echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=1\">"._AFFLUENZE."</a></b></p></td>\n";
654 if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
655 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=4\">"._GRUPPO."</a></b></p></td>\n";
656 }
657 if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
658 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><p style=\"margin-left:10px;margin-right:10px;\"><b><a href=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3\">"._LISTA."</a></b></p></td>\n";
659 }
660 echo "</tr></table></td></tr></table><hr>\n";
661
662#############
663# posizionamento in mancanza di scelta
664#############
665if (!$ops){
666 if (!$id_sez) { echo"";#import( pagina di help );
667 } else{
668 $sql="SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
669$res = $dbi->prepare("$sql");
670$res->execute();
671
672
673 list($data,$orario)=$res->fetch(PDO::FETCH_NUM);
674 $sql="SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'";
675$res = $dbi->prepare("$sql");
676$res->execute();
677
678
679 list($voti) = $res->fetch(PDO::FETCH_NUM);
680 if (!$voti) $ops=1;
681 else {
682 if($genere<4){
683 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
684$res = $dbi->prepare("$sql");
685$res->execute();
686
687
688 list($voti) = $res->fetch(PDO::FETCH_NUM);
689 if ($voti==0 or $genere<3) $ops=4;
690 }
691 if(!$ops) $ops=3;
692 }
693
694 }
695}
696############ fine posizionamento
697
698 ///////////////////////////////////////////
699 // opzioni per le funzioni di immissione
700
701 if ($ops == 1) {
702 votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
703 }else{
704############# Controllo flag per cancellazione consultazione
705 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
706 ."//-->\n";
707 echo "function del_dati() {\n";
708 echo "if (document.getElementById('pwd3').checked==false) {\n";
709 echo "document.getElementById('update').value=\""._OK."\" \n";
710 echo "document.getElementById('do').value=\"0\" \n";
711 echo "}else{\n";
712 echo "document.getElementById('update').value=\""._DELETE."\" \n";
713 echo "document.getElementById('do').value=\"1\" \n";
714 echo "} \n";
715 echo "} \n";
716 echo "</script>\n";
717 }
718 if ($ops == 3) {
719 preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
720 }
721 if ($ops == 4) {
722 preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
723
724 }
725
726 }
727 CloseTable();
728
729}
730////////////////////////////////////////////////////////////////////////////////
731// FUNZIONI DI IMMISSIONE
732// - preferenze (candidati consiglieri)
733// - preferenze_gruppi
734// - votanti
735////////////////////////////////////////////////////////////////////////////////
736
737//////////////////////////////////////////////////////////////////////
738// da qui va la sezione per le preferenze candidati consiglieri
739//////////////////////////////////////////////////////////////////////
740function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
741 global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
742global $tipo_cons,$limite,$dettnulli,$disgiunto;
743
744$bgcolor1="#7777ff";
745$bgcolor2=$_SESSION['bgcolor2'];
746 //controlla se sono stati inseriti i votanti
747$sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
748$result = $dbi->prepare("$sql");
749$result->execute();
750
751
752list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
753
754####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
755if ($circo and $id_lista){
756 $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
757$res_lis = $dbi->prepare("$sql");
758$res_lis->execute();
759
760
761 list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
762 $sql="SELECT id_lista from ".$prefix."_ele_lista where num_lista=$num_lista and id_cons='$id_cons' $circo";
763$res_lis = $dbi->prepare("$sql");
764$res_lis->execute();
765
766
767 list($id_lista)=$res_lis->fetch(PDO::FETCH_NUM);
768}
769#######
770if(!$votog and ($genere==3 or $genere==5))
771 $sql="select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
772$result = $dbi->prepare("$sql");
773$result->execute();
774
775
776else
777 $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
778$result = $dbi->prepare("$sql");
779$result->execute();
780
781
782 list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
783 echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
784 $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
785$res_lis = $dbi->prepare("$sql");
786$res_lis->execute();
787
788
789 $num_liste = $res_lis->rowCount();
790 $ele_lista='';
791 if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
792 if(($genere==5 and $id_conf and $fascia<=$limite and !$disgiunto) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
793 $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1";
794$result = $dbi->prepare("$sql");
795$result->execute();
796
797
798 list($id_lista)=$result->fetch(PDO::FETCH_NUM);
799 }
800 echo "<td>&nbsp;</td></tr><tr><td style=\"vertical-align: top;\">";
801 echo "<form name=\"liste\" action=\"admin.php\">";
802 echo "<input type=\"hidden\" name=\"pag\" value=\"admin.php?op=voti&amp;id_cons_gen=$id_cons_gen&amp;id_sez=$id_sez&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;do=spoglio&amp;ops=3&amp;id_lista=\">";
803 echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
804 if ($id_lista){
805 echo "<option value=\"0\">"._VOTI_LISTA;
806 $ele_lista=" and t1.id_lista='$id_lista' ";
807 }else{
808 echo "<option value=\"0\" selected>"._VOTI_LISTA;
809 $ele_lista=" group by t1.id_lista ";
810if(!isset($votolista)) $votolista=0;
811
812 }
813 while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
814 $segna='';
815 $sql="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";
816$result = $dbi->prepare("$sql");
817$result->execute();
818
819
820 list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
821 $sql="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";
822$result = $dbi->prepare("$sql");
823$result->execute();
824
825
826 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
827 if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4)
828 $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
829$result = $dbi->prepare("$sql");
830$result->execute();
831
832
833 else{
834
835 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
836$result = $dbi->prepare("$sql");
837$result->execute();
838
839
840 list($id_gruppo)=$result;
841 $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
842$result = $dbi->prepare("$sql");
843$result->execute();
844
845
846 }
847 list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
848 if($votisezcand>($votisezlis*$numprefs))
849 {$segna="style=\"background-color: #dd0000;\"";}
850 elseif($ctrvoticand)
851 $segna="style=\"background-color: #99CC33;\"";
852 $sql="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'";
853$res4 = $dbi->prepare("$sql");
854$res4->execute();
855
856
857 $errcand[$id_rif]=array();
858 while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
859 if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
860
861 $sel = ($id_rif == $id_lista) ? "selected" : "";
862 echo "<option $segna value=\"$id_rif\" $sel>";
863 for ($j=strlen($num_lis);$j<2;$j++) { echo "&nbsp;&nbsp;";}
864 echo $num_lis.") ".substr($descrizione,0,30);
865 }
866 echo "</select></form></td>\n";
867 }else {
868 $id_lista=0;
869 }
870 echo "<td style=\"vertical-align: top;\">";
871
872 if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
873if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)
874 $sql="SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,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";
875$result = $dbi->prepare("$sql");
876$result->execute();
877
878
879else
880 $sql="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,t2.solo_gruppo 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";
881$result = $dbi->prepare("$sql");
882$result->execute();
883
884
885// aggiunte le variabili $sgpl e $vnulli2 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
886 $isscr= $result->rowCount();
887 list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
888 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
889 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
890$resg = $dbi->prepare("$sql");
891$resg->execute();
892
893
894 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
895 if ($sg != $sgpl) 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_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></table>";
896 }
897 $valista=$validi2;
898 if(!$id_lista or $genere==3){ //controllo di congruenza
899 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
900$res2 = $dbi->prepare("$sql");
901$res2->execute();
902
903
904 list($tot) = $res2->fetch(PDO::FETCH_NUM);
905 if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
906 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>";
907 }
908
909 if((($voti_sez)!=$validi2) and ($voti_sez>0)){
910 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>";
911 }
912 }elseif($genere==5){
913 $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_sez=$id_sez and t2.id_lista=$id_lista";
914$result = $dbi->prepare("$sql");
915$result->execute();
916
917
918 list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
919 if(($fascia>$limite or $disgiunto) or !$id_conf)
920 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
921$result = $dbi->prepare("$sql");
922$result->execute();
923
924
925 else{
926
927 $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
928$result = $dbi->prepare("$sql");
929$result->execute();
930
931
932 list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
933 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
934$result = $dbi->prepare("$sql");
935$result->execute();
936
937
938 }
939 list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
940 if($votisezcand>($votisezlis*$numprefs))
941 {
942 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>";
943 }
944 }
945#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
946 $errgrulis=array();
947 if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
948 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
949$resref = $dbi->prepare("$sql");
950$resref->execute();
951
952
953 $res4= mysql_query("SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
954$res4 = $dbi->prepare("$sql");
955$res4->execute();
956
957
958 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
959 if ($sezscrl)
960
961 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
962 {
963 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
964$res3 = $dbi->prepare("$sql");
965$res3->execute();
966
967
968 $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')";
969$res4 = $dbi->prepare("$sql");
970$res4->execute();
971
972
973 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
974 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
975 if($vliste>$vgruppo)
976 {
977 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
978$result = $dbi->prepare("$sql");
979$result->execute();
980
981
982 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
983 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 delle liste collegate<br/> superano i voti assegnati al gruppo $dgruppo </b><br></td></tr></table>";
984 $errgrulis[$id_gruppo]=1;
985 }
986 elseif($vliste<$vgruppo)
987 {
988 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
989$result = $dbi->prepare("$sql");
990$result->execute();
991
992
993 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
994 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 assegnati al gruppo $dgruppo<br/> superano i voti delle liste collegate </b><br></td></tr></table>";
995 $errgrulis[$id_gruppo]=1;
996 }
997 }
998 }
999
1000
1001
1002 echo "\n<form name=\"sezioni\" action=\"admin.php\">"
1003 ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
1004 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1005 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1006 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1007 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1008 ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
1009 ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
1010 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
1011 echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
1012 echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
1013 if ($genere<4){
1014// echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
1015 }
1016 echo "<b>"._NUM."</b></td>";
1017 if($id_lista){
1018 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
1019 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
1020 }else{
1021 echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
1022 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
1023 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
1024 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
1025 if($disgiunto){
1026 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
1027 }
1028 }
1029 echo "</tr>\n";
1030
1031
1032
1033
1034
1035 $sql="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";
1036$result = $dbi->prepare("$sql");
1037$result->execute();
1038
1039
1040 $max = $result->rowCount();
1041 $tot_pref=0;
1042 $i=1;
1043
1044 if($id_lista) {
1045 while(list($id_cand,$id_cons2,$id_lista2, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
1046 // dati lista
1047 $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
1048$result1 = $dbi->prepare("$sql");
1049$result1->execute();
1050
1051
1052 list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
1053 // dati gruppo
1054 $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1055$result2 = $dbi->prepare("$sql");
1056$result2->execute();
1057
1058
1059 list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
1060
1061 echo "<tr bgcolor=\"$bgcolor2\">";
1062 if ($genere<4){
1063 echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
1064 }
1065 echo "<td align=\"center\"><b> $num_cand </b></td>"
1066 ."<td align=\"left\"><b>$cognome $nome</b></td>";
1067 $cond_sele="and id_cand=$id_cand";
1068 $sql="SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
1069$res = $dbi->prepare("$sql");
1070$res->execute();
1071
1072
1073 $pro= $res->fetch(PDO::FETCH_BOTH);
1074 if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
1075 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
1076 echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
1077 $i++;
1078 $tot_pref+=$pro['voti'];
1079 }
1080 }else {
1081 $sql="select t2.voti,t1.id_lista, descrizione,simbolo,num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
1082 from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
1083 where t1.id_cons='$id_cons'
1084 and t1.id_lista=t2.id_lista
1085 and t2.id_sez=$id_sez
1086 order by t1.num_lista";
1087$result1 = $dbi->prepare("$sql");
1088$result1->execute();
1089
1090
1091 $num_lista=$result1->rowCount();
1092 if (!$num_lista){
1093 $sql="select '',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
1094 from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
1095 order by num_lista";
1096$result1 = $dbi->prepare("$sql");
1097$result1->execute();
1098
1099
1100 }
1101 while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
1102 echo "<tr bgcolor=\"$bgcolor2\">";
1103// if ($genere<4 or $votoc){
1104// }
1105 $errcolor='';
1106 if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
1107 echo "<td align=\"center\"><b> $num_lista </b></td>"
1108 ."<td align=\"left\"><b> $descr_lista</b></td>";
1109 $cond_sele="and id_lista=$id_lista3";
1110 echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
1111 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19) echo "</td><td align=\"right\"><input name=\"vnpl$i\" value=\"".$vnpl."\" size=\"7\" style=\"text-align:right\">";
1112 if($disgiunto) echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\">";
1113 echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
1114// echo "<td align=\"right\">$sgpl";
1115 echo "</tr>\n";
1116 $i++;
1117 $tot_pref+=$pro['voti'];
1118 }
1119 }
1120 if(!$id_lista) echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOT._VOTI_LISTA."</td><td align=\"center\">$tot_pref</td></tr>";
1121 else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
1122 // toglie ai candidati la visual... del solo_gruppo
1123 if(!$votog) {
1124 if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
1125 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>";
1126 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>";
1127 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\">"
1128 ."</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>";
1129
1130 }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
1131 echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
1132 }
1133######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
1134elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
1135$sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
1136$resvg = $dbi->prepare("$sql");
1137$resvg->execute();
1138
1139
1140list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
1141$sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
1142$resvg = $dbi->prepare("$sql");
1143$resvg->execute();
1144
1145
1146 list($voti_sind) = $resvg;
1147
1148echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
1149}
1150###### fine modifica del 16-04-2009
1151
1152 }
1153 echo "<tr>";
1154 echo "<td></td><td></td>";
1155 echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
1156 echo "</tr></table></form></tr>";
1157 if(chisei($id_cons_gen)>=64){
1158 echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."</td>";
1159 }
1160 echo "</table>";
1161 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
1162 ."document.sezioni.voti1.focus()\n"
1163 ."document.sezioni.voti1.select()\n"
1164 ."//-->\n";
1165 echo "function vai_lista() {\n";
1166 echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
1167 echo "}\n";
1168 echo "</script>\n";
1169# }
1170#if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
1171 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
1172 }
1173
1174/////////////////////////////////////////////
1175// registra le preferenze ai candidati
1176/////////////////////////////////////////////
1177
1178function rec_voti() {
1179 global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update,$dettnulli,$disgiunto,$tipo_cons;
1180
1181 $sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
1182 $sql=$sqlcomu);
1183 if($res)
1184 list($fascia,$id_conf)=$res->fetch(PDO::FETCH_NUM);
1185 else {$fascia=0; $id_conf=0;}
1186 if ($fileout) while (!$fp = fopen($fileout,"a"));
1187 $username=$aid;
1188 $log_data= date("Y/m/d");
1189 $log_ora=getdate(time());
1190 $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
1191 $arg2 = func_get_args();
1192 $arg = split(",",$arg2[0]);
1193 $id_cons_gen=intval($arg[1]);
1194 $id_sez = intval($arg[2]);
1195 $id_circ = intval($arg[3]);
1196 $id_sede = intval($arg[4]);
1197 $tab = $arg[5];
1198 $id_lista = intval($arg[6]);
1199 $do= intval($arg[7]);
1200 if ($tab=="_ele_voti_candidati") {
1201 $condizione="id_cand";
1202 }else{
1203 $condizione="id_lista";
1204 }
1205 if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and (($disgiunto or $fascia>$limite) or !$id_conf)) $y = (count($arg)-4);
1206 else $y=count($arg);#die ("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'");
1207 $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
1208$res = $dbi->prepare("$sql");
1209$res->execute();
1210
1211
1212 if($do==1) {
1213 $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
1214$res = $dbi->prepare("$sql");
1215$res->execute();
1216
1217
1218 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
1219$res = $dbi->prepare("$sql");
1220$res->execute();
1221
1222
1223 if($genere!=4)
1224 $sql="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'";
1225$res = $dbi->prepare("$sql");
1226$res->execute();
1227
1228
1229
1230 }else{
1231 for($i=8,$y--;$i< $y;$i++) {
1232 $voti = intval($arg[$i++]);
1233 $vnrigains=",'0'";
1234 $vnriga='';
1235 if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19 and $condizione!="id_cand") {$vnpl = intval($arg[$i++]); $vnriga=",nulli_lista='$vnpl'"; $vnrigains=",'".$vnpl."'";} else {if (!($condizione=="id_lista")) $vnrigains="";}
1236 if($disgiunto and $condizione!="id_cand") {$slpl = intval($arg[$i++]); $vnriga.=",solo_lista='$slpl'"; $vnrigains.=",'".$slpl."'";} else {$vnriga.=''; if ($condizione=="id_lista") $vnrigains.=",'0'"; else $vnrigains="";}
1237 $id_cand = intval($arg[$i]);
1238 $sql="select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'";
1239$result = $dbi->prepare("$sql");
1240$result->execute();
1241
1242
1243 $ar=$result->fetch(PDO::FETCH_BOTH);
1244
1245 if ($ar){
1246#die("T1:$dettnulli -- T2:$disgiunto -- update ".$prefix."$tab set voti='$voti'$vnriga where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'");
1247 if ($ar['voti']!=$voti or (isset($vnpl) and $ar['nulli_lista']!=$vnpl) or (isset($slpl) and $ar['solo_lista']!=$slpl)) {
1248 $sql="update ".$prefix."$tab set voti='$voti'$vnriga where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'";
1249$res = $dbi->prepare("$sql");
1250$res->execute();
1251
1252
1253 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");
1254 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')";
1255$res = $dbi->prepare("$sql");
1256$res->execute();
1257
1258
1259 }
1260 } else {//die ("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)");
1261 if ($voti)
1262 $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')";
1263$res = $dbi->prepare("$sql");
1264$res->execute();
1265
1266
1267 $sql="insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)";
1268$res = $dbi->prepare("$sql");
1269$res->execute();
1270
1271
1272 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
1273 }
1274 }
1275// foreach ($arg as $vval) echo $vval." - ";
1276 // solo gruppo e preferenze alle liste
1277
1278 if(!$votog) {
1279 if ((($genere==3) OR ($genere==5)) and !$id_lista and (($disgiunto or $fascia>$limite) or !$id_conf)) {
1280 $valista=$arg[$i++];
1281 $sql="update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'";
1282$res = $dbi->prepare("$sql");
1283$res->execute();
1284
1285
1286 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
1287 if ($condizione=="id_lista"){
1288 $sql="select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'";
1289$result = $dbi->prepare("$sql");
1290$result->execute();
1291
1292
1293 $ar=$result->fetch(PDO::FETCH_BOTH);
1294 ++$i;
1295 $sql="update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'";
1296$res = $dbi->prepare("$sql");
1297$res->execute();
1298
1299
1300 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
1301 if ($ar['validi']){
1302
1303
1304 if($valista)
1305 $sql="update ".$prefix."_ele_sezioni set validi_lista='$valista' where id_sez='$id_sez'";
1306$res = $dbi->prepare("$sql");
1307$res->execute();
1308
1309
1310 else
1311 $sql="update ".$prefix."_ele_sezioni set validi_lista=(`validi`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'";
1312$res = $dbi->prepare("$sql");
1313$res->execute();
1314
1315
1316 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");
1317 }
1318 }
1319 }
1320 }
1321 }
1322
1323// $ops = $arg[$argc];
1324 if ($fileout)fclose($fp);
1325 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");
1326}
1327
1328
1329////////////////////////////////////////////
1330// da qua va la sezione per i votanti
1331///////////////////////////////////////////
1332
1333function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
1334//function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
1335 global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
1336$bgcolor1=$_SESSION['bgcolor2'];
1337OpenTable();
1338$sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
1339$res = $dbi->prepare("$sql");
1340$res->execute();
1341
1342
1343if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
1344$sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
1345$res = $dbi->prepare("$sql");
1346$res->execute();
1347
1348
1349$num = $res->rowCount();
1350$sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
1351$ressez = $dbi->prepare("$sql");
1352$ressez->execute();
1353
1354
1355list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
1356$y=0;
1357echo "<tr><td>&nbsp;</td></tr>";
1358while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
1359 $y++;
1360 echo "\n<tr><td>";
1361 echo "<form name=\"votanti$y\" action=\"admin.php\">";
1362 echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
1363 if ($genere==0){ //e' un referendum
1364 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
1365 }
1366 echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
1367 ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
1368 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
1369 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
1370 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
1371 if ($genere==0){
1372 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
1373$res2 = $dbi->prepare("$sql");
1374$res2->execute();
1375
1376
1377 $max = $res2_>rowCount();
1378 }else{ $max=1;}
1379 echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
1380 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1381 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1382 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1383 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1384 echo "</td>"; //la riga viene chiusa nel ciclo for
1385 for ($i=1;$i<=$max;$i++){
1386 $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
1387 on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
1388 and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
1389 if ($genere==0){
1390 $query.=" and t2.num_gruppo=$i";
1391 }
1392 $sql=$query;
1393$result = $dbi->prepare("$sql");
1394$result->execute();
1395
1396
1397 list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
1398 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ";
1399$res2 = $dbi->prepare("$sql");
1400$res2->execute();
1401
1402
1403 $resril = mysql_query("select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1404$resril = $dbi->prepare("$sql");
1405$resril->execute();
1406
1407
1408 list($numril)=$resril->fetch(PDO::FETCH_NUM);
1409 if ($res2)
1410 list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
1411 else
1412 $gruppo=0;
1413 if (!$gruppo>0) {
1414 $gruppo=$i;
1415 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
1416$res3 = $dbi->prepare("$sql");
1417$res3->execute();
1418
1419
1420 if ($res3)
1421 list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
1422 }
1423 if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
1424 if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
1425 $precede[$id_gruppo]=$voti_t;
1426 if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
1427 echo "</tr><tr style=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
1428 }else{
1429 echo "</tr><tr class=\"tr-dx\">";
1430 }
1431 if ($genere==0){ // e' un referendum
1432 echo "<td align=\"center\">$gruppo</td>";
1433 }
1434
1435 list ($anno,$mese,$di)=explode('-',$giorno);
1436 echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
1437 if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\">";
1438 else echo "<td align=\"center\">";
1439 if ($y<$num and $vismf==0 and $voti_u==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
1440 echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
1441 if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\">";
1442 else echo "<td align=\"center\">";
1443 if ($y<$num and $vismf==0 and $voti_d==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
1444 echo " name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
1445 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\">";
1446 else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
1447 echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
1448 ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
1449 ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
1450 ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
1451 echo "</td>";
1452 }
1453 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>";
1454 else echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"></td>";
1455 echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td>";
1456 echo "</tr>";
1457
1458
1459
1460# echo "</table></form></td></tr>";
1461 echo "</table></form>";
1462 $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
1463$compl = $dbi->prepare("$sql");
1464$compl->execute();
1465
1466
1467 list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
1468 if (!$complessivi)
1469 {
1470 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1471 if ($y==$num) {
1472 echo "document.votanti$y.voti_u1.focus()\n";
1473 echo "document.votanti$y.voti_u1.select()\n";
1474 }else{
1475 echo "document.votanti$y.voti_t1.focus()\n";
1476 echo "document.votanti$y.voti_t1.select()\n";
1477 }
1478 echo "//-->\n"
1479 ."</script>\n";
1480 break;
1481 }
1482 echo "</td></tr>";
1483 }
1484CloseTable();
1485}
1486
1487
1488///////////////////////////
1489// registra i votanti
1490///////////////////////////
1491
1492function rec_add_votanti() {
1493global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
1494//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
1495// 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
1496if ($fileout) while (!$fp = fopen($fileout,"a"));
1497
1498$username="$aid";
1499$arg2 = func_get_args();
1500$arg = split(",",$arg2[0]);
1501$id_cons_gen=intval($arg[1]);
1502$id_sez=intval($arg[2]);
1503$id_circ=intval($arg[3]);
1504$id_sede=intval($arg[4]);
1505$op=$arg[count($arg)-2];
1506for($i=5;$i< count($arg)-2;) {
1507 $voti_u = intval($arg[$i++]);
1508 $voti_d = intval($arg[$i++]);
1509 $voti_t = intval($arg[$i++]);
1510 if($voti_t==0) $voti_t=$voti_d+$voti_u;
1511 $id_parz = intval($arg[$i++]);
1512 $giorno = $arg[$i++];
1513 $ora = $arg[$i++];
1514 $id_gruppo = intval($arg[$i++]);
1515 $data=date("Y/m/d");
1516 $tempo=date("H:i:s");
1517 $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
1518$res = $dbi->prepare("$sql");
1519$res->execute();
1520
1521
1522 $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
1523 if ($genere==0){
1524 $query.=" and id_gruppo=$id_gruppo";
1525 }
1526 $sql="$query";
1527$res = $dbi->prepare("$sql");
1528$res->execute();
1529
1530
1531 $righe=$res->rowCount();
1532 if (!$righe){
1533 $sql="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')";
1534$res = $dbi->prepare("$sql");
1535$res->execute();
1536
1537
1538 $sql="insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo')";
1539$res = $dbi->prepare("$sql");
1540$res->execute();
1541
1542
1543 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");
1544 } elseif($op=="true"){
1545 $sql="delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'";
1546$res = $dbi->prepare("$sql");
1547$res->execute();
1548
1549
1550 if ($fileout) fwrite($fp,"delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz';\n");
1551 } else {
1552 $sql="select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz";
1553$res = $dbi->prepare("$sql");
1554$res->execute();
1555
1556
1557 $ar=$res->fetch(PDO::FETCH_BOTH);
1558
1559 if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){
1560 $sql="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')";
1561$res = $dbi->prepare("$sql");
1562$res->execute();
1563
1564
1565 $sql="update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz'";
1566$res = $dbi->prepare("$sql");
1567$res->execute();
1568
1569
1570 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");
1571 }
1572 }
1573 }
1574if ($fileout)fclose($fp);
1575Header("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");
1576}
1577
1578
1579
1580function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1581 global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
1582////////////////////////////////////////////
1583// da qua va la sezione per i voti finali
1584///////////////////////////////////////////
1585$bgcolor1="#7777ff";
1586$bgcolor2=$_SESSION['bgcolor2'];
1587
1588
1589
1590 echo "<form name=\"spogliovoti\" action=\"admin.php\">"
1591 ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
1592 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1593 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1594 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1595 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
1596
1597 echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
1598/* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1599 echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
1600 else */
1601 echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
1602 echo "<td width=\"82\"><b>"._NULLI."</b></td>"
1603 ."<td><b>"._BIANCHI."</b></td>"
1604 ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
1605 ."<td><b>"._CONTESTATI."</b></td>"
1606 ."<td><b>"._TOTNON."</b></td>"
1607 ."<td><b>"._TOTALEVOTI."</b></td>"
1608 ."<td bgcolor=\"#ffffff\"></td> </tr>";
1609/*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
1610 $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' ";
1611$res = $dbi->prepare("$sql");
1612$res->execute();
1613
1614
1615else */
1616 $sql = "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' ";
1617$result = $dbi->prepare("$sql");
1618$result->execute();
1619
1620
1621 list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
1622 $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
1623 $tot_voti=$validi+$tot_nulli+$conts+$nullis;
1624// ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
1625
1626
1627 echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
1628/* if(($genere==3 or $genere==5) and !$votog and $ops==3){
1629 echo "</td><td>$nulli"
1630 ."</td><td>$bianchi";
1631 echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
1632 }else{ */
1633 echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
1634 ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
1635// }
1636 echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
1637 ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
1638 ."</td><td>$tot_nulli"
1639 ."</td><td>$tot_voti</td><td>"
1640// ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
1641 ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
1642 ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
1643 ."</td></tr></table></form>"; //</td></tr>";
1644
1645
1646// echo "</table>";
1647 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1648 if (!$validi) {
1649 echo "document.spogliovoti.validi.focus()\n";
1650 echo "document.spogliovoti.validi.select()\n";
1651 }
1652 echo "//-->\n"
1653 ."</script>\n";
1654
1655
1656 }
1657
1658
1659
1660
1661
1662
1663///////////////////////////
1664// registra voti finali
1665///////////////////////////
1666
1667function rec_finale() {
1668global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
1669
1670if ($fileout) while (!$fp = fopen($fileout,"a"));
1671$arg2 = func_get_args();
1672$arg = split(",",$arg2[0]);
1673$id_cons_gen=intval($arg[1]);
1674$id_sez = intval($arg[2]);
1675$id_circ = intval($arg[3]);
1676$id_sede = intval($arg[4]);
1677$validi = intval($arg[5]);
1678$nulli = intval($arg[6]);
1679$bianchi = intval($arg[7]);
1680$votinulli = intval($arg[8]);
1681$contestati = intval($arg[9]);
1682//$sololista = intval($arg[10]);
1683$ops = $arg[10];
1684$username="$aid";
1685$log_data= date("Y/m/d");
1686$log_ora=getdate(time());
1687$orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
1688$sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
1689$res = $dbi->prepare("$sql");
1690$res->execute();
1691
1692
1693
1694$sql="select voti_complessivi from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' order by id_parz desc";
1695$result = $dbi->prepare("$sql");
1696$result->execute();
1697
1698
1699list($voti_t) = $result->fetch(PDO::FETCH_NUM);
1700 $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
1701$sololista=$voti_t-$tot_voti;
1702 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1703$result = $dbi->prepare("$sql");
1704$result->execute();
1705
1706
1707 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
1708 $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
1709$result = $dbi->prepare("$sql");
1710$result->execute();
1711
1712
1713 $ar=$result->fetch(PDO::FETCH_NUM);
1714 $validilista=$validi-$ar['solo_gruppo'];
1715 if ($ar['solo_lista'] or !$disgiunto) $rigasl=''; else $rigasl=", solo_lista='$sololista'";
1716#die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
1717 if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
1718 $sql="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=$validilista, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')";
1719$res = $dbi->prepare("$sql");
1720$res->execute();
1721
1722
1723
1724/* $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' ";
1725$res = $dbi->prepare("$sql");
1726$res->execute();
1727
1728
1729 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"); */
1730 $sql="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' ";
1731$res = $dbi->prepare("$sql");
1732$res->execute();
1733
1734
1735 if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validilista', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' $rigasl where id_cons='$id_cons' and id_sez='$id_sez';\n");
1736 }else{
1737 $sql="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')";
1738$res = $dbi->prepare("$sql");
1739$res->execute();
1740
1741
1742 $valista="";
1743 if ($ar['validi_lista']){
1744 $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista'];
1745 $valista=",validi_lista='$tvalista'";
1746 }
1747
1748 $sql="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' ";
1749$res = $dbi->prepare("$sql");
1750$res->execute();
1751
1752
1753 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");
1754 }
1755// }
1756// Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
1757 if ($fileout) fclose($fp);
1758 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");
1759
1760/*}else{
1761
1762echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
1763echo "<hr><a href=\"admin.php?op=voti&amp;id_cons=$id_cons&amp;id_circ=$id_circ&amp;id_sede=$id_sede&amp;id_sez=$id_sez&amp;do=spoglio&amp;ops=$ops\">Torna e correggi i dati immessi</a></center>";
1764}*/
1765}
1766
1767
1768function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
1769 global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
1770////////////////////////////////////////////
1771// da qua va la sezione per le preferenze ai gruppi
1772///////////////////////////////////////////
1773// Controllo immmissioni
1774
1775$bgcolor1="#7777ff";
1776$bgcolor2=$_SESSION['bgcolor2'];
1777 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
1778$res = $dbi->prepare("$sql");
1779$res->execute();
1780
1781
1782 $max = $res->rowCount();
1783 $max = $max-1;
1784 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
1785 if ($genere==0) {
1786 echo "document.sezioni.si1.focus()\n";
1787 echo "document.sezioni.si1.select()\n";
1788 } else {
1789 echo "document.sezioni.voti1.focus()\n"
1790 ."document.sezioni.voti1.select()\n";
1791 }
1792 echo "//-->\n"
1793 ."</script>\n";
1794// tabella votanti
1795 echo "<center>";
1796 if ($genere!=0){
1797 $sql="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";
1798$result = $dbi->prepare("$sql");
1799$result->execute();
1800
1801
1802 list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM)
1803 echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
1804 ."<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>"
1805 ."<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>";
1806 echo "</table>";
1807 }
1808 echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
1809 if ($genere==0){
1810 $sql="SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' ";
1811$res = $dbi->prepare("$sql");
1812$res->execute();
1813
1814
1815 while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
1816 if ($voti_parz!=$validi){
1817 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
1818$res2 = $dbi->prepare("$sql");
1819$res2->execute();
1820
1821
1822 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1823 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI_REF." $num_gruppo: ".$voti_parz." "._NO_VAL_VOTI.": ".$validi."</b><br></td></tr>";
1824 }
1825 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
1826$res2 = $dbi->prepare("$sql");
1827$res2->execute();
1828
1829
1830 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1831 if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
1832 $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
1833$res2 = $dbi->prepare("$sql");
1834$res2->execute();
1835
1836
1837 list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
1838 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI_REF." $num_gruppo: ".$tot." "._NO_SOMMA." ".($validi+$nulli+$bianchi+$contestati)."</b><br></td></tr>";
1839 }
1840 }
1841 }else{
1842 $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
1843$result = $dbi->prepare("$sql");
1844$result->execute();
1845
1846
1847 list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
1848 $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
1849$res = $dbi->prepare("$sql");
1850$res->execute();
1851
1852
1853 list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
1854 $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
1855$res = $dbi->prepare("$sql");
1856$res->execute();
1857
1858
1859 list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
1860 if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
1861 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".($validi-$solo_lista)."</b><br></td><tr>";
1862 }
1863 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
1864$res2 = $dbi->prepare("$sql");
1865$res2->execute();
1866
1867
1868 list($tot) = $res2->fetch(PDO::FETCH_NUM);
1869 if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
1870 echo "<tr><td style=\"background-color: rgb(255, 0, 0); text-align:center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTANTI." ".$tot." "._NO_TOT_VOTI." ".($validi+$nulli+$bianchi+$contestati+$votinulli)."</b><br></td></tr>";
1871 }
1872 $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
1873$resg = $dbi->prepare("$sql");
1874$resg->execute();
1875
1876
1877 list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
1878 if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
1879
1880 $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
1881$resg = $dbi->prepare("$sql");
1882$resg->execute();
1883
1884
1885 list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
1886 $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
1887$resg = $dbi->prepare("$sql");
1888$resg->execute();
1889
1890
1891 list($sg)=$resg->fetch(PDO::FETCH_NUM);
1892 if ($sg != $sgpl) echo "<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_UNI." ".$sgpl." "._ATT_TOT_UNI." ".$sg."</b><br></td></tr>";
1893 }
1894#controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
1895if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
1896 $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
1897$resref = $dbi->prepare("$sql");
1898$resref->execute();
1899
1900
1901 $errgrulis=array();
1902 $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
1903$res4 = $dbi->prepare("$sql");
1904$res4->execute();
1905
1906
1907 list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
1908 if ($sezscrl)
1909 while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
1910 {
1911 $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
1912$res3 = $dbi->prepare("$sql");
1913$res3->execute();
1914
1915
1916 $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')";
1917$res4 = $dbi->prepare("$sql");
1918$res4->execute();
1919
1920
1921 list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
1922 list($vliste)=$res4->fetch(PDO::FETCH_NUM);
1923 if($vliste>$vgruppo and ($tipo_cons=18 or $tipo_cons=19))
1924 {
1925 $errgrulis[$id_gruppo]=1;
1926 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1927$result = $dbi->prepare("$sql");
1928$result->execute();
1929
1930
1931 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1932 echo "<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 delle liste collegate<br/> superano i voti assegnati al gruppo $dgruppo </b><br></td></tr>";
1933 }
1934 elseif($vliste<$vgruppo and ($tipo_cons=18 or $tipo_cons=19))
1935 {
1936 $errgrulis[$id_gruppo]=1;
1937 $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
1938$result = $dbi->prepare("$sql");
1939$result->execute();
1940
1941
1942 list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
1943 echo "<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 assegnati al gruppo $dgruppo <br/> superano i voti delle liste collegate</b><br></td></tr>";
1944 }
1945 }
1946}
1947
1948 }
1949 if(!isset($votinulli)) $votinulli=0;
1950 echo "<tr><td></td></tr></table>";
1951 if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
1952 echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"admin.php\">";
1953 echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
1954 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
1955 ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
1956 ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
1957 ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
1958 ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
1959 echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
1960 ."<td width=\"3%\"><b>"._NUM."</b></td>"
1961 ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
1962 if ($genere==0){
1963 echo "<td><b>"._SI."</b></td>"
1964 ."<td><b>"._NO."</b></td>"
1965 ."<td><b>"._VALIDI."</b></td>"
1966 ."<td><b>"._BIANCHI."</b></td>"
1967 ."<td><b>"._CONTESTATI."</b></td>"
1968 ."<td><b>"._NULLI."</b></td>"
1969 ."<td><b>"._TOTNON."</b></td>"
1970 ."<td><b>"._TOTALEVOTI."</b></td>"
1971 ."<td><b>"._VOTANTI."</b></td>";
1972 }else{
1973 echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
1974 if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
1975 }
1976 echo "</tr>";
1977 $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
1978$res = $dbi->prepare("$sql");
1979$res->execute();
1980
1981
1982 $max = $res->rowCount();
1983 //echo "Massimo:$max - id=$id_cons - circo: $circo";
1984 $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
1985$result = $dbi->prepare("$sql");
1986$result->execute();
1987
1988
1989 $i=1;
1990 $tot_pref=0;
1991 $totsg=0;
1992 while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
1993
1994 //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
1995
1996
1997 if ($num_gruppo != ''){
1998 if ($genere==0){
1999 $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
2000$res = $dbi->prepare("$sql");
2001$res->execute();
2002
2003
2004 list($tot) = $res->fetch(PDO::FETCH_NUM);
2005 $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
2006$res = $dbi->prepare("$sql");
2007$res->execute();
2008
2009
2010 $pro= $res->fetch(PDO::FETCH_BOTH);
2011
2012 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)){
2013 echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
2014 }else{
2015 echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
2016 }
2017 $descr = explode('.',$descr_gruppo, 100);
2018 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
2019 ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
2020 $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
2021 $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
2022 $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
2023 $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
2024 $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
2025 $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
2026 $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
2027 $tot_voti=$pro['validi']+$tot_nulli;
2028 echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\"></td>";
2029 echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\"></td>";
2030 echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
2031 echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
2032 echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
2033 echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
2034 echo "</td><td align=\"right\">$tot_nulli</td>";
2035 echo "</td><td align=\"right\">$tot_voti</td>";
2036 echo "</td><td align=\"right\">$tot</td>";
2037 }else{
2038 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>"
2039 ."</td><td align=\"left\"><b> $descr_gruppo </b>";
2040 $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
2041$res = $dbi->prepare("$sql");
2042$res->execute();
2043
2044
2045 $pro= $res->fetch(PDO::FETCH_BOTH);
2046 $errcolor='';
2047 if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
2048 echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
2049
2050 if($dettnulli) {echo "<td align=\"right\"><input name=\"solog$i\" value=\"".$pro['solo_gruppo']."\" size=\"7\" style=\"text-align:right\"></td>"; $totsg+=$pro['solo_gruppo'];}
2051 $tot_pref += $pro['voti'];
2052 echo "</tr>";
2053 }
2054
2055 $i++;
2056 }
2057
2058 }
2059 if ($genere!=0) {
2060 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
2061$res = $dbi->prepare("$sql");
2062$res->execute();
2063
2064
2065 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
2066 $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
2067$res = $dbi->prepare("$sql");
2068$res->execute();
2069
2070
2071 list($sololis)=$res->fetch(PDO::FETCH_NUM);
2072 echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
2073 if($dettnulli) echo "<td>$totsg</td>";
2074 echo "</tr>";
2075 if($disgiunto)
2076 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>";
2077 }
2078
2079 echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
2080
2081 echo "</tr></table></form></td></tr>";
2082 if(chisei($id_cons_gen)>=64){
2083 echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
2084 }
2085
2086 echo "</td></tr></table></center>";
2087 }
2088 if ($genere!=0){
2089 finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
2090 }
2091}
2092
2093
2094
2095
2096
2097
2098///////////////////////////
2099// registra le preferenze ai gruppi
2100///////////////////////////
2101
2102function rec_voti_gruppi() {
2103global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout,$dettnulli;
2104if ($fileout) while (!$fp = fopen($fileout,"a"));
2105
2106$username="$aid";
2107$log_data= date("Y/m/d");
2108$log_ora=getdate(time());
2109$arg2 = func_get_args();
2110$arg = split(",",$arg2[0]);
2111$id_cons_gen=intval($arg[1]);
2112$id_sez = intval($arg[2]);
2113$id_circ = intval($arg[3]);
2114$id_sede = intval($arg[4]);
2115$do = intval($arg[5]);
2116$y=count($arg)-1;
2117 $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
2118$res = $dbi->prepare("$sql");
2119$res->execute();
2120
2121
2122 if($do==1) {
2123 $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
2124$res = $dbi->prepare("$sql");
2125$res->execute();
2126
2127
2128 $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
2129$res = $dbi->prepare("$sql");
2130$res->execute();
2131
2132
2133 $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
2134$res = $dbi->prepare("$sql");
2135$res->execute();
2136
2137
2138 $sql="delete from ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez'";
2139$res = $dbi->prepare("$sql");
2140$res->execute();
2141
2142
2143 $sql="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'";
2144$res = $dbi->prepare("$sql");
2145$res->execute();
2146
2147
2148
2149 }else{
2150
2151if ($genere==0) {
2152 $tab="_ele_voti_ref";
2153} else {
2154 $tab="_ele_voti_gruppo";
2155 $y--;
2156 $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
2157$res = $dbi->prepare("$sql");
2158$res->execute();
2159
2160
2161 list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
2162 if($disgiunto)
2163 $sql="update ".$prefix."_ele_sezioni set solo_lista='".$arg[$y--]."' where id_sez='$id_sez'";
2164$res = $dbi->prepare("$sql");
2165$res->execute();
2166
2167
2168
2169}
2170
2171for($i=6;$i< $y;) {
2172 $id_gruppo = intval($arg[$i++]);
2173 $testval=0;
2174 switch ($genere){
2175 case (0):
2176 if($arg[$i].$arg[$i+1]=='' ) {
2177 $i+=6;
2178 $testval=1;
2179 }else{
2180 $si=intval($arg[$i++]);
2181 $no=intval($arg[$i++]);
2182 $val=intval($arg[$i++]);
2183 if ($val==0){$val=$si+$no;}
2184 $bia=intval($arg[$i++]);
2185 $con=intval($arg[$i++]);
2186 $nul=intval($arg[$i++]);
2187 $voti = "'$si','$no','$val','$nul','$bia','$con'";
2188 $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
2189 $sgriga='';
2190 }
2191 break;
2192 default:
2193 $voti = intval($arg[$i++]);
2194 if($dettnulli) { $sg=intval($arg[$i++]); $sgriga = ', solo_gruppo='.$sg;} else {$sgriga=''; $sg=0;}
2195 if (!$voti) {$voti="0";}
2196 $riga="voti=$voti".$sgriga;
2197 $sgriga=",'$sg'";
2198 break;
2199 }
2200 if($testval) continue;
2201 $sql="select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
2202$result = $dbi->prepare("$sql");
2203$result->execute();
2204
2205
2206 $ar=$result->fetch(PDO::FETCH_BOTH);
2207 $sql="select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
2208$res = $dbi->prepare("$sql");
2209$res->execute();
2210
2211
2212 list($num_gruppo)=$res->fetch(PDO::FETCH_NUM);
2213 $oldval='';
2214 if ($ar){
2215 switch ($genere){
2216 case (0):
2217 if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
2218 or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
2219 $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
2220 }
2221 break;
2222 default:
2223 if ($ar['voti']!=$voti or $ar['solo_gruppo']!=$sg) {
2224 $oldval="voti:".$ar['voti'];
2225 $voti.=",null";
2226 }
2227 if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
2228 break;
2229 }
2230 if ($oldval) {
2231 $sql="update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
2232$res = $dbi->prepare("$sql");
2233$res->execute();
2234
2235
2236 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");
2237 $sql="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')";
2238$res = $dbi->prepare("$sql");
2239$res->execute();
2240
2241
2242 }
2243 } else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)");
2244 $sql="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')";
2245$res = $dbi->prepare("$sql");
2246$res->execute();
2247
2248
2249 $sql="insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga)";
2250$res = $dbi->prepare("$sql");
2251$res->execute();
2252
2253
2254 if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga);\n");
2255 //
2256 }
2257
2258}
2259}
2260//$ops = $arg[$argc];
2261if ($fileout) fclose($fp);
2262Header("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");
2263
2264}
2265
2266
2267 if (!preg_match("/rec/",$op)) {
2268 ele(); //menu
2269/* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
2270 numeri_sezione(8);
2271 echo "<td></td></tr></table>\n";*/
2272 echo"</td></tr></table>";
2273 }
2274
2275 switch ($op){
2276 case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
2277# voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
2278 voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
2279 break;
2280 default :
2281 $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
2282 }
2283echo"</td></tr></table>";
2284 include_once("modules/Elezioni/language/lang-$currentlang.php");
2285 include ("footer.php");
2286?>
2287
Note: See TracBrowser for help on using the repository browser.