source: trunk/admin/modules/Elezioni/ele_comuni.php@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 12.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 Comuni */
9/* Amministrazione */
10/************************************************************************/
11if (!defined('ADMIN_FILE')) {
12 die ("You can't access this file directly...");
13}
14#foreach($_FILES as $key=>$val) echo $key;die();
15$aid=$_SESSION['aid'];
16$dbi=$_SESSION['dbi'];
17$prefix=$_SESSION['prefix'];
18$id_comune=$_SESSION['id_comune'];
19$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
20$id_cons_gen=intval($param['id_cons_gen']);
21$perms=ChiSei(0);
22//if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
23if ($perms!=256) die("$perms Non hai i permessi per inserire dati!");
24if (isset($param['desc'])) get_magic_quotes_gpc() ? $desc=$param['desc']:$desc=addslashes($param['desc']); else $desc='';
25if (isset($param['indirizzo'])) get_magic_quotes_gpc() ? $indirizzo=$param['indirizzo']:$indirizzo=addslashes($param['indirizzo']); else $indirizzo='';
26if (isset($param['centralino'])) get_magic_quotes_gpc() ? $centralino=$param['centralino']:$centralino=addslashes($param['centralino']); else $centralino='';
27if (isset($param['fax'])) get_magic_quotes_gpc() ? $fax=$param['fax']:$fax=addslashes($param['fax']); else $fax='';
28if (isset($param['email'])) get_magic_quotes_gpc() ? $email=$param['email']:$email=addslashes($param['email']); else $email='';
29if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
30if (isset($param['min'])) $min=intval($param['min']); else $min='';
31if (isset($param['ok'])) $ok=addslashes($param['ok']); else $ok='';
32if (isset($param['fascia'])) $fascia=intval($param['fascia']); else $fascia=0;
33if (isset($param['prov'])) $prov=intval($param['prov']); else $prov=0;
34if (isset($param['simbolo'])) get_magic_quotes_gpc() ? $simbolo=$param['simbolo']:$simbolo=addslashes($param['simbolo']); else $simbolo='';
35if (isset($param['cerca'])) get_magic_quotes_gpc() ? $cerca=$param['cerca']:$cerca=addslashes($param['cerca']); else $cerca='';
36
37 $res = mysql_query("SELECT t1.tipo_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' " , $dbi);
38 list($tipo_cons) = mysql_fetch_row($res);
39 $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
40 list($genere) = mysql_fetch_row($res);
41 include("modules/Elezioni/funzionidata.php");
42 include("modules/Elezioni/ele.php");
43
44 // Offset - visualizza il numero di elementi per pagina
45
46 $offset=15;
47 if (!isset($min)) $min=0;
48
49 $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
50
51
52
53 /******************************************************/
54 /*Funzione di visualizzazione globale */
55 /*****************************************************/
56 //crea la pagina delle affluenze
57function all() {
58 global $bgcolor1, $bgcolor2, $prefix, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$email,$fascia,$prov,$id_comune2,$id_cons_gen,$cerca;
59
60 echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
61 echo "function controllo_id() {\n";
62 echo "var is_num = /^[0-9]+$/;";
63 echo "if (document.modello.id_comune2.value.match(is_num)) \n return true;\n";
64 echo "else {\n";
65 echo "document.modello.id_comune2.bgColor=\"#FF0000\" \n";
66 echo "alert ('"._COD_NV."!')\n return false; \n";
67 echo "}\n";
68 echo "}\n//-->\n";
69 echo "</script>\n";
70
71
72 $resmod = mysql_query("SELECT id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo FROM ".$prefix."_ele_comuni where descrizione like '$cerca%' order by descrizione", $dbi);
73 echo "<table width=\"100%\"><tr><td bgcolor=\"$bgcolor2\"> <form name=\"cerca\" action=\"admin.php\">"
74 ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
75 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
76 echo "<table>";
77 echo "<tr><td><b>"._FILTRO."</b><input name=\"cerca\"></td>";
78 echo "<td><input type=\"submit\" name=\"invia\" value=\""._OK."\"></td></tr></table></form></td></tr></table>";
79
80 echo "<form name=\"modello\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\" onSubmit=\"return controllo_id()\">"
81 ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
82 echo "<table width=\"100%\"><tr>";
83 echo "<td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td><td><input type=\"file\" name=\"stemma\" size=\"10\"></td>";
84 echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
85 if ($desc)
86 echo "<td><input type=\"hidden\" name=\"id_comune2\" value=\"$id_comune2\">$id_comune2</td>";
87 else
88 echo "<td><input name=\"id_comune2\" value=\"$id_comune2\" size=\"4\"></td>";
89 echo "</tr>";
90 $sel[1]='';$sel[2]='';$sel[3]='';$sel[4]='';$sel[5]='';$sel[6]='';$sel[7]='';$sel[8]='';$sel[9]='';
91 $sel[$fascia]='selected';
92 if($prov==1) $selpv='selected'; else $selpv='';
93 echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._PROV."</b></td><td><select name=\"prov\"> <option value=\"0\">No<option value=\"1\" $selpv>Si</select></td>";
94 echo "<td bgcolor=\"$bgcolor1\"><b>"._DESCR."</b></td><td><input name=\"desc\" value=\"$desc\"></td></tr>";
95 echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._INDIRIZZO."</b></td><td><input name=\"indirizzo\" value=\"$indirizzo\"></td>";
96 echo "<td bgcolor=\"$bgcolor1\"><b>"._CENTRALINO."</b></td><td><input name=\"centralino\" value=\"$centralino\" size=\"6\"></td></tr>";
97 echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._FASCIA."</b></td><td><select name=\"fascia\">"
98 ."<option value=\"1\"".$sel[1].">0-3.000"
99 ."<option value=\"2\"".$sel[2].">3.001-10.000"
100 ."<option value=\"3\"".$sel[3].">10.001-15.000"
101 ."<option value=\"4\"".$sel[4].">15.001-30.000"
102 ."<option value=\"5\"".$sel[5].">30.001-100.000"
103 ."<option value=\"6\"".$sel[6].">100.001-250.000"
104 ."<option value=\"7\"".$sel[7].">250.001-500.000"
105 ."<option value=\"8\"".$sel[8].">500.001-1.000.000"
106 ."<option value=\"9\"".$sel[9]."> >1.000.000";
107 echo "</select></td>";
108 echo "<td bgcolor=\"$bgcolor1\"><b>"._FAX."</b></td><td><input name=\"fax\" value=\"$fax\" size=\"6\"></td></tr>";
109 echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td><td><input name=\"email\" value=\"$email\"></td>";
110 echo "<td></td><td><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
111 echo "<input type=\"hidden\" name=\"ok\" value=0>";
112 if ($desc) {
113 echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
114 echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
115 }else{
116 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
117 echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
118 }
119 $i=1;
120####
121echo "</table><hr>";
122 echo "<table><tr><td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td>";
123 echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
124 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._PROV."</b></td>";
125 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DESCR."</b></td>"
126 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
127 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._CENTRALINO."</b></td>";
128 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FAX."</b></td>";
129 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._EMAIL."</b></td>";
130 echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td></tr>";
131
132####
133 while (list($id_comune2,$desc,$indirizzo,$centralino,$fax,$email,$fascia,$prov,$simbolo) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
134 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
135 if (!$simbolo) $simbolo="nulla.jpg";
136 $valprov= $prov==0 ? 'No':'Si';
137 echo "<form name=\"modello$i\" action=\"admin.php\">"
138 ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
139 echo "<input type=\"hidden\" name=\"do\" value=\"delete\">";
140 echo "<input type=\"hidden\" name=\"desc\" value=\"$desc\">";
141 echo "<tr align=\"left\" bgcolor=\"$bgcolor1\">";
142 echo "<td align=\"center\">
143 <img src=\"admin.php?op=foto&amp;id_comune=$id_comune2&amp;prefix=$prefix\" width=\"50\" heigth=\"50\"></td>";
144
145 echo "<td width=\"32\"><b>$id_comune2</b></td>";
146 echo "<td width=\"32\"><b>$valprov</b></td>";
147 echo "<td><b>$desc</b></td>";
148 echo "<td><b>$indirizzo</b></td>";
149 echo "<td><b>$centralino</b></td>";
150 echo "<td><b>$fax</b></td>";
151 echo "<td><b>".substr($email,0,15)."...</b></td>";
152 switch ($fascia) {
153 case '0': $valfascia="-"; break;
154 case '1': $valfascia="< 3.000"; break;
155 case '2': $valfascia="3.001-10.000"; break;
156 case '3':$valfascia="10.001-15.000"; break;
157 case '4':$valfascia="15.001-30.000"; break;
158 case '5':$valfascia="30.001-100.000"; break;
159 case '6':$valfascia="100.001-250.000"; break;
160 case '7':$valfascia="250.001-500.000"; break;
161 case '8':$valfascia="500.001-1000.000"; break;
162 case '9': $valfascia=" >1.000.000"; break;
163 }
164 echo "<td><b>$valfascia</b></td>";
165 echo "<input type=\"hidden\" name=\"ok\" value=0>";
166 echo "</td><td nowrap>[<a
167 href=\"admin.php?op=inscomuni&amp;desc=$desc&amp;id_comune2=$id_comune2&amp;indirizzo=$indirizzo&amp;centralino=$centralino&amp;fax=$fax&amp;email=$email&amp;fascia=$fascia&amp;prov=$prov&amp;id_cons_gen=$id_cons_gen\"><img align=\"center\" src=\"modules/Elezioni/images/edit.gif\"
168 border=\"0\"> "._EDIT."</a>]";
169 echo "</tr></form>";
170 $i++;
171 }
172 echo "</table>";
173 CloseTable();
174 }
175
176function comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune,$fascia,$prov,$simbolo) {
177 global $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons_gen,$genere;
178/* if ($do == "delete") {
179 if ($ok !="1") {
180// ele($id_cons);operatori
181 echo "<center><br><br>"._DOMCANCELLA." "._COMUNE." $desc ?<br>";
182 echo "[ <a href=\"admin.php?op=inscomuni&amp;id_comune=$id_comune&amp;desc=$desc\">"._NO."</a> ] - [<a href=\"admin.php?op=inscomuni&amp;do=delete&amp;desc=$desc&amp;id_comune=$id_comune&amp;ok=1\">"._YES."</a> ]";
183 }else{
184 $result = sql_query("delete from ".$prefix."_ele_comuni where id_comune='$id_comune'", $dbi) || die("<br><br>Errore di eliminazione: ".mysql_error());
185 if (!$result) return;
186 Header("Location: admin.php?op=inscomuni&id_comune=$id_comune");
187 }
188 }else*/
189 $_SESSION['id_comune']=$id_comune;
190 if ($do == "add") {
191 if ($desc) {
192 $stemmablob='';
193 $stemmanome='';
194 $STEMM=$_FILES['stemma'];
195 $filestemma=$STEMM['tmp_name'];
196 $nomestemma=$STEMM['name'];
197 $sqlset='';
198 if ($filestemma){
199 $fdstemma = fopen ("$filestemma", "rb");
200 $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
201 fclose ($fdstemma);
202 $stemmablob=addslashes($stemmacontents);
203 $stemmanome=addslashes($nomestemma);
204 }
205 $result = mysql_query("insert into ".$prefix."_ele_comuni (id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo,stemma) values ('$id_comune','$desc','$indirizzo','$centralino','$fax','$email','$fascia','$prov','$stemmanome','$stemmablob')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
206 Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
207 } else {
208 OpenTable();
209 echo "<center>"._GESTIONE." "._OPERATORI." desc=$desc; ";
210 echo "<br><br><a href=\"admin.php?op=inscomuni&amp;id_comune=$id_comune\">"._IMM." "._OPERATORI."</a></center>";
211 CloseTable();
212 }
213 }else if ($do == "update") {
214 $stemmablob='';
215 $stemmanome='';
216 $STEMM=$_FILES['stemma'];
217 $filestemma=$STEMM['tmp_name'];
218 $nomestemma=$STEMM['name'];
219 $sqlset='';
220 if ($filestemma){
221 $fdstemma = fopen ("$filestemma", "rb");
222 $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
223 fclose ($fdstemma);
224 $stemmablob=addslashes($stemmacontents);
225 $stemmanome=addslashes($nomestemma);
226 $cond=", simbolo='$stemmanome', stemma='$stemmablob'";
227 } else {$cond='';$stemmanome=''; $stemmablob='';}
228 $result = mysql_query("update ".$prefix."_ele_comuni set descrizione='$desc' , indirizzo='$indirizzo', centralino='$centralino', fax='$fax', email='$email', fascia='$fascia',capoluogo='$prov' $cond where id_comune='$id_comune'", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
229 Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
230 }
231}
232
233if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
234
235if ($do)
236 comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune2,$fascia,$prov,$simbolo);
237ele();
238all();
239include("footer.php");
240
241?>
242
Note: See TracBrowser for help on using the repository browser.