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 Consultazioni */
|
---|
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 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
19 | $perms=ChiSei(0);
|
---|
20 | //if ($perms<128 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
21 | if ($perms!=256) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
22 | if (isset($param['id_cons_gen'])){
|
---|
23 | $id_cons_gen=intval($param['id_cons_gen']);
|
---|
24 | $res = mysql_query("SELECT tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen=$id_cons_gen " , $dbi);
|
---|
25 | list($tipo_cons) = mysql_fetch_row($res);
|
---|
26 | } else {
|
---|
27 | $id_cons_gen=0;
|
---|
28 | $tipo_cons=0;
|
---|
29 | }
|
---|
30 | if (isset($param['min'])) $min=intval($param['min']); else $min=0;
|
---|
31 | if (isset($param['ok'])) $ok=intval($param['ok']); else $ok=0;
|
---|
32 | if (isset($param['data_in'])) get_magic_quotes_gpc() ? $data_in=$param['data_in']:$data_in=addslashes($param['data_in']); else $data_in='';
|
---|
33 | if (isset($param['data_fine'])) get_magic_quotes_gpc() ? $data_fine=$param['data_fine']:$data_fine=addslashes($param['data_fine']); else $data_fine='';
|
---|
34 | if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
|
---|
35 | if (isset($param['dig'])) $dig=intval($param['dig']); else $dig=date("d",time());
|
---|
36 | if (isset($param['dim'])) $dim=intval($param['dim']); else $dim=date("m",time());
|
---|
37 | if (isset($param['dia'])) $dia=intval($param['dia']); else $dia=date("Y",time());
|
---|
38 | if (isset($param['dfg'])) $dfg=intval($param['dfg']); else $dfg=date("d",time());
|
---|
39 | if (isset($param['dfm'])) $dfm=intval($param['dfm']); else $dfm=date("m",time());
|
---|
40 | if (isset($param['dfa'])) $dfa=intval($param['dfa']); else $dfa=date("Y",time());
|
---|
41 | if (isset($param['duplica'])) $duplica=intval($param['duplica']); else $duplica='';
|
---|
42 | if (isset($param['referendum'])) get_magic_quotes_gpc() ? $referendum=$param['referendum']:$referendum=addslashes($param['referendum']); else $referendum='';
|
---|
43 | if (isset($param['liste'])) get_magic_quotes_gpc() ? $liste=$param['liste']:$liste=addslashes($param['liste']); else $liste='';
|
---|
44 | if (isset($param['gruppi'])) get_magic_quotes_gpc() ? $gruppi=$param['gruppi']:$gruppi=addslashes($param['gruppi']); else $gruppi='';
|
---|
45 | if (isset($param['votigruppo'])) get_magic_quotes_gpc() ? $votigruppo=$param['votigruppo']:$votigruppo=addslashes($param['votigruppo']); else $votigruppo='';
|
---|
46 | if (isset($param['votilista'])) get_magic_quotes_gpc() ? $votilista=$param['votilista']:$votilista=addslashes($param['votilista']); else $votilista='';
|
---|
47 | if (isset($param['voticandi'])) get_magic_quotes_gpc() ? $voticandi=$param['voticandi']:$voticandi=addslashes($param['voticandi']); else $voticandi='';
|
---|
48 | if (isset($param['ballo'])) get_magic_quotes_gpc() ? $ballo=$param['ballo']:$ballo=addslashes($param['ballo']); else $ballo='';
|
---|
49 | if (isset($param['circo'])) get_magic_quotes_gpc() ? $circo=$param['circo']:$circo=addslashes($param['circo']); else $circo='';
|
---|
50 | if (isset($param['descr_cons2'])) get_magic_quotes_gpc() ? $descr_cons2=$param['descr_cons2']:$descr_cons2=addslashes($param['descr_cons2']); else $descr_cons2='';
|
---|
51 | if (isset($param['tipocons'])) get_magic_quotes_gpc() ? $tipocons=$param['tipocons']:$tipocons=addslashes($param['tipocons']); else $tipocons=$tipo_cons;
|
---|
52 | if (isset($param['help'])) $help=intval($param['help']);
|
---|
53 | $id_comune=$_SESSION['id_comune'];
|
---|
54 |
|
---|
55 | //die("dig:$dig dim:$dim dia:$dia");
|
---|
56 |
|
---|
57 | include("modules/Elezioni/funzionidata.php");
|
---|
58 | include("modules/Elezioni/ele.php");
|
---|
59 |
|
---|
60 | // Offset - visualizza il numero di elementi per pagina
|
---|
61 |
|
---|
62 | $offset=10;
|
---|
63 | if (!isset($min)) $min=0;
|
---|
64 |
|
---|
65 | /******************************************************/
|
---|
66 | /*Funzione di visualizzazione globale */
|
---|
67 | /*****************************************************/
|
---|
68 |
|
---|
69 | function all() {
|
---|
70 | global $genere, $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons_gen, $perms,$tipo_cons, $tipocons,$do, $dig, $dim, $dia, $dfg, $dfm, $dfa, $help;
|
---|
71 | $language=$_SESSION['lang'];
|
---|
72 | if (($perms>64)) {
|
---|
73 | ############# Controllo flag per cancellazione consultazione
|
---|
74 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
|
---|
75 | ."//-->\n";
|
---|
76 | echo "function del_cons() {\n";
|
---|
77 | echo "if (document.consultazione.pwd3.checked==false) {\n";
|
---|
78 | echo "document.consultazione.update.value=\""._MODIFY."\" \n";
|
---|
79 | echo "document.consultazione.do.value=\"update\" \n";
|
---|
80 | echo "}else{\n";
|
---|
81 | echo "document.consultazione.update.value=\""._DELETE."\" \n";
|
---|
82 | echo "document.consultazione.do.value=\"delete\" \n";
|
---|
83 | echo "} \n";
|
---|
84 | echo "} \n";
|
---|
85 | echo "</script>\n";
|
---|
86 | #########################
|
---|
87 | if (isset($help)) include("language/$language/ele_consultazioni.html");
|
---|
88 |
|
---|
89 | if ($do == "modify") {
|
---|
90 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'", $dbi);
|
---|
91 | $pro= mysql_fetch_array($res, 3);
|
---|
92 | $res_tipo = mysql_query("SELECT * FROM ".$prefix."_ele_tipo where tipo_cons='".$pro['tipo_cons']."' and lingua='$language'", $dbi);
|
---|
93 | $tip=mysql_fetch_array($res_tipo, 3);
|
---|
94 |
|
---|
95 | list($dia1,$dim1,$dig1) = explode("-",$pro['data_inizio']=="0000-00-00" ? " - - ": $pro['data_inizio']) ;
|
---|
96 | list($dfa1,$dfm1,$dfg1) = explode("-",$pro['data_fine']=="0000-00-00" ? " - - ": $pro['data_fine']) ;
|
---|
97 | echo "<form name=\"consultazione\" method=\"post\" action=\"admin.php\" >"
|
---|
98 | ."<input type=\"hidden\" name=\"op\" value=\"consultazione\">"
|
---|
99 | ."<input type=\"hidden\" name=\"do\" value=\"update\">"
|
---|
100 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"".$pro['id_cons_gen']."\">"
|
---|
101 | ."<table width=\"100%\"><tr><td>"._MODIFY." ".$pro['descrizione']." <br><br>";
|
---|
102 | switch ($genere) {
|
---|
103 | case "0" : $gencons=_GENCONS0;break;
|
---|
104 | case "1" : $gencons=_GENCONS1;break;
|
---|
105 | case "2" : $gencons=_GENCONS2;break;
|
---|
106 | case "3" : $gencons=_GENCONS3;break;
|
---|
107 | case "4" : $gencons=_GENCONS4;break;
|
---|
108 | case "5" : if($tip['voto_c'])
|
---|
109 | $gencons=_GENCONS3;
|
---|
110 | else
|
---|
111 | $gencons=_GENCONS5;
|
---|
112 | break;
|
---|
113 | default :$gencons="";
|
---|
114 | }
|
---|
115 | echo "</td></tr><tr><td>"._TIPO."</td><td>$gencons</td></tr>";
|
---|
116 | echo "<tr bgcolor=\"$bgcolor2\"><td>"._DESCR. "</td><td><input name=\"descr_cons2\" value=\"".$pro['descrizione']."\" size=\"15\"></td></tr>";
|
---|
117 | echo "<tr><td>"._DATAIN." :</td><td>";
|
---|
118 | echo "<select name=\"dig\" >";
|
---|
119 | echo "<option value=\"$dig1\" selected>$dig1</option>";giorno(0,0);
|
---|
120 | echo "<select name=\"dim\" >";
|
---|
121 | echo "<option value= \"$dim1\" selected>$dim1</option>"; mese();
|
---|
122 | echo "<select name= \"dia\" >";
|
---|
123 | echo "<option value=\"$dia1\" selected>$dia1</option>"; anno();
|
---|
124 | echo "</td></tr>";
|
---|
125 | echo "<tr><td>"._DATAFINE." :</td><td>";
|
---|
126 | echo "<select name=\"dfg\" >";
|
---|
127 | echo "<option value=\"$dfg1\" selected>$dfg1</option>";giorno(0,0);
|
---|
128 | echo "<select name= \"dfm\" >";
|
---|
129 | echo "<option value= \"$dfm1\" selected>$dfm1</option>"; mese();
|
---|
130 | echo "<select name= \"dfa\" >";
|
---|
131 | echo "<option value=\"$dfa1\" selected>$dfa1</option>"; anno();
|
---|
132 | echo "</td></tr><tr>";
|
---|
133 | $resdel = mysql_query("SELECT * FROM ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen'", $dbi);
|
---|
134 | if(mysql_num_rows($resdel)==0)
|
---|
135 | echo "<td><fieldset><legend>Abilita la cancellazione</legend><label id=\"prov\">"._SPUNTAELIMINA." <input type=\"checkbox\" name=\"pwd3\" value=\"\" onchange=\"del_cons()\"></label></fieldset></td>";
|
---|
136 | else echo "<td></td>";
|
---|
137 | echo "<td><input type=\"submit\" name=\"update\" value=\""._MODIFY."\">"
|
---|
138 | ."</td></tr></table></form>";
|
---|
139 | } else {
|
---|
140 | echo "<form name=\"consultazione\" action=\"admin.php\">"
|
---|
141 | ."<input type=\"hidden\" name=\"op\" value=\"consultazione\">"
|
---|
142 | ."<input type=\"hidden\" name=\"do\" value=\"add\">"
|
---|
143 | ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"
|
---|
144 | ."<hr><h6>"
|
---|
145 | ._ADD." "._CONSULTA."<br><br>";
|
---|
146 | echo _DEFCONS.":</h6><br><table width=\"100%\">";
|
---|
147 |
|
---|
148 | $res=mysql_query("SELECT * FROM ".$prefix."_ele_tipo where lingua='$language'", $dbi);
|
---|
149 | echo "<tr><td><b>"._TIPO." :</b></td><td>";
|
---|
150 | echo "<select name=\"tipocons\" >";
|
---|
151 | while(list($idtipo,$destipo)= mysql_fetch_row($res)){
|
---|
152 | if ($idtipo == $tipo_cons) {
|
---|
153 | $sel = "selected";
|
---|
154 | } else {
|
---|
155 | $sel = "";
|
---|
156 | }
|
---|
157 |
|
---|
158 | echo "<option value=\"$idtipo\" $sel>$destipo";
|
---|
159 | }
|
---|
160 | echo "</select>";
|
---|
161 | echo "<tr><td><b>"._DESCR. "</b></td><td><input type=\"text\" name=\"descr_cons2\" maxlength=\"100\"></td></tr>"
|
---|
162 | ."<tr><td><b>"._DATAIN. "</b></td><td>";
|
---|
163 | echo "<select name= \"dig\" ><option value=\"$dig\" selected>$dig</option>"; giorno(0,0);
|
---|
164 | echo "<select name= \"dim\" ><option value=\"$dim\" selected>$dim</option>"; mese();
|
---|
165 | echo "<select name= \"dia\" ><option value=\"$dia\" selected>$dia</option>"; anno() ;
|
---|
166 | echo "</td></tr>"
|
---|
167 |
|
---|
168 | ."<tr><td><b>"._DATAFINE. "</b></td><td>";
|
---|
169 | echo "<select name= \"dfg\" ><option value=\"$dfg\" selected>$dfg</option>"; giorno(0,0);
|
---|
170 | echo "<select name= \"dfm\" ><option value=\"$dfm\" selected>$dfm</option>"; mese();
|
---|
171 | echo "<select name= \"dfa\" ><option value=\"$dfa\" selected>$dfa</option>"; anno() ;
|
---|
172 | echo "</td></tr>"
|
---|
173 | ."</table>"
|
---|
174 | ."<input type=\"submit\" name=\"add\" value=\""._ADD."\">"
|
---|
175 | ."</form>";
|
---|
176 | }
|
---|
177 | echo "<center><font class=\"title\"><b>"._MODIFY." "._CONSULTA."</b></font><br><br><table border=\"0\" width=\"100%\">"
|
---|
178 | ."<tr><td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DESCR."</b> </td>"
|
---|
179 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"> <b>"._DATAIN."</b> </td>"
|
---|
180 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DATAFINE."</b></td>"
|
---|
181 | ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
|
---|
182 | $res = mysql_query("SELECT * FROM ".$prefix."_ele_consultazione " , $dbi);
|
---|
183 | $max = mysql_num_rows($res);
|
---|
184 | $result = mysql_query("select * from ".$prefix."_ele_consultazione ORDER BY data_fine desc LIMIT $min,$offset", $dbi);
|
---|
185 | while(list($id, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) {
|
---|
186 | $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
|
---|
187 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
188 | echo "<tr ><td bgcolor=\"$bgcolor1\" align=\"left\" ><a href=\"admin.php?op=ele&id_cons_gen=$id\"><b>$descr_cons</b></a>"
|
---|
189 | ."</td><td align=\"center\" >$data_inizio</td>"
|
---|
190 | ."<td align=\"center\">$data_fine"
|
---|
191 | ."</td><td align=\"center\" nowrap bgcolor=\"$bgcolor1\">[<a
|
---|
192 | href=\"admin.php?op=consultazione&do=modify&id_cons_gen=$id\"><img src=\"modules/Elezioni/images/edit.gif\"
|
---|
193 | border=\"0\" align=\"middle\" alt=\"Edit\"> "._EDIT."</a>]"
|
---|
194 | ."</td></tr>";
|
---|
195 | }
|
---|
196 | echo "</table></center>";
|
---|
197 | #'Pagina precedente' e 'Pagina Successiva'
|
---|
198 | echo"<table align=\"center\" width=\"100%\" bgcolor=\"$bgcolor1\"><tr>";
|
---|
199 | $prev=$min-$offset;
|
---|
200 | if ($prev>=0) {
|
---|
201 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=consultazione&id_cons_gen=$id_cons_gen&min=$prev\">";
|
---|
202 | echo "<b>$offset "._PREV_MATCH."</b></a></td>";
|
---|
203 | }
|
---|
204 | $next=$min+$offset;
|
---|
205 | if ($next>=($offset-1)) {
|
---|
206 | if($next>=$max) $next = $max;
|
---|
207 | else {
|
---|
208 | echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor2\"><a href=\"admin.php?op=consultazione&id_cons_gen=$id_cons_gen&min=$next\">";
|
---|
209 | echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
|
---|
210 | }
|
---|
211 | }
|
---|
212 | echo "</tr></table><br>";
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 |
|
---|
217 |
|
---|
218 | function consultazione($ok, $id_cons_gen,$tipocons, $data_in, $data_fine,$do, $dig, $dim, $dia, $dfg, $dfm, $dfa, $duplica,$referendum,$liste,$gruppi,$ballo,$votigruppo) {
|
---|
219 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons2,$tipo_cons,$perms,$do,$votilista,$voticandi,$circo;
|
---|
220 |
|
---|
221 |
|
---|
222 | if ($perms>=128) {
|
---|
223 | if ($do == "delete") {
|
---|
224 | $result = mysql_query("delete from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'", $dbi);
|
---|
225 | if (!$result) return;
|
---|
226 | Header("Location: admin.php?op=consultazione");
|
---|
227 | }
|
---|
228 | if ($do == "add") {
|
---|
229 | if ($descr_cons2) {
|
---|
230 | if($referendum=='true') {
|
---|
231 | $genere=0;
|
---|
232 | } elseif ($ballo=='true') {
|
---|
233 | $genere=1;
|
---|
234 | }else{
|
---|
235 | $genere=2;
|
---|
236 | if($liste!='true') {$genere+=2;}
|
---|
237 | if($gruppi=='true') {$genere+=1;}
|
---|
238 | }
|
---|
239 | $votigruppo=$votigruppo=='true'? 1:0;
|
---|
240 | $votilista=$votilista=='true'? 1:0;
|
---|
241 | $voticandi=$voticandi=='true'? 1:0;
|
---|
242 | $circo=$circo=='true'? 1:0;
|
---|
243 | $data_inizio="$dia-$dim-$dig";
|
---|
244 | $data_fine="$dfa-$dfm-$dfg";
|
---|
245 | $id_consulta=$id_cons_gen;
|
---|
246 | $result = mysql_query("insert into ".$prefix."_ele_consultazione (descrizione,data_inizio,data_fine,tipo_cons) values ('$descr_cons2','$data_inizio','$data_fine','$tipocons')", $dbi) || die("Errore di inserimento: ".mysql_error());
|
---|
247 | /* $y=$result;
|
---|
248 | $res=mysql_query("select id_cons_gen from ".$prefix."_ele_consultazione where descrizione='$descr_cons2'
|
---|
249 | and data_inizio='$data_inizio' and data_fine='$data_fine' and tipo_cons='$tipocons'", $dbi);
|
---|
250 | list($idc)=mysql_fetch_row($res);
|
---|
251 | mkdir("images/consultazioni/$idc",0750);
|
---|
252 | copy("images/consultazioni/nulla.jpg","images/consultazioni/$idc/nulla.jpg");*/
|
---|
253 | } else {
|
---|
254 | OpenTable();
|
---|
255 | echo "<center>"._GESTIONE." "._CONSULTAZIONE."";
|
---|
256 | echo "<br><br><a href=\"admin.php?op=consultazione&id_cons_gen=$id_cons_gen\">"._IMMCONS."</a></center>";
|
---|
257 | CloseTable();
|
---|
258 | }
|
---|
259 | }else if ($do == "update") {
|
---|
260 | $data_inizio="$dia-$dim-$dig";
|
---|
261 | $data_fine="$dfa-$dfm-$dfg";
|
---|
262 | $result = mysql_query("update ".$prefix."_ele_consultazione set descrizione='$descr_cons2',data_inizio='$data_inizio',
|
---|
263 | data_fine='$data_fine' WHERE id_cons_gen='$id_cons_gen'", $dbi);
|
---|
264 | if (!$result) return;
|
---|
265 | Header("Location: admin.php?op=consultazione&id_cons_gen=$id_cons_gen");
|
---|
266 | }
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | function help_cons()
|
---|
271 | {
|
---|
272 | //da mettere
|
---|
273 | }
|
---|
274 | if ($op=="consultazione")
|
---|
275 | if (isset($param['do']) and $do!='modify')
|
---|
276 | consultazione($ok, $id_cons_gen,$tipocons, $data_in, $data_fine,$do, $dig, $dim, $dia, $dfg, $dfm, $dfa, $duplica,$referendum,$liste,$gruppi,$ballo,$votigruppo);
|
---|
277 | # else consultazione('', $id_cons_gen,'','','','','','','','','','','','','','','','','');
|
---|
278 | ele();
|
---|
279 | all();
|
---|
280 | echo"</td></tr></table></div>";
|
---|
281 | include("footer.php");
|
---|
282 |
|
---|
283 |
|
---|
284 |
|
---|
285 | ?>
|
---|
286 |
|
---|