1 | <?php
|
---|
2 | /************************************************************************/
|
---|
3 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
4 | /* by Roberto Gigli & Luciano Apolito */
|
---|
5 | /* http://www.eleonline.it */
|
---|
6 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
7 | /************************************************************************/
|
---|
8 | /* Modulo Inserimento dati */
|
---|
9 | /* Amministrazione */
|
---|
10 | /************************************************************************/
|
---|
11 |
|
---|
12 | if (!defined('ADMIN_FILE')) {
|
---|
13 | die ("You can't access this file directly...");
|
---|
14 | }
|
---|
15 | $aid=$_SESSION['aid'];
|
---|
16 | $dbi=$_SESSION['dbi'];
|
---|
17 | $prefix=$_SESSION['prefix'];
|
---|
18 | $currentlang=$_SESSION['lang'];
|
---|
19 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
20 | $vari= implode(',',$_GET);//param);
|
---|
21 | $id_comune=$_SESSION['id_comune'];
|
---|
22 | $id_cons_gen=intval($_GET['id_cons_gen']);
|
---|
23 | $perms=ChiSei($id_cons_gen);
|
---|
24 | if ($perms<16 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
25 |
|
---|
26 | $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
|
---|
27 | list($tipo_cons) = mysql_fetch_row($res);
|
---|
28 | if ($tipo_cons!=3) $limite=0; #die ("limite: $limite");}
|
---|
29 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
30 | //if (isset($param['id_cons'])) $id_cons=intval($param['id_cons']); else $id_cons='';
|
---|
31 | if (isset($param['ops'])) $ops=intval($param['ops']); else $ops='';
|
---|
32 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
33 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
|
---|
34 | if (isset($param['ov'])) $ov=intval($param['ov']); else $ov='';
|
---|
35 | if (isset($param['mv'])) $mv=intval($param['mv']); else $mv='';
|
---|
36 | if (isset($param['gv'])) $gv=intval($param['gv']); else $gv='';
|
---|
37 | if (isset($param['msv'])) $msv=intval($param['msv']); else $msv='';
|
---|
38 | if (isset($param['av'])) $av=intval($param['av']); else $av='';
|
---|
39 | if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else
|
---|
40 | if (isset($_SESSION['id_circ'])) $id_circ=intval($_SESSION['id_circ']); else $id_circ='';
|
---|
41 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
|
---|
42 | if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
|
---|
43 | if (isset($param['id_lista'])) $id_lista=intval($param['id_lista']); else $id_lista='';
|
---|
44 | if (isset($param['prev_sez'])) $prev_sez=intval($param['prev_sez']); else $prev_sez='';
|
---|
45 | if (isset($param['id_gruppo'])) $id_gruppo=intval($param['id_gruppo']); else $id_gruppo='';
|
---|
46 | include("modules/Elezioni/funzionidata.php");
|
---|
47 | include("modules/Elezioni/ele.php");
|
---|
48 | $res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
|
---|
49 | list($num_circ)=mysql_fetch_row($res);
|
---|
50 | if ($conscirc){ // or $num_circ==1
|
---|
51 | if (!$id_circ){
|
---|
52 | $res = mysql_query("SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1", $dbi);
|
---|
53 | if (!$res) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
|
---|
54 | list($id_circ)=mysql_fetch_row($res);
|
---|
55 | $_SESSION['id_circ']=$id_circ;
|
---|
56 | }
|
---|
57 | $result = mysql_query("select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'", $dbi);
|
---|
58 | $i=0;
|
---|
59 | while(list($tmp) = mysql_fetch_row($result)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
|
---|
60 | unset($idsedi);$i=0;$idsezi=array();unset($result);
|
---|
61 | $result = mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)", $dbi);
|
---|
62 | unset($tmp);
|
---|
63 | while(list($tmp) = mysql_fetch_row($result)) $idsezi[$i++]=$tmp;
|
---|
64 | $tmp=implode (",",$idsezi);
|
---|
65 | $sezi = "and id_sez in ($tmp)";
|
---|
66 | $circo = "and id_circ='$id_circ'";
|
---|
67 | }else{
|
---|
68 | $sezi='';
|
---|
69 | $circo='';
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 | // Offset - visualizza il numero di elementi per pagina
|
---|
75 | $offset=2;
|
---|
76 | if (!isset($min)) $min=0;
|
---|
77 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
78 |
|
---|
79 | function numeri_sezione() {
|
---|
80 | // tabella visualizzazione sezioni per numero
|
---|
81 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$id_cons,$id_lista,$ops, $perms,$id_sez;
|
---|
82 | // $ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where aid='$aid'",$dbi);
|
---|
83 | // list ($perms)=mysql_fetch_row($ressup);
|
---|
84 | //if ($perms>16) { // tolto per guidonia
|
---|
85 | $res = mysql_query("SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' order by num_sez", $dbi);
|
---|
86 | $max = mysql_num_rows($res);
|
---|
87 | echo "\n<table align=\"left\" border=\"0\" width=\"90%\"><tr bgcolor=\"$bgcolor1\">";
|
---|
88 | //if ($max>=64){
|
---|
89 | $i=0;
|
---|
90 | while(list($sez_num, $sez_id ,$sede_id) = mysql_fetch_row($res)) {
|
---|
91 | $i++;
|
---|
92 | $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ", $dbi);
|
---|
93 | list($circ_id) = mysql_fetch_row($result);
|
---|
94 | //clora la sezione
|
---|
95 | $res2= mysql_query("SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
96 | list($numero_sez) = mysql_fetch_row($res2);
|
---|
97 | if ($sez_num==$numero_sez) {$bgsez="#FFFF00";}else{$bgsez="";}
|
---|
98 | echo "\n<td align=\"center\" width=\"5%\" bgcolor=\"$bgsez\"><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></td>\n";
|
---|
99 | if (($i%8) ==0) echo "</tr>\n<tr bgcolor=\"$bgcolor1\">";
|
---|
100 | }
|
---|
101 | //}
|
---|
102 | echo "<td></td></tr></table>\n";
|
---|
103 |
|
---|
104 | echo"</td></tr></table>";
|
---|
105 | //}// fine tabella per numero sezioni
|
---|
106 | // inizio tabella centrale
|
---|
107 | echo "\n</td><td valign=\"top\" align=\"left\">";
|
---|
108 | }
|
---|
109 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
110 |
|
---|
111 |
|
---|
112 | function voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
|
---|
113 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc;
|
---|
114 |
|
---|
115 | echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr>";
|
---|
116 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
|
---|
117 | //echo "<h6>";
|
---|
118 | ///////////////////////
|
---|
119 | // Circoscrizione : scelta
|
---|
120 | ///////////////////////
|
---|
121 |
|
---|
122 | $resoper=mysql_query("SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
|
---|
123 | ".$prefix."_ele_sede as t2
|
---|
124 | where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'", $dbi);
|
---|
125 | list($id_sede2,$id_circ2) = mysql_fetch_row($resoper);
|
---|
126 | if ($id_sede2 and !($id_sede==$id_sede2)) {
|
---|
127 | $id_sede=$id_sede2;
|
---|
128 | $id_circ=$id_circ2;
|
---|
129 | $do="spoglio";
|
---|
130 | $res= mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede=$id_sede order by num_sez limit 0,1", $dbi);
|
---|
131 | list($id_sez) = mysql_fetch_row($res);
|
---|
132 | }
|
---|
133 | if ($do == "circo") {
|
---|
134 | OpenTable();
|
---|
135 | echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
|
---|
136 | ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
137 | ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
|
---|
138 | // Circoscrizione: lista
|
---|
139 | //**************************************
|
---|
140 | .""._CIRCO.": "
|
---|
141 | ."<select name=\"id_circ\">";
|
---|
142 | $res= mysql_query("SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ", $dbi);
|
---|
143 | while(list($id,$descr) = mysql_fetch_row($res)) {
|
---|
144 | if ($descr!="Tutte"){
|
---|
145 | if ($id == $id_circ) {
|
---|
146 | $sel = "selected";
|
---|
147 | } else {
|
---|
148 | $sel = "";
|
---|
149 | }
|
---|
150 | echo "<option value=\"$id\" $sel>$descr";
|
---|
151 | }
|
---|
152 | }
|
---|
153 | echo "</select>"
|
---|
154 | //***********************************
|
---|
155 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
156 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
157 | ."</form></td></tr>";
|
---|
158 | CloseTable();
|
---|
159 | }
|
---|
160 |
|
---|
161 | ///////////////////////
|
---|
162 | // sede : scelta
|
---|
163 | ///////////////////////
|
---|
164 |
|
---|
165 |
|
---|
166 | if ($do == "sede") {
|
---|
167 | OpenTable();
|
---|
168 | echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
|
---|
169 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
170 | list( $descr_circ) = mysql_fetch_row($res);
|
---|
171 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->";
|
---|
172 | echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
173 | ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
174 |
|
---|
175 | // Indirizzo: lista
|
---|
176 | //**************************************
|
---|
177 | .""._INDIRIZZO.": "
|
---|
178 | ."<select name=\"id_sede\">";
|
---|
179 | $res= mysql_query("SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_circ='$id_circ' order by indirizzo", $dbi);
|
---|
180 | // echo "$id_circ - $id_cons";
|
---|
181 | while(list($id,$indir) = mysql_fetch_row($res)) {
|
---|
182 | if ($id == $id_sede) {
|
---|
183 | $sel = "selected";
|
---|
184 | } else {
|
---|
185 | $sel = "";
|
---|
186 | }
|
---|
187 | echo "<option value=\"$id\" $sel>$indir";
|
---|
188 | }
|
---|
189 | echo "</select>"
|
---|
190 | //*************************************
|
---|
191 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
192 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
193 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
194 | ."</form></td></tr>\n";
|
---|
195 | CloseTable();
|
---|
196 | }
|
---|
197 |
|
---|
198 | ///////////////////////
|
---|
199 | // sezione : scelta
|
---|
200 | ///////////////////////
|
---|
201 | if ($do == "spoglio") {
|
---|
202 | echo "\n<form name=\"sezione\" action=\"admin.php\">";
|
---|
203 | OpenTable();
|
---|
204 | echo "<tr><td>";
|
---|
205 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
206 | list($descr_circ) = mysql_fetch_row($res);
|
---|
207 | $res= mysql_query("SELECT indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' AND id_sede='$id_sede' order by indirizzo", $dbi);
|
---|
208 | list($indir) = mysql_fetch_row($res);
|
---|
209 | echo "<input type=\"hidden\" name=\"pag_sez\" value=\"admin.php?op=voti&do=spoglio&ops=$ops&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_lista=$id_lista&id_sez=\">";
|
---|
210 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->
|
---|
211 | <a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&do=sede\">"._INDIRIZZO."</a> $indir ->
|
---|
212 | <input type=\"hidden\" name=\"op\" value=\"voti\">
|
---|
213 | <input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
214 | // Sezioni:lista
|
---|
215 | //**************************************
|
---|
216 | ."<b>"._SEZIONE."</b>: "
|
---|
217 | ."<select name=\"id_sez\" onChange=\"top.location.href=this.form.pag_sez.value+this.form.id_sez.options[this.form.id_sez.selectedIndex].value;return false\">";
|
---|
218 | $res= mysql_query("SELECT id_sez,num_sez FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sede='$id_sede' order by num_sez", $dbi);
|
---|
219 | $rif_sez=0;
|
---|
220 | $next_sez=0;
|
---|
221 | unset($prev_sez);
|
---|
222 | while(list($id,$num) = mysql_fetch_row($res)) {
|
---|
223 | if (!($id_sez>0)) {$id_sez=$id;}
|
---|
224 | if ($id == $id_sez) {
|
---|
225 | $sel = "selected";
|
---|
226 | $prev_sez=$rif_sez;
|
---|
227 | } else {
|
---|
228 | $sel = "";
|
---|
229 | if (isset($prev_sez) and ($next_sez==0)) { $next_sez=$id;}
|
---|
230 | $rif_sez=$id;
|
---|
231 | }
|
---|
232 | echo "<option value=\"$id\" $sel>$num";
|
---|
233 | }
|
---|
234 | echo "</select>"
|
---|
235 | //*************************************
|
---|
236 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">\n"
|
---|
237 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">\n"
|
---|
238 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">\n"
|
---|
239 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">\n"
|
---|
240 | ." <input type=\"submit\" name=\"update\" value=\""._OK."\">\n";
|
---|
241 | if ($prev_sez) {
|
---|
242 | echo " <a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=spoglio&id_circ=$id_circ&id_sede=$id_sede&id_sez=$prev_sez&ops=$ops&id_lista=$id_lista\">"._PREV."</a> \n";
|
---|
243 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._PREV."</span> ";}
|
---|
244 | if ($next_sez) {
|
---|
245 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=spoglio&id_circ=$id_circ&id_sede=$id_sede&id_sez=$next_sez&ops=$ops&id_lista=$id_lista\">"._NEXT."</a>\n";
|
---|
246 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._NEXT."</span>\n";}
|
---|
247 | echo "\n</td></tr>";
|
---|
248 | CloseTable();
|
---|
249 |
|
---|
250 | echo "</form>\n";
|
---|
251 | echo "\n</td></tr><tr><td>\n";
|
---|
252 | // echo "\n</td></tr></table>\n";
|
---|
253 |
|
---|
254 |
|
---|
255 | //************************************
|
---|
256 | // Menu spoglio
|
---|
257 | //************************************
|
---|
258 | $result = mysql_query("select id_cons,id_sez,id_sede,num_sez, maschi, femmine from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
259 | list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = mysql_fetch_row($result);
|
---|
260 |
|
---|
261 | //$bgcolor1="#b0b0b0";
|
---|
262 | echo "<table border=\"0\" width=\"60%\" align=\"center\"><tr>";
|
---|
263 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"center\"><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></td>\n";
|
---|
264 | if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
|
---|
265 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><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></td>\n";
|
---|
266 | }
|
---|
267 | if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
|
---|
268 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><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\">"._PREFLISTA."</a></b></td>\n";
|
---|
269 | }
|
---|
270 | echo "</tr></table>\n";
|
---|
271 | // echo "\n</td></tr></table>\n";
|
---|
272 |
|
---|
273 |
|
---|
274 | ///////////////////////////////////////////
|
---|
275 | // opzioni per le funzioni di immissione
|
---|
276 |
|
---|
277 | if ($ops == 1) {
|
---|
278 | votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
|
---|
279 | }
|
---|
280 | /*
|
---|
281 | if ($ops == 2) {
|
---|
282 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
283 | }
|
---|
284 | */
|
---|
285 | if ($ops == 3) {
|
---|
286 | preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
287 | }
|
---|
288 | if ($ops == 4) {
|
---|
289 | preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
290 |
|
---|
291 | }
|
---|
292 |
|
---|
293 | }
|
---|
294 | CloseTable();
|
---|
295 |
|
---|
296 | }
|
---|
297 | ////////////////////////////////////////////////////////////////////////////////
|
---|
298 | // FUNZIONI DI IMMISSIONE
|
---|
299 | // - preferenze (candidati consiglieri)
|
---|
300 | // - preferenze_gruppi
|
---|
301 | // - votanti
|
---|
302 | ////////////////////////////////////////////////////////////////////////////////
|
---|
303 |
|
---|
304 | //////////////////////////////////////////////////////////////////////
|
---|
305 | // da qui va la sezione per le preferenze candidati consiglieri
|
---|
306 | //////////////////////////////////////////////////////////////////////
|
---|
307 | function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
308 | global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
|
---|
309 | global $tipo_cons,$fascia,$limite;
|
---|
310 | $bgcolor1="#7777ff";
|
---|
311 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
312 | //controlla se sono stati inseriti i votanti
|
---|
313 | if(!$votog and ($genere==3 or $genere==5))
|
---|
314 | $result = mysql_query("select validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
315 | else
|
---|
316 | $result = mysql_query("select validi,nulli,bianchi,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
317 | #e
|
---|
318 | list($validi,$nulli,$bianchi,$contestati,$votinulli) = mysql_fetch_row($result);
|
---|
319 | # if ($validi+$nulli+$bianchi) die("entra($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)");
|
---|
320 | echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr>";
|
---|
321 | $res_lis = mysql_query("SELECT id_lista, descrizione,num_lista from ".$prefix."_ele_lista where id_cons=$id_cons $circo order by num_lista",$dbi);
|
---|
322 | $num_liste = mysql_num_rows($res_lis);
|
---|
323 | $ele_lista='';
|
---|
324 | if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
|
---|
325 | if($fascia<=$limite and !$id_lista) {
|
---|
326 | $result = mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1",$dbi);
|
---|
327 | list($id_lista)=mysql_fetch_row($result);
|
---|
328 | }
|
---|
329 | echo "<td> </td></tr><tr><td style=\"vertical-align: top;\">";
|
---|
330 | echo "<form name=\"liste\" action=\"admin.php\">";
|
---|
331 | 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=\">";
|
---|
332 | echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
|
---|
333 | if ($id_lista){
|
---|
334 | echo "<option value=\"0\">"._VOTI_LISTA;
|
---|
335 | $ele_lista=" and t1.id_lista='$id_lista' ";
|
---|
336 | }else{
|
---|
337 | echo "<option value=\"0\" selected>"._VOTI_LISTA;
|
---|
338 | $ele_lista=" group by t1.id_lista ";
|
---|
339 |
|
---|
340 | }
|
---|
341 | while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
|
---|
342 | $sel = ($id_rif == $id_lista) ? "selected" : "";
|
---|
343 | echo "<option value=\"$id_rif\" $sel>";
|
---|
344 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
345 | echo $num_lis.") ".substr($descrizione,0,30);
|
---|
346 | }
|
---|
347 | echo "</select></form></td>\n";
|
---|
348 | }else {
|
---|
349 | $id_lista=0;
|
---|
350 | }
|
---|
351 | echo "<td style=\"vertical-align: top;\">";
|
---|
352 |
|
---|
353 | if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
|
---|
354 | ###############prova
|
---|
355 | if($genere==4 and !$id_lista)
|
---|
356 | $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati,t2.voti_nulli from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez",$dbi);
|
---|
357 | else
|
---|
358 | $result = mysql_query("SELECT sum(t1.voti),t2.validi_lista, t2.solo_gruppo,t2.contestati,t2.voti_nulli from ".$prefix."_ele_sezioni as t2 left join ".$prefix.$tab." as t1 on (t1.id_sez=t2.id_sez) where t2.id_sez=$id_sez group by t1.id_sez",$dbi);
|
---|
359 | list( $voti_sez, $validi2, $sg,$cont2,$vnulli2) = mysql_fetch_row($result);
|
---|
360 | if(!$id_lista or $genere==3){ //controllo di congruenza
|
---|
361 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
362 | list($tot) = mysql_fetch_row($res2);
|
---|
363 | if ($validi+$nulli+$bianchi+$contestati+$votinulli+$sg!=$tot and $validi+$sg>0){
|
---|
364 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0); 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+$sg)."</b><br></td></table>";
|
---|
365 | }
|
---|
366 |
|
---|
367 | if((($voti_sez)!=$validi2) and ($voti_sez>0)){
|
---|
368 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
369 | }
|
---|
370 | }
|
---|
371 |
|
---|
372 |
|
---|
373 |
|
---|
374 | echo "\n<form name=\"sezioni\" action=\"admin.php\">"
|
---|
375 | ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
|
---|
376 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
377 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
378 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
379 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
380 | ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
|
---|
381 | ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n";
|
---|
382 | echo "<table border=\"0\" width=\"90%\" align=\"center\">";
|
---|
383 | echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
|
---|
384 | if ($genere<4){
|
---|
385 | // echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
|
---|
386 | }
|
---|
387 | echo "<b>"._NUM."</b></td>";
|
---|
388 | if($id_lista){
|
---|
389 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
|
---|
390 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
391 | }else{
|
---|
392 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
|
---|
393 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
394 | }
|
---|
395 | echo "</tr>\n";
|
---|
396 |
|
---|
397 |
|
---|
398 |
|
---|
399 |
|
---|
400 |
|
---|
401 | $result = mysql_query("select t1.* from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on (t1.id_lista=t2.id_lista) WHERE t1.id_cons=$id_cons and t1.id_cons=t2.id_cons $ele_lista ORDER BY t2.num_lista,t1.num_cand", $dbi);
|
---|
402 | $max = mysql_num_rows($result);
|
---|
403 | $tot_pref=0;
|
---|
404 | $i=1;
|
---|
405 |
|
---|
406 | if($id_lista) {
|
---|
407 | while(list($id_cand,$id_cons2,$id_lista2, $cognome, $nome, $note, $simbolo, $num_cand) = mysql_fetch_row($result)){
|
---|
408 | // dati lista
|
---|
409 | $result1 = mysql_query("select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'", $dbi);
|
---|
410 | list($id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1);
|
---|
411 | // dati gruppo
|
---|
412 | $result2 = mysql_query("select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
413 | list($descr_gruppo,$simb_gruppo)=mysql_fetch_row($result2);
|
---|
414 |
|
---|
415 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
416 | if ($genere<4){
|
---|
417 | echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
|
---|
418 | }
|
---|
419 | echo "<td align=\"center\"><b> $num_cand </b></td>"
|
---|
420 | ."<td align=\"left\"><b>$cognome $nome</b></td>";
|
---|
421 | $cond_sele="and id_cand=$id_cand";
|
---|
422 | $res = mysql_query("SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele", $dbi);
|
---|
423 | $pro= mysql_fetch_array($res, 3);
|
---|
424 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" >";
|
---|
425 | echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
|
---|
426 | $i++;
|
---|
427 | $tot_pref+=$pro['voti'];
|
---|
428 | }
|
---|
429 | }else {
|
---|
430 | $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista
|
---|
431 | from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
|
---|
432 | where t1.id_cons='$id_cons'
|
---|
433 | and t1.id_lista=t2.id_lista
|
---|
434 | and t2.id_sez=$id_sez
|
---|
435 | order by t1.num_lista", $dbi);
|
---|
436 | $num_lista=mysql_num_rows($result1);
|
---|
437 | if (!$num_lista){
|
---|
438 | $result1 = mysql_query("select '',t1.id_lista, descrizione,simbolo,num_lista
|
---|
439 | from ".$prefix."_ele_lista as t1 where t1.id_cons='$id_cons' $circo
|
---|
440 | order by t1.num_lista", $dbi);
|
---|
441 | }
|
---|
442 | while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1)){
|
---|
443 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
444 | // if ($genere<4 or $votoc){
|
---|
445 | // }
|
---|
446 |
|
---|
447 | echo "<td align=\"center\"><b> $num_lista </b></td>"
|
---|
448 | ."<td align=\"left\"><b> $descr_lista</b></td>";
|
---|
449 | $cond_sele="and id_lista=$id_lista3";
|
---|
450 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" >";
|
---|
451 | echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n";
|
---|
452 | $i++;
|
---|
453 | $tot_pref+=$pro['voti'];
|
---|
454 | }
|
---|
455 | }
|
---|
456 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
|
---|
457 | // toglie ai candidati la visual... del solo_gruppo
|
---|
458 | if(!$votog) {
|
---|
459 | if (($genere==3 OR $genere==5) and (!$id_lista) and ($fascia>$limite)) { //gruppo e liste
|
---|
460 | echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\"><input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\"><input name=\"sg\" value=\"$sg\" size=\"5\"></td></tr>";
|
---|
461 | echo "<tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._NULLI_LISTE."</b></td><td align=\"center\"><input name=\"votinulli\" value=\"$votinulli\" size=\"5\">"
|
---|
462 | ."</td></tr><tr bgcolor=\"$bgcolor2\"><td></td><td><b>"._CONTESTATI_LISTE."</b></td><td align=\"center\"><input name=\"contestati\" value=\"$contestati\" size=\"5\"></td></tr>";
|
---|
463 |
|
---|
464 | }elseif (($genere==3 OR $genere==5) and !$votoc and $fascia>$limite){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
|
---|
465 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
|
---|
466 | }
|
---|
467 | ######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
|
---|
468 | elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite)) {
|
---|
469 | $resvg = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
|
---|
470 | list($id_gruppo) = mysql_fetch_row($resvg);
|
---|
471 | $resvg = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'", $dbi);
|
---|
472 | list($voti_sind) = mysql_fetch_row($resvg);
|
---|
473 |
|
---|
474 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
|
---|
475 | }
|
---|
476 | ###### fine modifica del 16-04-2009
|
---|
477 |
|
---|
478 | }
|
---|
479 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" value=\" "._OK. "\"></td>";
|
---|
480 | echo "</tr></table></form></tr></table>";
|
---|
481 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
482 | ."document.sezioni.voti1.focus()\n"
|
---|
483 | ."document.sezioni.voti1.select()\n"
|
---|
484 | ."//-->\n";
|
---|
485 | echo "function vai_lista() {\n";
|
---|
486 | echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
|
---|
487 | echo "}\n";
|
---|
488 | echo "</script>\n";
|
---|
489 | # }
|
---|
490 | if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
|
---|
491 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
492 | }
|
---|
493 |
|
---|
494 | /////////////////////////////////////////////
|
---|
495 | // registra le preferenze ai candidati
|
---|
496 | /////////////////////////////////////////////
|
---|
497 |
|
---|
498 | function rec_voti() {
|
---|
499 | global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite;
|
---|
500 | $sqlcomu="select fascia from ".$prefix."_ele_comuni where id_comune='$id_comune'";
|
---|
501 | $res = mysql_query($sqlcomu);
|
---|
502 | list($fascia)=mysql_fetch_row($res);
|
---|
503 |
|
---|
504 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
505 | $username=$aid;
|
---|
506 | $log_data= date("Y/m/d");
|
---|
507 | $log_ora=getdate(time());
|
---|
508 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
509 | $arg2 = func_get_args();
|
---|
510 | $arg = split(",",$arg2[0]);
|
---|
511 | $id_cons_gen=intval($arg[1]);
|
---|
512 | $id_sez = intval($arg[2]);
|
---|
513 | $id_circ = intval($arg[3]);
|
---|
514 | $id_sede = intval($arg[4]);
|
---|
515 | $tab = $arg[5];
|
---|
516 | $id_lista = intval($arg[6]);
|
---|
517 | if ($tab=="_ele_voti_candidati") {
|
---|
518 | $condizione="id_cand";
|
---|
519 | }else{
|
---|
520 | $condizione="id_lista";
|
---|
521 | }
|
---|
522 | if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ($fascia>$limite)) $y = (count($arg)-4);
|
---|
523 | else $y=count($arg);
|
---|
524 | for($i=7,$y--;$i< $y;$i++) {
|
---|
525 | $voti = intval($arg[$i++]);
|
---|
526 | $id_cand = intval($arg[$i]);
|
---|
527 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
528 | $ar=mysql_fetch_array($result);
|
---|
529 | if ($ar){
|
---|
530 | if ($ar['voti']!=$voti) {
|
---|
531 | mysql_query("update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
532 | 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");
|
---|
533 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','voti=".$ar['voti']."','$condizione:$id_cand voti: $voti','$tab')", $dbi);
|
---|
534 | }
|
---|
535 | } else {
|
---|
536 | if ($voti)
|
---|
537 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi);
|
---|
538 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti')", $dbi);
|
---|
539 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
|
---|
540 | }
|
---|
541 | }
|
---|
542 | // foreach ($arg as $vval) echo $vval." - ";
|
---|
543 | // solo gruppo e preferenze alle liste
|
---|
544 | if(!$votog) {
|
---|
545 | if ((($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)) {
|
---|
546 | $result = mysql_query("update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'",$dbi);
|
---|
547 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
|
---|
548 | if ($condizione=="id_lista"){
|
---|
549 | $result = mysql_query("select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
550 | $ar=mysql_fetch_array($result);
|
---|
551 | ++$i;
|
---|
552 | mysql_query("update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'", $dbi);
|
---|
553 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
|
---|
554 | # if ($ar['validi'] and !$ar['validi_lista']){
|
---|
555 | if ($ar['validi']){
|
---|
556 | # $result = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez'", $dbi);
|
---|
557 | # list($val)=mysql_fetch_row($result);
|
---|
558 | # mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$val' where id_sez='$id_sez'", $dbi);
|
---|
559 | mysql_query("update ".$prefix."_ele_sezioni set validi_lista=(`validi`+`contestati`+`voti_nulli`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'", $dbi);
|
---|
560 | 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");
|
---|
561 | }
|
---|
562 | }
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | // $ops = $arg[$argc];
|
---|
567 | if ($fileout)fclose($fp);
|
---|
568 | 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");
|
---|
569 | }
|
---|
570 |
|
---|
571 |
|
---|
572 | ////////////////////////////////////////////
|
---|
573 | // da qua va la sezione per i votanti
|
---|
574 | ///////////////////////////////////////////
|
---|
575 |
|
---|
576 | function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
577 | //function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
578 | global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
|
---|
579 | $bgcolor1=$_SESSION['bgcolor2'];
|
---|
580 | OpenTable();
|
---|
581 | echo "<tr><td> </td></tr>";
|
---|
582 | $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ", $dbi);
|
---|
583 | $num = mysql_num_rows($res);
|
---|
584 | $ressez = mysql_query("SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez", $dbi);
|
---|
585 | list($maschi,$femmine)=mysql_fetch_row($ressez);
|
---|
586 | $y=0;
|
---|
587 | while (list($ora,$giorno)= mysql_fetch_row($res)){
|
---|
588 | $y++;
|
---|
589 | echo "\n<tr><td>";
|
---|
590 | echo "<form name=\"votanti$y\" action=\"admin.php\">";
|
---|
591 | echo "<table border=\"0\" width=\"100%\" align=\"center\"><tr>";
|
---|
592 | if ($genere==0){ //e' un referendum
|
---|
593 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
|
---|
594 | }
|
---|
595 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
|
---|
596 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
|
---|
597 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
|
---|
598 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
|
---|
599 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
|
---|
600 | if ($genere==0){
|
---|
601 | $res2 = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
602 | $max = mysql_num_rows($res2);
|
---|
603 | }else{ $max=1;}
|
---|
604 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
|
---|
605 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
606 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
607 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
608 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
609 | echo "</td>"; //la riga viene chiusa nel ciclo for
|
---|
610 | for ($i=1;$i<=$max;$i++){
|
---|
611 | $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
|
---|
612 | on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
|
---|
613 | and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
614 | if ($genere==0){
|
---|
615 | $query.=" and t2.num_gruppo=$i";
|
---|
616 | }
|
---|
617 | $result = mysql_query($query, $dbi);
|
---|
618 | list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = mysql_fetch_row($result);
|
---|
619 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ", $dbi);
|
---|
620 | if ($res2)
|
---|
621 | list($gruppo)= mysql_fetch_row($res2);
|
---|
622 | else
|
---|
623 | $gruppo=0;
|
---|
624 | if (!$gruppo>0) {
|
---|
625 | $gruppo=$i;
|
---|
626 | $res3 = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons", $dbi);
|
---|
627 | if ($res3)
|
---|
628 | list($id_gruppo)=mysql_fetch_row($res3);
|
---|
629 | }
|
---|
630 | if ($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t){
|
---|
631 | echo "</tr><tr style=\"background-color: rgb(255, 0, 0); align=center\">";
|
---|
632 | }else{
|
---|
633 | echo "</tr><tr align=\"center\">";
|
---|
634 | }
|
---|
635 | if ($genere==0){ // e' un referendum
|
---|
636 | echo "<td align=\"center\">$gruppo</td>";
|
---|
637 | }
|
---|
638 |
|
---|
639 | list ($anno,$mese,$di)=explode('-',$giorno);
|
---|
640 | echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
|
---|
641 | if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\"><input";
|
---|
642 | else echo "<td align=\"center\"><input";
|
---|
643 | if ($y<$num) { echo " type=\"hidden\"";}
|
---|
644 | echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
|
---|
645 | if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\"><input";
|
---|
646 | else echo "<td align=\"center\"><input";
|
---|
647 | if ($y<$num) { echo " type=\"hidden\"";}
|
---|
648 | echo " name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
|
---|
649 | if ($voti_t > ($maschi+$femmine)) echo "<td align=\"center\" bgcolor=\"red\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\">";
|
---|
650 | else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\">";
|
---|
651 | echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
|
---|
652 | ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
|
---|
653 | ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
|
---|
654 | ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
|
---|
655 | echo "</td>";
|
---|
656 | }
|
---|
657 | echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td></tr>";
|
---|
658 |
|
---|
659 |
|
---|
660 |
|
---|
661 | echo "</table></form></td></tr>";
|
---|
662 | $compl= mysql_query("select voti_complessivi from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez", $dbi);
|
---|
663 | list ($complessivi)= mysql_fetch_row($compl);
|
---|
664 | if (!$complessivi)
|
---|
665 | {
|
---|
666 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
667 | if ($y==$num) {
|
---|
668 | echo "document.votanti$y.voti_u1.focus()\n";
|
---|
669 | echo "document.votanti$y.voti_u1.select()\n";
|
---|
670 | }else{
|
---|
671 | echo "document.votanti$y.voti_t1.focus()\n";
|
---|
672 | echo "document.votanti$y.voti_t1.select()\n";
|
---|
673 | }
|
---|
674 | echo "//-->\n"
|
---|
675 | ."</script>\n";
|
---|
676 | break;
|
---|
677 | }
|
---|
678 | }
|
---|
679 | CloseTable();
|
---|
680 | }
|
---|
681 |
|
---|
682 |
|
---|
683 | ///////////////////////////
|
---|
684 | // registra i votanti
|
---|
685 | ///////////////////////////
|
---|
686 |
|
---|
687 | function rec_add_votanti() {
|
---|
688 | global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
|
---|
689 | //ordine dei parametri: 0)op 1)voti_u 2) voti_d 3)voti_t 4)id_cons 5)id_sez 6)id_circ 7)id_sede
|
---|
690 | // 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
|
---|
691 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
692 |
|
---|
693 | $username="$aid";
|
---|
694 | $arg2 = func_get_args();
|
---|
695 | $arg = split(",",$arg2[0]);//foreach($arg as $key=>$val) echo "$key:$val<br>";die();
|
---|
696 | $arg = split(",",$arg2[0]);
|
---|
697 | $id_cons_gen=intval($arg[1]);
|
---|
698 | $id_sez=intval($arg[2]);
|
---|
699 | $id_circ=intval($arg[3]);
|
---|
700 | $id_sede=intval($arg[4]);
|
---|
701 | for($i=5;$i< count($arg)-1;) {
|
---|
702 | $voti_u = intval($arg[$i++]);
|
---|
703 | $voti_d = intval($arg[$i++]);
|
---|
704 | $voti_t = intval($arg[$i++]);
|
---|
705 | if($voti_t==0) $voti_t=$voti_d+$voti_u;
|
---|
706 | $id_parz = intval($arg[$i++]);
|
---|
707 | $giorno = $arg[$i++];
|
---|
708 | $ora = $arg[$i++];
|
---|
709 | $id_gruppo = intval($arg[$i++]);
|
---|
710 | $data=date("Y/m/d");
|
---|
711 | $tempo=date("H:i:s");
|
---|
712 | $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
|
---|
713 | if ($genere==0){
|
---|
714 | $query.=" and id_gruppo=$id_gruppo";
|
---|
715 | }
|
---|
716 | $res=mysql_query("$query",$dbi);
|
---|
717 | $righe=mysql_num_rows($res);
|
---|
718 | if (!$righe){
|
---|
719 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')", $dbi);
|
---|
720 | mysql_query("insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo')", $dbi);
|
---|
721 | if ($fileout) fwrite($fp,"insert into ".$prefix."_ele_voti_parziale values ('$id_cons', '$id_sez','$id_parz','$ora','$giorno','$voti_u','$voti_d','$voti_t','$id_gruppo');\n");
|
---|
722 | } else {
|
---|
723 | $res=mysql_query("select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz",$dbi);
|
---|
724 | $ar=mysql_fetch_array($res);
|
---|
725 | if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){
|
---|
726 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$data','$tempo','ora:$ar[3] data:$ar[4] voti uomini:$ar[5] donne:$ar[6] totali:$ar[7] gruppo:$ar[8]','id_parz:$id_parz ora: $ora data:$giorno voti uomini:$voti_u donne:$voti_d totali:$voti_t id_gruppo:$id_gruppo','".$prefix."_ele_voti_parziale')", $dbi);
|
---|
727 | $result = mysql_query("update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz'", $dbi);
|
---|
728 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_voti_parziale set voti_uomini='$voti_u', voti_donne='$voti_d', voti_complessivi='$voti_t' where id_parz='$id_parz';\n");
|
---|
729 | }
|
---|
730 | }
|
---|
731 | }
|
---|
732 | if ($fileout)fclose($fp);
|
---|
733 | Header("Location: admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&id_sede=$id_sede&id_sez=$id_sez&ops=1&do=spoglio");
|
---|
734 | }
|
---|
735 |
|
---|
736 |
|
---|
737 |
|
---|
738 | function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
739 | global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
|
---|
740 | ////////////////////////////////////////////
|
---|
741 | // da qua va la sezione per i voti finali
|
---|
742 | ///////////////////////////////////////////
|
---|
743 | $bgcolor1="#7777ff";
|
---|
744 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
745 |
|
---|
746 |
|
---|
747 |
|
---|
748 | echo "<form name=\"spogliovoti\" action=\"admin.php\">"
|
---|
749 | ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
|
---|
750 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
751 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
752 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
753 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
754 |
|
---|
755 | echo "<table border=\"0\" width=\"80%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
|
---|
756 | /* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
757 | echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
|
---|
758 | else */
|
---|
759 | echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
|
---|
760 | echo "<td width=\"32\"><b>"._NULLI."</b></td>"
|
---|
761 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
762 | ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
|
---|
763 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
764 | ."<td><b>"._TOTNON."</b></td>"
|
---|
765 | ."<td><b>"._TOTALEVOTI."</b></td>"
|
---|
766 | ."<td bgcolor=\"#ffffff\"></td> </tr>";
|
---|
767 | /*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
768 | $result = mysql_query("select id_cons,id_sez,validi_lista,nulli,bianchi,contestati_lista,voti_nulli_lista,solo_gruppo,contestati,voti_nulli from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
769 | else */
|
---|
770 | $result = mysql_query("select id_cons,id_sez,validi,nulli,bianchi,contestati,voti_nulli,'0','0','0' from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
771 | list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis) = mysql_fetch_row($result);
|
---|
772 | $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
|
---|
773 | $tot_voti=$validi+$tot_nulli+$sg+$conts+$nullis;
|
---|
774 |
|
---|
775 | echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\">";
|
---|
776 | /* if(($genere==3 or $genere==5) and !$votog and $ops==3){
|
---|
777 | echo "</td><td>$nulli"
|
---|
778 | ."</td><td>$bianchi";
|
---|
779 | echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
|
---|
780 | }else{ */
|
---|
781 | echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\">"
|
---|
782 | ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\">";
|
---|
783 | // }
|
---|
784 | echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\">"
|
---|
785 | ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\">"
|
---|
786 | ."</td><td>$tot_nulli"
|
---|
787 | ."</td><td>$tot_voti</td><td>"
|
---|
788 | // ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
|
---|
789 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
|
---|
790 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
791 | ."</td></tr></table></form>"; //</td></tr>";
|
---|
792 |
|
---|
793 |
|
---|
794 | // echo "</table>";
|
---|
795 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
796 | if (!$validi) {
|
---|
797 | echo "document.spogliovoti.validi.focus()\n";
|
---|
798 | echo "document.spogliovoti.validi.select()\n";
|
---|
799 | }
|
---|
800 | echo "//-->\n"
|
---|
801 | ."</script>\n";
|
---|
802 |
|
---|
803 |
|
---|
804 | }
|
---|
805 |
|
---|
806 |
|
---|
807 |
|
---|
808 |
|
---|
809 |
|
---|
810 |
|
---|
811 | ///////////////////////////
|
---|
812 | // registra voti finali
|
---|
813 | ///////////////////////////
|
---|
814 |
|
---|
815 | function rec_finale() {
|
---|
816 | global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
|
---|
817 |
|
---|
818 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
819 | $arg2 = func_get_args();
|
---|
820 | $arg = split(",",$arg2[0]);
|
---|
821 | $id_cons_gen=intval($arg[1]);
|
---|
822 | $id_sez = intval($arg[2]);
|
---|
823 | $id_circ = intval($arg[3]);
|
---|
824 | $id_sede = intval($arg[4]);
|
---|
825 | $validi = intval($arg[5]);
|
---|
826 | $nulli = intval($arg[6]);
|
---|
827 | $bianchi = intval($arg[7]);
|
---|
828 | $votinulli = intval($arg[8]);
|
---|
829 | $contestati = intval($arg[9]);
|
---|
830 | $ops = $arg[10];
|
---|
831 | $username="$aid";
|
---|
832 | $log_data= date("Y/m/d");
|
---|
833 | $log_ora=getdate(time());
|
---|
834 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
835 |
|
---|
836 | $result= mysql_query("select voti_complessivi from ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' order by id_parz desc", $dbi);
|
---|
837 | list($voti_t) = mysql_fetch_row($result);
|
---|
838 | $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
|
---|
839 | $result= mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
840 | $ar=mysql_fetch_array($result);
|
---|
841 | #die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
|
---|
842 | if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
843 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi_lista:$ar[14] nulli:$ar[7] bianchi:$ar[8] contestati_lista:$ar[15] voti_nulli_lista:$ar[16]','validi_lista=$validi, nulli=$nulli,bianchi=$bianchi,contestati_lista=$contestati,voti_nulli_lista=$votinulli','_ele_sezioni')", $dbi);
|
---|
844 |
|
---|
845 | /* $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli_lista='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
846 | 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"); */
|
---|
847 | $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
848 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', contestati='$contestati', validi_lista='$validi', nulli='$nulli',bianchi='$bianchi',contestati_lista='$contestati', voti_nulli='$votinulli' where id_cons='$id_cons' and id_sez='$id_sez';\n");
|
---|
849 | }else{
|
---|
850 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario','validi:$ar[6] nulli:$ar[7] bianchi:$ar[8] contestati:$ar[9] voti_nulli:$ar[13]','validi=$validi, nulli=$nulli,bianchi=$bianchi,contestati=$contestati, voti_nulli=$votinulli','_ele_sezioni')", $dbi);
|
---|
851 | $valista="";
|
---|
852 | if ($ar['validi_lista']){
|
---|
853 | $tvalista=$validi+$contestati+$votinulli-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista'];
|
---|
854 | $valista=",validi_lista='$tvalista'";
|
---|
855 | }
|
---|
856 |
|
---|
857 | $result = mysql_query("update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $valista where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
858 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set validi='$validi', nulli='$nulli',bianchi='$bianchi',contestati='$contestati',voti_nulli='$votinulli' $valista where id_cons='$id_cons' and id_sez='$id_sez';\n");
|
---|
859 | }
|
---|
860 | // }
|
---|
861 | // Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
|
---|
862 | if ($fileout) fclose($fp);
|
---|
863 | 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");
|
---|
864 |
|
---|
865 | /*}else{
|
---|
866 |
|
---|
867 | echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
|
---|
868 | 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>";
|
---|
869 | }*/
|
---|
870 | }
|
---|
871 |
|
---|
872 |
|
---|
873 | function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
874 | global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo;
|
---|
875 | ////////////////////////////////////////////
|
---|
876 | // da qua va la sezione per le preferenze ai gruppi
|
---|
877 | ///////////////////////////////////////////
|
---|
878 | // Controllo immmissioni
|
---|
879 | $bgcolor1="#7777ff";
|
---|
880 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
881 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
882 | $max = mysql_num_rows($res);
|
---|
883 | $max = $max-1;
|
---|
884 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
885 | if ($genere==0) {
|
---|
886 | echo "document.sezioni.si1.focus()\n";
|
---|
887 | echo "document.sezioni.si1.select()\n";
|
---|
888 | } else {
|
---|
889 | echo "document.sezioni.voti1.focus()\n"
|
---|
890 | ."document.sezioni.voti1.select()\n";
|
---|
891 | }
|
---|
892 | echo "//-->\n"
|
---|
893 | ."</script>\n";
|
---|
894 | // tabella votanti
|
---|
895 | if ($genere!=0){
|
---|
896 | $result = mysql_query("SELECT voti_uomini,voti_donne, voti_complessivi FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_cons='$id_cons' and (voti_uomini > 0 or voti_donne > 0)", $dbi);
|
---|
897 | list( $voti_u, $voti_d, $voti_t) = mysql_fetch_row($result);
|
---|
898 | echo "<table border=\"0\" width=\"50%\" align=\"center\">"
|
---|
899 | ."<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>"
|
---|
900 | ."<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>";
|
---|
901 | echo "</table>";
|
---|
902 | }
|
---|
903 | echo "<table border=\"0\" width=\"50%\" align=\"center\"><tr>";
|
---|
904 | if ($genere==0){
|
---|
905 | $res = mysql_query("SELECT id_gruppo,si+no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
906 | while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = mysql_fetch_row($res)){
|
---|
907 | if ($voti_parz!=$validi){
|
---|
908 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
909 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
910 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
911 | }
|
---|
912 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
913 | list($tot) = mysql_fetch_row($res2);
|
---|
914 | if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
|
---|
915 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
916 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
917 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
918 | }
|
---|
919 | }
|
---|
920 | }else{
|
---|
921 | $res = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
922 | list($voti_parz) = mysql_fetch_row($res);
|
---|
923 | $res = mysql_query("SELECT validi,nulli,bianchi,contestati,solo_gruppo,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
924 | list($validi,$nulli,$bianchi,$contestati,$solo_gruppo,$votinulli) = mysql_fetch_row($res);
|
---|
925 | if ($voti_parz!=$validi and $voti_parz>0){
|
---|
926 | echo "<td style=\"background-color: rgb(255, 0, 0); align=center\"><img src=\"modules/Elezioni/images/alert.gif\" align=\"middle\" alt=\"\"><br><b> "._ATT_VOTI." ".$voti_parz." "._NO_VAL_VOTI." ".$validi."</b><br></td>";
|
---|
927 | }
|
---|
928 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
929 | list($tot) = mysql_fetch_row($res2);
|
---|
930 | if ($validi+$nulli+$bianchi+$contestati+$votinulli!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
|
---|
931 | echo "<td style=\"background-color: rgb(255, 0, 0); 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>";
|
---|
932 | }
|
---|
933 | }
|
---|
934 | echo "<td></td></tr></table>";
|
---|
935 | if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
|
---|
936 | echo "<form name=\"sezioni\" action=\"admin.php\">";
|
---|
937 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
|
---|
938 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
939 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
940 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
941 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
942 | echo "<br><br> <table border=\"0\" width=\"60%\" align=\"center\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
|
---|
943 | ."<td width=\"3%\"><b>"._NUM."</b></td>"
|
---|
944 | ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
|
---|
945 | if ($genere==0){
|
---|
946 | echo "<td><b>"._SI."</b></td>"
|
---|
947 | ."<td><b>"._NO."</b></td>"
|
---|
948 | ."<td><b>"._VALIDI."</b></td>"
|
---|
949 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
950 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
951 | ."<td><b>"._NULLI."</b></td>"
|
---|
952 | ."<td><b>"._TOTNON."</b></td>";
|
---|
953 | }else{
|
---|
954 | echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
|
---|
955 | }
|
---|
956 | echo "</tr>";
|
---|
957 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
|
---|
958 | $max = mysql_num_rows($res);
|
---|
959 | //echo "Massimo:$max - id=$id_cons - circo: $circo";
|
---|
960 | $result = mysql_query("select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ", $dbi);
|
---|
961 | $i=1;
|
---|
962 | $tot_pref=0;
|
---|
963 |
|
---|
964 | while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = mysql_fetch_row($result)){
|
---|
965 |
|
---|
966 | //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
|
---|
967 |
|
---|
968 |
|
---|
969 | if ($num_gruppo != ''){
|
---|
970 | if ($genere==0){
|
---|
971 | $res = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
972 | list($tot) = mysql_fetch_row($res);
|
---|
973 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_ref where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
974 | $pro= mysql_fetch_array($res, 3);
|
---|
975 |
|
---|
976 | 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)){
|
---|
977 | echo "<tr style=\"background-color: rgb(255, 0, 0); align=center\">";
|
---|
978 | }else{
|
---|
979 | echo "<tr style=\"background-color: $bgcolor2; align=center\">";
|
---|
980 | }
|
---|
981 | $descr = explode('.',$descr_gruppo, 100);
|
---|
982 | echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
983 | ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
|
---|
984 | $pro['si']=$pro['si']>0 ? $pro['si']:0;
|
---|
985 | $pro['no']=$pro['no']>0 ? $pro['no']:0;
|
---|
986 | $pro['validi']=$pro['validi']>0 ? $pro['validi']:0;
|
---|
987 | $pro['bianchi']=$pro['bianchi']>0 ? $pro['bianchi']:0;
|
---|
988 | $pro['contestati']=$pro['contestati']>0 ? $pro['contestati']:0;
|
---|
989 | $pro['nulli']=$pro['nulli']>0 ? $pro['nulli']:0;
|
---|
990 | $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
|
---|
991 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" ></td>";
|
---|
992 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" ></td>";
|
---|
993 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" ></td>";
|
---|
994 | echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" ></td>";
|
---|
995 | echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" ></td>";
|
---|
996 | echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" ></td>";
|
---|
997 | echo "</td><td align=\"right\">$tot_nulli</td>";
|
---|
998 | }else{
|
---|
999 | echo "<tr style=\"background-color: $bgcolor2; align=center\"><td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
1000 | ."</td><td align=\"left\"><b> $descr_gruppo </b>";
|
---|
1001 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
1002 | $pro= mysql_fetch_array($res, 3);
|
---|
1003 | echo "</td><td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" ></td>";
|
---|
1004 | $tot_pref += $pro['voti'];
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | $i++;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | }
|
---|
1011 | if ($genere!=0) {
|
---|
1012 | echo "<tr style=\"background-color: $bgcolor1; align=center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td></tr>";
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" value=\" "._OK. "\"></td>";
|
---|
1016 |
|
---|
1017 | echo "</tr></table></form><br><br> ";
|
---|
1018 | }
|
---|
1019 | if ($genere!=0){
|
---|
1020 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 |
|
---|
1025 |
|
---|
1026 |
|
---|
1027 |
|
---|
1028 |
|
---|
1029 | ///////////////////////////
|
---|
1030 | // registra le preferenze ai gruppi
|
---|
1031 | ///////////////////////////
|
---|
1032 |
|
---|
1033 | function rec_voti_gruppi() {
|
---|
1034 | global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout;
|
---|
1035 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
1036 | $username="$aid";
|
---|
1037 | $log_data= date("Y/m/d");
|
---|
1038 | $log_ora=getdate(time());
|
---|
1039 | $arg2 = func_get_args();
|
---|
1040 | $arg = split(",",$arg2[0]);
|
---|
1041 | $id_cons_gen=intval($arg[1]);
|
---|
1042 | $id_sez = intval($arg[2]);
|
---|
1043 | $id_circ = intval($arg[3]);
|
---|
1044 | $id_sede = intval($arg[4]);
|
---|
1045 | $y=count($arg)-1;
|
---|
1046 | if ($genere==0) {
|
---|
1047 | $tab="_ele_voti_ref";
|
---|
1048 | } else {
|
---|
1049 | $tab="_ele_voti_gruppo";
|
---|
1050 | $y--;
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 | for($i=5;$i< $y;) {
|
---|
1054 | $id_gruppo = intval($arg[$i++]);
|
---|
1055 | switch ($genere){
|
---|
1056 | case (0):
|
---|
1057 | $si=intval($arg[$i++]);
|
---|
1058 | $no=intval($arg[$i++]);
|
---|
1059 | $val=intval($arg[$i++]);
|
---|
1060 | if ($val==0){$val=$si+$no;}
|
---|
1061 | $bia=intval($arg[$i++]);
|
---|
1062 | $con=intval($arg[$i++]);
|
---|
1063 | $nul=intval($arg[$i++]);
|
---|
1064 | $voti = "$si,$no,$val,$nul,$bia,$con";
|
---|
1065 | $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
|
---|
1066 | break;
|
---|
1067 | default:
|
---|
1068 | $voti = intval($arg[$i++]);
|
---|
1069 | if (!$voti) {$voti="0";}
|
---|
1070 | $riga="voti=$voti";
|
---|
1071 | break;
|
---|
1072 | }
|
---|
1073 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1074 | $ar=mysql_fetch_array($result);
|
---|
1075 | $res = mysql_query("select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1076 | list($num_gruppo)=mysql_fetch_array($res);
|
---|
1077 | $oldval='';
|
---|
1078 | if ($ar){
|
---|
1079 | switch ($genere){
|
---|
1080 | case (0):
|
---|
1081 | if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
|
---|
1082 | or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
|
---|
1083 | $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
|
---|
1084 | }
|
---|
1085 | break;
|
---|
1086 | default:
|
---|
1087 | if ($ar['voti']!=$voti) {
|
---|
1088 | $oldval="voti:".$ar['voti'];
|
---|
1089 | $voti.=",null";
|
---|
1090 | }
|
---|
1091 | if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
|
---|
1092 | break;
|
---|
1093 | }
|
---|
1094 | if ($oldval) {
|
---|
1095 | mysql_query("update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1096 | 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");
|
---|
1097 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','$oldval','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
|
---|
1098 | }
|
---|
1099 | } else {
|
---|
1100 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','".$log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']."','','num_gruppo:$num_gruppo $riga','$tab')", $dbi);
|
---|
1101 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)", $dbi);
|
---|
1102 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti);\n");
|
---|
1103 | //
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | }
|
---|
1107 | //$ops = $arg[$argc];
|
---|
1108 | if ($fileout) fclose($fp);
|
---|
1109 | 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");
|
---|
1110 |
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 |
|
---|
1114 | if (!ereg("rec",$op)) {
|
---|
1115 | ele(); //menu
|
---|
1116 | numeri_sezione();
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 | switch ($op){
|
---|
1120 | case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
|
---|
1121 | voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
1122 | break;
|
---|
1123 | default :
|
---|
1124 | $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
|
---|
1125 | }
|
---|
1126 | echo"</td></tr></table>";
|
---|
1127 | include ("footer.php");
|
---|
1128 | ?>
|
---|
1129 |
|
---|
1130 |
|
---|