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