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