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