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 | // Offset - visualizza il numero di elementi per pagina
|
---|
114 | $offset=2;
|
---|
115 | if (!isset($min)) $min=0;
|
---|
116 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
117 |
|
---|
118 | function numeri_sezione($nums) {
|
---|
119 | // tabella visualizzazione sezioni per numero
|
---|
120 | 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;
|
---|
121 | $idrefgruppo='';
|
---|
122 | $solosede='';
|
---|
123 | if ($perms<32) {
|
---|
124 | $sql="SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons";
|
---|
125 | $res = $dbi->prepare("$sql");
|
---|
126 | $res->execute();
|
---|
127 |
|
---|
128 |
|
---|
129 | if ($res) {
|
---|
130 | list($solouna)=$res->fetch(PDO::FETCH_NUM);
|
---|
131 | if ($solouna>0) $solosede="and id_sede='$solouna'";
|
---|
132 | }
|
---|
133 | }
|
---|
134 | $sql="SELECT num_sez, id_sez ,id_sede,colore FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez";
|
---|
135 | $res = $dbi->prepare("$sql");
|
---|
136 | $res->execute();
|
---|
137 |
|
---|
138 |
|
---|
139 | $max = $res->rowCount();
|
---|
140 | //if ($max>=64){
|
---|
141 | $i=0;
|
---|
142 | echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
|
---|
143 |
|
---|
144 |
|
---|
145 | echo "<div id=\"navmenu\"> <ul>";
|
---|
146 | while(list($sez_num, $sez_id ,$sede_id,$colore) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
147 | $ops='';
|
---|
148 | if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
|
---|
149 | $i++;
|
---|
150 | $sql="SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ";
|
---|
151 | $result = $dbi->prepare("$sql");
|
---|
152 | $result->execute();
|
---|
153 |
|
---|
154 |
|
---|
155 | list($circ_id) = $result->fetch(PDO::FETCH_NUM);
|
---|
156 |
|
---|
157 | if(!$ops) $ops=1;
|
---|
158 | $sql="SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'";
|
---|
159 | $res2 = $dbi->prepare("$sql");
|
---|
160 | $res2->execute();
|
---|
161 |
|
---|
162 |
|
---|
163 | list($numero_sez) = $res2->fetch(PDO::FETCH_NUM);
|
---|
164 | if ($sez_num==$numero_sez) {
|
---|
165 | $cursez= "style=\" background: $colore; border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px; \"";}
|
---|
166 | else $cursez="style=\" background: $colore; \"";
|
---|
167 | echo "\n<li $cursez><b><a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$circ_id&id_sede=$sede_id&id_sez=$sez_id&ops=$ops&do=spoglio&id_lista=$id_lista\">$sez_num</a></b></li>\n";
|
---|
168 | }
|
---|
169 | //}
|
---|
170 | echo "</ul></div></td></tr></table>\n";
|
---|
171 | //}// fine tabella per numero sezioni
|
---|
172 | }
|
---|
173 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
174 |
|
---|
175 |
|
---|
176 | function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
|
---|
177 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez;
|
---|
178 |
|
---|
179 | echo "<table border=\"0\" width=\"760\" align=\"left\"><tr>";
|
---|
180 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
|
---|
181 | numeri_sezione(22);
|
---|
182 | echo "\n</td></tr><tr><td>\n";
|
---|
183 |
|
---|
184 |
|
---|
185 | ///////////////////////
|
---|
186 | // Circoscrizione : scelta
|
---|
187 | ///////////////////////
|
---|
188 |
|
---|
189 | $sql="SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
|
---|
190 | ".$prefix."_ele_sede as t2
|
---|
191 | where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'";
|
---|
192 | $resoper = $dbi->prepare("$sql");
|
---|
193 | $resoper->execute();
|
---|
194 |
|
---|
195 |
|
---|
196 | list($id_sede2,$id_circ2) = $resoper->fetch(PDO::FETCH_NUM);
|
---|
197 | if ($id_sede2 and !($id_sede==$id_sede2)) {
|
---|
198 | $id_sede=$id_sede2;
|
---|
199 | $id_circ=$id_circ2;
|
---|
200 | $do="spoglio";
|
---|
201 | $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";
|
---|
202 | $res = $dbi->prepare("$sql");
|
---|
203 | $res->execute();
|
---|
204 |
|
---|
205 |
|
---|
206 | list($id_sez) = $res->fetch(PDO::FETCH_NUM);
|
---|
207 | }
|
---|
208 | if ($do == "circo") {
|
---|
209 | OpenTable();
|
---|
210 | echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
|
---|
211 | ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
212 | ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
|
---|
213 | // Circoscrizione: lista
|
---|
214 | //**************************************
|
---|
215 | .""._CIRCO.": "
|
---|
216 | ."<select name=\"id_circ\">";
|
---|
217 | $sql="SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ";
|
---|
218 | $res = $dbi->prepare("$sql");
|
---|
219 | $res->execute();
|
---|
220 |
|
---|
221 |
|
---|
222 | while(list($id,$descr) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
223 | if ($descr!="Tutte"){
|
---|
224 | if ($id == $id_circ) {
|
---|
225 | $sel = "selected";
|
---|
226 | } else {
|
---|
227 | $sel = "";
|
---|
228 | }
|
---|
229 | echo "<option value=\"$id\" $sel>$descr";
|
---|
230 | }
|
---|
231 | }
|
---|
232 | echo "</select>"
|
---|
233 | //***********************************
|
---|
234 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
235 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
236 | ."</form></td></tr>";
|
---|
237 | CloseTable();
|
---|
238 | }
|
---|
239 |
|
---|
240 | ///////////////////////
|
---|
241 | // sede : scelta
|
---|
242 | ///////////////////////
|
---|
243 |
|
---|
244 |
|
---|
245 | if ($do == "sede") {
|
---|
246 | OpenTable();
|
---|
247 | echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
|
---|
248 | $sql="SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ";
|
---|
249 | $res = $dbi->prepare("$sql");
|
---|
250 | $res->execute();
|
---|
251 |
|
---|
252 |
|
---|
253 | list( $descr_circ) = $res->fetch(PDO::FETCH_NUM);
|
---|
254 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->";
|
---|
255 | echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
256 | ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
257 |
|
---|
258 | // Indirizzo: lista
|
---|
259 | //**************************************
|
---|
260 | .""._INDIRIZZO.": "
|
---|
261 | ."<select name=\"id_sede\">";
|
---|
262 | $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo";
|
---|
263 | $res = $dbi->prepare("$sql");
|
---|
264 | $res->execute();
|
---|
265 |
|
---|
266 |
|
---|
267 | // echo "$id_circ - $id_cons";
|
---|
268 | while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
269 | if ($id == $id_sede) {
|
---|
270 | $sel = "selected";
|
---|
271 | } else {
|
---|
272 | $sel = "";
|
---|
273 | }
|
---|
274 | echo "<option value=\"$id\" $sel>$indir";
|
---|
275 | }
|
---|
276 | echo "</select>"
|
---|
277 | //*************************************
|
---|
278 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
279 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
280 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
281 | ."</form></td></tr>\n";
|
---|
282 | CloseTable();
|
---|
283 | }
|
---|
284 |
|
---|
285 | ///////////////////////
|
---|
286 | // sezione : scelta
|
---|
287 | ///////////////////////
|
---|
288 | if ($do == "spoglio") {
|
---|
289 |
|
---|
290 |
|
---|
291 | //************************************
|
---|
292 | // Menu spoglio
|
---|
293 | //************************************
|
---|
294 | $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'";
|
---|
295 | $result = $dbi->prepare("$sql");
|
---|
296 | $result->execute();
|
---|
297 |
|
---|
298 |
|
---|
299 | list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = $result->fetch(PDO::FETCH_NUM);
|
---|
300 |
|
---|
301 | 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>";
|
---|
302 | 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";
|
---|
303 | if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
|
---|
304 | 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";
|
---|
305 | }
|
---|
306 | if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
|
---|
307 | 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";
|
---|
308 | }
|
---|
309 | echo "</tr></table></td></tr></table><hr>\n";
|
---|
310 |
|
---|
311 | #############
|
---|
312 | # posizionamento in mancanza di scelta
|
---|
313 | #############
|
---|
314 | if (!$ops){
|
---|
315 | if (!$id_sez) { echo"";#import( pagina di help );
|
---|
316 | } else{
|
---|
317 | $sql="SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
|
---|
318 | $res = $dbi->prepare("$sql");
|
---|
319 | $res->execute();
|
---|
320 |
|
---|
321 |
|
---|
322 | list($data,$orario)=$res->fetch(PDO::FETCH_NUM);
|
---|
323 | $sql="SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'";
|
---|
324 | $res = $dbi->prepare("$sql");
|
---|
325 | $res->execute();
|
---|
326 |
|
---|
327 |
|
---|
328 | list($voti) = $res->fetch(PDO::FETCH_NUM);
|
---|
329 | if (!$voti) $ops=1;
|
---|
330 | else {
|
---|
331 | if($genere<4){
|
---|
332 | $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
|
---|
333 | $res = $dbi->prepare("$sql");
|
---|
334 | $res->execute();
|
---|
335 |
|
---|
336 |
|
---|
337 | list($voti) = $res->fetch(PDO::FETCH_NUM);
|
---|
338 | if ($voti==0 or $genere<3) $ops=4;
|
---|
339 | }
|
---|
340 | if(!$ops) $ops=3;
|
---|
341 | }
|
---|
342 |
|
---|
343 | }
|
---|
344 | }
|
---|
345 | ############ fine posizionamento
|
---|
346 |
|
---|
347 | ///////////////////////////////////////////
|
---|
348 | // opzioni per le funzioni di immissione
|
---|
349 |
|
---|
350 | if ($ops == 1) {
|
---|
351 | votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
|
---|
352 | }else{
|
---|
353 | ############# Controllo flag per cancellazione consultazione
|
---|
354 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
355 | ."//-->\n";
|
---|
356 | echo "function del_dati() {\n";
|
---|
357 | echo "if (document.getElementById('pwd3').checked==false) {\n";
|
---|
358 | echo "document.getElementById('update').value=\""._OK."\" \n";
|
---|
359 | echo "document.getElementById('do').value=\"0\" \n";
|
---|
360 | echo "}else{\n";
|
---|
361 | echo "document.getElementById('update').value=\""._DELETE."\" \n";
|
---|
362 | echo "document.getElementById('do').value=\"1\" \n";
|
---|
363 | echo "} \n";
|
---|
364 | echo "} \n";
|
---|
365 | echo "</script>\n";
|
---|
366 | }
|
---|
367 | if ($ops == 3) {
|
---|
368 | preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
369 | }
|
---|
370 | if ($ops == 4) {
|
---|
371 | preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
372 |
|
---|
373 | }
|
---|
374 |
|
---|
375 | }
|
---|
376 | CloseTable();
|
---|
377 |
|
---|
378 | }
|
---|
379 | ////////////////////////////////////////////////////////////////////////////////
|
---|
380 | // FUNZIONI DI IMMISSIONE
|
---|
381 | // - preferenze (candidati consiglieri)
|
---|
382 | // - preferenze_gruppi
|
---|
383 | // - votanti
|
---|
384 | ////////////////////////////////////////////////////////////////////////////////
|
---|
385 |
|
---|
386 | //////////////////////////////////////////////////////////////////////
|
---|
387 | // da qui va la sezione per le preferenze candidati consiglieri
|
---|
388 | //////////////////////////////////////////////////////////////////////
|
---|
389 | function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
390 | global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
|
---|
391 | global $tipo_cons,$limite,$dettnulli,$disgiunto;
|
---|
392 |
|
---|
393 | $bgcolor1="#7777ff";
|
---|
394 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
395 | //controlla se sono stati inseriti i votanti
|
---|
396 | $sql="SELECT preferenze, id_fascia, id_conf,solo_gruppo, disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
|
---|
397 | $result = $dbi->prepare("$sql");
|
---|
398 | $result->execute();
|
---|
399 |
|
---|
400 |
|
---|
401 | list($numprefs,$fascia,$id_conf,$flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
|
---|
402 |
|
---|
403 | ####### 06-11-2014 - circoscrizionali - nello spostamento ad altra sezione resta sullo stesso numero di lista anche se sono sezioni di diverse circoscrizioni
|
---|
404 | if ($circo and $id_lista){
|
---|
405 | $sql="SELECT num_lista from ".$prefix."_ele_lista where id_lista=$id_lista";
|
---|
406 | $res_lis = $dbi->prepare("$sql");
|
---|
407 | $res_lis->execute();
|
---|
408 |
|
---|
409 |
|
---|
410 | list($num_lista)=$res_lis->fetch(PDO::FETCH_NUM);
|
---|
411 | $sql="SELECT id_lista from ".$prefix."_ele_lista where num_lista=$num_lista and id_cons='$id_cons' $circo";
|
---|
412 | $res_lis = $dbi->prepare("$sql");
|
---|
413 | $res_lis->execute();
|
---|
414 |
|
---|
415 |
|
---|
416 | list($id_lista)=$res_lis->fetch(PDO::FETCH_NUM);
|
---|
417 | }
|
---|
418 | #######
|
---|
419 | if(!$votog and ($genere==3 or $genere==5)){
|
---|
420 | $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' ";
|
---|
421 | $result = $dbi->prepare("$sql");
|
---|
422 | $result->execute();
|
---|
423 |
|
---|
424 |
|
---|
425 | }else{
|
---|
426 | $sql="select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
427 | $result = $dbi->prepare("$sql");
|
---|
428 | $result->execute();
|
---|
429 | }
|
---|
430 |
|
---|
431 | list($validi,$nulli,$bianchi,$contestati,$votinulli) = $result->fetch(PDO::FETCH_NUM);
|
---|
432 | echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
|
---|
433 | $sql="SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista";
|
---|
434 | $res_lis = $dbi->prepare("$sql");
|
---|
435 | $res_lis->execute();
|
---|
436 |
|
---|
437 | echo"if(($genere==5 and $id_conf and $fascia<=$limite and !$disgiunto) and !$id_lista) {";
|
---|
438 | $num_liste = $res_lis->rowCount();
|
---|
439 | $ele_lista='';
|
---|
440 | if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
|
---|
441 | 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
|
---|
442 | $sql="SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1";
|
---|
443 | $result = $dbi->prepare("$sql");
|
---|
444 | $result->execute();
|
---|
445 |
|
---|
446 |
|
---|
447 | list($id_lista)=$result->fetch(PDO::FETCH_NUM);
|
---|
448 | }
|
---|
449 | echo "<td> </td></tr><tr><td style=\"vertical-align: top;\">";
|
---|
450 | echo "<form name=\"liste\" action=\"modules/Elezioni/salva_liste.php\">";
|
---|
451 | 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=\">";
|
---|
452 | echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
|
---|
453 | if ($id_lista){
|
---|
454 | echo "<option value=\"0\">"._VOTI_LISTA;
|
---|
455 | $ele_lista=" and t1.id_lista='$id_lista' ";
|
---|
456 | }else{
|
---|
457 | echo "<option value=\"0\" selected>"._VOTI_LISTA;
|
---|
458 | $ele_lista=" group by t1.id_lista ";
|
---|
459 | if(!isset($votolista)) $votolista=0;
|
---|
460 |
|
---|
461 | }
|
---|
462 | while(list($id_rif,$descrizione,$num_lis) = $res_lis->fetch(PDO::FETCH_NUM)) {
|
---|
463 | $segna='';
|
---|
464 | $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";
|
---|
465 | $result = $dbi->prepare("$sql");
|
---|
466 | $result->execute();
|
---|
467 |
|
---|
468 |
|
---|
469 | list($ctrvoticand)=$result->fetch(PDO::FETCH_NUM);
|
---|
470 | $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";
|
---|
471 | $result = $dbi->prepare("$sql");
|
---|
472 | $result->execute();
|
---|
473 |
|
---|
474 |
|
---|
475 | list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
|
---|
476 | if((($fascia>$limite or $disgiunto) or !$id_conf) or $genere==4){
|
---|
477 | $sql="SELECT voti,solo_lista from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'";
|
---|
478 | $result = $dbi->prepare("$sql");
|
---|
479 | $result->execute();
|
---|
480 | }else{
|
---|
481 | $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'";
|
---|
482 | $result = $dbi->prepare("$sql");
|
---|
483 | $result->execute();
|
---|
484 | list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
485 | $sql="SELECT sum(voti),0 from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
486 | $result = $dbi->prepare("$sql");
|
---|
487 | $result->execute();
|
---|
488 | }
|
---|
489 | list($votisezlis,$sgpl)=$result->fetch(PDO::FETCH_NUM);
|
---|
490 | if($votisezcand>($votisezlis*$numprefs))
|
---|
491 | {$segna="style=\"background-color: #dd0000;\"";}
|
---|
492 | elseif($ctrvoticand)
|
---|
493 | $segna="style=\"background-color: #99CC33;\"";
|
---|
494 | $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'";
|
---|
495 | $res4 = $dbi->prepare("$sql");
|
---|
496 | $res4->execute();
|
---|
497 |
|
---|
498 |
|
---|
499 | $errcand[$id_rif]=array();
|
---|
500 | while(list($testvotic,$numcand)=$res4->fetch(PDO::FETCH_NUM))
|
---|
501 | if($votisezlis<$testvotic) { $segna="style=\"background-color: #dd0000;\"";$errcand[$id_rif][]=$numcand;}
|
---|
502 |
|
---|
503 | $sel = ($id_rif == $id_lista) ? "selected" : "";
|
---|
504 | echo "<option $segna value=\"$id_rif\" $sel>";
|
---|
505 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
506 | echo $num_lis.") ".substr($descrizione,0,30);
|
---|
507 | }
|
---|
508 | echo "</select></form></td>\n";
|
---|
509 | }else {
|
---|
510 | $id_lista=0;
|
---|
511 | }
|
---|
512 | echo "<td style=\"vertical-align: top;\">";
|
---|
513 |
|
---|
514 | if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
|
---|
515 | if(($genere==4 or ($genere==5 and $votog)) and !$id_lista) {
|
---|
516 | $sql="SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.nulli,t2.contestati,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";
|
---|
517 | $result = $dbi->prepare("$sql");
|
---|
518 | $result->execute();
|
---|
519 |
|
---|
520 |
|
---|
521 | }else{
|
---|
522 | $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";
|
---|
523 | $result = $dbi->prepare("$sql");
|
---|
524 | $result->execute();
|
---|
525 | }
|
---|
526 |
|
---|
527 | // 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
|
---|
528 | $isscr= $result->rowCount();
|
---|
529 | list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2,$sgpl) = $result->fetch(PDO::FETCH_NUM);
|
---|
530 | if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
|
---|
531 | $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
|
---|
532 | $resg = $dbi->prepare("$sql");
|
---|
533 | $resg->execute();
|
---|
534 |
|
---|
535 |
|
---|
536 | list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
|
---|
537 | 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>";
|
---|
538 | }
|
---|
539 | $valista=$validi2;
|
---|
540 | if(!$id_lista or $genere==3){ //controllo di congruenza
|
---|
541 | $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
542 | $res2 = $dbi->prepare("$sql");
|
---|
543 | $res2->execute();
|
---|
544 |
|
---|
545 |
|
---|
546 | list($tot) = $res2->fetch(PDO::FETCH_NUM);
|
---|
547 | if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
|
---|
548 | 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>";
|
---|
549 | }
|
---|
550 |
|
---|
551 | if((($voti_sez)!=$validi2) and ($voti_sez>0)){
|
---|
552 | 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>";
|
---|
553 | }
|
---|
554 | }elseif($genere==5){
|
---|
555 | $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";
|
---|
556 | $result = $dbi->prepare("$sql");
|
---|
557 | $result->execute();
|
---|
558 |
|
---|
559 |
|
---|
560 | list($votisezcand)=$result->fetch(PDO::FETCH_NUM);
|
---|
561 | if(($fascia>$limite or $disgiunto) or !$id_conf){
|
---|
562 | $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'";
|
---|
563 | $result = $dbi->prepare("$sql");
|
---|
564 | $result->execute();
|
---|
565 |
|
---|
566 |
|
---|
567 | }else{
|
---|
568 |
|
---|
569 | $sql="SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'";
|
---|
570 | $result = $dbi->prepare("$sql");
|
---|
571 | $result->execute();
|
---|
572 |
|
---|
573 |
|
---|
574 | list($id_gruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
575 | $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
576 | $result = $dbi->prepare("$sql");
|
---|
577 | $result->execute();
|
---|
578 |
|
---|
579 |
|
---|
580 | }
|
---|
581 | list($votisezlis)=$result->fetch(PDO::FETCH_NUM);
|
---|
582 | if($votisezcand>($votisezlis*$numprefs))
|
---|
583 | {
|
---|
584 | 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>";
|
---|
585 | }
|
---|
586 | }
|
---|
587 | #controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
|
---|
588 | $errgrulis=array();
|
---|
589 | if($genere==5 and !$disgiunto and ($tipo_cons==18 or $tipo_cons==19)){
|
---|
590 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
|
---|
591 | $resref = $dbi->prepare("$sql");
|
---|
592 | $resref->execute();
|
---|
593 |
|
---|
594 |
|
---|
595 | $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
|
---|
596 | $res4 = $dbi->prepare("$sql");
|
---|
597 | $res4->execute();
|
---|
598 |
|
---|
599 |
|
---|
600 | list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
|
---|
601 | if ($sezscrl)
|
---|
602 |
|
---|
603 | while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
|
---|
604 | {
|
---|
605 | $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
606 | $res3 = $dbi->prepare("$sql");
|
---|
607 | $res3->execute();
|
---|
608 |
|
---|
609 |
|
---|
610 | $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')";
|
---|
611 | $res4 = $dbi->prepare("$sql");
|
---|
612 | $res4->execute();
|
---|
613 |
|
---|
614 |
|
---|
615 | list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
|
---|
616 | list($vliste)=$res4->fetch(PDO::FETCH_NUM);
|
---|
617 | if($vliste>$vgruppo)
|
---|
618 | {
|
---|
619 | $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
620 | $result = $dbi->prepare("$sql");
|
---|
621 | $result->execute();
|
---|
622 |
|
---|
623 |
|
---|
624 | list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
625 | 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>";
|
---|
626 | $errgrulis[$id_gruppo]=1;
|
---|
627 | }
|
---|
628 | elseif($vliste<$vgruppo)
|
---|
629 | {
|
---|
630 | $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
631 | $result = $dbi->prepare("$sql");
|
---|
632 | $result->execute();
|
---|
633 |
|
---|
634 |
|
---|
635 | list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
636 | 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>";
|
---|
637 | $errgrulis[$id_gruppo]=1;
|
---|
638 | }
|
---|
639 | }
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 |
|
---|
644 | echo "\n<form name=\"sezioni\" action=\"modules/Elezioni/salva_liste.php\">"
|
---|
645 | ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
|
---|
646 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
647 | ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
|
---|
648 | ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
|
---|
649 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
650 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
651 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
652 | ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
|
---|
653 | ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
|
---|
654 | ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
|
---|
655 | echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
|
---|
656 | echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
|
---|
657 | if ($genere<4){
|
---|
658 | // echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
|
---|
659 | }
|
---|
660 | echo "<b>"._NUM."</b></td>";
|
---|
661 | if($id_lista){
|
---|
662 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
|
---|
663 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
664 | }else{
|
---|
665 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
|
---|
666 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
667 | if($dettnulli && !$disgiunto && $tipo_cons!=18 && $tipo_cons!=19)
|
---|
668 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NULLI_LISTE."</b></td>";
|
---|
669 | if($disgiunto){
|
---|
670 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLOLIS."</b></td>";
|
---|
671 | }
|
---|
672 | }
|
---|
673 | echo "</tr>\n";
|
---|
674 |
|
---|
675 |
|
---|
676 |
|
---|
677 |
|
---|
678 |
|
---|
679 | $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";
|
---|
680 | $result = $dbi->prepare("$sql");
|
---|
681 | $result->execute();
|
---|
682 |
|
---|
683 |
|
---|
684 | $max = $result->rowCount();
|
---|
685 | $tot_pref=0;
|
---|
686 | $i=1;
|
---|
687 |
|
---|
688 | if($id_lista) {
|
---|
689 | while(list($id_cand,$id_cons2,$id_lista2,$nl, $cognome, $nome, $note, $simbolo, $num_cand) = $result->fetch(PDO::FETCH_NUM)){
|
---|
690 | // dati lista
|
---|
691 | $sql="select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'";
|
---|
692 | $result1 = $dbi->prepare("$sql");
|
---|
693 | $result1->execute();
|
---|
694 |
|
---|
695 |
|
---|
696 | list($id_lista3,$descr_lista,$simb_lista,$num_lista)=$result1->fetch(PDO::FETCH_NUM);
|
---|
697 | // dati gruppo
|
---|
698 | $sql="select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
699 | $result2 = $dbi->prepare("$sql");
|
---|
700 | $result2->execute();
|
---|
701 |
|
---|
702 |
|
---|
703 | list($descr_gruppo,$simb_gruppo)=$result2->fetch(PDO::FETCH_NUM);
|
---|
704 |
|
---|
705 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
706 | if ($genere<4){
|
---|
707 | echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
|
---|
708 | }
|
---|
709 | echo "<td align=\"center\"><b> $num_cand </b></td>"
|
---|
710 | ."<td align=\"left\"><b>$cognome $nome</b></td>";
|
---|
711 | $cond_sele="and id_cand=$id_cand";
|
---|
712 | $sql="SELECT voti FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele";
|
---|
713 | $res = $dbi->prepare("$sql");
|
---|
714 | $res->execute();
|
---|
715 |
|
---|
716 |
|
---|
717 | list($voti)= $res->fetch(PDO::FETCH_NUM);
|
---|
718 | if(in_array($num_cand,$errcand[$id_lista])) $errcolor="style=\"background-color: rgb(255, 0, 0);\""; else $errcolor='';
|
---|
719 | echo "<td align=\"right\" $errcolor><input name=\"voti$num_cand\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
|
---|
720 | echo "<input type=\"hidden\" name=\"id_cand$num_cand\" value=\"$id_cand\"></td></tr>\n";
|
---|
721 | $i++;
|
---|
722 | $tot_pref+=$voti;
|
---|
723 | }
|
---|
724 | }else {
|
---|
725 | $sql="select t2.voti,t1.id_lista, descrizione,simbolo,t1.num_lista,t2.nulli_lista,t2.solo_lista,t1.id_gruppo
|
---|
726 | from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
|
---|
727 | where t1.id_cons='$id_cons'
|
---|
728 | and t1.id_lista=t2.id_lista
|
---|
729 | and t2.id_sez=$id_sez
|
---|
730 | order by t1.num_lista";
|
---|
731 |
|
---|
732 | try {
|
---|
733 | $result1 = $dbi->prepare("$sql");
|
---|
734 | $result1->execute();
|
---|
735 |
|
---|
736 | }
|
---|
737 | catch(PDOException $e)
|
---|
738 | {
|
---|
739 | echo $sql . "<br>" . $e->getMessage();
|
---|
740 | }
|
---|
741 |
|
---|
742 | $num_lista=$result1->rowCount();
|
---|
743 | if (!$num_lista){
|
---|
744 | $sql="select '0',id_lista, descrizione,simbolo,num_lista,'','',id_gruppo
|
---|
745 | from ".$prefix."_ele_lista where id_cons='$id_cons' $circo
|
---|
746 | order by num_lista";
|
---|
747 | $result1 = $dbi->prepare("$sql");
|
---|
748 | $result1->execute();
|
---|
749 |
|
---|
750 |
|
---|
751 | }
|
---|
752 | while (list($voti,$id_lista3,$descr_lista,$simb_lista,$num_lista,$vnpl,$slpl,$rifgruppo)=$result1->fetch(PDO::FETCH_NUM)){
|
---|
753 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
754 | // if ($genere<4 or $votoc){
|
---|
755 | // }
|
---|
756 | $errcolor='';
|
---|
757 | if(isset($errgrulis[$rifgruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
|
---|
758 | echo "<td align=\"center\"><b> $num_lista </b></td>"
|
---|
759 | ."<td align=\"left\"><b> $descr_lista</b></td>";
|
---|
760 | $cond_sele="and id_lista=$id_lista3";
|
---|
761 | echo "<td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$voti."\" size=\"7\" style=\"text-align:right\">";
|
---|
762 | 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\">";
|
---|
763 | if($disgiunto) echo "</td><td align=\"right\"><input name=\"slpl$i\" value=\"".$slpl."\" size=\"7\" style=\"text-align:right\">";
|
---|
764 | echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td>";
|
---|
765 | // echo "<td align=\"right\">$sgpl";
|
---|
766 | echo "</tr>\n";
|
---|
767 | $i++;
|
---|
768 | $tot_pref+=$voti;
|
---|
769 | }
|
---|
770 | }
|
---|
771 | if(!$id_lista) echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOT._VOTI_LISTA."</td><td align=\"center\">$tot_pref</td></tr>";
|
---|
772 | else echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
|
---|
773 | // toglie ai candidati la visual... del solo_gruppo
|
---|
774 | if(!$votog) {
|
---|
775 | if (($genere==3 OR $genere==5) and (!$id_lista) and (($disgiunto or $fascia>$limite) or !$id_conf)) { //gruppo e liste
|
---|
776 | 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>";
|
---|
777 | 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>";
|
---|
778 | 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\">"
|
---|
779 | ."</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>";
|
---|
780 |
|
---|
781 | }elseif (($genere==3 OR $genere==5) and !$votoc and (($disgiunto or $fascia>$limite) or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
|
---|
782 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
|
---|
783 | }
|
---|
784 | ######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
|
---|
785 | elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf) and $numprefs==1) {
|
---|
786 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'";
|
---|
787 | $resvg = $dbi->prepare("$sql");
|
---|
788 | $resvg->execute();
|
---|
789 |
|
---|
790 |
|
---|
791 | list($id_gruppo) = $resvg->fetch(PDO::FETCH_NUM);
|
---|
792 | $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'";
|
---|
793 | $resvg = $dbi->prepare("$sql");
|
---|
794 | $resvg->execute();
|
---|
795 |
|
---|
796 |
|
---|
797 | list($voti_sind) = $resvg;
|
---|
798 |
|
---|
799 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
|
---|
800 | }
|
---|
801 | ###### fine modifica del 16-04-2009
|
---|
802 |
|
---|
803 | }
|
---|
804 | echo "<tr>";
|
---|
805 | echo "<td></td><td></td>";
|
---|
806 | echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
|
---|
807 | echo "</tr></table>";
|
---|
808 | if(chisei($id_cons_gen)>=64){
|
---|
809 | echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"1\">"._DELETE."</td>";
|
---|
810 | } # onclick=\"javascript:del_dati()\"
|
---|
811 | echo "</form></tr></table>";
|
---|
812 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
813 | ."document.sezioni.voti1.focus()\n"
|
---|
814 | ."document.sezioni.voti1.select()\n"
|
---|
815 | ."//-->\n";
|
---|
816 | echo "function vai_lista() {\n";
|
---|
817 | echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
|
---|
818 | echo "}\n";
|
---|
819 | echo "</script>\n";
|
---|
820 | # }
|
---|
821 | #if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
|
---|
822 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
823 | }
|
---|
824 |
|
---|
825 | /////////////////////////////////////////////
|
---|
826 | // registra le preferenze ai candidati
|
---|
827 | /////////////////////////////////////////////
|
---|
828 |
|
---|
829 | function rec_voti() {
|
---|
830 | global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update,$dettnulli,$disgiunto,$tipo_cons;
|
---|
831 |
|
---|
832 | $sql="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
|
---|
833 | if($res)
|
---|
834 | list($fascia,$id_conf)=$res->fetch(PDO::FETCH_NUM);
|
---|
835 | else {$fascia=0; $id_conf=0;}
|
---|
836 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
837 | $username=$aid;
|
---|
838 | $log_data= date("Y/m/d");
|
---|
839 | $log_ora=getdate(time());
|
---|
840 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
841 | $arg2 = func_get_args();
|
---|
842 | $arg = preg_split("/\,+/",$arg2[0]);
|
---|
843 | $id_cons_gen=intval($arg[1]);
|
---|
844 | $id_sez = intval($arg[2]);
|
---|
845 | $id_circ = intval($arg[3]);
|
---|
846 | $id_sede = intval($arg[4]);
|
---|
847 | $tab = $arg[5];
|
---|
848 | $id_lista = intval($arg[6]);
|
---|
849 | $do= intval($arg[7]);
|
---|
850 | if ($tab=="_ele_voti_candidati") {
|
---|
851 | $condizione="id_cand";
|
---|
852 | }else{
|
---|
853 | $condizione="id_lista";
|
---|
854 | }
|
---|
855 | if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and (($disgiunto or $fascia>$limite) or !$id_conf)) $y = (count($arg)-4);
|
---|
856 | else $y=count($arg);#die ("delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'");
|
---|
857 | $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
858 | $res = $dbi->prepare("$sql");
|
---|
859 | $res->execute();
|
---|
860 |
|
---|
861 |
|
---|
862 | if($do==1) {
|
---|
863 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
864 | $res = $dbi->prepare("$sql");
|
---|
865 | $res->execute();
|
---|
866 |
|
---|
867 |
|
---|
868 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
869 | $res = $dbi->prepare("$sql");
|
---|
870 | $res->execute();
|
---|
871 |
|
---|
872 |
|
---|
873 | if($genere!=4)
|
---|
874 | $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'";
|
---|
875 | $res = $dbi->prepare("$sql");
|
---|
876 | $res->execute();
|
---|
877 |
|
---|
878 |
|
---|
879 |
|
---|
880 | }else{
|
---|
881 | for($i=8,$y--;$i< $y;$i++) {
|
---|
882 | $voti = intval($arg[$i++]);
|
---|
883 | $vnrigains=",'0'";
|
---|
884 | $vnriga='';
|
---|
885 | 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="";}
|
---|
886 | 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="";}
|
---|
887 | $id_cand = intval($arg[$i]);
|
---|
888 | $sql="select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'";
|
---|
889 | $result = $dbi->prepare("$sql");
|
---|
890 | $result->execute();
|
---|
891 |
|
---|
892 |
|
---|
893 | $ar=$result->fetch(PDO::FETCH_BOTH);
|
---|
894 |
|
---|
895 | if ($ar){
|
---|
896 | #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'");
|
---|
897 | if ($ar['voti']!=$voti or (isset($vnpl) and $ar['nulli_lista']!=$vnpl) or (isset($slpl) and $ar['solo_lista']!=$slpl)) {
|
---|
898 | $sql="update ".$prefix."$tab set voti='$voti'$vnriga where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'";
|
---|
899 | $res = $dbi->prepare("$sql");
|
---|
900 | $res->execute();
|
---|
901 |
|
---|
902 |
|
---|
903 | 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");
|
---|
904 | $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')";
|
---|
905 | $res = $dbi->prepare("$sql");
|
---|
906 | $res->execute();
|
---|
907 |
|
---|
908 |
|
---|
909 | }
|
---|
910 | } else {//die ("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)");
|
---|
911 | if ($voti)
|
---|
912 | $sql="insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')";
|
---|
913 | $res = $dbi->prepare("$sql");
|
---|
914 | $res->execute();
|
---|
915 |
|
---|
916 |
|
---|
917 | $sql="insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti'$vnrigains)";
|
---|
918 | $res = $dbi->prepare("$sql");
|
---|
919 | $res->execute();
|
---|
920 |
|
---|
921 |
|
---|
922 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
|
---|
923 | }
|
---|
924 | }
|
---|
925 | // foreach ($arg as $vval) echo $vval." - ";
|
---|
926 | // solo gruppo e preferenze alle liste
|
---|
927 |
|
---|
928 | if(!$votog) {
|
---|
929 | if ((($genere==3) OR ($genere==5)) and !$id_lista and (($disgiunto or $fascia>$limite) or !$id_conf)) {
|
---|
930 | $valista=$arg[$i++];
|
---|
931 | $sql="update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'";
|
---|
932 | $res = $dbi->prepare("$sql");
|
---|
933 | $res->execute();
|
---|
934 |
|
---|
935 |
|
---|
936 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
|
---|
937 | if ($condizione=="id_lista"){
|
---|
938 | $sql="select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'";
|
---|
939 | $result = $dbi->prepare("$sql");
|
---|
940 | $result->execute();
|
---|
941 |
|
---|
942 |
|
---|
943 | $ar=$result->fetch(PDO::FETCH_BOTH);
|
---|
944 | ++$i;
|
---|
945 | $sql="update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'";
|
---|
946 | $res = $dbi->prepare("$sql");
|
---|
947 | $res->execute();
|
---|
948 |
|
---|
949 |
|
---|
950 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
|
---|
951 | if ($ar['validi']){
|
---|
952 |
|
---|
953 |
|
---|
954 | if($valista) {
|
---|
955 | $sql="update ".$prefix."_ele_sezioni set validi_lista='$valista' where id_sez='$id_sez'";
|
---|
956 | $res = $dbi->prepare("$sql");
|
---|
957 | $res->execute();
|
---|
958 |
|
---|
959 |
|
---|
960 | }else{
|
---|
961 | $sql="update ".$prefix."_ele_sezioni set validi_lista=(`validi`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'";
|
---|
962 | $res = $dbi->prepare("$sql");
|
---|
963 | $res->execute();}
|
---|
964 |
|
---|
965 |
|
---|
966 | 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");
|
---|
967 | }
|
---|
968 | }
|
---|
969 | }
|
---|
970 | }
|
---|
971 | }
|
---|
972 |
|
---|
973 | // $ops = $arg[$argc];
|
---|
974 | if ($fileout)fclose($fp);
|
---|
975 | 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");
|
---|
976 | }
|
---|
977 |
|
---|
978 |
|
---|
979 | ////////////////////////////////////////////
|
---|
980 | // da qua va la sezione per i votanti
|
---|
981 | ///////////////////////////////////////////
|
---|
982 |
|
---|
983 | function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
984 | //function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
985 | global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen,$id_comune;
|
---|
986 | $bgcolor1=$_SESSION['bgcolor2'];
|
---|
987 |
|
---|
988 | #OpenTable();
|
---|
989 | $sql="SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
|
---|
990 | $res = $dbi->prepare("$sql");
|
---|
991 | $res->execute();
|
---|
992 |
|
---|
993 |
|
---|
994 | if($res) list($vismf)= $res->fetch(PDO::FETCH_NUM); else $vismf=0;
|
---|
995 | $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ";
|
---|
996 | $res = $dbi->prepare("$sql");
|
---|
997 | $res->execute();
|
---|
998 |
|
---|
999 | echo "<table><tr><td>";
|
---|
1000 | $num = $res->rowCount();
|
---|
1001 | $sql="SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez";
|
---|
1002 | $ressez = $dbi->prepare("$sql");
|
---|
1003 | $ressez->execute();
|
---|
1004 | ##################
|
---|
1005 | echo "<style>";
|
---|
1006 | echo "DIV.table";
|
---|
1007 | echo "{
|
---|
1008 | display:table;
|
---|
1009 | }
|
---|
1010 | FORM.tr
|
---|
1011 | {
|
---|
1012 | display:table-row;
|
---|
1013 | text-align: center;
|
---|
1014 | }
|
---|
1015 | DIV.tr
|
---|
1016 | {
|
---|
1017 | display:table-row;
|
---|
1018 | background-color: #D3D3D3;
|
---|
1019 | text-align: center;
|
---|
1020 | }
|
---|
1021 | SPAN.tdm
|
---|
1022 | {
|
---|
1023 | display:table-cell;
|
---|
1024 | border: 1px solid black;
|
---|
1025 | padding: 5px;
|
---|
1026 | }
|
---|
1027 | SPAN.td
|
---|
1028 | {
|
---|
1029 | display:table-cell;
|
---|
1030 | }";
|
---|
1031 | echo "</style>";
|
---|
1032 |
|
---|
1033 | /*
|
---|
1034 | echo "<form class=\"tr\" name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
|
---|
1035 | echo "<span class=\"td\"><input type=\"text\"/></span>";
|
---|
1036 | <span class="td"><input type="text"/></span>
|
---|
1037 | </form>
|
---|
1038 | <div class="tr">
|
---|
1039 | <span class="td">(cell data)</span>
|
---|
1040 | <span class="td">(cell data)</span>
|
---|
1041 | </div>
|
---|
1042 | ...
|
---|
1043 | </div>
|
---|
1044 | */
|
---|
1045 | ##################
|
---|
1046 |
|
---|
1047 | list($maschi,$femmine)=$ressez->fetch(PDO::FETCH_NUM);
|
---|
1048 | $y=0;
|
---|
1049 | echo "<div class=\"table\">";
|
---|
1050 | #echo "<tr><td> </td></tr>";
|
---|
1051 | $riga=array();
|
---|
1052 | $rigat=array();
|
---|
1053 | while (list($ora,$giorno)= $res->fetch(PDO::FETCH_NUM)){
|
---|
1054 | $y++;
|
---|
1055 | $rigat[$y]='';
|
---|
1056 | $riga[$y]='';
|
---|
1057 | # echo "\n<tr><td>";
|
---|
1058 | # echo "<form name=\"votanti$y\" action=\"modules/Elezioni/salva_aff.php\">";
|
---|
1059 | # echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
|
---|
1060 | $rigat[$y]= "<div class=\"tr\">";
|
---|
1061 | if ($genere==0){ //e' un referendum
|
---|
1062 | # echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
|
---|
1063 | $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></span>";
|
---|
1064 | }
|
---|
1065 | $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></span>"
|
---|
1066 | ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._DATA."</b></span>";
|
---|
1067 | $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></span>";
|
---|
1068 | $rigat[$y].= "<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></span>"
|
---|
1069 | ."<span class=\"tdm\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b></span>";
|
---|
1070 | if ($genere==0){
|
---|
1071 | $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
|
---|
1072 | $res2 = $dbi->prepare("$sql");
|
---|
1073 | $res2->execute();
|
---|
1074 |
|
---|
1075 |
|
---|
1076 | $max = $res2->rowCount();
|
---|
1077 | }else{ $max=1;} $op="rec_add_votanti";
|
---|
1078 | $rigat[$y].= "</div>";
|
---|
1079 |
|
---|
1080 | for ($i=1;$i<=$max;$i++){
|
---|
1081 | $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
|
---|
1082 | on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
|
---|
1083 | and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
1084 | if ($genere==0){
|
---|
1085 | $query.=" and t2.num_gruppo=$i";
|
---|
1086 | }
|
---|
1087 | $sql=$query;
|
---|
1088 | $result = $dbi->prepare("$sql");
|
---|
1089 | $result->execute();
|
---|
1090 |
|
---|
1091 |
|
---|
1092 | list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = $result->fetch(PDO::FETCH_NUM);
|
---|
1093 | $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo' ";
|
---|
1094 | $res2 = $dbi->prepare("$sql");
|
---|
1095 | $res2->execute();
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | $sql="select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
1099 | $resril = $dbi->prepare("$sql");
|
---|
1100 | $resril->execute();
|
---|
1101 |
|
---|
1102 |
|
---|
1103 | list($numril)=$resril->fetch(PDO::FETCH_NUM);
|
---|
1104 | if ($res2)
|
---|
1105 | list($gruppo)= $res2->fetch(PDO::FETCH_NUM);
|
---|
1106 | else
|
---|
1107 | $gruppo=0;
|
---|
1108 | if (!$gruppo>0) {
|
---|
1109 | $gruppo=$i;
|
---|
1110 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons";
|
---|
1111 | $res3 = $dbi->prepare("$sql");
|
---|
1112 | $res3->execute();
|
---|
1113 |
|
---|
1114 |
|
---|
1115 | if ($res3)
|
---|
1116 | list($id_gruppo)=$res3->fetch(PDO::FETCH_NUM);
|
---|
1117 | }
|
---|
1118 | if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
|
---|
1119 | if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
|
---|
1120 | $precede[$id_gruppo]=$voti_t;
|
---|
1121 | if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
|
---|
1122 | # echo "</tr><tr styl.e=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
|
---|
1123 | $riga[$y].= "<form class=\"tr\" style=\"background-color: rgb(255, 0, 0); text-align: center\" name=\"votanti\" action=\"modules/Elezioni/salva_aff.php\">";
|
---|
1124 | }else{
|
---|
1125 | $riga[$y].= "<form class=\"tr\" action=\"modules/Elezioni/salva_aff.php\">";
|
---|
1126 | }
|
---|
1127 | if ($genere==0){ // e' un referendum
|
---|
1128 | $riga[$y].= "<span class=\"td\" align=\"center\">$gruppo</span>";
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 |
|
---|
1132 | $riga[$y].= "<span class=\"td\"><input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\"/>";
|
---|
1133 | $riga[$y].= "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"/>"
|
---|
1134 | ."<input type=\"hidden\" name=\"genere\" value=\"$genere\"/>"
|
---|
1135 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"/>"
|
---|
1136 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\"/>"
|
---|
1137 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\"/>";
|
---|
1138 | #$riga[$y].= "</span>";
|
---|
1139 | list ($anno,$mese,$di)=explode('-',$giorno);
|
---|
1140 | $riga[$y].= "$ora</span><span class=\"td\" align=\"center\">$di-$mese-$anno</span>";
|
---|
1141 | if ($voti_u > $maschi) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\">";
|
---|
1142 | else $riga[$y].= "<span class=\"td\" align=\"center\">";
|
---|
1143 | 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\"";
|
---|
1144 | $riga[$y].= " size=\"5\"/></span>";
|
---|
1145 | if ($voti_d > $femmine) $riga[$y].= "<span class=\"td\" align=\"center\" bgcolor=\"red\"/>";
|
---|
1146 | else $riga[$y].= "<span class=\"td\" align=\"center\">";
|
---|
1147 | 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\"";
|
---|
1148 | $riga[$y].= " size=\"5\"/></span>";
|
---|
1149 | 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\"/>";
|
---|
1150 | 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\"/>";
|
---|
1151 | $riga[$y].= "<input type=\"hidden\" name=\"id_parz\" value=\"$id_parz\"/>"
|
---|
1152 | ."<input type=\"hidden\" name=\"data\" value=\"$giorno\"/>"
|
---|
1153 | ."<input type=\"hidden\" name=\"orario\" value=\"$ora\"/>"
|
---|
1154 | ."<input type=\"hidden\" name=\"id_comune\" value=\"$id_comune\"/>"
|
---|
1155 | ."<input type=\"hidden\" name=\"id_gruppo\" value=\"$id_gruppo\"/>";
|
---|
1156 | $riga[$y].= "</span>";
|
---|
1157 |
|
---|
1158 | 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>";
|
---|
1159 | else $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"/></span>";
|
---|
1160 | $riga[$y].= "<span class=\"td\" style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"/></span>";
|
---|
1161 | $riga[$y].= "</form>";
|
---|
1162 |
|
---|
1163 | }
|
---|
1164 | # echo "</table></form>";
|
---|
1165 | echo "</div>";
|
---|
1166 |
|
---|
1167 |
|
---|
1168 | $sql="select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez";
|
---|
1169 | $compl = $dbi->prepare("$sql");
|
---|
1170 | $compl->execute();
|
---|
1171 |
|
---|
1172 |
|
---|
1173 | list ($complessivi)= $compl->fetch(PDO::FETCH_NUM);
|
---|
1174 | if (!$complessivi)
|
---|
1175 | {
|
---|
1176 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
1177 | $numy=$y.'1';
|
---|
1178 | if ($y==$num) {
|
---|
1179 | echo "document.votanti$y.voti_u$numy.focus()\n";
|
---|
1180 | echo "document.votanti$y.voti_u$numy.select()\n";
|
---|
1181 | }else{
|
---|
1182 | echo "this.voti_t$numy.focus()\n";
|
---|
1183 | echo "this.voti_t$numy.select()\n";
|
---|
1184 | }
|
---|
1185 | echo "//-->\n"
|
---|
1186 | ."</script>\n";
|
---|
1187 | break;
|
---|
1188 | }
|
---|
1189 | # echo "</td></tr>";
|
---|
1190 | }
|
---|
1191 | #CloseTable();
|
---|
1192 | foreach($riga as $key=>$val){
|
---|
1193 | echo $rigat[$key];
|
---|
1194 | echo $riga[$key];
|
---|
1195 | }
|
---|
1196 | echo "</div></td></tr></table>";
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 |
|
---|
1200 |
|
---|
1201 | function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
1202 | global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
|
---|
1203 | ////////////////////////////////////////////
|
---|
1204 | // da qua va la sezione per i voti finali
|
---|
1205 | ///////////////////////////////////////////
|
---|
1206 | $bgcolor1="#7777ff";
|
---|
1207 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
1208 |
|
---|
1209 |
|
---|
1210 |
|
---|
1211 | echo "<form name=\"spogliovoti\" action=\"modules/Elezioni/salva_voti.php\">"
|
---|
1212 | ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
|
---|
1213 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
1214 | ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
|
---|
1215 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
1216 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
1217 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
1218 |
|
---|
1219 | echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
|
---|
1220 | /* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
1221 | echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
|
---|
1222 | else */
|
---|
1223 | echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
|
---|
1224 | echo "<td width=\"82\"><b>"._NULLI."</b></td>"
|
---|
1225 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
1226 | ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
|
---|
1227 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
1228 | ."<td><b>"._TOTNON."</b></td>"
|
---|
1229 | ."<td><b>"._TOTALEVOTI."</b></td>"
|
---|
1230 | ."<td bgcolor=\"#ffffff\"></td> </tr>";
|
---|
1231 | /*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
1232 | $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' ";
|
---|
1233 | $res = $dbi->prepare("$sql");
|
---|
1234 | $res->execute();
|
---|
1235 |
|
---|
1236 |
|
---|
1237 | else */
|
---|
1238 | $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' ";
|
---|
1239 | $result = $dbi->prepare("$sql");
|
---|
1240 | $result->execute();
|
---|
1241 |
|
---|
1242 |
|
---|
1243 | list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = $result->fetch(PDO::FETCH_NUM);
|
---|
1244 | $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
|
---|
1245 | $tot_voti=$validi+$tot_nulli+$conts+$nullis;
|
---|
1246 | // ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
|
---|
1247 |
|
---|
1248 |
|
---|
1249 | echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
|
---|
1250 | /* if(($genere==3 or $genere==5) and !$votog and $ops==3){
|
---|
1251 | echo "</td><td>$nulli"
|
---|
1252 | ."</td><td>$bianchi";
|
---|
1253 | echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
|
---|
1254 | }else{ */
|
---|
1255 | echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
|
---|
1256 | ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
|
---|
1257 | // }
|
---|
1258 | echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
|
---|
1259 | ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
|
---|
1260 | ."</td><td>$tot_nulli"
|
---|
1261 | ."</td><td>$tot_voti</td><td>"
|
---|
1262 | ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
|
---|
1263 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
|
---|
1264 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
1265 | ."</td></tr></table></form>"; //</td></tr>";
|
---|
1266 |
|
---|
1267 |
|
---|
1268 | // echo "</table>";
|
---|
1269 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
1270 | if (!$validi) {
|
---|
1271 | echo "document.spogliovoti.validi.focus()\n";
|
---|
1272 | echo "document.spogliovoti.validi.select()\n";
|
---|
1273 | }
|
---|
1274 | echo "//-->\n"
|
---|
1275 | ."</script>\n";
|
---|
1276 |
|
---|
1277 |
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 |
|
---|
1281 |
|
---|
1282 |
|
---|
1283 |
|
---|
1284 |
|
---|
1285 | ///////////////////////////
|
---|
1286 | // registra voti finali
|
---|
1287 | ///////////////////////////
|
---|
1288 |
|
---|
1289 | function rec_finale() {
|
---|
1290 | global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
|
---|
1291 |
|
---|
1292 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
1293 | $arg2 = func_get_args();
|
---|
1294 | $arg = split(",",$arg2[0]);
|
---|
1295 | $id_cons_gen=intval($arg[1]);
|
---|
1296 | $id_sez = intval($arg[2]);
|
---|
1297 | $id_circ = intval($arg[3]);
|
---|
1298 | $id_sede = intval($arg[4]);
|
---|
1299 | $validi = intval($arg[5]);
|
---|
1300 | $nulli = intval($arg[6]);
|
---|
1301 | $bianchi = intval($arg[7]);
|
---|
1302 | $votinulli = intval($arg[8]);
|
---|
1303 | $contestati = intval($arg[9]);
|
---|
1304 | //$sololista = intval($arg[10]);
|
---|
1305 | $ops = $arg[10];
|
---|
1306 | $username="$aid";
|
---|
1307 | $log_data= date("Y/m/d");
|
---|
1308 | $log_ora=getdate(time());
|
---|
1309 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
1310 | $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1311 | $res = $dbi->prepare("$sql");
|
---|
1312 | $res->execute();
|
---|
1313 |
|
---|
1314 |
|
---|
1315 |
|
---|
1316 | $sql="select voti_complessivi from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' order by id_parz desc";
|
---|
1317 | $result = $dbi->prepare("$sql");
|
---|
1318 | $result->execute();
|
---|
1319 |
|
---|
1320 |
|
---|
1321 | list($voti_t) = $result->fetch(PDO::FETCH_NUM);
|
---|
1322 | $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
|
---|
1323 | $sololista=$voti_t-$tot_voti;
|
---|
1324 | $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
1325 | $result = $dbi->prepare("$sql");
|
---|
1326 | $result->execute();
|
---|
1327 |
|
---|
1328 |
|
---|
1329 | list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
|
---|
1330 | $sql="select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ";
|
---|
1331 | $result = $dbi->prepare("$sql");
|
---|
1332 | $result->execute();
|
---|
1333 |
|
---|
1334 |
|
---|
1335 | $ar=$result->fetch(PDO::FETCH_NUM);
|
---|
1336 | $validilista=$validi-$ar['solo_gruppo'];
|
---|
1337 | if ($ar['solo_lista'] or !$disgiunto) $rigasl=''; else $rigasl=", solo_lista='$sololista'";
|
---|
1338 | #die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
|
---|
1339 | if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
1340 | $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')";
|
---|
1341 | $res = $dbi->prepare("$sql");
|
---|
1342 | $res->execute();
|
---|
1343 |
|
---|
1344 |
|
---|
1345 |
|
---|
1346 | /* $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' ";
|
---|
1347 | $res = $dbi->prepare("$sql");
|
---|
1348 | $res->execute();
|
---|
1349 |
|
---|
1350 |
|
---|
1351 | 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"); */
|
---|
1352 | $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' ";
|
---|
1353 | $res = $dbi->prepare("$sql");
|
---|
1354 | $res->execute();
|
---|
1355 |
|
---|
1356 |
|
---|
1357 | 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");
|
---|
1358 | }else{
|
---|
1359 | $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')";
|
---|
1360 | $res = $dbi->prepare("$sql");
|
---|
1361 | $res->execute();
|
---|
1362 |
|
---|
1363 |
|
---|
1364 | $valista="";
|
---|
1365 | if ($ar['validi_lista']){
|
---|
1366 | $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista'];
|
---|
1367 | $valista=",validi_lista='$tvalista'";
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | $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' ";
|
---|
1371 | $res = $dbi->prepare("$sql");
|
---|
1372 | $res->execute();
|
---|
1373 |
|
---|
1374 |
|
---|
1375 | 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");
|
---|
1376 | }
|
---|
1377 | // }
|
---|
1378 | // Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
|
---|
1379 | if ($fileout) fclose($fp);
|
---|
1380 | 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");
|
---|
1381 |
|
---|
1382 | /*}else{
|
---|
1383 |
|
---|
1384 | echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
|
---|
1385 | 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>";
|
---|
1386 | }*/
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 |
|
---|
1390 | function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
1391 | global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo,$dettnulli;
|
---|
1392 | ////////////////////////////////////////////
|
---|
1393 | // da qua va la sezione per le preferenze ai gruppi
|
---|
1394 | ///////////////////////////////////////////
|
---|
1395 | // Controllo immmissioni
|
---|
1396 |
|
---|
1397 | $bgcolor1="#7777ff";
|
---|
1398 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
1399 | $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ";
|
---|
1400 | $res = $dbi->prepare("$sql");
|
---|
1401 | $res->execute();
|
---|
1402 |
|
---|
1403 |
|
---|
1404 | $max = $res->rowCount();
|
---|
1405 | $max = $max-1;
|
---|
1406 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
1407 | if ($genere==0) {
|
---|
1408 | echo "document.sezioni.si1.focus()\n";
|
---|
1409 | echo "document.sezioni.si1.select()\n";
|
---|
1410 | } else {
|
---|
1411 | echo "document.sezioni.voti1.focus()\n"
|
---|
1412 | ."document.sezioni.voti1.select()\n";
|
---|
1413 | }
|
---|
1414 | echo "//-->\n"
|
---|
1415 | ."</script>\n";
|
---|
1416 | // tabella votanti
|
---|
1417 | echo "<center>";
|
---|
1418 | if ($genere!=0){
|
---|
1419 | $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";
|
---|
1420 | $result = $dbi->prepare("$sql");
|
---|
1421 | $result->execute();
|
---|
1422 |
|
---|
1423 |
|
---|
1424 | list( $voti_u, $voti_d, $voti_t) = $result->fetch(PDO::FETCH_NUM);
|
---|
1425 | echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
|
---|
1426 | ."<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>"
|
---|
1427 | ."<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>";
|
---|
1428 | echo "</table>";
|
---|
1429 | }
|
---|
1430 | echo "<table class=\"table-menu\" style=\"width: 50%; color: black\">";
|
---|
1431 | if ($genere==0){
|
---|
1432 | $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' ";
|
---|
1433 | $res = $dbi->prepare("$sql");
|
---|
1434 | $res->execute();
|
---|
1435 |
|
---|
1436 |
|
---|
1437 | while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = $res->fetch(PDO::FETCH_NUM)){
|
---|
1438 | if ($voti_parz!=$validi){
|
---|
1439 | $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ";
|
---|
1440 | $res2 = $dbi->prepare("$sql");
|
---|
1441 | $res2->execute();
|
---|
1442 |
|
---|
1443 |
|
---|
1444 | list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
|
---|
1445 | 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>";
|
---|
1446 | }
|
---|
1447 | $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' ";
|
---|
1448 | $res2 = $dbi->prepare("$sql");
|
---|
1449 | $res2->execute();
|
---|
1450 |
|
---|
1451 |
|
---|
1452 | list($tot) = $res2->fetch(PDO::FETCH_NUM);
|
---|
1453 | if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
|
---|
1454 | $sql="SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
|
---|
1455 | $res2 = $dbi->prepare("$sql");
|
---|
1456 | $res2->execute();
|
---|
1457 |
|
---|
1458 |
|
---|
1459 | list($num_gruppo) = $res2->fetch(PDO::FETCH_NUM);
|
---|
1460 | 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>";
|
---|
1461 | }
|
---|
1462 | }
|
---|
1463 | }else{
|
---|
1464 | $sql="select solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
1465 | $result = $dbi->prepare("$sql");
|
---|
1466 | $result->execute();
|
---|
1467 |
|
---|
1468 |
|
---|
1469 | list($flagsg,$disgiunto)=$result->fetch(PDO::FETCH_NUM);
|
---|
1470 | $sql="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1471 | $res = $dbi->prepare("$sql");
|
---|
1472 | $res->execute();
|
---|
1473 |
|
---|
1474 |
|
---|
1475 | list($voti_parz) = $res->fetch(PDO::FETCH_NUM);
|
---|
1476 | $sql="SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1477 | $res = $dbi->prepare("$sql");
|
---|
1478 | $res->execute();
|
---|
1479 |
|
---|
1480 |
|
---|
1481 | list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = $res->fetch(PDO::FETCH_NUM);
|
---|
1482 | if ($voti_parz!=($validi-$solo_lista) and $voti_parz>0){
|
---|
1483 | 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>";
|
---|
1484 | }
|
---|
1485 | $sql="SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1486 | $res2 = $dbi->prepare("$sql");
|
---|
1487 | $res2->execute();
|
---|
1488 |
|
---|
1489 |
|
---|
1490 | list($tot) = $res2->fetch(PDO::FETCH_NUM);
|
---|
1491 | if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
|
---|
1492 | 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>";
|
---|
1493 | }
|
---|
1494 | $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons and id_sez=$id_sez";
|
---|
1495 | $resg = $dbi->prepare("$sql");
|
---|
1496 | $resg->execute();
|
---|
1497 |
|
---|
1498 |
|
---|
1499 | list($voti_sez)=$resg->fetch(PDO::FETCH_NUM);
|
---|
1500 | if(($genere==5 and !$disgiunto and $voti_sez and $flagsg and ($tipo_cons==18 or $tipo_cons==19))){
|
---|
1501 |
|
---|
1502 | $sql="SELECT sum(solo_gruppo) from ".$prefix."_ele_voti_gruppo where id_cons=$id_cons and id_sez=$id_sez";
|
---|
1503 | $resg = $dbi->prepare("$sql");
|
---|
1504 | $resg->execute();
|
---|
1505 |
|
---|
1506 |
|
---|
1507 | list($sgpl)=$resg->fetch(PDO::FETCH_NUM);
|
---|
1508 | $sql="SELECT solo_gruppo from ".$prefix."_ele_sezioni where id_cons=$id_cons and id_sez=$id_sez";
|
---|
1509 | $resg = $dbi->prepare("$sql");
|
---|
1510 | $resg->execute();
|
---|
1511 |
|
---|
1512 |
|
---|
1513 | list($sg)=$resg->fetch(PDO::FETCH_NUM);
|
---|
1514 | 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>";
|
---|
1515 | }
|
---|
1516 | #controllo voti a liste collegate <= voto di gruppo per voto non disgiunto
|
---|
1517 | if($genere==5 and !$disgiunto and $flagsg and ($tipo_cons==18 or $tipo_cons==19)){
|
---|
1518 | $sql="SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'";
|
---|
1519 | $resref = $dbi->prepare("$sql");
|
---|
1520 | $resref->execute();
|
---|
1521 |
|
---|
1522 |
|
---|
1523 | $errgrulis=array();
|
---|
1524 | $sql="SELECT count(0) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
|
---|
1525 | $res4 = $dbi->prepare("$sql");
|
---|
1526 | $res4->execute();
|
---|
1527 |
|
---|
1528 |
|
---|
1529 | list($sezscrl)=$res4->fetch(PDO::FETCH_NUM);
|
---|
1530 | if ($sezscrl)
|
---|
1531 | while ( list($id_gruppo)=$resref->fetch(PDO::FETCH_NUM))
|
---|
1532 | {
|
---|
1533 | $sql="SELECT sum(voti-solo_gruppo) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
1534 | $res3 = $dbi->prepare("$sql");
|
---|
1535 | $res3->execute();
|
---|
1536 |
|
---|
1537 |
|
---|
1538 | $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')";
|
---|
1539 | $res4 = $dbi->prepare("$sql");
|
---|
1540 | $res4->execute();
|
---|
1541 |
|
---|
1542 |
|
---|
1543 | list($vgruppo)=$res3->fetch(PDO::FETCH_NUM);
|
---|
1544 | list($vliste)=$res4->fetch(PDO::FETCH_NUM);
|
---|
1545 | if($vliste>$vgruppo and ($tipo_cons=18 or $tipo_cons=19))
|
---|
1546 | {
|
---|
1547 | $errgrulis[$id_gruppo]=1;
|
---|
1548 | $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
1549 | $result = $dbi->prepare("$sql");
|
---|
1550 | $result->execute();
|
---|
1551 |
|
---|
1552 |
|
---|
1553 | list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
1554 | 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>";
|
---|
1555 | }
|
---|
1556 | elseif($vliste<$vgruppo and ($tipo_cons=18 or $tipo_cons=19))
|
---|
1557 | {
|
---|
1558 | $errgrulis[$id_gruppo]=1;
|
---|
1559 | $sql="SELECT descrizione FROM ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'";
|
---|
1560 | $result = $dbi->prepare("$sql");
|
---|
1561 | $result->execute();
|
---|
1562 |
|
---|
1563 |
|
---|
1564 | list($dgruppo)=$result->fetch(PDO::FETCH_NUM);
|
---|
1565 | 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>";
|
---|
1566 | }
|
---|
1567 | }
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | }
|
---|
1571 | if(!isset($votinulli)) $votinulli=0;
|
---|
1572 | echo "<tr><td></td></tr></table>";
|
---|
1573 | if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
|
---|
1574 | 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\">";
|
---|
1575 | else echo "<table class=\"table-menu\" style=\" width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"modules/Elezioni/salva_gruppi.php\">";
|
---|
1576 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppiq\">"
|
---|
1577 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
1578 | ."<input type=\"hidden\" name=\"id_cons\" value=\"$id_cons\">"
|
---|
1579 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
1580 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
1581 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
1582 | ."<input type=\"hidden\" name=\"circo\" value=\"$circo\">"
|
---|
1583 | ."<input type=\"hidden\" name=\"genere\" value=\"$genere\">"
|
---|
1584 | ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
|
---|
1585 | echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
|
---|
1586 | ."<td width=\"3%\"><b>"._NUM."</b></td>"
|
---|
1587 | ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
|
---|
1588 | if ($genere==0){
|
---|
1589 | echo "<td><b>"._SI."</b></td>"
|
---|
1590 | ."<td><b>"._NO."</b></td>"
|
---|
1591 | ."<td><b>"._VALIDI."</b></td>"
|
---|
1592 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
1593 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
1594 | ."<td><b>"._NULLI."</b></td>"
|
---|
1595 | ."<td><b>"._TOTNON."</b></td>"
|
---|
1596 | ."<td><b>"._TOTALEVOTI."</b></td>"
|
---|
1597 | ."<td><b>"._VOTANTI."</b></td>";
|
---|
1598 | }else{
|
---|
1599 | echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
|
---|
1600 | if($dettnulli) echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SOLO_GRUPPO."</b></td>";
|
---|
1601 | }
|
---|
1602 | echo "</tr>";
|
---|
1603 | $sql="SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ";
|
---|
1604 | $res = $dbi->prepare("$sql");
|
---|
1605 | $res->execute();
|
---|
1606 |
|
---|
1607 |
|
---|
1608 | $max = $res->rowCount();
|
---|
1609 | //echo "Massimo:$max - id=$id_cons - circo: $circo";
|
---|
1610 | $sql="select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ";
|
---|
1611 | $result = $dbi->prepare("$sql");
|
---|
1612 | $result->execute();
|
---|
1613 |
|
---|
1614 |
|
---|
1615 | $i=1;
|
---|
1616 | $tot_pref=0;
|
---|
1617 | $totsg=0;
|
---|
1618 | while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = $result->fetch(PDO::FETCH_NUM)){
|
---|
1619 |
|
---|
1620 | //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
|
---|
1621 |
|
---|
1622 |
|
---|
1623 | if ($num_gruppo != ''){
|
---|
1624 | if ($genere==0){
|
---|
1625 | $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' ";
|
---|
1626 | $res = $dbi->prepare("$sql");
|
---|
1627 | $res->execute();
|
---|
1628 |
|
---|
1629 |
|
---|
1630 | list($tot) = $res->fetch(PDO::FETCH_NUM);
|
---|
1631 | $sql="SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
|
---|
1632 | $res = $dbi->prepare("$sql");
|
---|
1633 | $res->execute();
|
---|
1634 |
|
---|
1635 |
|
---|
1636 | $pro= $res->fetch(PDO::FETCH_BOTH);
|
---|
1637 |
|
---|
1638 | 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)){
|
---|
1639 | echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
|
---|
1640 | }else{
|
---|
1641 | echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
|
---|
1642 | }
|
---|
1643 | $descr = explode('.',$descr_gruppo, 100);
|
---|
1644 | echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
1645 | ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
|
---|
1646 | $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'0';
|
---|
1647 | $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'0';
|
---|
1648 | $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'0';
|
---|
1649 | $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'0';
|
---|
1650 | $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'0';
|
---|
1651 | $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'0';
|
---|
1652 | $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
|
---|
1653 | $tot_voti=$pro['validi']+$tot_nulli;
|
---|
1654 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1655 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1656 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
|
---|
1657 | echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1658 | echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1659 | echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1660 | echo "</td><td align=\"right\">$tot_nulli</td>";
|
---|
1661 | echo "</td><td align=\"right\">$tot_voti</td>";
|
---|
1662 | echo "</td><td align=\"right\">$tot</td>";
|
---|
1663 | }else{
|
---|
1664 | 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>"
|
---|
1665 | ."</td><td align=\"left\"><b> $descr_gruppo </b>";
|
---|
1666 | $sql="SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ";
|
---|
1667 | $res = $dbi->prepare("$sql");
|
---|
1668 | $res->execute();
|
---|
1669 |
|
---|
1670 |
|
---|
1671 | $pro= $res->fetch(PDO::FETCH_BOTH);
|
---|
1672 | $errcolor='';
|
---|
1673 | if(isset($errgrulis[$id_gruppo])) $errcolor="style=\"background-color: rgb(255, 0, 0);\"";
|
---|
1674 | echo "</td><td align=\"right\" $errcolor><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1675 |
|
---|
1676 | 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'];}
|
---|
1677 | $tot_pref += $pro['voti'];
|
---|
1678 | echo "</tr>";
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 | $i++;
|
---|
1682 | }
|
---|
1683 |
|
---|
1684 | }
|
---|
1685 | if ($genere!=0) {
|
---|
1686 | $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
1687 | $res = $dbi->prepare("$sql");
|
---|
1688 | $res->execute();
|
---|
1689 |
|
---|
1690 |
|
---|
1691 | list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
|
---|
1692 | $sql="SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ";
|
---|
1693 | $res = $dbi->prepare("$sql");
|
---|
1694 | $res->execute();
|
---|
1695 |
|
---|
1696 |
|
---|
1697 | list($sololis)=$res->fetch(PDO::FETCH_NUM);
|
---|
1698 | echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td>";
|
---|
1699 | if($dettnulli) echo "<td>$totsg</td>";
|
---|
1700 | echo "</tr>";
|
---|
1701 | if($disgiunto)
|
---|
1702 | 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>";
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
|
---|
1706 |
|
---|
1707 | echo "</tr></table></form></td></tr>";
|
---|
1708 | if(chisei($id_cons_gen)>=64){
|
---|
1709 | echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | echo "</td></tr></table></center>";
|
---|
1713 | }
|
---|
1714 | if ($genere!=0){
|
---|
1715 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
1716 | }
|
---|
1717 | }
|
---|
1718 |
|
---|
1719 |
|
---|
1720 |
|
---|
1721 |
|
---|
1722 |
|
---|
1723 |
|
---|
1724 | ///////////////////////////
|
---|
1725 | // registra le preferenze ai gruppi
|
---|
1726 | ///////////////////////////
|
---|
1727 |
|
---|
1728 | function rec_voti_gruppi() {
|
---|
1729 | global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout,$dettnulli;
|
---|
1730 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
1731 |
|
---|
1732 | $username="$aid";
|
---|
1733 | $log_data= date("Y/m/d");
|
---|
1734 | $log_ora=getdate(time());
|
---|
1735 | $arg2 = func_get_args();
|
---|
1736 | $arg = preg_split("/\,+/",$arg2[0]);
|
---|
1737 | $id_cons_gen=intval($arg[1]);
|
---|
1738 | $id_sez = intval($arg[2]);
|
---|
1739 | $id_circ = intval($arg[3]);
|
---|
1740 | $id_sede = intval($arg[4]);
|
---|
1741 | $do = intval($arg[5]);
|
---|
1742 | $y=count($arg)-1;
|
---|
1743 | $sql="delete from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1744 | $res = $dbi->prepare("$sql");
|
---|
1745 | $res->execute();
|
---|
1746 |
|
---|
1747 |
|
---|
1748 | if($do==1) {
|
---|
1749 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1750 | $res = $dbi->prepare("$sql");
|
---|
1751 | $res->execute();
|
---|
1752 |
|
---|
1753 |
|
---|
1754 | $sql="delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1755 | $res = $dbi->prepare("$sql");
|
---|
1756 | $res->execute();
|
---|
1757 |
|
---|
1758 |
|
---|
1759 | $sql="delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1760 | $res = $dbi->prepare("$sql");
|
---|
1761 | $res->execute();
|
---|
1762 |
|
---|
1763 |
|
---|
1764 | $sql="delete from ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez'";
|
---|
1765 | $res = $dbi->prepare("$sql");
|
---|
1766 | $res->execute();
|
---|
1767 |
|
---|
1768 |
|
---|
1769 | $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'";
|
---|
1770 | $res = $dbi->prepare("$sql");
|
---|
1771 | $res->execute();
|
---|
1772 |
|
---|
1773 |
|
---|
1774 |
|
---|
1775 | }else{
|
---|
1776 |
|
---|
1777 | if ($genere==0) {
|
---|
1778 | $tab="_ele_voti_ref";
|
---|
1779 | } else {
|
---|
1780 | $tab="_ele_voti_gruppo";
|
---|
1781 | $y--;
|
---|
1782 | $sql="SELECT disgiunto FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons' ";
|
---|
1783 | $res = $dbi->prepare("$sql");
|
---|
1784 | $res->execute();
|
---|
1785 |
|
---|
1786 |
|
---|
1787 | list($disgiunto)=$res->fetch(PDO::FETCH_NUM);
|
---|
1788 | if($disgiunto)
|
---|
1789 | $sql="update ".$prefix."_ele_sezioni set solo_lista='".$arg[$y--]."' where id_sez='$id_sez'";
|
---|
1790 | $res = $dbi->prepare("$sql");
|
---|
1791 | $res->execute();
|
---|
1792 |
|
---|
1793 |
|
---|
1794 |
|
---|
1795 | }
|
---|
1796 |
|
---|
1797 | for($i=6;$i< $y;) {
|
---|
1798 | $id_gruppo = intval($arg[$i++]);
|
---|
1799 | $testval=0;
|
---|
1800 | switch ($genere){
|
---|
1801 | case (0):
|
---|
1802 | if($arg[$i].$arg[$i+1]=='' ) {
|
---|
1803 | $i+=6;
|
---|
1804 | $testval=1;
|
---|
1805 | }else{
|
---|
1806 | $si=intval($arg[$i++]);
|
---|
1807 | $no=intval($arg[$i++]);
|
---|
1808 | $val=intval($arg[$i++]);
|
---|
1809 | if ($val==0){$val=$si+$no;}
|
---|
1810 | $bia=intval($arg[$i++]);
|
---|
1811 | $con=intval($arg[$i++]);
|
---|
1812 | $nul=intval($arg[$i++]);
|
---|
1813 | $voti = "'$si','$no','$val','$nul','$bia','$con'";
|
---|
1814 | $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
|
---|
1815 | $sgriga='';
|
---|
1816 | }
|
---|
1817 | break;
|
---|
1818 | default:
|
---|
1819 | $voti = intval($arg[$i++]);
|
---|
1820 | if($dettnulli) { $sg=intval($arg[$i++]); $sgriga = ', solo_gruppo='.$sg;} else {$sgriga=''; $sg=0;}
|
---|
1821 | if (!$voti) {$voti="0";}
|
---|
1822 | $riga="voti=$voti".$sgriga;
|
---|
1823 | $sgriga=",'$sg'";
|
---|
1824 | break;
|
---|
1825 | }
|
---|
1826 | if($testval) continue;
|
---|
1827 | $sql="select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
1828 | $result = $dbi->prepare("$sql");
|
---|
1829 | $result->execute();
|
---|
1830 |
|
---|
1831 |
|
---|
1832 | $ar=$result->fetch(PDO::FETCH_BOTH);
|
---|
1833 | $sql="select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'";
|
---|
1834 | $res = $dbi->prepare("$sql");
|
---|
1835 | $res->execute();
|
---|
1836 |
|
---|
1837 |
|
---|
1838 | list($num_gruppo)=$res->fetch(PDO::FETCH_NUM);
|
---|
1839 | $oldval='';
|
---|
1840 | if ($ar){
|
---|
1841 | switch ($genere){
|
---|
1842 | case (0):
|
---|
1843 | if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
|
---|
1844 | or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
|
---|
1845 | $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
|
---|
1846 | }
|
---|
1847 | break;
|
---|
1848 | default:
|
---|
1849 | if ($ar['voti']!=$voti or $ar['solo_gruppo']!=$sg) {
|
---|
1850 | $oldval="voti:".$ar['voti'];
|
---|
1851 | $voti.=",null";
|
---|
1852 | }
|
---|
1853 | if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
|
---|
1854 | break;
|
---|
1855 | }
|
---|
1856 | if ($oldval) {
|
---|
1857 | $sql="update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'";
|
---|
1858 | $res = $dbi->prepare("$sql");
|
---|
1859 | $res->execute();
|
---|
1860 |
|
---|
1861 |
|
---|
1862 | 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");
|
---|
1863 | $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')";
|
---|
1864 | $res = $dbi->prepare("$sql");
|
---|
1865 | $res->execute();
|
---|
1866 |
|
---|
1867 |
|
---|
1868 | }
|
---|
1869 | } else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)");
|
---|
1870 | $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')";
|
---|
1871 | $res = $dbi->prepare("$sql");
|
---|
1872 | $res->execute();
|
---|
1873 |
|
---|
1874 |
|
---|
1875 | $sql="insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga)";
|
---|
1876 | $res = $dbi->prepare("$sql");
|
---|
1877 | $res->execute();
|
---|
1878 |
|
---|
1879 |
|
---|
1880 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti $sgriga);\n");
|
---|
1881 | //
|
---|
1882 | }
|
---|
1883 |
|
---|
1884 | }
|
---|
1885 | }
|
---|
1886 | //$ops = $arg[$argc];
|
---|
1887 | if ($fileout) fclose($fp);
|
---|
1888 | 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");
|
---|
1889 |
|
---|
1890 | }
|
---|
1891 |
|
---|
1892 |
|
---|
1893 | if (!preg_match("/rec/",$op)) {
|
---|
1894 | ele(); //menu
|
---|
1895 | /* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
|
---|
1896 | numeri_sezione(8);
|
---|
1897 | echo "<td></td></tr></table>\n";*/
|
---|
1898 | echo"</td></tr></table>";
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | switch ($op){
|
---|
1902 | case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
|
---|
1903 | # voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
1904 | voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
1905 | break;
|
---|
1906 | case "rec_add_votanti":
|
---|
1907 | rec_add_votanti($vari);
|
---|
1908 | break;
|
---|
1909 | default :
|
---|
1910 | $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
|
---|
1911 | }
|
---|
1912 | echo"</td></tr></table>";
|
---|
1913 | include_once("modules/Elezioni/language/lang-$currentlang.php");
|
---|
1914 | include ("footer.php");
|
---|
1915 | ?>
|
---|
1916 |
|
---|