source: trunk/admin/modules/Elezioni/ele_consultazioni.php@ 335

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