1 | <?php
|
---|
2 |
|
---|
3 | /************************************************************************/
|
---|
4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
5 | /* by Roberto Gigli & Luciano Apolito */
|
---|
6 | /* http://www.eleonline.it */
|
---|
7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
8 | /************************************************************************/
|
---|
9 | /* Modulo Autorizzazione Comuni */
|
---|
10 | /* Amministrazione */
|
---|
11 | /************************************************************************/
|
---|
12 | # e' l'unico file in cui Ú presente un controllo su tipo_cons, per ora va bene così. Per toglierlo va inserito un campo-flag in ele_tipo per indicare se per il tipo di consultazione si dovra' procedere al calcolo dell'assegnazione dei seggi
|
---|
13 | if (!defined('ADMIN_FILE')) {
|
---|
14 | die ("You can't access this file directly...");
|
---|
15 | }
|
---|
16 |
|
---|
17 | $aid=$_SESSION['aid'];
|
---|
18 | $dbi=$_SESSION['dbi'];
|
---|
19 | $prefix=$_SESSION['prefix'];
|
---|
20 | $id_comune=$_SESSION['id_comune'];
|
---|
21 | $id_cons_gen=intval($_GET['id_cons_gen']);
|
---|
22 | $perms=ChiSei(0);
|
---|
23 | if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
24 | $res = mysql_query("SELECT t1.tipo_cons,t1.descrizione,t2.id_cons,t2.id_conf FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' " , $dbi);
|
---|
25 | list($tipo_cons,$descr_cons,$id_cons,$id_conf) = mysql_fetch_row($res);
|
---|
26 |
|
---|
27 | $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
|
---|
28 | list($genere) = mysql_fetch_row($res);
|
---|
29 |
|
---|
30 | include("modules/Elezioni/funzionidata.php");
|
---|
31 | include("modules/Elezioni/ele.php");
|
---|
32 | if (isset($_GET['descr_comu'])) get_magic_quotes_gpc() ? $descr_comu=$param['descr_comu']:$descr_comu=addslashes($param['descr_comu']); else $descr_comu='';
|
---|
33 | if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
34 | if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok='';
|
---|
35 | if (isset($_GET['id_cons_comu'])) $id_cons_comu=intval($_GET['id_cons_comu']); else $id_cons_comu='';
|
---|
36 | if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']); else $id_collegio='';
|
---|
37 | if (isset($_GET['idcomune'])) $idcomune=intval($_GET['idcomune']); else $idcomune='';
|
---|
38 | if (isset($_GET['idcomunenew'])) $idcomunenew=intval($_GET['idcomunenew']); else $idcomunenew='';
|
---|
39 | if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa='';
|
---|
40 | if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']); else $id_conf=0;
|
---|
41 | if (isset($_GET['idfascia'])) $idfascia=intval($_GET['idfascia']); else $idfascia=0;
|
---|
42 | if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
|
---|
43 | if (isset($_GET['help'])) $help=intval($_GET['help']);
|
---|
44 | if (isset($_GET['pwd4'])) $pwd4=intval($_GET['pwd4']);
|
---|
45 | if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1;
|
---|
46 | if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0;
|
---|
47 | if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg=0;
|
---|
48 | if (isset($_GET['disgiunto'])) $disgiunto=intval($_GET['disgiunto']); else $disgiunto=0;
|
---|
49 |
|
---|
50 | $offset=15;
|
---|
51 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
52 |
|
---|
53 |
|
---|
54 | /******************************************************/
|
---|
55 | /*Funzione di visualizzazione globale */
|
---|
56 | /*****************************************************/
|
---|
57 | //
|
---|
58 | function all() {
|
---|
59 | global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf,$sg,$disgiunto,$id_cons_comu;
|
---|
60 | $aid=$_SESSION['aid'];
|
---|
61 | $dbi=$_SESSION['dbi'];
|
---|
62 | $prefix=$_SESSION['prefix'];
|
---|
63 | ############# Controllo flag per cancellazione consultazione
|
---|
64 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
65 | ."//-->\n";
|
---|
66 | echo "function del_cons() {\n";
|
---|
67 | echo "if (document.getElementById('pwd3').checked==false) {\n";
|
---|
68 | echo "if (document.getElementById('chiusa').selectedIndex==3) document.getElementById('chiusa').options[0].selected=true \n";
|
---|
69 | echo "document.getElementById('pwd4').checked=false \n";
|
---|
70 | echo "document.getElementById('trspunta').style.visibility='hidden' \n";
|
---|
71 | echo "} \n";
|
---|
72 | echo "else document.getElementById('trspunta').style.visibility='visible' \n";
|
---|
73 | # echo "if (document.getElementById('chiusa').options[3].selected==false) { \n";
|
---|
74 | echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n";
|
---|
75 | echo "document.getElementById('add').value=\""._MODIFY."\" \n";
|
---|
76 | echo "document.getElementById('do').value=\"update\" \n";
|
---|
77 | echo "}else{\n";
|
---|
78 | echo "if (document.getElementById('pwd4').checked==false) \n";
|
---|
79 | echo "document.getElementById('add').value=\""._DELETE." "._DATI."\" \n";
|
---|
80 | echo "else document.getElementById('add').value=\""._DELETE." "._CONSULTA."\" \n";
|
---|
81 | echo "document.getElementById('do').value=\"delete\" \n";
|
---|
82 | echo "} \n";
|
---|
83 | echo "} \n";
|
---|
84 | echo "</script>\n";
|
---|
85 |
|
---|
86 | echo "<script type=\"text/javascript\" language=\"JavaScript\" >\n\n<!--\n"
|
---|
87 | ."//-->\n";
|
---|
88 | echo "function showdate(str,posiz,tempo)\n";
|
---|
89 | echo "{\n";
|
---|
90 | echo "if (str==\"\")\n";
|
---|
91 | echo " {\n";
|
---|
92 | echo " document.getElementById(posiz).innerHTML=\"\";\n";
|
---|
93 | echo " return;\n";
|
---|
94 | echo " }\n";
|
---|
95 | echo "if (window.XMLHttpRequest)\n";
|
---|
96 | echo " {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
|
---|
97 | echo " xmlhttp=new XMLHttpRequest();\n";
|
---|
98 | echo " }\n";
|
---|
99 | echo "else\n";
|
---|
100 | echo " {// code for IE6, IE5\n";
|
---|
101 | echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
|
---|
102 | echo " }\n";
|
---|
103 | echo "xmlhttp.onreadystatechange=function()\n";
|
---|
104 | echo " {\n";
|
---|
105 | echo " if (xmlhttp.readyState==4 && xmlhttp.status==200 && posiz!=null)\n";
|
---|
106 | echo " {\n";
|
---|
107 | echo " document.getElementById(posiz).innerHTML=xmlhttp.responseText;\n";
|
---|
108 | echo " }\n";
|
---|
109 | echo " }\n";
|
---|
110 | echo "xmlhttp.open(\"GET\",str,true);\n";
|
---|
111 | echo "xmlhttp.send();\n";
|
---|
112 |
|
---|
113 | echo "}\n";
|
---|
114 | echo "</script>\n";
|
---|
115 |
|
---|
116 | #########################
|
---|
117 | if (isset($help)) include("language/$language/ele_associazioni.html");
|
---|
118 | OpenTable();
|
---|
119 | echo "<tr><td><hr><br>";
|
---|
120 | $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
|
---|
121 | list ($descr_cons) = mysql_fetch_row($res);
|
---|
122 | //inserire avviso su mancanza dei permessi
|
---|
123 | echo "<form name=\"model\" action=\"admin.php\">";
|
---|
124 | echo "<table width=\"100%\" border=\"3\">";
|
---|
125 | echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
|
---|
126 | # echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
|
---|
127 | echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
|
---|
128 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
|
---|
129 | echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
|
---|
130 | if($tipo_cons==3){
|
---|
131 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
|
---|
132 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
|
---|
133 | }
|
---|
134 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
|
---|
135 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
|
---|
136 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
|
---|
137 | # echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&id_cons_gen=\">";
|
---|
138 | echo "</tr>";
|
---|
139 | echo "<tr align=\"center\"><td>";
|
---|
140 | echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
141 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
|
---|
142 | # $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
|
---|
143 | # if ($num_coll=mysql_num_rows($ressede)){
|
---|
144 | # echo "<td><select name=\"id_collegio\">";
|
---|
145 | # while(list($id,$descr_coll)=mysql_fetch_row($ressede)){
|
---|
146 | # $sel= ($id == $id_collegio) ? "selected":"";
|
---|
147 | # echo "<option value=\"$id\" $sel>$descr_coll";
|
---|
148 | # }
|
---|
149 | # echo "</select></td>";
|
---|
150 | # } else echo "<td></td>";
|
---|
151 | $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
|
---|
152 | echo "<td>";
|
---|
153 | if($idcomune) {
|
---|
154 | while ($listele=mysql_fetch_array($rescomu))
|
---|
155 | if($listele['id_comune']==$idcomune) {
|
---|
156 | echo $listele['descrizione'];
|
---|
157 | echo "<input type=\"hidden\" name=\"idcomunenew\" value=\"$idcomune\">";
|
---|
158 | }
|
---|
159 |
|
---|
160 | }else{
|
---|
161 | echo "<select name=\"idcomunenew\">";
|
---|
162 | echo "<option value=\"0\"> ";
|
---|
163 | while(list($id,$descr_comu)=mysql_fetch_row($rescomu)){
|
---|
164 | $sel= ($id == $idcomune) ? "selected":"";
|
---|
165 | echo "<option value=\"$id\" $sel>$descr_comu";
|
---|
166 | }
|
---|
167 | echo "</select>";
|
---|
168 | }
|
---|
169 | echo "</td>";
|
---|
170 | echo "<td><input type=\"text\" name=\"preferenze\" value=\"$preferenze\" size=\"2\"></td>";
|
---|
171 | $selez['0']='';
|
---|
172 | $selez['1']='';
|
---|
173 | $selez['2']='';
|
---|
174 | $selez['3']='';
|
---|
175 | $selez[$chiusa]="selected";
|
---|
176 | echo "<td><select name=\"chiusa\" id=\"chiusa\" onChange=\"javascript:del_cons()\">";
|
---|
177 | echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
|
---|
178 | echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
|
---|
179 | echo "<option value=\"2\" ".$selez[2].">"._NULLA;
|
---|
180 |
|
---|
181 | if($idcomune) echo "<option value=\"3\" ".$selez[3].">"._ELIMINA;
|
---|
182 | echo "</select></td>";
|
---|
183 | if($tipo_cons==3){
|
---|
184 | if($idcomune) {
|
---|
185 | $rescomu = mysql_query("SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'", $dbi);
|
---|
186 | if($rescomu)
|
---|
187 | list($fasciacom)=mysql_fetch_row($rescomu);
|
---|
188 | } else $fasciacom=0;
|
---|
189 | $rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc", $dbi);
|
---|
190 | echo "<td><select name=\"id_conf\" id=\"id_conf\" onchange=\"javascript:showdate('modules/Elezioni/ele_desc_fasce.php?fascia=$fasciacom&id_conf=' + model.id_conf.options[model.id_conf.selectedIndex].value,'fasceconf');\">";
|
---|
191 | echo "<option value=\"0\"> ";
|
---|
192 | while(list($id,$descr_conf)=mysql_fetch_row($rescomu)){
|
---|
193 | $sel='';
|
---|
194 | if ($idcomune and $id == $id_conf) $sel="selected";
|
---|
195 | echo "<option value=\"$id\" $sel>$descr_conf";
|
---|
196 | }
|
---|
197 | echo "</select></td>";
|
---|
198 | if(!$id_conf) $id_conf=1;
|
---|
199 | $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
|
---|
200 |
|
---|
201 | echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
|
---|
202 | echo "<option value=\"0\"> ";
|
---|
203 | $inffascia=0;
|
---|
204 | while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
|
---|
205 | $sel='';
|
---|
206 | if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
|
---|
207 | echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
|
---|
208 | $inffascia=$abitanti;
|
---|
209 | }
|
---|
210 | echo "</select></td>";
|
---|
211 |
|
---|
212 |
|
---|
213 | }
|
---|
214 | unset($sel);
|
---|
215 | $rescomu = mysql_query("SELECT vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'", $dbi);
|
---|
216 | list($vismf,$sg,$disgiunto)=mysql_fetch_row($rescomu);
|
---|
217 | echo "<td><select name=\"vismf\">";
|
---|
218 | if ($vismf==0) $sel="selected"; else $sel="";
|
---|
219 | echo "<option value=\"0\" $sel>No";
|
---|
220 | if ($vismf==1) $sel="selected"; else $sel="";
|
---|
221 | echo "<option value=\"1\" $sel>Si";
|
---|
222 | echo "</select></td>";
|
---|
223 | echo "<td><select name=\"sg\">";
|
---|
224 | if ($sg==0) $sel="selected"; else $sel="";
|
---|
225 | echo "<option value=\"0\" $sel>No";
|
---|
226 | if ($sg==1) $sel="selected"; else $sel="";
|
---|
227 | echo "<option value=\"1\" $sel>Si";
|
---|
228 | echo "</select></td>";
|
---|
229 | echo "<td><select name=\"disgiunto\">";
|
---|
230 | if ($disgiunto==0) $sel="selected"; else $sel="";
|
---|
231 | echo "<option value=\"0\" $sel>No";
|
---|
232 | if ($disgiunto==1) $sel="selected"; else $sel="";
|
---|
233 | echo "<option value=\"1\" $sel>Si";
|
---|
234 | echo "</select></td>";
|
---|
235 |
|
---|
236 | echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
|
---|
237 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
238 | if ($idcomune) {
|
---|
239 | echo "<input type=\"hidden\" id=\"do\" name=\"do\" value=\"update\">";
|
---|
240 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
|
---|
241 | echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
|
---|
242 | echo "<tr><td colspan=\"5\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov1\">"._SPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_cons()\"></label></fieldset></td></tr>";
|
---|
243 | # <div id=\"trspunta\" style=\"visibility:hidden\"> </div>
|
---|
244 | echo "<tr id=\"trspunta\" style=\"visibility:hidden\"><td colspan=\"4\"><fieldset><legend>"._SPUNTALABEL2."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd4\" name=\"pwd4\" value=\"1\" onclick=\"javascript:del_cons()\"></label></fieldset>";
|
---|
245 | }else{
|
---|
246 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
247 | echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\">";
|
---|
248 | }
|
---|
249 | $i=0;
|
---|
250 | echo "</td></tr></table></form>";
|
---|
251 | ############
|
---|
252 | echo "<hr><br><table width=\"100%\" border=\"3\">";
|
---|
253 | echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."TEST:$id_cons_comu</b></td>";
|
---|
254 | # echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
|
---|
255 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
|
---|
256 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
|
---|
257 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
|
---|
258 | if($tipo_cons==3){
|
---|
259 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
|
---|
260 | echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
|
---|
261 | }
|
---|
262 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
|
---|
263 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
|
---|
264 | echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
|
---|
265 | # echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SG."</b></td>";
|
---|
266 | echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b> "._FUNZIONI."</td></tr>";
|
---|
267 | ###############
|
---|
268 |
|
---|
269 | # if ($num_coll>0)
|
---|
270 | # $resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
|
---|
271 | # else
|
---|
272 | $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
|
---|
273 | while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
|
---|
274 | $resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
|
---|
275 | list($descr_conf) = mysql_fetch_row($resconf);
|
---|
276 | $i++;
|
---|
277 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
278 | if($tipo_cons==3) echo "<tr><td colspan=\"8\">"; else echo "<tr><td colspan=\"8\">";
|
---|
279 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
280 | ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
281 | // echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
282 | # echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
|
---|
283 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
|
---|
284 | echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
|
---|
285 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
286 | echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
|
---|
287 | echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
|
---|
288 | echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
|
---|
289 | echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
|
---|
290 | echo "<td width=\"15%\"><b>$descr_cons</b></td>";
|
---|
291 | echo "<td width=\"20%\"><b>$descr_comu</b></td>";
|
---|
292 | echo "<td width=\"10%\"><b>$preferenze2</b></td>";
|
---|
293 | $stato['0']=_ATTIVA;
|
---|
294 | $stato['1']=_CHIUSA;
|
---|
295 | $stato['2']=_NULLA;
|
---|
296 | echo "<td width=\"10%\"><b>".$stato[$chiusa]."</b></td>";
|
---|
297 | if($tipo_cons==3){
|
---|
298 | echo "<td width=\"20%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
|
---|
299 | $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
|
---|
300 | $inffascia=0;
|
---|
301 | while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
|
---|
302 | $sel='';
|
---|
303 | if ($id == $fasciacom)
|
---|
304 | echo "<td width=\"20%\">$inffascia - $abitanti</td>";
|
---|
305 | $inffascia=$abitanti;
|
---|
306 | }
|
---|
307 |
|
---|
308 | }
|
---|
309 | if ($vismf2==0) $sel=_NO; else $sel=_SI;
|
---|
310 | echo "<td width=\"10%\">$sel</td>";
|
---|
311 | if ($sg2==0) $sel=_NO; else $sel=_SI;
|
---|
312 | echo "<td width=\"10%\">$sel</td>";
|
---|
313 | if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
|
---|
314 | echo "<td width=\"10%\">$sel</td>";
|
---|
315 | # if ($sg==0) $sel=_NO; else $sel=_SI;
|
---|
316 | # echo "<td width=\"10%\">$sel</td>";
|
---|
317 | echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
|
---|
318 | ."</td></tr></table></form></td></tr>\n";
|
---|
319 | }
|
---|
320 | echo "</table></td></tr>";
|
---|
321 | echo "</table></td></tr>";
|
---|
322 | CloseTable();
|
---|
323 | # echo "</div>";
|
---|
324 | }
|
---|
325 |
|
---|
326 | function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
|
---|
327 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg,$disgiunto;
|
---|
328 | $delcons=0;
|
---|
329 | if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
|
---|
330 | $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
|
---|
331 | $max = mysql_num_rows($rescomu); //esiste autorizzazione?
|
---|
332 | list($delcons)=mysql_fetch_row($rescomu);
|
---|
333 | if (!$max){ //se no la inserisce
|
---|
334 | $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo,disgiunto) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg','$disgiunto')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
335 | $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
|
---|
336 | list($id_cons_comu)=mysql_fetch_row($rescomu);
|
---|
337 | $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' ", $dbi);
|
---|
338 | list($id_cons_pred)=mysql_fetch_row($res);
|
---|
339 | if (!$id_cons_pred)
|
---|
340 | $res = mysql_query("update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' ", $dbi);
|
---|
341 |
|
---|
342 | }
|
---|
343 | if ($do == "update") {
|
---|
344 | if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
|
---|
345 | else $newid='';
|
---|
346 | $result = mysql_query("update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi) || die(mysql_error());
|
---|
347 | if (!$result) return;
|
---|
348 | $result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf',solo_gruppo='$sg',disgiunto='$disgiunto' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
|
---|
349 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
350 | }elseif ($do == "add") {
|
---|
351 | if ($id_collegio){
|
---|
352 | $result = mysql_query("insert into ".$prefix."_ele_comu_collegi (id_collegio,id_cons,id_comune,id_cons_gen) values ('$id_collegio','$id_cons_comu','$idcomunenew','$id_cons_gen')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
353 | }
|
---|
354 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
355 | }elseif ($do == "delete" and $delcons>0) {
|
---|
356 | $idcns=$delcons;
|
---|
357 | $res_del = mysql_query("delete from ".$prefix."_ele_voti_ref where id_cons=$idcns" ,$dbi);
|
---|
358 | $res_del = mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns" ,$dbi);
|
---|
359 | $res_del = mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons=$idcns" ,$dbi);
|
---|
360 | $res_del = mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns" ,$dbi);
|
---|
361 | $res_del = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns" ,$dbi);
|
---|
362 | $res_del = mysql_query("delete from ".$prefix."_ele_controllosez where id_cons=$idcns" ,$dbi);
|
---|
363 | if ($pwd4==1){
|
---|
364 | $res_del = mysql_query("delete from ".$prefix."_ele_candidati where id_cons=$idcns" ,$dbi);
|
---|
365 | $res_del = mysql_query("delete from ".$prefix."_ele_lista where id_cons=$idcns" ,$dbi);
|
---|
366 | $res_del = mysql_query("delete from ".$prefix."_ele_gruppo where id_cons=$idcns" ,$dbi);
|
---|
367 | $res_del = mysql_query("delete from ".$prefix."_ele_sezioni where id_cons=$idcns" ,$dbi);
|
---|
368 | $res_del = mysql_query("delete from ".$prefix."_ele_cons_comune where id_cons=$idcns" ,$dbi);
|
---|
369 | $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ", $dbi);
|
---|
370 | list($id_cons_pred)=mysql_fetch_row($res);
|
---|
371 | if ($idcns==$id_cons_pred) {
|
---|
372 | $res = mysql_query("select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1" ,$dbi);
|
---|
373 | list($id_cons_pred)=mysql_fetch_row($res);
|
---|
374 | $res = mysql_query("update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' ", $dbi);
|
---|
375 | }
|
---|
376 | }else{
|
---|
377 | $res_del = mysql_query("update ".$prefix."_ele_sezioni set validi='0', nulli='0', bianchi='0', contestati='0', solo_gruppo='0', autorizzati_m='0', autorizzati_f='0', voti_nulli='0', validi_lista='0', contestati_lista='0', voti_nulli_lista='0' where id_cons=$idcns" ,$dbi);
|
---|
378 |
|
---|
379 | }
|
---|
380 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
381 | }
|
---|
382 | }
|
---|
383 | }
|
---|
384 |
|
---|
385 |
|
---|
386 |
|
---|
387 |
|
---|
388 | # die ("do:$do - id_cons:$id_cons_comu - idcomune:$id_comune - new: $idcomunenew");
|
---|
389 |
|
---|
390 | //****************************
|
---|
391 | // switch
|
---|
392 | //****************************
|
---|
393 | if ($op=="associazioni"){
|
---|
394 | associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf,$preferenze);
|
---|
395 | }
|
---|
396 | ele();
|
---|
397 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
|
---|
398 | all();
|
---|
399 | include("footer.php");
|
---|
400 |
|
---|
401 | ?>
|
---|
402 |
|
---|
403 |
|
---|