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 sezioni */
|
---|
9 | /* Amministrazione */
|
---|
10 | /************************************************************************/
|
---|
11 | if (!defined('ADMIN_FILE')) {
|
---|
12 | die ("You can't access this file directly...");
|
---|
13 | }
|
---|
14 | $id_comune=$_SESSION['id_comune'];
|
---|
15 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
16 | $perms=ChiSei($id_cons_gen);
|
---|
17 | if ($perms<32 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
18 |
|
---|
19 |
|
---|
20 | $sql="SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
|
---|
21 | $res = $dbi->prepare("$sql");
|
---|
22 | $res->execute();
|
---|
23 | list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
24 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
25 | if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
|
---|
26 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
27 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
|
---|
28 | if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez='';
|
---|
29 | if (isset($param['aut_m'])) $aut_m=intval($param['aut_m']); else $aut_m='';
|
---|
30 | if (isset($param['aut_f'])) $aut_f=intval($param['aut_f']); else $aut_f='';
|
---|
31 | if (isset($param['maschi'])) $maschi=intval($param['maschi']); else $maschi='';
|
---|
32 | if (isset($param['femmine'])) $femmine=intval($param['femmine']); else $femmine='';
|
---|
33 | if (isset($param['id_sez2'])) $id_sez2=intval($param['id_sez2']); else $id_sez2='';
|
---|
34 | if (isset($param['num_sez'])) $num_sez=intval($param['num_sez']); else $num_sez='';
|
---|
35 |
|
---|
36 | include("modules/Elezioni/funzionidata.php");
|
---|
37 | include("modules/Elezioni/ele.php");
|
---|
38 | // Offset - visualizza il numero di elementi per pagina
|
---|
39 | $offset=10;
|
---|
40 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
41 |
|
---|
42 |
|
---|
43 | /******************************************************/
|
---|
44 | /*Funzione di visualizzazione globale */
|
---|
45 | /*****************************************************/
|
---|
46 |
|
---|
47 | function all() {
|
---|
48 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen;
|
---|
49 | # OpenTable();
|
---|
50 | $y=0;
|
---|
51 | echo "<center><font class=\"title\"><a NAME=riga><b>"._SEZIONE."</b></a></font><br><br><table border=\"0\" width=\"95%\"><tr>"
|
---|
52 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NUM."</b></td>"
|
---|
53 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
|
---|
54 | ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._MASCHI."</b></td>"
|
---|
55 | ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._FEMMINE."</b></td>"
|
---|
56 | ."<td bgcolor=\"$bgcolor1\" align=\"center\" ><b>"._TOTS." "._ISCRITTI."</b></td>"
|
---|
57 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
58 | $sql="SELECT * FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' ";
|
---|
59 | $res = $dbi->prepare("$sql");
|
---|
60 | $res->execute();
|
---|
61 | $max = $res->rowCount();
|
---|
62 | echo "<tr align=\"center\"><form name=\"sezi\" action=\"admin.php\">"
|
---|
63 | ."<input type=\"hidden\" name=\"op\" value=\"sezione\">"
|
---|
64 | ."<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
65 |
|
---|
66 | $nuova= $max+1;
|
---|
67 | $sql="SELECT id_sede FROM ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='$max' ";
|
---|
68 | $res = $dbi->prepare("$sql");
|
---|
69 | $res->execute();
|
---|
70 | list($id_sede_old) = $res->fetch(PDO::FETCH_NUM);
|
---|
71 |
|
---|
72 | echo "<td><input type=\"text\" name=\"num_sez\" value=\"$nuova\" size=\"5\"></td>";
|
---|
73 |
|
---|
74 | echo "<td><select name=\"id_sede\">";
|
---|
75 | $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' order by indirizzo";
|
---|
76 | $res = $dbi->prepare("$sql");
|
---|
77 | $res->execute();
|
---|
78 | while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
79 | if ($id == $id_sede_old) {
|
---|
80 | $sel = "selected";
|
---|
81 | } else {
|
---|
82 | $sel = "";
|
---|
83 | }
|
---|
84 | echo "<option value=\"$id\" $sel>$indir";
|
---|
85 | }
|
---|
86 | echo "</select></td>";
|
---|
87 | //*************************************
|
---|
88 |
|
---|
89 | echo "<td><input type=\"text\" name=\"maschi\" size=\"4\"></td>";
|
---|
90 |
|
---|
91 |
|
---|
92 | echo "<td><input type=\"text\" name=\"femmine\" size=\"4\"></td>";
|
---|
93 |
|
---|
94 | echo "<td><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
95 | echo "<input type=\"hidden\" name=\"min\" value=\"$min\">"
|
---|
96 | ."</td><td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>"
|
---|
97 | ."</form>";
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 | $sql="select id_cons, id_sez, id_sede, num_sez, maschi, femmine, autorizzati_m, autorizzati_f from ".$prefix."_ele_sezioni where id_cons='$id_cons' ORDER BY num_sez LIMIT $min,$offset";
|
---|
104 | $result = $dbi->prepare("$sql");
|
---|
105 | $result->execute();
|
---|
106 | while(list($id_cons2,$id_sez,$id_sede,$num_sez, $maschi, $femmine,$aut_m,$aut_f) = $result->fetch(PDO::FETCH_NUM)) {
|
---|
107 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
108 | // dati circoscrizione
|
---|
109 | $sql="select indirizzo from ".$prefix."_ele_sede where id_sede='$id_sede'";
|
---|
110 | $result1 = $dbi->prepare("$sql");
|
---|
111 | $result1->execute();
|
---|
112 | list($indir)=$result1->fetch(PDO::FETCH_NUM);
|
---|
113 | $totali=$maschi+$femmine+$aut_m+$aut_f;
|
---|
114 | $y++;
|
---|
115 | echo "<form name=\"sez$y\" action=\"admin.php\">"
|
---|
116 | ."<input type=\"hidden\" name=\"op\" value=\"sezione\">"
|
---|
117 | ."<input type=\"hidden\" name=\"do\" value=\"update\">"
|
---|
118 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
119 | ."<input type=\"hidden\" name=\"min\" value=\"$min\">"
|
---|
120 | ."<input type=\"hidden\" name=\"id_sez2\" value=\"$id_sez\">"
|
---|
121 | ."<input type=\"hidden\" name=\"num_sez\" value=\"$num_sez\">";
|
---|
122 |
|
---|
123 | echo "<tr bgcolor=\"$bgcolor1\"><td align=\"right\" size=\"90\"><b>$num_sez</b></td>";
|
---|
124 | echo "<td align=\"right\" size=\"120\"><select name=\"id_sede\">";
|
---|
125 | $sql="SELECT id_sede,indirizzo FROM ".$prefix."_ele_sede where id_cons='$id_cons' order by indirizzo";
|
---|
126 | $res = $dbi->prepare("$sql");
|
---|
127 | $res->execute();
|
---|
128 | while(list($id,$indir) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
129 | if ($id == $id_sede) {
|
---|
130 | $sel = "selected";
|
---|
131 | } else {
|
---|
132 | $sel = "";
|
---|
133 | }
|
---|
134 | echo "<option value=\"$id\" $sel>$indir";
|
---|
135 | }
|
---|
136 | echo "</select></td>";
|
---|
137 |
|
---|
138 | echo "<td align=\"center\"><b><input type=\"text\" size=\"4\" name=\"maschi\" value=\"$maschi\"></b>";
|
---|
139 | echo "</td><td align=\"center\"><b><input type=\"text\" size=\"4\" name=\"femmine\" value=\"$femmine\"></b>";
|
---|
140 | echo "</td><td align=\"center\"><b>$totali</b>"
|
---|
141 | ."</td><td align=\"center\" nowrap><table><tr><td align=\"center\" width=\"50%\">"
|
---|
142 | ."<input type=\"submit\" name=\"update$y\" value=\""._OK."\">" ;
|
---|
143 | echo "</td><td align=\"center\" nowrap width=\"50%\">"
|
---|
144 | ."[<a href=\"admin.php?op=sezione&do=delete&id_sede=$id_sede&id_sez=$id_sez&id_cons_gen=$id_cons_gen&num_sez=$num_sez&min=$min\">"._DELETE."<img src=\"modules/Elezioni/images/delete.gif\"
|
---|
145 | border=\"0\" align=\"center\"></a>]</td></tr></table>";
|
---|
146 | echo "</td></tr></form>\n";
|
---|
147 | }
|
---|
148 | echo "</table></center>";
|
---|
149 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
150 | ."document.sez2.maschi.focus()\n"
|
---|
151 | ."document.sez2.maschi.select()\n"
|
---|
152 | ."//-->\n"
|
---|
153 | ."</script>\n";
|
---|
154 |
|
---|
155 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
156 | echo"<table align=\"center\" width=\"100%\"><tr>";
|
---|
157 | if ($min<$offset and $min!=0) $min=$offset;
|
---|
158 | $prev=$min-$offset;
|
---|
159 |
|
---|
160 | if ($prev>=0) {
|
---|
161 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sezione&id_sede=$id_sede&id_sez=$id_sez&id_cons_gen=$id_cons_gen&min=$prev\">";
|
---|
162 | echo "<b>"._PREV_MATCH."</b></a></td>";
|
---|
163 | }
|
---|
164 |
|
---|
165 | $next=$min+$offset;
|
---|
166 | if ($next>=($offset-1)) {
|
---|
167 | if($next>=$max) $next = $max;
|
---|
168 | else {
|
---|
169 |
|
---|
170 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sezione&id_sede=$id_sede&id_sez=$id_sez&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
171 | echo "<b>"._NEXT_MATCH."</b></a></td>";
|
---|
172 | }
|
---|
173 | }
|
---|
174 | echo "</tr></table><br>";
|
---|
175 | #CloseTable();
|
---|
176 | #include("footer.php");
|
---|
177 | }
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 | function sezione($ok, $do,$id_sede,$id_sez, $num_sez, $aut_ma, $aut_fe, $maschi, $femmine, $id_sez2,$min) {
|
---|
182 | global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons,$id_cons_gen;
|
---|
183 | $perms=ChiSei($id_cons_gen);
|
---|
184 | if ($perms>16) {
|
---|
185 | $aut_m=intval($aut_ma);
|
---|
186 | $aut_f=intval($aut_fe);
|
---|
187 | if ($do == "delete") {
|
---|
188 | if ($ok !="1") {
|
---|
189 | ele();
|
---|
190 | echo "<center><br><br>"._DOMCANCELLA." "._NUM." "._SEZIONE." $num_sez ?<br>";
|
---|
191 | echo "[ <a href=\"admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min\">"._NO."</a> ] - [<a href=\"admin.php?op=sezione&do=delete&id_sede=$id_sede&id_sez=$id_sez&id_cons_gen=$id_cons_gen&ok=1&min=$min\">"._YES."</a> ]";
|
---|
192 | include("footer.php");
|
---|
193 | die();
|
---|
194 | }else{
|
---|
195 | $sql="delete from ".$prefix."_ele_voti_candidati where id_sez='$id_sez'";
|
---|
196 | $res = $dbi->prepare("$sql");
|
---|
197 | $res->execute();
|
---|
198 | $sql="delete from ".$prefix."_ele_voti_lista where id_sez='$id_sez'";
|
---|
199 | $res = $dbi->prepare("$sql");
|
---|
200 | $res->execute();
|
---|
201 | $sql="delete from ".$prefix."_ele_voti_gruppo where id_sez='$id_sez'";
|
---|
202 | $res = $dbi->prepare("$sql");
|
---|
203 | $res->execute();
|
---|
204 | $sql="delete from ".$prefix."_ele_voti_ref where id_sez='$id_sez'";
|
---|
205 | $res = $dbi->prepare("$sql");
|
---|
206 | $res->execute();
|
---|
207 | $sql="delete from ".$prefix."_ele_voti_parziale where id_sez='$id_sez'";
|
---|
208 | $res = $dbi->prepare("$sql");
|
---|
209 | $res->execute();
|
---|
210 | $sql="delete from ".$prefix."_ele_sezioni where id_sez='$id_sez'";
|
---|
211 | $res = $dbi->prepare("$sql");
|
---|
212 | $res->execute();
|
---|
213 | Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min");
|
---|
214 | }
|
---|
215 | }elseif ($do == "add") {
|
---|
216 | if ($num_sez) {
|
---|
217 | $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine, autorizzati_m,autorizzati_f) values ('$id_cons', '$id_sede', '$num_sez','$maschi','$femmine','$aut_m', '$aut_f')";
|
---|
218 | $res = $dbi->prepare("$sql");
|
---|
219 | $res->execute();
|
---|
220 | Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min");
|
---|
221 | } else {
|
---|
222 | ele();
|
---|
223 | OpenTable();
|
---|
224 | echo "<center>"._GESTIONE." "._SEZIONE." ";
|
---|
225 | echo "<br><br><a href=\"admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$min\">"._IMM." "._SEZIONE."</a></center>";
|
---|
226 | CloseTable();
|
---|
227 | }
|
---|
228 | }elseif ($do == "update") {
|
---|
229 | $sql="update ".$prefix."_ele_sezioni set id_sede='$id_sede', maschi='$maschi', femmine='$femmine', autorizzati_m='$aut_m', autorizzati_f='$aut_f' where id_sez='$id_sez2' ";
|
---|
230 | $res = $dbi->prepare("$sql");
|
---|
231 | $res->execute();
|
---|
232 | $num_sez--;
|
---|
233 | Header("Location: admin.php?op=sezione&id_cons_gen=$id_cons_gen&min=$num_sez");
|
---|
234 | }
|
---|
235 |
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 |
|
---|
241 |
|
---|
242 |
|
---|
243 | if ($op=="sezione")
|
---|
244 | sezione($ok, $do,$id_sede,$id_sez, $num_sez, $aut_m, $aut_f, $maschi, $femmine, $id_sez2, $min);
|
---|
245 | ele();
|
---|
246 | all();
|
---|
247 | echo"</td></tr></table>";
|
---|
248 | include ("footer.php");
|
---|
249 |
|
---|
250 | ?>
|
---|
251 |
|
---|