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

Last change on this file since 404 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
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 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
[257]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);
[2]29
30include("modules/Elezioni/funzionidata.php");
31include("modules/Elezioni/ele.php");
[344]32if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
33if (isset($param['descr_circ'])) $descr_circ=addslashes($param['descr_circ']); else $descr_circ='';
[2]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='';
[344]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='';
[371]47if (isset($param['delmap'])) $delmap=addslashes($param['delmap']);
[2]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() {
[371]62 global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min,$id_cons,$id_cons_gen,$do,$id_sede,$id_circ,$delmap;
[2]63
[80]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>"
[2]69 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._CIRCO."</b></td>"
70 ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>"
[371]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>"
[2]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){
[257]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);
[2]85 }else{
86 $pro['indirizzo']='';$pro['filemappa']='';$pro['telefono1']='';$pro['fax']='';
87 $pro['responsabile']='';$pro['id_circ']='';
88 }
[80]89 echo "<tr>";
90 echo "<td align=\"right\"><select name=\"id_circ\">";
[257]91 $sql= "SELECT id_circ,descrizione FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' order by num_circ";
[258]92 $res = $dbi->prepare("$sql");echo $sql;
[257]93 $res->execute();
94 while(list($id,$descr) = $res->fetch(PDO::FETCH_NUM)) {
[2]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
[80]104 echo "<td><input type=\"text\" name=\"indir\" value=\"".$pro['indirizzo']."\"></td>"
[2]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
[80]109 ."<td><input type=\"text\" name=\"resp\" size=\"10\" value=\"".$pro['responsabile']."\"></td>";
[2]110 if ($do == "modify"){
[80]111 echo "<td align=\"center\"><input type=\"hidden\" name=\"id_sede\" value=\"$id_sede\">"
[2]112 ."<input type=\"hidden\" name=\"do\" value=\"update\">";
[80]113 echo "<input type=\"submit\" name=\"update\" value=\""._MODIFY."\"></td></tr>";
[2]114 } else {
[80]115 echo "<td align=\"center\"><input type=\"hidden\" name=\"do\" value=\"add\"><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr>";
[2]116 }
[80]117# echo "</table></form><table>";
[2]118
119
120
121
[257]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)) {
[2]130 // dati circoscrizione
[257]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
[2]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\"
[80]148 border=\"0\" align=\"middle\" alt=\"edit\"> "._EDIT."</a>]";
[2]149 if (!$numtemp)
[80]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>]";
[2]151 else
[80]152 echo "["._DELETE." <img src=\"modules/Elezioni/images/delete.gif\" border=\"0\" align=\"middle\" alt=\"delete\">]";
[2]153 echo "</td></tr>";
154 }
[80]155 echo "</table></form></center>";
[2]156
157
158 #'Pagina precedente' e 'Pagina Successiva'
[80]159 if ($max>$offset){
[2]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;
[80]170 else {
[2]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>";
[80]177 }
[2]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) {
[371]190global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons,$id_cons_gen,$id_comune,$delmap;
[2]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{
[257]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;
[2]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
[257]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;
[2]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'";
[371]259 } else {
260 if ( $delmap=='false') {$cond=", mappa='', filemappa=''";}
261 else $cond='';
262 }
[257]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");
[2]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.