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 definiione consultazione */
|
---|
9 | /* Amministrazione */
|
---|
10 | /************************************************************************/
|
---|
11 | if (!defined('ADMIN_FILE')) {
|
---|
12 | die ("You can't access this file directly...");
|
---|
13 | }
|
---|
14 |
|
---|
15 | $aid=$_SESSION['aid'];
|
---|
16 | $dbi=$_SESSION['dbi'];
|
---|
17 | $prefix=$_SESSION['prefix'];
|
---|
18 | if($param)
|
---|
19 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
20 | $vari= implode(',',$param);
|
---|
21 | $id_cons_gen=$_GET['id_cons_gen'];
|
---|
22 | $id_comune=$_SESSION['id_comune'];
|
---|
23 | $perms=ChiSei(0);
|
---|
24 | if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
25 | $res = mysql_query("SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' " , $dbi);
|
---|
26 | list($tipo_cons,$descr_cons) = mysql_fetch_row($res);
|
---|
27 | include("modules/Elezioni/funzionidata.php");
|
---|
28 | include("modules/Elezioni/ele.php");
|
---|
29 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
30 | if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
|
---|
31 | if (isset($param['id_cons2'])) $id_cons2=intval($param['id_cons2']); else $id_cons2='';
|
---|
32 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
33 | if (isset($param['duplica'])) $duplica=intval($param['duplica']); else $duplica='';
|
---|
34 | if (isset($param['elettori'])) get_magic_quotes_gpc() ? $elettori=$param['elettori']:$elettori=addslashes($param['elettori']); else $elettori='';
|
---|
35 | if (isset($param['predefinita'])) $predefinita=intval($param['predefinita']); else $predefinita='';
|
---|
36 |
|
---|
37 | $offset=10;
|
---|
38 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
39 |
|
---|
40 |
|
---|
41 | /******************************************************/
|
---|
42 | /*Funzione di visualizzazione globale */
|
---|
43 | /*****************************************************/
|
---|
44 |
|
---|
45 | function all() {
|
---|
46 | global $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons,$id_cons2, $id_comune,$descr_cons,$id_cons_gen,$perms;
|
---|
47 |
|
---|
48 | $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi);
|
---|
49 | if (isset($res)) list($idpred) = mysql_fetch_row($res); else $idpred='';
|
---|
50 | $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
|
---|
51 | $max = mysql_num_rows($res);
|
---|
52 | echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>";
|
---|
53 | echo "<form name=\"imppred\" action=\"admin.php\">";
|
---|
54 | echo "<table border=\"0\"><tr><td bgcolor=\"$bgcolor1\">"
|
---|
55 | ." <b>"._CONSPRED."</b> </td><td><select name=\"predefinita\">";
|
---|
56 | echo "<option value=\"\">";
|
---|
57 | while($arr=mysql_fetch_array($res,3)){
|
---|
58 | $sel='';
|
---|
59 | if (($idpred))
|
---|
60 | $sel= ($arr['id_cons'] == $idpred) ? "selected":"";
|
---|
61 | echo "<option value=\"".$arr['id_cons']."\" $sel>".$arr['descrizione'];
|
---|
62 | }
|
---|
63 | echo "</select></td><td>";
|
---|
64 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
65 | echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
|
---|
66 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
67 | echo "<input type=\"submit\" name=\"add\" value=\""._OK."\"></td>";
|
---|
68 | echo "</tr></table></form></td></tr></table><hr>";
|
---|
69 |
|
---|
70 | echo "<center><font class=\"title\"><b><BR>"._COPIA." "._LA." "._STRUTTURA." "._DA." $descr_cons</b></font><br><br><table border=\"0\" width=\"100%\">"
|
---|
71 | ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DESCR."</b> </td>"
|
---|
72 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DATAIN."</b> </td>"
|
---|
73 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DATAFINE."</b></td>"
|
---|
74 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>"
|
---|
75 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
76 | $result = mysql_query("select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset", $dbi);
|
---|
77 | $i=0;
|
---|
78 | while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) {
|
---|
79 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
80 | $ressez = mysql_query("select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'", $dbi);
|
---|
81 | list($somma)=mysql_fetch_row($ressez);
|
---|
82 | $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
|
---|
83 | echo "<tr bgcolor=\"$bgcolor1\" align=\"center\" ><td align=\"left\" ><a href=\"admin.php?op=cons_comuni&id_cons_gen=$idconsgen2\"><b>$descr_cons</b></a></td>"
|
---|
84 | ."<td>$data_inizio</td>"
|
---|
85 | ."<td>$data_fine</td>";
|
---|
86 | if ($somma==0){
|
---|
87 | $i++;
|
---|
88 | echo "<form name=\"scelta$i\" action=\"admin.php\">";
|
---|
89 | echo "<td align=\"center\"><select name=\"elettori\">";
|
---|
90 | echo "<option value=\"false\">"._NO."</option>";
|
---|
91 | echo "<option value=\"true\">"._SI."</option>";
|
---|
92 | echo "</select></td>";
|
---|
93 | echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
|
---|
94 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
95 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
96 | echo "<input type=\"hidden\" name=\"id_cons2\" value=\"$id_cons2\">";
|
---|
97 | echo "<td align=\"center\"><input type=\"submit\" value=\""._POPOLA."\"></td>";
|
---|
98 | echo "</form>";
|
---|
99 | }elseif($perms==256){
|
---|
100 | $i++;
|
---|
101 | echo "<form name=\"scelta$i\" action=\"admin.php\">";
|
---|
102 | echo "<td align=\"center\">Aggiorna il numero elettori</td>";
|
---|
103 | echo "<input type=\"hidden\" name=\"op\" value=\"cons_comuni\">";
|
---|
104 | echo "<input type=\"hidden\" name=\"do\" value=\"elettori\">";
|
---|
105 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
106 | echo "<input type=\"hidden\" name=\"id_cons2\" value=\"$id_cons2\">";
|
---|
107 | echo "<td align=\"center\"><input type=\"submit\" value=\""._UPDATE."\"></td>";
|
---|
108 | echo "</form>";
|
---|
109 |
|
---|
110 | }
|
---|
111 | echo "</tr>";
|
---|
112 | }
|
---|
113 | echo "</table></center>";
|
---|
114 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
115 | echo "<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>";
|
---|
116 | $prev=$min-$offset;
|
---|
117 | if ($prev>=0) {
|
---|
118 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen&min=$prev\">";
|
---|
119 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
120 | }
|
---|
121 |
|
---|
122 | $next=$min+$offset;
|
---|
123 | if ($next>=($offset-1)) {
|
---|
124 | if($next>=$max) $next = $max;
|
---|
125 | else {
|
---|
126 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
127 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
128 | }
|
---|
129 | }
|
---|
130 | echo "</tr></table><br>";
|
---|
131 | }
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 | function cons_comuni($ok, $id_cons2,$do, $duplica,$elettori)
|
---|
136 | {
|
---|
137 | global $prefix, $dbi,$id_comune,$id_cons_gen,$perms,$predefinita;
|
---|
138 | if ($perms>32) {
|
---|
139 | $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune";
|
---|
140 | $res=mysql_query("$sql",$dbi);
|
---|
141 | list($id_consulta)=mysql_fetch_row($res);
|
---|
142 | $sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen";
|
---|
143 | $res=mysql_query("$sql",$dbi);
|
---|
144 | list($descr_cons2)=mysql_fetch_row($res);
|
---|
145 | if ($do == "add") {
|
---|
146 | if ($id_cons2) {
|
---|
147 | // copia circoscrizione
|
---|
148 | $res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi);
|
---|
149 | while (list($id,$idcirc,$num,$des)=mysql_fetch_row($res)){
|
---|
150 | $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi);
|
---|
151 | list($contr_circ)=mysql_fetch_row($resconnew);
|
---|
152 | if (! $contr_circ){
|
---|
153 | mysql_query("insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')", $dbi) || die("Impossibile inserire i dati delle circoscrizioni! ".mysql_error());
|
---|
154 | }
|
---|
155 | $res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi);
|
---|
156 | list($id_circ)=mysql_fetch_row($res0);
|
---|
157 | // copia sede
|
---|
158 | $res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi);
|
---|
159 | while(list($id1,$idsede1,$idcirc1,$ind,$tel,$tel2,$fax,$resp,$mappa2,$filemappa)=mysql_fetch_row($res1)){
|
---|
160 | $mappa=addslashes($mappa2);
|
---|
161 | $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi);
|
---|
162 | list($contr_sed)=mysql_fetch_row($ressednew);
|
---|
163 | if (! $contr_sed){
|
---|
164 | mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')", $dbi) || die("Impossibile inserire i dati delle sedi! ".mysql_error());
|
---|
165 | }
|
---|
166 | $res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi);
|
---|
167 | list($id_sede)=mysql_fetch_row($res2);
|
---|
168 | //copia sezione
|
---|
169 | $res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi);
|
---|
170 | while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3,
|
---|
171 | $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){
|
---|
172 | if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')";
|
---|
173 | else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
|
---|
174 | mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error());
|
---|
175 | }
|
---|
176 | }
|
---|
177 | }
|
---|
178 | # Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
179 | }
|
---|
180 | }
|
---|
181 | if ($do == "elettori") {
|
---|
182 | if ($ok !="1") {
|
---|
183 | ele();
|
---|
184 | echo "<center><br><br>"._DOMAGGIORNA." Consultazione $descr_cons2 ?<br>";
|
---|
185 | echo "[ <a href=\"admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&do=elettori&id_cons_gen=$id_cons_gen&id_cons2=$id_cons2&ok=1\">"._YES."</a> ]";exit;
|
---|
186 | }else{
|
---|
187 | $result = mysql_query("update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez", $dbi);
|
---|
188 | if (!$result) return;
|
---|
189 | Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
190 | }
|
---|
191 | }
|
---|
192 | if ($do == "update") {
|
---|
193 | if ($predefinita)
|
---|
194 | $result = mysql_query("update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi);
|
---|
195 | else
|
---|
196 | $result = mysql_query("update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi);
|
---|
197 | if (!$result) return;
|
---|
198 | Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
|
---|
199 | }
|
---|
200 | }
|
---|
201 | }
|
---|
202 |
|
---|
203 | function help_cons()
|
---|
204 | {
|
---|
205 | //da mettere
|
---|
206 | }
|
---|
207 |
|
---|
208 | if ($do) {
|
---|
209 | cons_comuni($ok, $id_cons2,$do, $duplica, $elettori);
|
---|
210 | }
|
---|
211 | ele();
|
---|
212 | //OpenTable();
|
---|
213 | all();
|
---|
214 | CloseTable();
|
---|
215 | include("footer.php");
|
---|
216 | ?>
|
---|
217 |
|
---|