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