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

Last change on this file since 95 was 91, checked in by roby, 14 years ago
  • Sistemata la cancellazione della consultazione generale in ele_consultazione
File size: 14.4 KB
RevLine 
[2]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;
[45]52if (isset($param['help'])) $help=intval($param['help']);
[2]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() {
[45]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;
[2]71$language=$_SESSION['lang'];
72if (($perms>64)) {
[79]73############# Controllo flag per cancellazione consultazione
74 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
75 ."//-->\n";
76 echo "function del_cons() {\n";
[91]77 echo "if (document.getElementById('pwd3').checked==false) {\n";
78 echo "document.getElementById('update').value=\""._MODIFY."\" \n";
79 echo "document.getElementById('do').value=\"update\" \n";
[79]80 echo "}else{\n";
[91]81 echo "document.getElementById('update').value=\""._DELETE." "._CONSULTA."\" \n";
82 echo "document.getElementById('do').value=\"delete\" \n";
[79]83 echo "} \n";
84 echo "} \n";
85 echo "</script>\n";
86#########################
87 if (isset($help)) include("language/$language/ele_consultazioni.html");
[45]88
[2]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\">"
[91]99 ."<input type=\"hidden\" id=\"do\" name=\"do\" value=\"update\">"
[2]100 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"".$pro['id_cons_gen']."\">"
[79]101 ."<table width=\"100%\"><tr><td>"._MODIFY." ".$pro['descrizione']." <br><br>";
[2]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 }
[79]115 echo "</td></tr><tr><td>"._TIPO."</td><td>$gencons</td></tr>";
[2]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\" >";
[79]119 echo "<option value=\"$dig1\" selected>$dig1</option>";giorno(0,0);
[2]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\" >";
[79]127 echo "<option value=\"$dfg1\" selected>$dfg1</option>";giorno(0,0);
[2]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();
[79]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)
[91]135 echo "<td><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\"name=\"pwd3\" value=\"\" onclick=\"del_cons()\"></label></fieldset></td>";
[79]136 else echo "<td></td>";
[91]137 echo "<td><input type=\"submit\" id=\"update\" name=\"update\" value=\""._MODIFY."\">"
[2]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\">"
[45]144 ."<hr><h6>"
145 ._ADD." "._CONSULTA."<br><br>";
[79]146 echo _DEFCONS.":</h6><br><table width=\"100%\">";
[2]147
148 $res=mysql_query("SELECT * FROM ".$prefix."_ele_tipo where lingua='$language'", $dbi);
[45]149 echo "<tr><td><b>"._TIPO." :</b></td><td>";
[2]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>";
[79]163 echo "<select name= \"dig\" ><option value=\"$dig\" selected>$dig</option>"; giorno(0,0);
[2]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>";
[79]169 echo "<select name= \"dfg\" ><option value=\"$dfg\" selected>$dfg</option>"; giorno(0,0);
[2]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\">&nbsp;<b>"._DESCR."</b>&nbsp;</td>"
179 ."<td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._DATAIN."</b>&nbsp;</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&amp;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&amp;do=modify&amp;id_cons_gen=$id\"><img src=\"modules/Elezioni/images/edit.gif\"
[79]193 border=\"0\" align=\"middle\" alt=\"Edit\"> "._EDIT."</a>]"
[2]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&amp;id_cons_gen=$id_cons_gen&amp;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&amp;id_cons_gen=$id_cons_gen&amp;min=$next\">";
209 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
210 }
211 }
212 echo "</tr></table><br>";
213}
214}
215
216
217
218function 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
222if ($perms>=128) {
[79]223 if ($do == "delete") {
[87]224 $result = mysql_query("delete from ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen'", $dbi);
225 if (!$result) return;
[79]226 $result = mysql_query("delete from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'", $dbi);
[2]227 if (!$result) return;
228 Header("Location: admin.php?op=consultazione");
[79]229 }
[2]230 if ($do == "add") {
231 if ($descr_cons2) {
232 if($referendum=='true') {
233 $genere=0;
234 } elseif ($ballo=='true') {
235 $genere=1;
236 }else{
237 $genere=2;
238 if($liste!='true') {$genere+=2;}
239 if($gruppi=='true') {$genere+=1;}
240 }
241 $votigruppo=$votigruppo=='true'? 1:0;
242 $votilista=$votilista=='true'? 1:0;
243 $voticandi=$voticandi=='true'? 1:0;
244 $circo=$circo=='true'? 1:0;
245 $data_inizio="$dia-$dim-$dig";
246 $data_fine="$dfa-$dfm-$dfg";
247 $id_consulta=$id_cons_gen;
248 $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());
249/* $y=$result;
250 $res=mysql_query("select id_cons_gen from ".$prefix."_ele_consultazione where descrizione='$descr_cons2'
251 and data_inizio='$data_inizio' and data_fine='$data_fine' and tipo_cons='$tipocons'", $dbi);
252 list($idc)=mysql_fetch_row($res);
253 mkdir("images/consultazioni/$idc",0750);
254 copy("images/consultazioni/nulla.jpg","images/consultazioni/$idc/nulla.jpg");*/
255 } else {
256 OpenTable();
257 echo "<center>"._GESTIONE." "._CONSULTAZIONE."";
258 echo "<br><br><a href=\"admin.php?op=consultazione&amp;id_cons_gen=$id_cons_gen\">"._IMMCONS."</a></center>";
259 CloseTable();
260 }
261 }else if ($do == "update") {
262 $data_inizio="$dia-$dim-$dig";
263 $data_fine="$dfa-$dfm-$dfg";
264 $result = mysql_query("update ".$prefix."_ele_consultazione set descrizione='$descr_cons2',data_inizio='$data_inizio',
265 data_fine='$data_fine' WHERE id_cons_gen='$id_cons_gen'", $dbi);
266 if (!$result) return;
267 Header("Location: admin.php?op=consultazione&id_cons_gen=$id_cons_gen");
268 }
269 }
270}
271
272function help_cons()
273{
274//da mettere
275}
276if ($op=="consultazione")
[79]277 if (isset($param['do']) and $do!='modify')
[2]278 consultazione($ok, $id_cons_gen,$tipocons, $data_in, $data_fine,$do, $dig, $dim, $dia, $dfg, $dfm, $dfa, $duplica,$referendum,$liste,$gruppi,$ballo,$votigruppo);
[79]279# else consultazione('', $id_cons_gen,'','','','','','','','','','','','','','','','','');
[2]280ele();
281all();
[79]282echo"</td></tr></table></div>";
[2]283include("footer.php");
284
285
286
287?>
Note: See TracBrowser for help on using the repository browser.