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

Last change on this file since 400 was 371, checked in by roby, 2 years ago

In client:

  • rivista la funzione di esportazione pdf, xls e stampe
  • tema futura2: eliminato il taglio a 30 caratteri del nome della consultazione
  • modificata la barra da 2D a 3D per i grafici di affluenza e votanti

In admin:

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