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

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

client - correzione per consultazione predefinita
admin - eliminati altri notice, modificata la funzione di visualizzazione della barra di elenco delle sezioni, aggiunti help per Scarica liste e Importa liste, corrette alcune incompatibilità con xhtml

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