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

Last change on this file since 45 was 45, checked in by roby, 15 years ago

inserimento menu contestuale per la sezione admin

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