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 | 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;
|
---|
46 | if(!isset($votolista)) $votolista=0;
|
---|
47 | $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
|
---|
48 | list($tipo_cons) = mysql_fetch_row($res);
|
---|
49 | if ($tipo_cons!=3 or $votolista==1) $limite=0; #die ("limite: $limite");}
|
---|
50 | $res = mysql_query("SELECT count(id_circ) FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ", $dbi);
|
---|
51 | list($num_circ)=mysql_fetch_row($res);
|
---|
52 | if ($conscirc){ // or $num_circ==1
|
---|
53 | if (!$id_circ){
|
---|
54 | $res = mysql_query("SELECT id_circ FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ limit 0,1", $dbi);
|
---|
55 | if (!$res) die("Errore, non trovo circoscrizioni inserite! Consultare l'amministratore");
|
---|
56 | list($id_circ)=mysql_fetch_row($res);
|
---|
57 | $_SESSION['id_circ']=$id_circ;
|
---|
58 | }
|
---|
59 | $result = mysql_query("select id_sede from ".$prefix."_ele_sede where id_circ='$id_circ'", $dbi);
|
---|
60 | $i=0;
|
---|
61 | while(list($tmp) = mysql_fetch_row($result)) $idsedi[$i++]=$tmp;$tmp=implode (",",$idsedi);
|
---|
62 | unset($idsedi);$i=0;$idsezi=array();unset($result);
|
---|
63 | $result = mysql_query("SELECT id_sez FROM ".$prefix."_ele_sezioni where id_sede in ($tmp)", $dbi);
|
---|
64 | unset($tmp);
|
---|
65 | while(list($tmp) = mysql_fetch_row($result)) $idsezi[$i++]=$tmp;
|
---|
66 | $tmp=implode (",",$idsezi);
|
---|
67 | $sezi = "and id_sez in ($tmp)";
|
---|
68 | $circo = "and id_circ='$id_circ'";
|
---|
69 | }else{
|
---|
70 | $sezi='';
|
---|
71 | $circo='';
|
---|
72 | }
|
---|
73 |
|
---|
74 | function stato_rilevazione($id_sez,$solosede){
|
---|
75 | global $id_cons, $prefix, $dbi, $id_cons_gen,$status,$genere,$votol, $votog, $idrefgruppo;
|
---|
76 |
|
---|
77 | if($idrefgruppo) $perref= "and id_gruppo='$idrefgruppo'";
|
---|
78 | else $perref="";
|
---|
79 | $ops=0;
|
---|
80 | $status=0;
|
---|
81 | if($ops==0){
|
---|
82 | #controllo congruenza affluenze
|
---|
83 | $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc", $dbi);
|
---|
84 | if($res)
|
---|
85 | while (list($ora,$giorno) = mysql_fetch_row($res)){
|
---|
86 | $query="SELECT sum(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";
|
---|
87 | $res2 = mysql_query("$query", $dbi);
|
---|
88 | list($voti)=mysql_fetch_row($res2);
|
---|
89 | if($voti) {
|
---|
90 | if(isset($ora)){
|
---|
91 | $query="SELECT count(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' $perref and orario='$ora' and data='$giorno'";
|
---|
92 | $res3 = mysql_query("$query", $dbi);
|
---|
93 | list($numscru)=mysql_fetch_row($res3);
|
---|
94 | $res3= mysql_query("SELECT count(num_sez) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
|
---|
95 | list($numtot) = mysql_fetch_row($res3);
|
---|
96 | $res3= mysql_query("SELECT maschi+autorizzati_m,femmine+autorizzati_f FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
97 | list($iscrittim,$iscrittif) = mysql_fetch_row($res3);
|
---|
98 | $iscritti=$iscrittim+$iscrittif;
|
---|
99 |
|
---|
100 | $query="SELECT voti_complessivi, voti_uomini, voti_donne FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' $perref and orario='$ora' and data='$giorno'";
|
---|
101 | $res3 = mysql_query("$query", $dbi);
|
---|
102 | list($voti, $uomini, $donne)=mysql_fetch_row($res3);
|
---|
103 | # if($voti>0) {#echo $query;
|
---|
104 | if ((($uomini+$donne)==0 and ($voti)<=$iscritti) or ((($uomini+$donne)==$voti) and ($uomini<=$iscrittim) and ($donne<=$iscrittif))){
|
---|
105 | #if($numscru<$numtot and $numscru>0)
|
---|
106 | {$status=1;$ops=-1;break;}#
|
---|
107 | # else
|
---|
108 | # {$status=0;$ops=-1;break;}
|
---|
109 | }else {return 1;}
|
---|
110 | # } else return 0;
|
---|
111 | }
|
---|
112 | } else {return -1;}
|
---|
113 | }
|
---|
114 | # return 0;
|
---|
115 | #controllo congruenza voti espressi
|
---|
116 | #per referendum
|
---|
117 | if($genere==0){
|
---|
118 | $res2= mysql_query("SELECT si,no,validi,nulli,bianchi,contestati FROM ".$prefix."_ele_voti_ref where id_sez='$id_sez' and id_gruppo='$idrefgruppo'", $dbi);
|
---|
119 | $refscru=mysql_num_rows($res2);
|
---|
120 | if($refscru){
|
---|
121 | # echo "$voti - $ora - $giorno :<br>";
|
---|
122 | list($si,$no,$validi,$nulli,$bianchi,$contestati)=mysql_fetch_row($res2);
|
---|
123 | if(($si+$no==$validi) and ($validi+$nulli+$bianchi+$contestati==$voti)) {$status=1;return (-4);}
|
---|
124 | else return (4);
|
---|
125 | } else {$status=0; return (-4);}
|
---|
126 | }
|
---|
127 | #per le altre consultazione
|
---|
128 | $res2= mysql_query("SELECT sum(validi) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
|
---|
129 | if($res2){
|
---|
130 | list($validi) = mysql_fetch_row($res2);
|
---|
131 | if($validi) {
|
---|
132 | $status=0;
|
---|
133 | $query="SELECT validi,nulli,bianchi,contestati,voti_nulli,solo_gruppo,validi_lista,contestati_lista,voti_nulli_lista,solo_lista FROM ".$prefix."_ele_sezioni as t1 where t1.id_sez='$id_sez'";
|
---|
134 | $res4 = mysql_query("$query", $dbi);
|
---|
135 | list($validi, $nulli, $bianchi,$contestati,$votinulli,$sologruppo,$validilista,$contestatilista,$votinullilista,$sololista)=mysql_fetch_row($res4);
|
---|
136 | if($validi>0) {
|
---|
137 | if (($validi+$nulli+$bianchi+$contestati+$votinulli+$sololista)==$voti)
|
---|
138 | {$status=1;$ops=(-4+$votog);}
|
---|
139 | else return (4-$votog);
|
---|
140 | } #else return 0;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | #controllo congruenza voti di gruppo
|
---|
144 | $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons'", $dbi);
|
---|
145 | if($res3 and !$votog){$status=0;$ops=-4;
|
---|
146 | list($votig) = mysql_fetch_row($res3);
|
---|
147 | if($votig and $genere!=2) {
|
---|
148 | $status=0;
|
---|
149 | $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
|
---|
150 | $res4 = mysql_query("$query", $dbi);
|
---|
151 | list($votigs)=mysql_fetch_row($res4);
|
---|
152 | if($votigs>0) {
|
---|
153 | if (($votigs)==$validi)
|
---|
154 | {$status=1;$ops=-3;}
|
---|
155 | else return 4;
|
---|
156 | } #else return 0;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | #controllo congruenza voti di lista
|
---|
160 | $res3= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons'", $dbi);
|
---|
161 | if($res3 and ($genere>1 and !$votol)){$status=0;
|
---|
162 | list($votil) = mysql_fetch_row($res3);
|
---|
163 | if($votil) {
|
---|
164 |
|
---|
165 | $query="SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
|
---|
166 | $res4 = mysql_query("$query", $dbi);
|
---|
167 | list($votils)=mysql_fetch_row($res4);
|
---|
168 | if($votils>0) {
|
---|
169 | $query="SELECT id_lista FROM ".$prefix."_ele_lista where id_cons='$id_cons'";
|
---|
170 | $res3 = mysql_query("$query", $dbi);
|
---|
171 | $testcand=0;
|
---|
172 | while(list($testlista)=mysql_fetch_row($res3)){
|
---|
173 | $res4= mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez' and id_lista='$testlista'", $dbi);
|
---|
174 | if($res4) list($testvotil)=mysql_fetch_row($res4); else $testvotil=0;
|
---|
175 | $res4= mysql_query("SELECT sum(t1.voti) FROM ".$prefix."_ele_voti_candidati as t1 left join ".$prefix."_ele_candidati as t2 on t1.id_cand=t2.id_cand where t1.id_cons='$id_cons' and t1.id_sez='$id_sez' and t2.id_lista='$testlista'", $dbi);
|
---|
176 | if($res4) list($testvotic)=mysql_fetch_row($res4); else $testvotic=0;
|
---|
177 | $res4= mysql_query("SELECT preferenze FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
|
---|
178 | if($res4) list($testpref)=mysql_fetch_row($res4); else $testpref=0;
|
---|
179 | if(($testvotil*$testpref)<$testvotic) { $testcand=1;break;}
|
---|
180 | }
|
---|
181 | if($genere==4 or $votog) $contestatilista=0;
|
---|
182 | if (($votils+$sologruppo+$contestatilista+$votinullilista)==($validi+$sololista) and $validilista==$votils and $testcand==0)
|
---|
183 | {$status=1;$ops=-3;}
|
---|
184 | else {return 3;}
|
---|
185 | } #else return 0;
|
---|
186 | }
|
---|
187 | }elseif($ops==-3){ $ops=-4;}
|
---|
188 |
|
---|
189 |
|
---|
190 | return ($ops);
|
---|
191 | }
|
---|
192 |
|
---|
193 | }
|
---|
194 |
|
---|
195 | // Offset - visualizza il numero di elementi per pagina
|
---|
196 | $offset=2;
|
---|
197 | if (!isset($min)) $min=0;
|
---|
198 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
199 |
|
---|
200 | function numeri_sezione($nums) {
|
---|
201 | // tabella visualizzazione sezioni per numero
|
---|
202 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$id_cons,$id_lista,$ops, $perms,$id_sez;
|
---|
203 | // $ressup = mysql_query("select permessi from ".$prefix."_ele_operatori where aid='$aid'",$dbi);
|
---|
204 | // list ($perms)=mysql_fetch_row($ressup);
|
---|
205 | $solosede='';
|
---|
206 | if ($perms<32) {
|
---|
207 | $res = mysql_query("SELECT id_sede FROM ".$prefix."_ele_operatori where aid='$aid' and id_cons=$id_cons", $dbi);
|
---|
208 | if ($res) {
|
---|
209 | list($solouna)=mysql_fetch_row($res);
|
---|
210 | if ($solouna>0) $solosede="and id_sede='$solouna'";
|
---|
211 | }
|
---|
212 | }
|
---|
213 | $res = mysql_query("SELECT num_sez, id_sez ,id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' $solosede order by num_sez", $dbi);
|
---|
214 | $max = mysql_num_rows($res);
|
---|
215 | //if ($max>=64){
|
---|
216 | $i=0;
|
---|
217 | echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
|
---|
218 |
|
---|
219 |
|
---|
220 | echo "<div id=\"navmenu\"> <ul>";
|
---|
221 | while(list($sez_num, $sez_id ,$sede_id) = mysql_fetch_row($res)) {
|
---|
222 | $ops='';
|
---|
223 | if(!$id_sez) {$id_sez=$sez_id; $id_sede=$sede_id;}
|
---|
224 | $i++;
|
---|
225 | $result = mysql_query("SELECT id_circ FROM ".$prefix."_ele_sede where id_cons='$id_cons' and id_sede='$sede_id' ", $dbi);
|
---|
226 | list($circ_id) = mysql_fetch_row($result);
|
---|
227 | //colora la sezione
|
---|
228 | $sezstat=0; #die($ops);
|
---|
229 | global $status;
|
---|
230 | global $idrefgruppo; $idrefgruppo='';
|
---|
231 | if($genere==0){
|
---|
232 | $resref = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons'", $dbi);
|
---|
233 | while(list($idrefgruppo)=mysql_fetch_row($resref)) {
|
---|
234 | $sezstat=stato_rilevazione($sez_id,$solosede);
|
---|
235 | if ($sezstat>0) break;
|
---|
236 | }
|
---|
237 | }else
|
---|
238 | $sezstat=stato_rilevazione($sez_id,$solosede);
|
---|
239 | $cursez="style=\" background: #bbbbbb;";
|
---|
240 | $bgsez="";
|
---|
241 | # if ($sezstat==(-1)) $bgsez="#99CC33"; #verde
|
---|
242 |
|
---|
243 | # if ($status==1 and $sezstat<0) { $ops=abs($sezstat);$bgsez="#99CC33";} #verde
|
---|
244 | if ($status==1 and $sezstat<0) { $ops=abs($sezstat);$cursez="style=\" background: #99CC33;";} #verde
|
---|
245 | elseif ($sezstat<0) {$ops=abs($sezstat);}
|
---|
246 | elseif ($sezstat>0) {
|
---|
247 | # $bgsez="#FF3300";#rosso;
|
---|
248 | $cursez="style=\" background: #FF3300;";#rosso;
|
---|
249 | if ($sezstat) $ops=$sezstat; else $ops=1;
|
---|
250 | }
|
---|
251 | else{$cursez="style=\" background: #8CC8C7;";}
|
---|
252 | if(!$ops) $ops=1;
|
---|
253 | $res2= mysql_query("SELECT num_sez FROM ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
254 | list($numero_sez) = mysql_fetch_row($res2);
|
---|
255 | # if ($sez_num==$numero_sez) {$cursez= "style=\" border-color: YELLOW; border-width: 5px;\"";}
|
---|
256 | if ($sez_num==$numero_sez) {$cursez.= " border: solid; border-color: YELLOW; border-width: 4px; border-left: solid gray 4px; border-top: solid gray 4px;\"";} else $cursez.="\"";
|
---|
257 | # echo "\n<td align=\"center\" width=\"5%\" bgcolor=\"$bgsez\" $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></td>\n";
|
---|
258 | 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";
|
---|
259 | # if (($i%$nums) ==0) echo "</ul></div></td></tr></table>\n"; #<tr bgcolor=\"$bgcolor1\">
|
---|
260 | }
|
---|
261 | //}
|
---|
262 | echo "</ul></div></td></tr></table>\n";
|
---|
263 | # echo"</td></tr></table>";
|
---|
264 | //}// fine tabella per numero sezioni
|
---|
265 | // inizio tabella centrale
|
---|
266 | # echo "\n</td><td valign=\"top\" align=\"left\">";
|
---|
267 | }
|
---|
268 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
269 |
|
---|
270 |
|
---|
271 | function voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista) {
|
---|
272 | global $aid,$bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $tipo_cons, $genere,$id_cons_gen,$prev_sez,$votog,$votol,$votoc,$conscirc,$id_sez;
|
---|
273 |
|
---|
274 | echo "<table border=\"0\" width=\"770\" align=\"left\"><tr>";
|
---|
275 | echo "\n<td bgcolor=\"$bgcolor1\" align=\"left\">";
|
---|
276 | //echo "<h6>";
|
---|
277 | # echo "\n<table align=\"left\" width=\"100%\" border=\"3\"><tr bgcolor=\"$bgcolor1\"><td>";
|
---|
278 | numeri_sezione(22);
|
---|
279 | # echo "<td></td></tr></table>\n";
|
---|
280 | # echo "</td></tr></table>\n";
|
---|
281 | echo "\n</td></tr><tr><td>\n";
|
---|
282 |
|
---|
283 |
|
---|
284 | ///////////////////////
|
---|
285 | // Circoscrizione : scelta
|
---|
286 | ///////////////////////
|
---|
287 |
|
---|
288 | $resoper=mysql_query("SELECT t1.id_sede,t2.id_circ FROM ".$prefix."_ele_operatori as t1,
|
---|
289 | ".$prefix."_ele_sede as t2
|
---|
290 | where t1.id_cons='$id_cons' AND t1.id_sede=t2.id_sede and t1.aid='$aid'", $dbi);
|
---|
291 | list($id_sede2,$id_circ2) = mysql_fetch_row($resoper);
|
---|
292 | if ($id_sede2 and !($id_sede==$id_sede2)) {
|
---|
293 | $id_sede=$id_sede2;
|
---|
294 | $id_circ=$id_circ2;
|
---|
295 | $do="spoglio";
|
---|
296 | $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);
|
---|
297 | list($id_sez) = mysql_fetch_row($res);
|
---|
298 | }
|
---|
299 | if ($do == "circo") {
|
---|
300 | OpenTable();
|
---|
301 | echo "<tr><td><form name=\"voti\" action=\"admin.php\">"
|
---|
302 | ."<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
303 | ."<input type=\"hidden\" name=\"do\" value=\"sede\">"
|
---|
304 | // Circoscrizione: lista
|
---|
305 | //**************************************
|
---|
306 | .""._CIRCO.": "
|
---|
307 | ."<select name=\"id_circ\">";
|
---|
308 | $res= mysql_query("SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ", $dbi);
|
---|
309 | while(list($id,$descr) = mysql_fetch_row($res)) {
|
---|
310 | if ($descr!="Tutte"){
|
---|
311 | if ($id == $id_circ) {
|
---|
312 | $sel = "selected";
|
---|
313 | } else {
|
---|
314 | $sel = "";
|
---|
315 | }
|
---|
316 | echo "<option value=\"$id\" $sel>$descr";
|
---|
317 | }
|
---|
318 | }
|
---|
319 | echo "</select>"
|
---|
320 | //***********************************
|
---|
321 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
322 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
323 | ."</form></td></tr>";
|
---|
324 | CloseTable();
|
---|
325 | }
|
---|
326 |
|
---|
327 | ///////////////////////
|
---|
328 | // sede : scelta
|
---|
329 | ///////////////////////
|
---|
330 |
|
---|
331 |
|
---|
332 | if ($do == "sede") {
|
---|
333 | OpenTable();
|
---|
334 | echo "\n<tr><td><form name=\"sede\" action=\"admin.php\">";
|
---|
335 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
336 | list( $descr_circ) = mysql_fetch_row($res);
|
---|
337 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->";
|
---|
338 | echo "<input type=\"hidden\" name=\"op\" value=\"voti\">"
|
---|
339 | ."<input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
340 |
|
---|
341 | // Indirizzo: lista
|
---|
342 | //**************************************
|
---|
343 | .""._INDIRIZZO.": "
|
---|
344 | ."<select name=\"id_sede\">";
|
---|
345 | $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);
|
---|
346 | // echo "$id_circ - $id_cons";
|
---|
347 | while(list($id,$indir) = mysql_fetch_row($res)) {
|
---|
348 | if ($id == $id_sede) {
|
---|
349 | $sel = "selected";
|
---|
350 | } else {
|
---|
351 | $sel = "";
|
---|
352 | }
|
---|
353 | echo "<option value=\"$id\" $sel>$indir";
|
---|
354 | }
|
---|
355 | echo "</select>"
|
---|
356 | //*************************************
|
---|
357 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
358 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
359 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
360 | ."</form></td></tr>\n";
|
---|
361 | CloseTable();
|
---|
362 | }
|
---|
363 |
|
---|
364 | ///////////////////////
|
---|
365 | // sezione : scelta
|
---|
366 | ///////////////////////
|
---|
367 | if ($do == "spoglio") {
|
---|
368 | /* echo "\n<form name=\"sezione\" action=\"admin.php\">";
|
---|
369 | OpenTable();
|
---|
370 | echo "<tr><td>";
|
---|
371 | $res= mysql_query("SELECT descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' AND id_circ='$id_circ' order by num_circ", $dbi);
|
---|
372 | list($descr_circ) = mysql_fetch_row($res);
|
---|
373 | $res= mysql_query("SELECT indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' AND id_sede='$id_sede' order by indirizzo", $dbi);
|
---|
374 | list($indir) = mysql_fetch_row($res);
|
---|
375 | 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=\">";
|
---|
376 | echo "<a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&do=circo\">"._CIRCO."</a> $descr_circ ->
|
---|
377 | <a href=\"admin.php?op=voti&id_cons_gen=$id_cons_gen&id_circ=$id_circ&do=sede\">"._INDIRIZZO."</a> $indir ->
|
---|
378 | <input type=\"hidden\" name=\"op\" value=\"voti\">
|
---|
379 | <input type=\"hidden\" name=\"do\" value=\"spoglio\">"
|
---|
380 | // Sezioni:lista
|
---|
381 | //**************************************
|
---|
382 | ."<b>"._SEZIONE."</b>: "
|
---|
383 | ."<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\">";
|
---|
384 | $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);
|
---|
385 | $rif_sez=0;
|
---|
386 | $next_sez=0;
|
---|
387 | unset($prev_sez);
|
---|
388 | while(list($id,$num) = mysql_fetch_row($res)) {
|
---|
389 | if (!($id_sez>0)) {$id_sez=$id;}
|
---|
390 | if ($id == $id_sez) {
|
---|
391 | $sel = "selected";
|
---|
392 | $prev_sez=$rif_sez;
|
---|
393 | } else {
|
---|
394 | $sel = "";
|
---|
395 | if (isset($prev_sez) and ($next_sez==0)) { $next_sez=$id;}
|
---|
396 | $rif_sez=$id;
|
---|
397 | }
|
---|
398 | echo "<option value=\"$id\" $sel>$num";
|
---|
399 | }
|
---|
400 | echo "</select>"
|
---|
401 | //*************************************
|
---|
402 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">\n"
|
---|
403 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">\n"
|
---|
404 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">\n"
|
---|
405 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">\n"
|
---|
406 | ." <input type=\"submit\" name=\"update\" value=\""._OK."\">\n";
|
---|
407 | if ($prev_sez) {
|
---|
408 | 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";
|
---|
409 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._PREV."</span> ";}
|
---|
410 | if ($next_sez) {
|
---|
411 | 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";
|
---|
412 | }else {echo " <span style=\"color: rgb(204, 204, 204);\">"._NEXT."</span>\n";}
|
---|
413 | echo "\n</td></tr>";
|
---|
414 | CloseTable();
|
---|
415 |
|
---|
416 | echo "</form>\n";
|
---|
417 | echo "\n</td></tr><tr><td>\n";
|
---|
418 | // echo "\n</td></tr></table>\n";
|
---|
419 | */
|
---|
420 |
|
---|
421 | //************************************
|
---|
422 | // Menu spoglio
|
---|
423 | //************************************
|
---|
424 | $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);
|
---|
425 | list($id_cons2,$id_sez2,$id_sede,$num_sez, $maschi, $femmine) = mysql_fetch_row($result);
|
---|
426 |
|
---|
427 | //$bgcolor1="#b0b0b0";
|
---|
428 | # echo "<hr><table border=\"0\" width=\"60%\" align=\"center\"><tr>";
|
---|
429 | echo "<hr><table class=\"table-menu\"><tr>";
|
---|
430 | 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";
|
---|
431 | if(!($genere==4) and !($votog)){ //if(!($genere==4) and !($tipo_cons==10 or $tipo_cons==11)){
|
---|
432 | 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";
|
---|
433 | }
|
---|
434 | if(($genere>2 or $votog)){ //if(($genere>2 or $tipo_cons==10 or $tipo_cons==11)){
|
---|
435 | 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";
|
---|
436 | }
|
---|
437 | echo "</tr></table><hr>\n";
|
---|
438 | // echo "\n</td></tr></table>\n";
|
---|
439 | #############
|
---|
440 | # posizionamento in mancanza di scelta
|
---|
441 | #############
|
---|
442 | if (!$ops){
|
---|
443 | if (!$id_sez) { echo"";#import( pagina di help );
|
---|
444 | } else{
|
---|
445 | $res= mysql_query("SELECT data, orario from ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
|
---|
446 | list($data,$orario)=mysql_fetch_row($res);
|
---|
447 | $res= mysql_query("SELECT voti_complessivi from ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and orario='$orario' and data='$data'", $dbi);
|
---|
448 | list($voti) = mysql_fetch_row($res);
|
---|
449 | if (!$voti) $ops=1;
|
---|
450 | else {
|
---|
451 | # $res= mysql_query("SELECT validi from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
452 | # list($voti) = mysql_fetch_row($res);
|
---|
453 | if($genere<4){
|
---|
454 | $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'", $dbi);
|
---|
455 | list($voti) = mysql_fetch_row($res);
|
---|
456 | if ($voti==0 or $genere<3) $ops=4;
|
---|
457 | }
|
---|
458 | if(!$ops) $ops=3;
|
---|
459 | }
|
---|
460 |
|
---|
461 | }
|
---|
462 | }
|
---|
463 | ############ fine posizionamento
|
---|
464 |
|
---|
465 | ///////////////////////////////////////////
|
---|
466 | // opzioni per le funzioni di immissione
|
---|
467 |
|
---|
468 | if ($ops == 1) {
|
---|
469 | votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av);
|
---|
470 | }else{
|
---|
471 | ############# Controllo flag per cancellazione consultazione
|
---|
472 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
473 | ."//-->\n";
|
---|
474 | echo "function del_dati() {\n";
|
---|
475 | echo "if (document.getElementById('pwd3').checked==false) {\n";
|
---|
476 | echo "document.getElementById('update').value=\""._OK."\" \n";
|
---|
477 | echo "document.getElementById('do').value=\"0\" \n";
|
---|
478 | echo "}else{\n";
|
---|
479 | echo "document.getElementById('update').value=\""._DELETE."\" \n";
|
---|
480 | echo "document.getElementById('do').value=\"1\" \n";
|
---|
481 | echo "} \n";
|
---|
482 | echo "} \n";
|
---|
483 | echo "</script>\n";
|
---|
484 | }
|
---|
485 | /*
|
---|
486 | if ($ops == 2) {
|
---|
487 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
488 | }
|
---|
489 | */
|
---|
490 | if ($ops == 3) {
|
---|
491 | preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
492 | }
|
---|
493 | if ($ops == 4) {
|
---|
494 | preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
495 |
|
---|
496 | }
|
---|
497 |
|
---|
498 | }
|
---|
499 | CloseTable();
|
---|
500 |
|
---|
501 | }
|
---|
502 | ////////////////////////////////////////////////////////////////////////////////
|
---|
503 | // FUNZIONI DI IMMISSIONE
|
---|
504 | // - preferenze (candidati consiglieri)
|
---|
505 | // - preferenze_gruppi
|
---|
506 | // - votanti
|
---|
507 | ////////////////////////////////////////////////////////////////////////////////
|
---|
508 |
|
---|
509 | //////////////////////////////////////////////////////////////////////
|
---|
510 | // da qui va la sezione per le preferenze candidati consiglieri
|
---|
511 | //////////////////////////////////////////////////////////////////////
|
---|
512 | function preferenze($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
513 | global $aid, $prefix, $dbi, $id_lista,$genere,$id_cons_gen,$id_gruppo,$sezi,$circo,$votog,$votol,$votoc,$conscirc;
|
---|
514 | global $tipo_cons,$limite;
|
---|
515 | $bgcolor1="#7777ff";
|
---|
516 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
517 | //controlla se sono stati inseriti i votanti
|
---|
518 | $result = mysql_query("SELECT preferenze, id_fascia, id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'",$dbi);
|
---|
519 | list($numprefs,$fascia,$id_conf)=mysql_fetch_row($result);
|
---|
520 |
|
---|
521 | if(!$votog and ($genere==3 or $genere==5))
|
---|
522 | $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);
|
---|
523 | else
|
---|
524 | $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);
|
---|
525 | #e
|
---|
526 | list($validi,$nulli,$bianchi,$contestati,$votinulli) = mysql_fetch_row($result);
|
---|
527 | # if ($validi+$nulli+$bianchi) die("entra($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite)");
|
---|
528 | echo "<table class=\"table-menu\" style=\"width: 100%;\"><tr>";
|
---|
529 | $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);
|
---|
530 | $num_liste = mysql_num_rows($res_lis);
|
---|
531 | $ele_lista='';
|
---|
532 | if (($genere==4 or $genere==5) and !$votoc) { //liste a piu' candidati
|
---|
533 | if(($genere==5 and $fascia<=$limite and $id_conf) and !$id_lista) { //esclude il voto di lista per le comunali nei comuni sotto fascia limite
|
---|
534 | $result = mysql_query("SELECT id_lista from ".$prefix."_ele_lista where id_cons=$id_cons limit 0,1",$dbi);
|
---|
535 | list($id_lista)=mysql_fetch_row($result);
|
---|
536 | }
|
---|
537 | echo "<td> </td></tr><tr><td style=\"vertical-align: top;\">";
|
---|
538 | echo "<form name=\"liste\" action=\"admin.php\">";
|
---|
539 | 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=\">";
|
---|
540 | echo "<select name=\"id_lista\" size=\"".($num_liste+1)."\" onChange=\"vai_lista()\">";
|
---|
541 | if ($id_lista){
|
---|
542 | echo "<option value=\"0\">"._VOTI_LISTA;
|
---|
543 | $ele_lista=" and t1.id_lista='$id_lista' ";
|
---|
544 | }else{
|
---|
545 | echo "<option value=\"0\" selected>"._VOTI_LISTA;
|
---|
546 | $ele_lista=" group by t1.id_lista ";
|
---|
547 | if(!isset($votolista)) $votolista=0;
|
---|
548 |
|
---|
549 | }
|
---|
550 | while(list($id_rif,$descrizione,$num_lis) = mysql_fetch_row($res_lis)) {
|
---|
551 | $segna='';
|
---|
552 | $result = mysql_query("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_rif",$dbi);
|
---|
553 | list($votisezcand)=mysql_fetch_row($result);
|
---|
554 | if(($fascia>$limite or !$id_conf) or $genere==4)
|
---|
555 | $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_rif'", $dbi);
|
---|
556 | else{
|
---|
557 |
|
---|
558 | $result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_rif'", $dbi);
|
---|
559 | list($id_gruppo)=mysql_fetch_row($result);
|
---|
560 | $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
561 | }
|
---|
562 | list($votisezlis)=mysql_fetch_row($result);
|
---|
563 | if($votisezcand>($votisezlis*$numprefs))
|
---|
564 | $segna="style=\"background-color: #dd0000;\"";
|
---|
565 |
|
---|
566 |
|
---|
567 |
|
---|
568 |
|
---|
569 |
|
---|
570 |
|
---|
571 |
|
---|
572 | $sel = ($id_rif == $id_lista) ? "selected" : "";
|
---|
573 | echo "<option $segna value=\"$id_rif\" $sel>";
|
---|
574 | for ($j=strlen($num_lis);$j<2;$j++) { echo " ";}
|
---|
575 | echo $num_lis.") ".substr($descrizione,0,30);
|
---|
576 | }
|
---|
577 | echo "</select></form></td>\n";
|
---|
578 | }else {
|
---|
579 | $id_lista=0;
|
---|
580 | }
|
---|
581 | echo "<td style=\"vertical-align: top;\">";
|
---|
582 |
|
---|
583 | if ((!$id_lista)){$tab="_ele_voti_lista";} else {$tab="_ele_voti_candidati";}
|
---|
584 | if(($genere==4 or ($genere==5 and $votog)) and !$id_lista)
|
---|
585 | $result = mysql_query("SELECT sum(t1.voti),t2.validi, t2.solo_gruppo,t2.contestati_lista,t2.voti_nulli,t2.bianchi,t2.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);
|
---|
586 | else
|
---|
587 | $result = mysql_query("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 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);
|
---|
588 | list( $voti_sez, $validi2, $sg,$cont2,$vnulli2,$bia2,$nul2,$con2,$vnul2) = mysql_fetch_row($result);
|
---|
589 | $valista=$validi2;
|
---|
590 | if(!$id_lista or $genere==3){ //controllo di congruenza
|
---|
591 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
592 | list($tot) = mysql_fetch_row($res2);
|
---|
593 | if ($validi2+$vnulli2+$cont2+$sg+$bia2+$nul2+$con2+$vnul2!=$tot and $validi+$sg>0){
|
---|
594 | 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>";
|
---|
595 | }
|
---|
596 |
|
---|
597 | if((($voti_sez)!=$validi2) and ($voti_sez>0)){
|
---|
598 | 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>";
|
---|
599 | }
|
---|
600 | }elseif($genere==5){
|
---|
601 | $result = mysql_query("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",$dbi);
|
---|
602 | list($votisezcand)=mysql_fetch_row($result);
|
---|
603 | if($fascia>$limite or !$id_conf)
|
---|
604 | $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez' and id_lista='$id_lista'", $dbi);
|
---|
605 | else{
|
---|
606 |
|
---|
607 | $result = mysql_query("SELECT id_gruppo from ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
|
---|
608 | list($id_gruppo)=mysql_fetch_row($result);
|
---|
609 | $result = mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
610 | }
|
---|
611 | list($votisezlis)=mysql_fetch_row($result);
|
---|
612 | if($votisezcand>($votisezlis*$numprefs))
|
---|
613 | 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>";
|
---|
614 |
|
---|
615 | }
|
---|
616 |
|
---|
617 |
|
---|
618 |
|
---|
619 | echo "\n<form name=\"sezioni\" action=\"admin.php\">"
|
---|
620 | ."<input type=\"hidden\" name=\"op\" value=\"rec_voti\">"
|
---|
621 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
622 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
623 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
624 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
625 | ."<input type=\"hidden\" name=\"tabella\" value=\"$tab\">"
|
---|
626 | ."<input type=\"hidden\" name=\"id_lista\" value=\"$id_lista\">\n"
|
---|
627 | ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">\n";
|
---|
628 | echo "<table class=\"table-menu\" style=\"width: 90%; color: black\">";
|
---|
629 | echo "<tr><td bgcolor=\"$bgcolor1\" align=\"left\" width=\"32\">";
|
---|
630 | if ($genere<4){
|
---|
631 | // echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._LISTA."</b></td>";
|
---|
632 | }
|
---|
633 | echo "<b>"._NUM."</b></td>";
|
---|
634 | if($id_lista){
|
---|
635 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._CANDIDATO."</b></td>"
|
---|
636 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
637 | }else{
|
---|
638 | echo "<td bgcolor=\"$bgcolor1\" align=\"left\"><b>"._DESCR."</b></td>"
|
---|
639 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTI."</b></td>";
|
---|
640 | }
|
---|
641 | echo "</tr>\n";
|
---|
642 |
|
---|
643 |
|
---|
644 |
|
---|
645 |
|
---|
646 |
|
---|
647 | $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);
|
---|
648 | $max = mysql_num_rows($result);
|
---|
649 | $tot_pref=0;
|
---|
650 | $i=1;
|
---|
651 |
|
---|
652 | if($id_lista) {
|
---|
653 | while(list($id_cand,$id_cons2,$id_lista2, $cognome, $nome, $note, $simbolo, $num_cand) = mysql_fetch_row($result)){
|
---|
654 | // dati lista
|
---|
655 | $result1 = mysql_query("select id_lista, descrizione,simbolo,num_lista from ".$prefix."_ele_lista where id_lista='$id_lista2'", $dbi);
|
---|
656 | list($id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1);
|
---|
657 | // dati gruppo
|
---|
658 | $result2 = mysql_query("select descrizione,simbolo from ".$prefix."_ele_gruppo where id_gruppo='$id_gruppo'", $dbi);
|
---|
659 | list($descr_gruppo,$simb_gruppo)=mysql_fetch_row($result2);
|
---|
660 |
|
---|
661 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
662 | if ($genere<4){
|
---|
663 | echo "<td align=\"left\"><b><img src=\"images/lista/$simb_lista \" width=\"32\" heigth=\"32\" align=\"center\" ALT=\"$descr_lista\" > </b></td>";
|
---|
664 | }
|
---|
665 | echo "<td align=\"center\"><b> $num_cand </b></td>"
|
---|
666 | ."<td align=\"left\"><b>$cognome $nome</b></td>";
|
---|
667 | $cond_sele="and id_cand=$id_cand";
|
---|
668 | $res = mysql_query("SELECT * FROM ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' $cond_sele", $dbi);
|
---|
669 | $pro= mysql_fetch_array($res, 3);
|
---|
670 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
|
---|
671 | echo "<input type=\"hidden\" name=\"id_cand$i\" value=\"$id_cand\"></td></tr>\n";
|
---|
672 | $i++;
|
---|
673 | $tot_pref+=$pro['voti'];
|
---|
674 | }
|
---|
675 | }else {
|
---|
676 | $result1 = mysql_query("select t2.voti,t1.id_lista, descrizione,simbolo,num_lista
|
---|
677 | from ".$prefix."_ele_lista as t1, ".$prefix."_ele_voti_lista as t2
|
---|
678 | where t1.id_cons='$id_cons'
|
---|
679 | and t1.id_lista=t2.id_lista
|
---|
680 | and t2.id_sez=$id_sez
|
---|
681 | order by t1.num_lista", $dbi);
|
---|
682 | $num_lista=mysql_num_rows($result1);
|
---|
683 | if (!$num_lista){
|
---|
684 | $result1 = mysql_query("select '',t1.id_lista, descrizione,simbolo,num_lista
|
---|
685 | from ".$prefix."_ele_lista as t1 where t1.id_cons='$id_cons' $circo
|
---|
686 | order by t1.num_lista", $dbi);
|
---|
687 | }
|
---|
688 | while (list($pro['voti'],$id_lista3,$descr_lista,$simb_lista,$num_lista)=mysql_fetch_row($result1)){
|
---|
689 | echo "<tr bgcolor=\"$bgcolor2\">";
|
---|
690 | // if ($genere<4 or $votoc){
|
---|
691 | // }
|
---|
692 |
|
---|
693 | echo "<td align=\"center\"><b> $num_lista </b></td>"
|
---|
694 | ."<td align=\"left\"><b> $descr_lista</b></td>";
|
---|
695 | $cond_sele="and id_lista=$id_lista3";
|
---|
696 | echo "<td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\">";
|
---|
697 | echo "<input type=\"hidden\" name=\"id_lista$i\" value=\"$id_lista3\"></td></tr>\n";
|
---|
698 | $i++;
|
---|
699 | $tot_pref+=$pro['voti'];
|
---|
700 | }
|
---|
701 | }
|
---|
702 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td>"._TOTPREF."</td><td align=\"center\">$tot_pref</td></tr>";
|
---|
703 | // toglie ai candidati la visual... del solo_gruppo
|
---|
704 | if(!$votog) {
|
---|
705 | if (($genere==3 OR $genere==5) and (!$id_lista) and ($fascia>$limite or !$id_conf)) { //gruppo e liste
|
---|
706 | 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>";
|
---|
707 | 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>";
|
---|
708 | 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\">"
|
---|
709 | ."</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>";
|
---|
710 |
|
---|
711 | }elseif (($genere==3 OR $genere==5) and !$votoc and ($fascia>$limite or !$id_conf)){ //}elseif ($tipo_cons!=10 and $tipo_cons!=11){
|
---|
712 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">$sg</td></tr>";
|
---|
713 | }
|
---|
714 | ######modifica del 16-04-2009 per visualizzare i voti al solo sindaco nei comuni con meno di 15000 abitanti
|
---|
715 | elseif(($genere==3 OR $genere==5) and ($id_lista) and ($fascia<=$limite or !$id_conf)) {
|
---|
716 | $resvg = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_lista where id_lista='$id_lista'", $dbi);
|
---|
717 | list($id_gruppo) = mysql_fetch_row($resvg);
|
---|
718 | $resvg = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_gruppo='$id_gruppo' and id_sez='$id_sez'", $dbi);
|
---|
719 | list($voti_sind) = mysql_fetch_row($resvg);
|
---|
720 |
|
---|
721 | echo "<tr bgcolor=\"$bgcolor1\"><td></td><td><b>"._SOLO_GRUPPO."</b></td><td align=\"center\">".($voti_sind - $tot_pref)."</td></tr>";
|
---|
722 | }
|
---|
723 | ###### fine modifica del 16-04-2009
|
---|
724 |
|
---|
725 | }
|
---|
726 | echo "<tr>";
|
---|
727 | echo "<td></td><td></td>";
|
---|
728 | echo "<td align=\"center\"><input type=\"submit\" id=\"update\" name=\"update\" value=\""._OK."\"></td>";
|
---|
729 | echo "</tr></table></form></tr>";
|
---|
730 | if(chisei($id_cons_gen)>=64){
|
---|
731 | echo "<td></td><td> <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."</td>";
|
---|
732 | }
|
---|
733 | echo "</table>";
|
---|
734 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
735 | ."document.sezioni.voti1.focus()\n"
|
---|
736 | ."document.sezioni.voti1.select()\n"
|
---|
737 | ."//-->\n";
|
---|
738 | echo "function vai_lista() {\n";
|
---|
739 | echo "window.document.location.href=document.liste.pag.value+document.liste.id_lista.value\n";
|
---|
740 | echo "}\n";
|
---|
741 | echo "</script>\n";
|
---|
742 | # }
|
---|
743 | #if (!((!$votog) and ($genere==3 OR $genere==5) and ($fascia>$limite)))
|
---|
744 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
745 | }
|
---|
746 |
|
---|
747 | /////////////////////////////////////////////
|
---|
748 | // registra le preferenze ai candidati
|
---|
749 | /////////////////////////////////////////////
|
---|
750 |
|
---|
751 | function rec_voti() {
|
---|
752 | global $prefix, $dbi,$aid,$id_cons,$ops,$genere,$votog,$fileout,$id_comune,$limite,$update;
|
---|
753 | $sqlcomu="select id_fascia,id_conf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
|
---|
754 | $res = mysql_query($sqlcomu);
|
---|
755 | if($res)
|
---|
756 | list($fascia,$id_conf)=mysql_fetch_row($res);
|
---|
757 | else {$fascia=0; $id_conf=0;}
|
---|
758 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
759 | $username=$aid;
|
---|
760 | $log_data= date("Y/m/d");
|
---|
761 | $log_ora=getdate(time());
|
---|
762 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
763 | $arg2 = func_get_args();
|
---|
764 | $arg = split(",",$arg2[0]);
|
---|
765 | $id_cons_gen=intval($arg[1]);
|
---|
766 | $id_sez = intval($arg[2]);
|
---|
767 | $id_circ = intval($arg[3]);
|
---|
768 | $id_sede = intval($arg[4]);
|
---|
769 | $tab = $arg[5];
|
---|
770 | $id_lista = intval($arg[6]);
|
---|
771 | $do= intval($arg[7]);
|
---|
772 | if ($tab=="_ele_voti_candidati") {
|
---|
773 | $condizione="id_cand";
|
---|
774 | }else{
|
---|
775 | $condizione="id_lista";
|
---|
776 | }
|
---|
777 | if ((($genere==3) OR ($genere==5)) and !$id_lista and !$votog and ($fascia>$limite or !$id_conf)) $y = (count($arg)-4);
|
---|
778 | else $y=count($arg);
|
---|
779 | if($do==1) {
|
---|
780 | mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
781 | mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
782 | if($genere!=4)
|
---|
783 | mysql_query("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'", $dbi);
|
---|
784 |
|
---|
785 | }else{
|
---|
786 | for($i=8,$y--;$i< $y;$i++) {
|
---|
787 | $voti = intval($arg[$i++]);
|
---|
788 | $id_cand = intval($arg[$i]);
|
---|
789 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
790 | $ar=mysql_fetch_array($result);
|
---|
791 | if ($ar){
|
---|
792 | if ($ar['voti']!=$voti) {
|
---|
793 | mysql_query("update ".$prefix."$tab set voti='$voti' where id_cons='$id_cons' and id_sez='$id_sez' and $condizione='$id_cand'", $dbi);
|
---|
794 | 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");
|
---|
795 | 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);
|
---|
796 | }
|
---|
797 | } else {
|
---|
798 | if ($voti)
|
---|
799 | mysql_query("insert into ".$prefix."_ele_log values('$id_cons','$id_sez','$username','$log_data','$orario',' ','$condizione:$id_cand voti: $voti','$tab')", $dbi);
|
---|
800 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti')", $dbi);
|
---|
801 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_cand','$id_sez','$voti');\n");
|
---|
802 | }
|
---|
803 | }
|
---|
804 | // foreach ($arg as $vval) echo $vval." - ";
|
---|
805 | // solo gruppo e preferenze alle liste
|
---|
806 |
|
---|
807 | if(!$votog) {
|
---|
808 | if ((($genere==3) OR ($genere==5)) and !$id_lista and ($fascia>$limite or !$id_conf)) {
|
---|
809 | $valista=$arg[$i++];
|
---|
810 | $result = mysql_query("update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez'",$dbi);
|
---|
811 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set solo_gruppo='".$arg[$i]."' where id_sez='$id_sez';\n");
|
---|
812 | if ($condizione=="id_lista"){
|
---|
813 | $result = mysql_query("select * from ".$prefix."_ele_sezioni where id_sez='$id_sez'", $dbi);
|
---|
814 | $ar=mysql_fetch_array($result);
|
---|
815 | ++$i;
|
---|
816 | mysql_query("update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez'", $dbi);
|
---|
817 | if ($fileout) fwrite($fp,"update ".$prefix."_ele_sezioni set voti_nulli_lista='".$arg[$i++]."', contestati_lista='".$arg[$i++]."' where id_sez='$id_sez';\n");
|
---|
818 | # if ($ar['validi'] and !$ar['validi_lista']){
|
---|
819 | if ($ar['validi']){
|
---|
820 | # $result = mysql_query("select sum(voti) from ".$prefix."_ele_voti_lista where id_sez='$id_sez'", $dbi);
|
---|
821 | # list($val)=mysql_fetch_row($result);
|
---|
822 | # mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$val' where id_sez='$id_sez'", $dbi);
|
---|
823 | if($valista)
|
---|
824 | mysql_query("update ".$prefix."_ele_sezioni set validi_lista='$valista' where id_sez='$id_sez'", $dbi);
|
---|
825 | else
|
---|
826 | mysql_query("update ".$prefix."_ele_sezioni set validi_lista=(`validi`-`solo_gruppo`-`voti_nulli_lista`-`contestati_lista`) where id_sez='$id_sez'", $dbi);
|
---|
827 | 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");
|
---|
828 | }
|
---|
829 | }
|
---|
830 | }
|
---|
831 | }
|
---|
832 | }
|
---|
833 |
|
---|
834 | // $ops = $arg[$argc];
|
---|
835 | if ($fileout)fclose($fp);
|
---|
836 | 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");
|
---|
837 | }
|
---|
838 |
|
---|
839 |
|
---|
840 | ////////////////////////////////////////////
|
---|
841 | // da qua va la sezione per i votanti
|
---|
842 | ///////////////////////////////////////////
|
---|
843 |
|
---|
844 | function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
845 | //function votanti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av){
|
---|
846 | global $aid, $prefix, $dbi,$tipo_cons,$genere,$id_cons_gen;
|
---|
847 | $bgcolor1=$_SESSION['bgcolor2'];
|
---|
848 | OpenTable();
|
---|
849 | $res = mysql_query("SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
|
---|
850 | if($res) list($vismf)= mysql_fetch_row($res); else $vismf=0;
|
---|
851 | $res = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data,orario ", $dbi);
|
---|
852 | $num = mysql_num_rows($res);
|
---|
853 | $ressez = mysql_query("SELECT maschi,femmine FROM ".$prefix."_ele_sezioni where id_sez=$id_sez", $dbi);
|
---|
854 | list($maschi,$femmine)=mysql_fetch_row($ressez);
|
---|
855 | $y=0;
|
---|
856 | echo "<tr><td> </td></tr>";
|
---|
857 | while (list($ora,$giorno)= mysql_fetch_row($res)){
|
---|
858 | $y++;
|
---|
859 | echo "\n<tr><td>";
|
---|
860 | echo "<form name=\"votanti$y\" action=\"admin.php\">";
|
---|
861 | echo "<table class=\"table-menu\" style=\"width: 100%; color: black;\"><tr>";
|
---|
862 | if ($genere==0){ //e' un referendum
|
---|
863 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._NUM."</b></td>";
|
---|
864 | }
|
---|
865 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\" width=\"32\"><b>"._ORA."</b></td>"
|
---|
866 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"width=\"32\"><b>"._DATA."</b></td>";
|
---|
867 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIU."</b></td>";
|
---|
868 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTID."</b></td>"
|
---|
869 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VOTIT."</b>";
|
---|
870 | if ($genere==0){
|
---|
871 | $res2 = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
872 | $max = mysql_num_rows($res2);
|
---|
873 | }else{ $max=1;}
|
---|
874 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_add_votanti\">";
|
---|
875 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
876 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
877 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
878 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
879 | echo "</td>"; //la riga viene chiusa nel ciclo for
|
---|
880 | for ($i=1;$i<=$max;$i++){
|
---|
881 | $query="SELECT * FROM ".$prefix."_ele_voti_parziale as t1 left join ".$prefix."_ele_gruppo as t2
|
---|
882 | on (t1.id_gruppo=t2.id_gruppo) where t1.id_sez='$id_sez'
|
---|
883 | and t1.id_cons='$id_cons' and t1.orario='$ora' and t1.data='$giorno'";
|
---|
884 | if ($genere==0){
|
---|
885 | $query.=" and t2.num_gruppo=$i";
|
---|
886 | }
|
---|
887 | $result = mysql_query($query, $dbi);
|
---|
888 | list($id_cons2,$id_sez2,$id_parz,$orario,$data, $voti_u, $voti_d, $voti_t,$id_gruppo) = mysql_fetch_row($result);
|
---|
889 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_gruppo=$id_gruppo ", $dbi);
|
---|
890 | $resril = mysql_query("select count(0) FROM ".$prefix."_ele_voti_parziale where id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
891 | list($numril)=mysql_fetch_row($resril);
|
---|
892 | if ($res2)
|
---|
893 | list($gruppo)= mysql_fetch_row($res2);
|
---|
894 | else
|
---|
895 | $gruppo=0;
|
---|
896 | if (!$gruppo>0) {
|
---|
897 | $gruppo=$i;
|
---|
898 | $res3 = mysql_query("SELECT id_gruppo FROM ".$prefix."_ele_gruppo where num_gruppo=$gruppo and id_cons=$id_cons", $dbi);
|
---|
899 | if ($res3)
|
---|
900 | list($id_gruppo)=mysql_fetch_row($res3);
|
---|
901 | }
|
---|
902 | if(!isset($precede[$id_gruppo])) $precede[$id_gruppo]=0; if(!isset($error)) $error=0;
|
---|
903 | if($precede[$id_gruppo]>($voti_t) and $voti_t!='') $error=1;
|
---|
904 | $precede[$id_gruppo]=$voti_t;
|
---|
905 | if (($voti_u+$voti_d and $voti_u+$voti_d!=$voti_t) or $error){
|
---|
906 | echo "</tr><tr style=\"background-color: rgb(255, 0, 0); text-align: center\">"; $error=0;
|
---|
907 | }else{
|
---|
908 | echo "</tr><tr class=\"tr-dx\">";
|
---|
909 | }
|
---|
910 | if ($genere==0){ // e' un referendum
|
---|
911 | echo "<td align=\"center\">$gruppo</td>";
|
---|
912 | }
|
---|
913 |
|
---|
914 | list ($anno,$mese,$di)=explode('-',$giorno);
|
---|
915 | echo "<td align=\"center\">$ora</td><td align=\"center\">$di-$mese-$anno</td>";
|
---|
916 | if ($voti_u > $maschi) echo "<td align=\"center\" bgcolor=\"red\">";
|
---|
917 | else echo "<td align=\"center\">";
|
---|
918 | if ($y<$num and $vismf==0 and $voti_u==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
|
---|
919 | echo " name=\"voti_u$i\" value=\"$voti_u\" size=\"5\"></td>";
|
---|
920 | if ($voti_d > $femmine) echo "<td align=\"center\" bgcolor=\"red\">";
|
---|
921 | else echo "<td align=\"center\">";
|
---|
922 | if ($y<$num and $vismf==0 and $voti_d==0) { echo "<input type=\"hidden\"";}else echo "<input type=\"text\" style=\"text-align:right\"";
|
---|
923 | echo " name=\"voti_d$i\" value=\"$voti_d\" size=\"5\"></td>";
|
---|
924 | if ($voti_t > ($maschi+$femmine)) echo "<td align=\"center\" bgcolor=\"red\"><input type=\"text\" name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
|
---|
925 | else echo "<td align=\"center\"><input name=\"voti_t$i\" value=\"$voti_t\" size=\"5\" style=\"text-align:right\">";
|
---|
926 | echo "<input type=\"hidden\" name=\"id_parz$i\" value=\"$id_parz\">"
|
---|
927 | ."<input type=\"hidden\" name=\"data$i\" value=\"$giorno\">"
|
---|
928 | ."<input type=\"hidden\" name=\"orario$i\" value=\"$ora\">"
|
---|
929 | ."<input type=\"hidden\" name=\"gruppo$i\" value=\"$id_gruppo\">";
|
---|
930 | echo "</td>";
|
---|
931 | }
|
---|
932 | if (chisei($id_cons_gen)>=64 and $y==$numril) echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\">"._DELETE." <input type=\"checkbox\" name=\"delete\" value=\"true\"></td>";
|
---|
933 | else echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"hidden\" name=\"delete\" value=\"\"></td>";
|
---|
934 | echo "<td style=\"text-align: right;\" rowspan=\"1\" colspan=\"6\"><input type=\"submit\" name=\"update\" value=\""._OK."\"></td>";
|
---|
935 | echo "</tr>";
|
---|
936 |
|
---|
937 |
|
---|
938 |
|
---|
939 | # echo "</table></form></td></tr>";
|
---|
940 | echo "</table></form>";
|
---|
941 | $compl= mysql_query("select count(voti_complessivi) from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez=$id_sez", $dbi);
|
---|
942 | list ($complessivi)= mysql_fetch_row($compl);
|
---|
943 | if (!$complessivi)
|
---|
944 | {
|
---|
945 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
946 | if ($y==$num) {
|
---|
947 | echo "document.votanti$y.voti_u1.focus()\n";
|
---|
948 | echo "document.votanti$y.voti_u1.select()\n";
|
---|
949 | }else{
|
---|
950 | echo "document.votanti$y.voti_t1.focus()\n";
|
---|
951 | echo "document.votanti$y.voti_t1.select()\n";
|
---|
952 | }
|
---|
953 | echo "//-->\n"
|
---|
954 | ."</script>\n";
|
---|
955 | break;
|
---|
956 | }
|
---|
957 | echo "</td></tr>";
|
---|
958 | }
|
---|
959 | CloseTable();
|
---|
960 | }
|
---|
961 |
|
---|
962 |
|
---|
963 | ///////////////////////////
|
---|
964 | // registra i votanti
|
---|
965 | ///////////////////////////
|
---|
966 |
|
---|
967 | function rec_add_votanti() {
|
---|
968 | global $prefix, $dbi,$aid,$tipo_cons,$genere,$id_cons,$fileout;
|
---|
969 | //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
|
---|
970 | // 8)id_parz 9)ops 10)data 11)orario 12)tipo 13)id_gruppo 14) update
|
---|
971 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
972 |
|
---|
973 | $username="$aid";
|
---|
974 | $arg2 = func_get_args();
|
---|
975 | $arg = split(",",$arg2[0]);
|
---|
976 | $id_cons_gen=intval($arg[1]);
|
---|
977 | $id_sez=intval($arg[2]);
|
---|
978 | $id_circ=intval($arg[3]);
|
---|
979 | $id_sede=intval($arg[4]);
|
---|
980 | $op=$arg[count($arg)-2];
|
---|
981 | for($i=5;$i< count($arg)-2;) {
|
---|
982 | $voti_u = intval($arg[$i++]);
|
---|
983 | $voti_d = intval($arg[$i++]);
|
---|
984 | $voti_t = intval($arg[$i++]);
|
---|
985 | if($voti_t==0) $voti_t=$voti_d+$voti_u;
|
---|
986 | $id_parz = intval($arg[$i++]);
|
---|
987 | $giorno = $arg[$i++];
|
---|
988 | $ora = $arg[$i++];
|
---|
989 | $id_gruppo = intval($arg[$i++]);
|
---|
990 | $data=date("Y/m/d");
|
---|
991 | $tempo=date("H:i:s");
|
---|
992 | $query="select * from ".$prefix."_ele_voti_parziale where data='$giorno' and orario='$ora' and id_sez='$id_sez'";
|
---|
993 | if ($genere==0){
|
---|
994 | $query.=" and id_gruppo=$id_gruppo";
|
---|
995 | }
|
---|
996 | $res=mysql_query("$query",$dbi);
|
---|
997 | $righe=mysql_num_rows($res);
|
---|
998 | if (!$righe){
|
---|
999 | 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);
|
---|
1000 | 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);
|
---|
1001 | 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");
|
---|
1002 | } elseif($op=="true"){
|
---|
1003 | $result = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz'", $dbi);
|
---|
1004 | if ($fileout) fwrite($fp,"delete from ".$prefix."_ele_voti_parziale where id_parz='$id_parz';\n");
|
---|
1005 | } else {
|
---|
1006 | $res=mysql_query("select * from ".$prefix."_ele_voti_parziale where id_parz=$id_parz",$dbi);
|
---|
1007 | $ar=mysql_fetch_array($res);
|
---|
1008 |
|
---|
1009 | if ($ar['voti_uomini']!=$voti_u or $ar['voti_donne']!=$voti_d or $ar['voti_complessivi']!=$voti_t){
|
---|
1010 | 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);
|
---|
1011 | $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);
|
---|
1012 | 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");
|
---|
1013 | }
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 | if ($fileout)fclose($fp);
|
---|
1017 | 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");
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 |
|
---|
1022 | function finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
1023 | global $aid, $prefix, $dbi,$id_cons_gen,$genere,$votog,$fascia,$limite;
|
---|
1024 | ////////////////////////////////////////////
|
---|
1025 | // da qua va la sezione per i voti finali
|
---|
1026 | ///////////////////////////////////////////
|
---|
1027 | $bgcolor1="#7777ff";
|
---|
1028 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
1029 |
|
---|
1030 |
|
---|
1031 |
|
---|
1032 | echo "<form name=\"spogliovoti\" action=\"admin.php\">"
|
---|
1033 | ."<input type=\"hidden\" name=\"op\" value=\"rec_finale\">";
|
---|
1034 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
1035 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
1036 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
1037 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">";
|
---|
1038 |
|
---|
1039 | echo "<table border=\"0\" width=\"90%\" align=\"center\"><tr bgcolor=\"$bgcolor1\" align=\"center\">";
|
---|
1040 | /* if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
1041 | echo "<td width=\"32\"><b>"._VOTI_LISTA."</b></td>";
|
---|
1042 | else */
|
---|
1043 | echo "<td width=\"32\"><b>"._VALIDI."</b></td>";
|
---|
1044 | echo "<td width=\"82\"><b>"._NULLI."</b></td>"
|
---|
1045 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
1046 | ."<td width=\"32\"><b>"._VOTINULLI."</b></td>"
|
---|
1047 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
1048 | ."<td><b>"._TOTNON."</b></td>"
|
---|
1049 | ."<td><b>"._TOTALEVOTI."</b></td>"
|
---|
1050 | ."<td bgcolor=\"#ffffff\"></td> </tr>";
|
---|
1051 | /*if($ops==3 and ($genere==3 or ($genere==5 and $fascia>$limite)) )
|
---|
1052 | $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);
|
---|
1053 | else */
|
---|
1054 | $result = mysql_query("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' ", $dbi);
|
---|
1055 | list($id_cons2,$id_sez2,$validi, $nulli, $bianchi, $contestati,$votinulli,$sg,$conts,$nullis,$sololista) = mysql_fetch_row($result);
|
---|
1056 | $tot_nulli=$nulli+$bianchi+$contestati+$votinulli;
|
---|
1057 | $tot_voti=$validi+$tot_nulli+$sg+$conts+$nullis+$sololista;
|
---|
1058 | // ."</td><td><input name=\"sololista\" value=\"$sololista\" size=\"5\" style=\"text-align:right\">" --- ."<td><b>"._SOLOLIS."</b></td>"
|
---|
1059 |
|
---|
1060 |
|
---|
1061 | echo "<tr bgcolor=\"$bgcolor2\" align=\"center\"><td align=\"left\"><input name=\"validi\" value=\"$validi\" size=\"5\" style=\"text-align:right\">";
|
---|
1062 | /* if(($genere==3 or $genere==5) and !$votog and $ops==3){
|
---|
1063 | echo "</td><td>$nulli"
|
---|
1064 | ."</td><td>$bianchi";
|
---|
1065 | echo "<input type=\"hidden\" name=\"nulli\" value=\"$nulli\"><input type=\"hidden\" name=\"bianchi\" value=\"$bianchi\">";
|
---|
1066 | }else{ */
|
---|
1067 | echo "</td><td><input name=\"nulli\" value=\"$nulli\" size=\"5\" style=\"text-align:right\">"
|
---|
1068 | ."</td><td><input name=\"bianchi\" value=\"$bianchi\" size=\"5\" style=\"text-align:right\">";
|
---|
1069 | // }
|
---|
1070 | echo "</td><td><input name=\"votinulli\" value=\"$votinulli\" size=\"5\" style=\"text-align:right\">"
|
---|
1071 | ."</td><td><input name=\"contestati\" value=\"$contestati\" size=\"5\" style=\"text-align:right\">"
|
---|
1072 | ."</td><td>$tot_nulli"
|
---|
1073 | ."</td><td>$tot_voti</td><td>"
|
---|
1074 | // ."<input type=\"hidden\" name=\"id_cand\" value=\"$id_cand\">"
|
---|
1075 | ."<input type=\"hidden\" name=\"ops\" value=\"$ops\">"
|
---|
1076 | ."<input type=\"submit\" name=\"update\" value=\""._OK."\">"
|
---|
1077 | ."</td></tr></table></form>"; //</td></tr>";
|
---|
1078 |
|
---|
1079 |
|
---|
1080 | // echo "</table>";
|
---|
1081 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
1082 | if (!$validi) {
|
---|
1083 | echo "document.spogliovoti.validi.focus()\n";
|
---|
1084 | echo "document.spogliovoti.validi.select()\n";
|
---|
1085 | }
|
---|
1086 | echo "//-->\n"
|
---|
1087 | ."</script>\n";
|
---|
1088 |
|
---|
1089 |
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 |
|
---|
1093 |
|
---|
1094 |
|
---|
1095 |
|
---|
1096 |
|
---|
1097 | ///////////////////////////
|
---|
1098 | // registra voti finali
|
---|
1099 | ///////////////////////////
|
---|
1100 |
|
---|
1101 | function rec_finale() {
|
---|
1102 | global $prefix, $dbi,$aid,$id_cons,$fileout,$genere,$votog;
|
---|
1103 |
|
---|
1104 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
1105 | $arg2 = func_get_args();
|
---|
1106 | $arg = split(",",$arg2[0]);
|
---|
1107 | $id_cons_gen=intval($arg[1]);
|
---|
1108 | $id_sez = intval($arg[2]);
|
---|
1109 | $id_circ = intval($arg[3]);
|
---|
1110 | $id_sede = intval($arg[4]);
|
---|
1111 | $validi = intval($arg[5]);
|
---|
1112 | $nulli = intval($arg[6]);
|
---|
1113 | $bianchi = intval($arg[7]);
|
---|
1114 | $votinulli = intval($arg[8]);
|
---|
1115 | $contestati = intval($arg[9]);
|
---|
1116 | //$sololista = intval($arg[10]);
|
---|
1117 | $ops = $arg[10];
|
---|
1118 | $username="$aid";
|
---|
1119 | $log_data= date("Y/m/d");
|
---|
1120 | $log_ora=getdate(time());
|
---|
1121 | $orario=($log_ora['hours'].":".$log_ora['minutes'].":".$log_ora['seconds']);
|
---|
1122 |
|
---|
1123 | $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);
|
---|
1124 | list($voti_t) = mysql_fetch_row($result);
|
---|
1125 | $tot_voti=$validi+$nulli+$bianchi+$contestati+$votinulli;
|
---|
1126 | $sololista=$voti_t-$tot_voti;
|
---|
1127 | $result= mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
1128 | $ar=mysql_fetch_array($result);
|
---|
1129 | if ($ar['solo_lista'] or !isdisgiunto()) $rigasl=''; else $rigasl=", solo_lista='$sololista'";
|
---|
1130 | #die("qui: if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and $votog){");
|
---|
1131 | if($ops==3 and ($genere==3 or $genere==4 or $genere==5) and ($votog or $genere==4)){
|
---|
1132 | 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);
|
---|
1133 |
|
---|
1134 | /* $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);
|
---|
1135 | 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"); */
|
---|
1136 | $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' $rigasl where id_cons='$id_cons' and id_sez='$id_sez' ", $dbi);
|
---|
1137 | 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' $rigasl where id_cons='$id_cons' and id_sez='$id_sez';\n");
|
---|
1138 | }else{
|
---|
1139 | 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);
|
---|
1140 | $valista="";
|
---|
1141 | if ($ar['validi_lista']){
|
---|
1142 | $tvalista=$validi-$ar['solo_gruppo']-$ar['voti_nulli_lista']-$ar['contestati_lista']+$ar['solo_lista'];
|
---|
1143 | $valista=",validi_lista='$tvalista'";
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | $result = mysql_query("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' ", $dbi);
|
---|
1147 | 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");
|
---|
1148 | }
|
---|
1149 | // }
|
---|
1150 | // Il test non e' piu' necessario perche' le sezioni sono state gia' inserite in precedenza
|
---|
1151 | if ($fileout) fclose($fp);
|
---|
1152 | 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");
|
---|
1153 |
|
---|
1154 | /*}else{
|
---|
1155 |
|
---|
1156 | echo "<b><br><center><h1>I voti totali non corrispondono con i votanti</h1><b>";
|
---|
1157 | 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>";
|
---|
1158 | }*/
|
---|
1159 | }
|
---|
1160 |
|
---|
1161 |
|
---|
1162 | function preferenze_gruppi($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops){
|
---|
1163 | global $aid, $prefix, $dbi, $tipo_cons, $genere,$id_cons_gen,$sezi,$circo;
|
---|
1164 | ////////////////////////////////////////////
|
---|
1165 | // da qua va la sezione per le preferenze ai gruppi
|
---|
1166 | ///////////////////////////////////////////
|
---|
1167 | // Controllo immmissioni
|
---|
1168 | $bgcolor1="#7777ff";
|
---|
1169 | $bgcolor2=$_SESSION['bgcolor2'];
|
---|
1170 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' ", $dbi);
|
---|
1171 | $max = mysql_num_rows($res);
|
---|
1172 | $max = $max-1;
|
---|
1173 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
1174 | if ($genere==0) {
|
---|
1175 | echo "document.sezioni.si1.focus()\n";
|
---|
1176 | echo "document.sezioni.si1.select()\n";
|
---|
1177 | } else {
|
---|
1178 | echo "document.sezioni.voti1.focus()\n"
|
---|
1179 | ."document.sezioni.voti1.select()\n";
|
---|
1180 | }
|
---|
1181 | echo "//-->\n"
|
---|
1182 | ."</script>\n";
|
---|
1183 | // tabella votanti
|
---|
1184 | if ($genere!=0){
|
---|
1185 | $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' order by data desc,orario desc limit 0,1", $dbi);
|
---|
1186 | list( $voti_u, $voti_d, $voti_t) = mysql_fetch_row($result);
|
---|
1187 | echo "<table class=\"table-menu\" style=\"width: 50%; color: black;\">"
|
---|
1188 | ."<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>"
|
---|
1189 | ."<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>";
|
---|
1190 | echo "</table>";
|
---|
1191 | }
|
---|
1192 | echo "<table class=\"table-menu\" style=\"width: 50%; color: black\"><tr>";
|
---|
1193 | if ($genere==0){
|
---|
1194 | $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);
|
---|
1195 | while (list($id_gruppo,$voti_parz,$validi,$nulli,$bianchi,$contestati) = mysql_fetch_row($res)){
|
---|
1196 | if ($voti_parz!=$validi){
|
---|
1197 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo' ", $dbi);
|
---|
1198 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
1199 | echo "<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>";
|
---|
1200 | }
|
---|
1201 | $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);
|
---|
1202 | list($tot) = mysql_fetch_row($res2);
|
---|
1203 | if (($validi+$nulli+$bianchi+$contestati)!= $tot ){
|
---|
1204 | $res2 = mysql_query("SELECT num_gruppo FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1205 | list($num_gruppo) = mysql_fetch_row($res2);
|
---|
1206 | echo "<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>";
|
---|
1207 | }
|
---|
1208 | }
|
---|
1209 | }else{
|
---|
1210 | $res = mysql_query("SELECT sum(voti) FROM ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1211 | list($voti_parz) = mysql_fetch_row($res);
|
---|
1212 | $res = mysql_query("SELECT validi,nulli,bianchi,contestati,solo_lista,voti_nulli FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1213 | list($validi,$nulli,$bianchi,$contestati,$solo_lista,$votinulli) = mysql_fetch_row($res);
|
---|
1214 | if ($voti_parz!=$validi and $voti_parz>0){
|
---|
1215 | echo "<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."</b><br></td>";
|
---|
1216 | }
|
---|
1217 | $res2 = mysql_query("SELECT max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1218 | list($tot) = mysql_fetch_row($res2);
|
---|
1219 | if ($validi+$nulli+$bianchi+$contestati+$votinulli+$solo_lista!=$tot and $validi+$nulli+$bianchi+$contestati+$votinulli>0){
|
---|
1220 | echo "<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>";
|
---|
1221 | }
|
---|
1222 | }
|
---|
1223 | if(!isset($votinulli)) $votinulli=0;
|
---|
1224 | echo "<td></td></tr></table>";
|
---|
1225 | if ($validi+$nulli+$bianchi+$contestati+$votinulli>0 or $genere==0) {
|
---|
1226 | echo "<table class=\"table-menu\" style=\"width: 60%; color: black\"><tr><td colspan=\"3\"><form name=\"sezioni\" action=\"admin.php\">";
|
---|
1227 | echo "<input type=\"hidden\" name=\"op\" value=\"rec_voti_gruppi\">"
|
---|
1228 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
1229 | ."<input type=\"hidden\" name=\"id_sez\" value=\"$id_sez\">"
|
---|
1230 | ."<input type=\"hidden\" name=\"id_circ\" value=\"$id_circ\">"
|
---|
1231 | ."<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
|
---|
1232 | ."<input type=\"hidden\" name=\"do\" id=\"do\" value=\"0\">";
|
---|
1233 | echo "<br><br> <table class=\"table-menu\" style=\"width: 100%; color: black\"><tr align=\"center\" bgcolor=\"$bgcolor1\">"
|
---|
1234 | ."<td width=\"3%\"><b>"._NUM."</b></td>"
|
---|
1235 | ."<td width=\"50%\"><b>"._GRUPPO."</b></td>";
|
---|
1236 | if ($genere==0){
|
---|
1237 | echo "<td><b>"._SI."</b></td>"
|
---|
1238 | ."<td><b>"._NO."</b></td>"
|
---|
1239 | ."<td><b>"._VALIDI."</b></td>"
|
---|
1240 | ."<td><b>"._BIANCHI."</b></td>"
|
---|
1241 | ."<td><b>"._CONTESTATI."</b></td>"
|
---|
1242 | ."<td><b>"._NULLI."</b></td>"
|
---|
1243 | ."<td><b>"._TOTNON."</b></td>";
|
---|
1244 | }else{
|
---|
1245 | echo "<td width=\"5%\"><b>"._VOTI."</b></td>";
|
---|
1246 | }
|
---|
1247 | echo "</tr>";
|
---|
1248 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ", $dbi);
|
---|
1249 | $max = mysql_num_rows($res);
|
---|
1250 | //echo "Massimo:$max - id=$id_cons - circo: $circo";
|
---|
1251 | $result = mysql_query("select * from ".$prefix."_ele_gruppo where id_cons='$id_cons' $circo ORDER BY num_gruppo ", $dbi);
|
---|
1252 | $i=1;
|
---|
1253 | $tot_pref=0;
|
---|
1254 |
|
---|
1255 | while(list($id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo) = mysql_fetch_row($result)){
|
---|
1256 |
|
---|
1257 | //echo "test: $id_cons2,$id_gruppo,$num_gruppo, $descr_gruppo, $simbolo";
|
---|
1258 |
|
---|
1259 |
|
---|
1260 | if ($num_gruppo != ''){
|
---|
1261 | if ($genere==0){
|
---|
1262 | $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);
|
---|
1263 | list($tot) = mysql_fetch_row($res);
|
---|
1264 | $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);
|
---|
1265 | $pro= mysql_fetch_array($res, 3);
|
---|
1266 |
|
---|
1267 | 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)){
|
---|
1268 | echo "<tr style=\"background-color: rgb(255, 0, 0); text-align:center\">";
|
---|
1269 | }else{
|
---|
1270 | echo "<tr style=\"background-color: $bgcolor2; text-align:center\">";
|
---|
1271 | }
|
---|
1272 | $descr = explode('.',$descr_gruppo, 100);
|
---|
1273 | echo "<td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
1274 | ."</td><td align=\"left\" width=\"50%\"><b> $descr[0] </b>";
|
---|
1275 | $pro['si']=(isset($pro['si']) and $pro['si']>=0) ? $pro['si']:'';
|
---|
1276 | $pro['no']=(isset($pro['no']) and $pro['no']>=0) ? $pro['no']:'';
|
---|
1277 | $pro['validi']=(isset($pro['validi']) and $pro['validi']>=0) ? $pro['validi']:'';
|
---|
1278 | $pro['bianchi']=(isset($pro['bianchi']) and $pro['bianchi']>=0) ? $pro['bianchi']:'';
|
---|
1279 | $pro['contestati']=(isset($pro['contestati']) and $pro['contestati']>=0) ? $pro['contestati']:'';
|
---|
1280 | $pro['nulli']=(isset($pro['nulli']) and $pro['nulli']>=0) ? $pro['nulli']:'';
|
---|
1281 | $tot_nulli=$pro['nulli']+$pro['bianchi']+$pro['contestati'];
|
---|
1282 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"si$i\" value=\"".$pro['si']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1283 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"no$i\" value=\"".$pro['no']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1284 | echo "</td><td align=\"right\" width=\"3%\"><input name=\"val$i\" value=\"".$pro['validi']."\" size=\"7\" style=\"text-align:right\" ></td>";
|
---|
1285 | echo "</td><td align=\"right\"><input name=\"bia$i\" value=\"".$pro['bianchi']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1286 | echo "</td><td align=\"right\"><input name=\"con$i\" value=\"".$pro['contestati']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1287 | echo "</td><td align=\"right\"><input name=\"nul$i\" value=\"".$pro['nulli']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1288 | echo "</td><td align=\"right\">$tot_nulli</td>";
|
---|
1289 | }else{
|
---|
1290 | echo "<tr style=\"background-color: $bgcolor2; text-align:center\"><td align=\"center\"><input type=\"hidden\" name=\"id_gruppo$i\" value=\"$id_gruppo\"><b>$num_gruppo</b>"
|
---|
1291 | ."</td><td align=\"left\"><b> $descr_gruppo </b>";
|
---|
1292 | $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);
|
---|
1293 | $pro= mysql_fetch_array($res, 3);
|
---|
1294 | echo "</td><td align=\"right\"><input name=\"voti$i\" value=\"".$pro['voti']."\" size=\"7\" style=\"text-align:right\"></td>";
|
---|
1295 | $tot_pref += $pro['voti'];
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | $i++;
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | }
|
---|
1302 | if ($genere!=0) {
|
---|
1303 | $res = mysql_query("SELECT solo_lista FROM ".$prefix."_ele_sezioni where id_sez='$id_sez' ", $dbi);
|
---|
1304 | list($sololis)=mysql_fetch_row($res);
|
---|
1305 | echo "<tr style=\"background-color: $bgcolor1; text-align:center\"><td></td><td>"._TOTPREF."</td><td>$tot_pref</td></tr>";
|
---|
1306 | if(isdisgiunto())
|
---|
1307 | 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>";
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 | echo "<tr><td></td><td></td><td align=\"center\"><input type=\"submit\" name=\"update\" id=\"update\" value=\" "._OK. "\"></td>";
|
---|
1311 |
|
---|
1312 | echo "</tr></table></form></td></tr>";
|
---|
1313 | if(chisei($id_cons_gen)>=64){
|
---|
1314 | echo "<tr><td><input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_dati()\">"._DELETE."";
|
---|
1315 | }
|
---|
1316 |
|
---|
1317 | echo "</td></tr></table>";
|
---|
1318 | }
|
---|
1319 | if ($genere!=0){
|
---|
1320 | finale($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops);
|
---|
1321 | }
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 |
|
---|
1325 |
|
---|
1326 |
|
---|
1327 |
|
---|
1328 |
|
---|
1329 | ///////////////////////////
|
---|
1330 | // registra le preferenze ai gruppi
|
---|
1331 | ///////////////////////////
|
---|
1332 |
|
---|
1333 | function rec_voti_gruppi() {
|
---|
1334 | global $prefix, $dbi,$aid, $tipo_cons, $genere,$id_cons,$ops,$fileout;
|
---|
1335 | if ($fileout) while (!$fp = fopen($fileout,"a"));
|
---|
1336 | $username="$aid";
|
---|
1337 | $log_data= date("Y/m/d");
|
---|
1338 | $log_ora=getdate(time());
|
---|
1339 | $arg2 = func_get_args();
|
---|
1340 | $arg = split(",",$arg2[0]);
|
---|
1341 | $id_cons_gen=intval($arg[1]);
|
---|
1342 | $id_sez = intval($arg[2]);
|
---|
1343 | $id_circ = intval($arg[3]);
|
---|
1344 | $id_sede = intval($arg[4]);
|
---|
1345 | $do = intval($arg[5]);
|
---|
1346 | $y=count($arg)-1;
|
---|
1347 | if($do==1) {
|
---|
1348 | mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1349 | mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1350 | mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons='$id_cons' and id_sez='$id_sez'", $dbi);
|
---|
1351 | mysql_query("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'", $dbi);
|
---|
1352 |
|
---|
1353 | }else{
|
---|
1354 |
|
---|
1355 | if ($genere==0) {
|
---|
1356 | $tab="_ele_voti_ref";
|
---|
1357 | } else {
|
---|
1358 | $tab="_ele_voti_gruppo";
|
---|
1359 | $y--;
|
---|
1360 | if(isdisgiunto())
|
---|
1361 | $res=mysql_query("update ".$prefix."_ele_sezioni set solo_lista='".$arg[$y--]."' where id_sez='$id_sez'", $dbi);
|
---|
1362 |
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | for($i=6;$i< $y;) {
|
---|
1366 | $id_gruppo = intval($arg[$i++]);
|
---|
1367 | $testval=0;
|
---|
1368 | switch ($genere){
|
---|
1369 | case (0):
|
---|
1370 | if($arg[$i].$arg[$i+1]=='' ) {
|
---|
1371 | $i+=6;
|
---|
1372 | $testval=1;
|
---|
1373 | }else{
|
---|
1374 | $si=intval($arg[$i++]);
|
---|
1375 | $no=intval($arg[$i++]);
|
---|
1376 | $val=intval($arg[$i++]);
|
---|
1377 | if ($val==0){$val=$si+$no;}
|
---|
1378 | $bia=intval($arg[$i++]);
|
---|
1379 | $con=intval($arg[$i++]);
|
---|
1380 | $nul=intval($arg[$i++]);
|
---|
1381 | $voti = "'$si','$no','$val','$nul','$bia','$con'";
|
---|
1382 | $riga="si=$si,no=$no,validi=$val,nulli=$nul,bianchi=$bia,contestati=$con";
|
---|
1383 | }
|
---|
1384 | break;
|
---|
1385 | default:
|
---|
1386 | $voti = intval($arg[$i++]);
|
---|
1387 | if (!$voti) {$voti="0";}
|
---|
1388 | $riga="voti=$voti";
|
---|
1389 | break;
|
---|
1390 | }
|
---|
1391 | if($testval) continue;
|
---|
1392 | $result = mysql_query("select * from ".$prefix."$tab where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1393 | $ar=mysql_fetch_array($result);
|
---|
1394 | $res = mysql_query("select num_gruppo from ".$prefix."_ele_gruppo where id_cons='$id_cons' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1395 | list($num_gruppo)=mysql_fetch_array($res);
|
---|
1396 | $oldval='';
|
---|
1397 | if ($ar){
|
---|
1398 | switch ($genere){
|
---|
1399 | case (0):
|
---|
1400 | if ($ar['si']!=$si or $ar['no']!=$no or $ar['validi']!=$val or $ar['nulli']!=$nul
|
---|
1401 | or $ar['bianchi']!=$bia or $ar['contestati']!=$con){
|
---|
1402 | $oldval=" si:$ar[3] no:$ar[4] validi:$ar[5] nulli:$ar[6] bianchi:$ar[7] contestati:$ar[8]";
|
---|
1403 | }
|
---|
1404 | break;
|
---|
1405 | default:
|
---|
1406 | if ($ar['voti']!=$voti) {
|
---|
1407 | $oldval="voti:".$ar['voti'];
|
---|
1408 | $voti.=",null";
|
---|
1409 | }
|
---|
1410 | if (isset($ar['num_gruppo'])) $dstgruppo=$ar['num_gruppo'];
|
---|
1411 | break;
|
---|
1412 | }
|
---|
1413 | if ($oldval) {
|
---|
1414 | mysql_query("update ".$prefix."$tab set $riga where id_cons='$id_cons' and id_sez='$id_sez' and id_gruppo='$id_gruppo'", $dbi);
|
---|
1415 | 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");
|
---|
1416 | 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);
|
---|
1417 | }
|
---|
1418 | } else { #die ("test in corso: insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)");
|
---|
1419 | 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);
|
---|
1420 | mysql_query("insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti)", $dbi);
|
---|
1421 | if ($fileout) fwrite($fp,"insert into ".$prefix."$tab values ('$id_cons', '$id_gruppo','$id_sez',$voti);\n");
|
---|
1422 | //
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 | }
|
---|
1426 | }
|
---|
1427 | //$ops = $arg[$argc];
|
---|
1428 | if ($fileout) fclose($fp);
|
---|
1429 | 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");
|
---|
1430 |
|
---|
1431 | }
|
---|
1432 |
|
---|
1433 |
|
---|
1434 | if (!preg_match("/rec/",$op)) {
|
---|
1435 | ele(); //menu
|
---|
1436 | /* echo "\n<table align=\"left\" border=\"0\" width=\"200\"><tr bgcolor=\"$bgcolor1\">";
|
---|
1437 | numeri_sezione(8);
|
---|
1438 | echo "<td></td></tr></table>\n";*/
|
---|
1439 | echo"</td></tr></table>";
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 | switch ($op){
|
---|
1443 | case "voti": //fa eccezione perche' chiamata con minor numero di parametri - riesaminare
|
---|
1444 | # voti($id_cons,$do,$id_circ,$id_sede,$id_sez,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
1445 | voti($id_cons,$do,$id_circ,$id_sede,$ops,$ov,$mv,$gv,$msv,$av,$id_lista);
|
---|
1446 | break;
|
---|
1447 | default :
|
---|
1448 | $op($vari); //chiamata a funzione variabile con parametri variabili (da cambiare!)
|
---|
1449 | }
|
---|
1450 | echo"</td></tr></table>";
|
---|
1451 | include ("footer.php");
|
---|
1452 | ?>
|
---|
1453 |
|
---|