source: trunk/admin/modules/Elezioni/ele_sede.php@ 22

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

importo il progetto

File size: 11.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 sedi */
9/* Amministrazione */
10/************************************************************************/
11
12
13if (!defined('ADMIN_FILE')) {
14 die ("You can't access this file directly...");
15}
16$id_comune=$_SESSION['id_comune'];
17
18$param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
19
20if (isset($param['id_cons_gen'])) $id_cons_gen=intval($param['id_cons_gen']); else $id_cons_gen='0';
21
22$perms=ChiSei($id_cons_gen);
23if ($perms>16) {
24
25$res = mysql_query("SELECT t1.tipo_cons,t2.id_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_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
26list($tipo_cons,$id_cons) = mysql_fetch_row($res);
27
28include("modules/Elezioni/funzionidata.php");
29include("modules/Elezioni/ele.php");
30if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
31if (isset($param['descr_circ'])) get_magic_quotes_gpc() ? $descr_circ=$param['descr_circ']:$descr_circ=addslashes($param['descr_circ']); else $descr_circ='';
32if (isset($param['min'])) $min=intval($param['min']); else $min=0;
33if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede='';
34if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
35if (isset($param['num_circ'])) $num_circ=intval($param['num_circ']); else $num_circ='';
36if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ='';
37if (isset($param['id_sede2'])) $id_sede2=intval($param['id_sede2']); else $id_sede2='';
38if (isset($param['indir'])) get_magic_quotes_gpc() ? $indir=$param['indir']:$indir=addslashes($param['indir']); else $indir='';
39if (isset($param['tel1'])) get_magic_quotes_gpc() ? $tel1=$param['tel1']:$tel1=addslashes($param['tel1']); else $tel1='';
40if (isset($param['tel2'])) get_magic_quotes_gpc() ? $tel2=$param['tel2']:$tel2=addslashes($param['tel2']); else $tel2='';
41if (isset($param['fax'])) get_magic_quotes_gpc() ? $fax=$param['fax']:$fax=addslashes($param['fax']); else $fax='';
42if (isset($param['resp'])) get_magic_quotes_gpc() ? $resp=$param['resp']:$resp=addslashes($param['resp']); else $resp='';
43if (isset($param['filemappa'])) get_magic_quotes_gpc() ? $filemappa=$param['filemappa']:$filemappa=addslashes($param['filemappa']); else $filemappa='';
44if (isset($param['mappa'])) get_magic_quotes_gpc() ? $mappa=$param['mappa']:$mappa=addslashes($param['mappa']); else $mappa='';
45
46
47
48// Offset - visualizza il numero di elementi per pagina
49
50$offset=15;
51$hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
52
53
54/******************************************************/
55/*Funzione di visualizzazione globale */
56/*****************************************************/
57
58function all() {
59 global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min,$id_cons,$id_cons_gen,$do,$id_sede,$id_circ;
60
61 echo "<center><font class=\"title\"><br><b>"._SEDE."</b></font><br><br><table border=\"0\" width=\"100%\" >"
62 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._CIRCO."</b></td>"
63 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
64 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._MAPPA."</b></td>"
65 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._TEL."</b></td>"
66 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FAX."</b></td>"
67 ."<td bgcolor=\"$bgcolor1\" align=\"center\">&nbsp;<b>"._RESP."</b>&nbsp;</td>"
68 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
69
70 echo "<form name=\"sede2\" enctype=\"multipart/form-data\" action=\"admin.php\" method=\"post\">"
71 ."<input type=\"hidden\" name=\"op\" value=\"sede\">"
72 ."<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
73 if ($id_sede){
74 $res = mysql_query("SELECT * FROM ".$prefix."_ele_sede where id_sede='$id_sede'", $dbi);
75 $pro= mysql_fetch_array($res, 3);
76 }else{
77 $pro['indirizzo']='';$pro['filemappa']='';$pro['telefono1']='';$pro['fax']='';
78 $pro['responsabile']='';$pro['id_circ']='';
79 }
80 echo "<tr><td align=\"right\"><select name=\"id_circ\">";
81 $res= mysql_query("SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ", $dbi);
82 while(list($id,$descr) = mysql_fetch_row($res)) {
83 if ($id == $pro['id_circ']) {
84 $sel = "selected";
85 } else {
86 $sel = "";
87 }
88 echo "<option value=\"$id\" $sel>$descr";
89 }
90 echo "</select></td>";
91
92 echo "<td><input type=\"text\" name=\"indir\" maxlength=\"40\" value=\"".$pro['indirizzo']."\"></td>"
93 ."<td><input type=\"file\" name=\"mappa\" size=\"12\" value=\"".$pro['filemappa']."\"></td>"
94 ."<td><input type=\"text\" name=\"tel1\" size=\"10\" value=\"".$pro['telefono1']."\"></td>"
95 ."<td><input type=\"text\" name=\"fax\" maxlength=\"12\" size=\"10\" value=\"".$pro['fax']."\"></td>"
96
97 ."<td><input type=\"text\" name=\"resp\" maxlength=\"60\" value=\"".$pro['responsabile']."\"></td>";
98 if ($do == "modify"){
99 echo "<input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
100 ."<input type=\"hidden\" name=\"do\" value=\"update\">";
101 echo "<td align=\"center\"><input type=\"submit\" name=\"update\" value=\""._MODIFY."\"></td></tr>";
102 } else {
103 echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
104
105
106
107
108 echo "<td align=\"center\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>";
109 }
110 echo "</form><tr></tr>";
111
112
113
114
115 $res = mysql_query("SELECT * FROM ".$prefix."_ele_sede where id_cons='$id_cons' ", $dbi);
116 $max = mysql_num_rows($res);
117 $result = mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_cons' ORDER BY id_circ LIMIT $min,$offset", $dbi);
118 while(list($id_cons2,$id_sede,$id_circ,$indir, $tel1, $tel2, $fax, $resp,$mappabin, $filemappa) = mysql_fetch_row($result)) {
119 // dati circoscrizione
120 $restemp = mysql_query("select count(0) from ".$prefix."_ele_sezioni where id_sede='$id_sede'", $dbi);
121 list($numtemp)=mysql_fetch_row($restemp);
122 $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
123 $result1 = mysql_query("select descrizione from ".$prefix."_ele_circoscrizione where id_circ='$id_circ'", $dbi);
124 list($descr_circ)=mysql_fetch_row($result1);
125 echo "<tr bgcolor=\"$bgcolor1\"><td align=\"left\"><b>$descr_circ</b>"
126 ."</td><td align=\"left\"><b>$indir</b>"
127 ."</td><td align=\"right\"><b>$filemappa</b>"
128 ."</td><td align=\"right\"><b>$tel1</b>"
129 ."</td><td align=\"right\"><b>$fax</b>"
130 ."</td><td align=\"left\"><b>$resp</b>"
131 ."</td><td align=\"center\" nowrap>[<a
132 href=\"admin.php?op=sede&amp;do=modify&amp;id_sede=$id_sede&amp;id_circ=$id_circ&amp;id_cons_gen=$id_cons_gen\"><img src=\"modules/Elezioni/images/edit.gif\"
133 border=\"0\" align=\"center\"> "._EDIT."</a>]";
134 if (!$numtemp)
135 echo "[<a href=\"admin.php?op=sede&amp;do=delete&amp;id_sede=$id_sede&amp;id_circ=$id_circ&amp;id_cons_gen=$id_cons_gen&amp;indir=$indir\">"._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\"></a>]";
136 else
137 echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"center\">]";
138 echo "</td></tr>";
139 }
140 echo "</table></center>";
141
142
143 #'Pagina precedente' e 'Pagina Successiva'
144 echo"<table align=\"center\" width=\"100%\" ><tr>";
145 $prev=$min-$offset;
146 if ($prev>=0) {
147 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sede&amp;id_sede=$id_sede&amp;id_circ=$id_circ&amp;id_cons_gen=$id_cons_gen&amp;min=$prev\">";
148 echo "<b>$offset "._PREV_MATCH."</b></a></td>";
149 }
150
151 $next=$min+$offset;
152 if ($next>=($offset-1)) {
153 if($next>=$max) $next = $max;
154 else {
155
156 echo "<td colspan=\"5\" align=\"center\" bgcolor=\"$bgcolor1\"><a href=\"admin.php?op=sede&amp;id_sede=$id_sede&amp;id_circ=$id_circ&amp;id_cons_gen=$id_cons_gen&amp;min=$next\">";
157 echo "<b>$offset "._NEXT_MATCH."</b></a></td>";
158 }
159 }
160 echo "</tr></table><br>";
161
162}
163
164
165
166//***********************************
167// Consultazione
168// ricordarsi di aggiungere l'eliminazione di tutti
169// i dati della consultazione nelle altre tabelle
170// hai capito?
171//***********************************
172
173function sede($ok, $do,$id_circ, $id_sede,$indir, $tel1, $tel2, $fax, $resp, $mappa, $filemappa, $id_sede2) {
174global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons,$id_cons_gen,$id_comune;
175$perms=ChiSei(0);
176
177if ($perms>16) {
178 if ($do == "delete") {
179 if ($ok !="1") {
180 ele();
181 echo "<center><br><br>"._DOMCANCELLA." $indir ?<br>";
182 echo "[ <a href=\"admin.php?op=sede\">"._NO."</a> ] - [<a href=\"admin.php?op=sede&amp;do=delete&amp;id_sede=$id_sede&amp;id_circ=$id_circ&amp;id_cons_gen=$id_cons_gen&amp;ok=1\">"._YES."</a> ]";
183 include("footer.php");
184 die();
185 }else{
186 $result = mysql_query("delete from ".$prefix."_ele_sede where id_sede='$id_sede'", $dbi);
187 if (!$result)return;
188 Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen");
189 }
190 }elseif ($do == "add") {
191 if ($indir) {
192
193
194 $mappablob='';
195 $mappanome='';
196 $MAPP=$_FILES['mappa'];
197
198 $filesmappa=$MAPP['tmp_name'];
199
200
201 $nomemappa=$MAPP['name'];
202 $sqlset='';
203 if ($filesmappa){
204 $fdmappa = fopen ("$filesmappa", "rb");
205 $mappacontents = fread ($fdmappa, filesize ("$filesmappa"));
206 fclose ($fdmappa);
207 $mappablob=addslashes($mappacontents);
208 $mappanome=addslashes($nomemappa);
209 }
210
211
212// echo "IDCIRC=$id_circ";
213
214
215 $result = mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons', '$id_circ','$indir','$tel1','$tel2', '$fax','$resp','$mappablob','$mappanome')", $dbi)|| die(mysql_error());
216 if (!$result) return;
217 Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen");
218 } else {
219 ele($id_cons);
220 OpenTable();
221 echo "<center>"._GESTIONE." "._SEDE." ";
222 echo "<br><br><a href=\"admin.php?op=sede&amp;id_cons_gen=$id_cons_gen\">"._IMM." "._SEDE."</a></center>";
223 CloseTable();
224 }
225 }elseif ($do == "update") {
226 $mappablob='';
227 $mappanome='';
228 $MAPPA=$_FILES['mappa'];
229 $filesmappa=$MAPPA['tmp_name'];
230 $nomemappa=$MAPPA['name'];
231 $sqlset='';
232 if ($filesmappa){
233 $fdmappa = fopen ("$filesmappa", "rb");
234 $mappacontents = fread ($fdmappa, filesize ("$filesmappa"));
235 fclose ($fdmappa);
236 $mappablob=addslashes($mappacontents);
237 $mappanome=addslashes($nomemappa);
238 $cond=", mappa='$mappablob', filemappa='$mappanome'";
239 } else {$cond='';}
240
241 $result = mysql_query("update ".$prefix."_ele_sede set id_circ='$id_circ',indirizzo='$indir' , telefono1='$tel1', telefono2='$tel2',fax='$fax',responsabile='$resp' $cond where id_sede='$id_sede2' ", $dbi)|| die(mysql_error());
242 if (!$result) return;
243 Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen&id_comune=$id_comune");
244 }
245}
246}
247
248
249
250
251
252
253 if($do and $do!="modify")
254 sede($ok, $do,$id_circ, $id_sede,$indir, $tel1, $tel2, $fax, $resp,$mappa, $filemappa,$id_sede);
255 ele();
256 all();
257 echo"</td></tr></table>";
258 include("footer.php");
259} else {
260 echo "Access Denied";
261}
262
263?>
264
Note: See TracBrowser for help on using the repository browser.