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['min'])) $min=intval($_GET['min']); else $min=0;
|
---|
42 |
|
---|
43 | $offset=15;
|
---|
44 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
45 |
|
---|
46 |
|
---|
47 | /******************************************************/
|
---|
48 | /*Funzione di visualizzazione globale */
|
---|
49 | /*****************************************************/
|
---|
50 | //crea la pagina delle affluenze
|
---|
51 | function all() {
|
---|
52 | 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;
|
---|
53 | $aid=$_SESSION['aid'];
|
---|
54 | $dbi=$_SESSION['dbi'];
|
---|
55 | $prefix=$_SESSION['prefix'];
|
---|
56 | OpenTable();
|
---|
57 | $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
|
---|
58 | list ($descr_cons) = mysql_fetch_row($res);
|
---|
59 | //inserire avviso su mancanza dei permessi
|
---|
60 | echo "<form name=\"model\" action=\"admin.php\">";
|
---|
61 | echo "<table>";
|
---|
62 | echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
|
---|
63 | # echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
|
---|
64 | echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
|
---|
65 | echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
|
---|
66 | if($tipo_cons==3)
|
---|
67 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
|
---|
68 | echo "</tr>";
|
---|
69 | echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
70 | echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&id_cons_gen=\">";
|
---|
71 | echo "<tr align=\"center\">";
|
---|
72 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"><td>$descr_cons</td>";
|
---|
73 | # $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
|
---|
74 | # if ($num_coll=mysql_num_rows($ressede)){
|
---|
75 | # echo "<td><select name=\"id_collegio\">";
|
---|
76 | # while(list($id,$descr_coll)=mysql_fetch_row($ressede)){
|
---|
77 | # $sel= ($id == $id_collegio) ? "selected":"";
|
---|
78 | # echo "<option value=\"$id\" $sel>$descr_coll";
|
---|
79 | # }
|
---|
80 | # echo "</select></td>";
|
---|
81 | # } else echo "<td></td>";
|
---|
82 | $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
|
---|
83 | echo "<td><select name=\"idcomunenew\">";
|
---|
84 | echo "<option value=\"0\"> ";
|
---|
85 | while(list($id,$descr_comu)=mysql_fetch_row($rescomu)){
|
---|
86 | $sel= ($id == $idcomune) ? "selected":"";
|
---|
87 | echo "<option value=\"$id\" $sel>$descr_comu";
|
---|
88 | }
|
---|
89 | echo "</select></td>";
|
---|
90 | $selez['0']='';
|
---|
91 | $selez['1']='';
|
---|
92 | $selez['2']='';
|
---|
93 | $selez[$chiusa]="selected";
|
---|
94 | echo "<td><select name=\"chiusa\">";
|
---|
95 | echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
|
---|
96 | echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
|
---|
97 | echo "<option value=\"2\" ".$selez[2].">"._NULLA;
|
---|
98 | echo "</select></td>";
|
---|
99 | if($tipo_cons==3){
|
---|
100 | $rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by descrizione asc", $dbi);
|
---|
101 | echo "<td><select name=\"id_conf\">";
|
---|
102 | echo "<option value=\"0\"> ";
|
---|
103 | while(list($id,$descr_conf)=mysql_fetch_row($rescomu)){
|
---|
104 | $sel='';
|
---|
105 | if ($idcomune and $id == $id_conf) $sel="selected"; elseif ($id==1) $sel="selected";
|
---|
106 | echo "<option value=\"$id\" $sel>$descr_conf";
|
---|
107 | }
|
---|
108 | echo "</select></td>";
|
---|
109 | }
|
---|
110 | unset($sel);
|
---|
111 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
112 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
113 | if ($idcomune) {
|
---|
114 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
115 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
|
---|
116 | echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
|
---|
117 | }else{
|
---|
118 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
119 | echo "<td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
|
---|
120 | }
|
---|
121 | $i=0;
|
---|
122 | # if ($num_coll>0)
|
---|
123 | # $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);
|
---|
124 | # else
|
---|
125 | $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf 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);
|
---|
126 | while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
|
---|
127 | $resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
|
---|
128 | list($descr_conf) = mysql_fetch_row($resconf);
|
---|
129 | $i++;
|
---|
130 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
131 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
132 | ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
|
---|
133 | // echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
134 | echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
|
---|
135 | echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
|
---|
136 | echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
|
---|
137 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
138 | echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
|
---|
139 | echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
|
---|
140 | echo "<tr align=\"center\" bgcolor=\"$bgcolor1\"><td></td>";
|
---|
141 | echo "<td width=\"32\"><b>$descr_coll</b></td>";
|
---|
142 | echo "<td width=\"32\"><b>$descr_comu</b></td>";
|
---|
143 | $stato['0']=_ATTIVA;
|
---|
144 | $stato['1']=_CHIUSA;
|
---|
145 | $stato['2']=_NULLA;
|
---|
146 | echo "<td width=\"32\"><b>".$stato[$chiusa]."</b></td>";
|
---|
147 | if($tipo_cons==3)
|
---|
148 | echo "<td width=\"32\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
|
---|
149 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
150 | echo "</td>";
|
---|
151 | echo "<td><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
|
---|
152 | ."</td></tr></form>";
|
---|
153 | }
|
---|
154 | echo "</table>";
|
---|
155 | CloseTable();
|
---|
156 | }
|
---|
157 |
|
---|
158 | function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf) {
|
---|
159 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew;
|
---|
160 | if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
|
---|
161 | $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
|
---|
162 | $max = mysql_num_rows($rescomu); //esiste autorizzazione?
|
---|
163 | if (!$max){ //se no la inserisce
|
---|
164 | $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf) values ('0','$idcomunenew','$id_cons_gen','$id_conf')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
|
---|
165 | $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
|
---|
166 | }
|
---|
167 | list($id_cons_comu)=mysql_fetch_row($rescomu);
|
---|
168 | if ($do == "update") {
|
---|
169 | if ($idcomunenew>0) $newid=", id_comune = $idcomunenew ";
|
---|
170 | else $newid='';
|
---|
171 | $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());
|
---|
172 | if (!$result) return;
|
---|
173 | $result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
|
---|
174 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
175 | }elseif ($do == "add") {
|
---|
176 | if ($id_collegio)
|
---|
177 | $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());
|
---|
178 | Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
|
---|
179 | }
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | //****************************
|
---|
185 | // switch
|
---|
186 | //****************************
|
---|
187 | if ($op=="associazioni"){
|
---|
188 | associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf);
|
---|
189 | }
|
---|
190 | ele();
|
---|
191 | if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0';
|
---|
192 | all();
|
---|
193 | include("footer.php");
|
---|
194 |
|
---|
195 | ?>
|
---|
196 |
|
---|