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