[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 Comuni */
|
---|
| 9 | /* Amministrazione */
|
---|
| 10 | /************************************************************************/
|
---|
| 11 | if (!defined('ADMIN_FILE')) {
|
---|
| 12 | die ("You can't access this file directly...");
|
---|
| 13 | }
|
---|
[257] | 14 | #foreach($_SESSION as $key=>$val) echo "$key : $val<br>";die();
|
---|
| 15 | global $dbi;
|
---|
[2] | 16 | $aid=$_SESSION['aid'];
|
---|
[257] | 17 | #$dbi=$_SESSION['dbi'];
|
---|
[2] | 18 | $prefix=$_SESSION['prefix'];
|
---|
| 19 | $id_comune=$_SESSION['id_comune'];
|
---|
| 20 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST;
|
---|
| 21 | $id_cons_gen=intval($param['id_cons_gen']);
|
---|
| 22 | $perms=ChiSei(0);
|
---|
| 23 | //if ($perms<128 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
|
---|
| 24 | if ($perms!=256) die("$perms Non hai i permessi per inserire dati!");
|
---|
[344] | 25 | if (isset($param['desc'])) $desc=addslashes($param['desc']); else $desc='';
|
---|
| 26 | if (isset($param['indirizzo'])) $indirizzo=addslashes($param['indirizzo']); else $indirizzo='';
|
---|
| 27 | if (isset($param['centralino'])) $centralino=addslashes($param['centralino']); else $centralino='';
|
---|
| 28 | if (isset($param['fax'])) $fax=addslashes($param['fax']); else $fax='';
|
---|
| 29 | if (isset($param['email'])) $email=addslashes($param['email']); else $email='';
|
---|
[2] | 30 | if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
|
---|
| 31 | if (isset($param['min'])) $min=intval($param['min']); else $min='';
|
---|
| 32 | if (isset($param['ok'])) $ok=addslashes($param['ok']); else $ok='';
|
---|
[96] | 33 | if (isset($param['fascia'])) $fasciatmp=intval($param['fascia']); else $fasciatmp=0;
|
---|
[2] | 34 | if (isset($param['prov'])) $prov=intval($param['prov']); else $prov=0;
|
---|
[344] | 35 | if (isset($param['simbolo'])) $simbolo=addslashes($param['simbolo']); else $simbolo='';
|
---|
| 36 | if (isset($param['cerca'])) $cerca=addslashes($param['cerca']); else $cerca='';
|
---|
| 37 | if (isset($param['cap'])) $cap=addslashes($param['cap']); else $cap='';
|
---|
[2] | 38 |
|
---|
[257] | 39 | $sql="SELECT t1.tipo_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_comune='$id_comune' ";
|
---|
| 40 | $res = $dbi->prepare("$sql");
|
---|
| 41 | $res->execute();
|
---|
| 42 | list($tipo_cons) = $res->fetch(PDO::FETCH_NUM);
|
---|
| 43 | $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
|
---|
| 44 | $res = $dbi->prepare("$sql");
|
---|
| 45 | $res->execute();
|
---|
| 46 | list($genere) = $res->fetch(PDO::FETCH_NUM);
|
---|
[2] | 47 | include("modules/Elezioni/funzionidata.php");
|
---|
| 48 | include("modules/Elezioni/ele.php");
|
---|
| 49 | // Offset - visualizza il numero di elementi per pagina
|
---|
| 50 |
|
---|
| 51 | $offset=15;
|
---|
| 52 | if (!isset($min)) $min=0;
|
---|
| 53 |
|
---|
| 54 | $hiddenInfo = "<input type=\"hidden\" name=\"min\" value=\"$min\">";
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | /******************************************************/
|
---|
| 59 | /*Funzione di visualizzazione globale */
|
---|
| 60 | /*****************************************************/
|
---|
| 61 | //crea la pagina delle affluenze
|
---|
| 62 | function all() {
|
---|
[247] | 63 | global $bgcolor1, $bgcolor2, $prefix, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$email,$fasciatmp,$prov,$id_comune2,$id_cons_gen,$cerca,$cap;
|
---|
[189] | 64 | if( !isset($id_conf) ) $id_conf=1;
|
---|
[2] | 65 | echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
|
---|
| 66 | echo "function controllo_id() {\n";
|
---|
| 67 | echo "var is_num = /^[0-9]+$/;";
|
---|
| 68 | echo "if (document.modello.id_comune2.value.match(is_num)) \n return true;\n";
|
---|
| 69 | echo "else {\n";
|
---|
| 70 | echo "document.modello.id_comune2.bgColor=\"#FF0000\" \n";
|
---|
| 71 | echo "alert ('"._COD_NV."!')\n return false; \n";
|
---|
| 72 | echo "}\n";
|
---|
| 73 | echo "}\n//-->\n";
|
---|
| 74 | echo "</script>\n";
|
---|
| 75 |
|
---|
| 76 |
|
---|
[257] | 77 | $sql="SELECT id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo,cap FROM ".$prefix."_ele_comuni where descrizione like '$cerca%' order by descrizione";
|
---|
| 78 | $resmod = $dbi->prepare("$sql");
|
---|
| 79 | $resmod->execute();
|
---|
| 80 | # list($tipo_cons) = $resmod->fetch(PDO::FETCH_NUM);
|
---|
[2] | 81 | echo "<table width=\"100%\"><tr><td bgcolor=\"$bgcolor2\"> <form name=\"cerca\" action=\"admin.php\">"
|
---|
| 82 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 83 | echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
| 84 | echo "<table>";
|
---|
| 85 | echo "<tr><td><b>"._FILTRO."</b><input name=\"cerca\"></td>";
|
---|
| 86 | echo "<td><input type=\"submit\" name=\"invia\" value=\""._OK."\"></td></tr></table></form></td></tr></table>";
|
---|
| 87 |
|
---|
| 88 | echo "<form name=\"modello\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\" onSubmit=\"return controllo_id()\">"
|
---|
| 89 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 90 | echo "<table width=\"100%\"><tr>";
|
---|
| 91 | echo "<td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td><td><input type=\"file\" name=\"stemma\" size=\"10\"></td>";
|
---|
| 92 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
|
---|
[228] | 93 | if ($id_comune2)
|
---|
[2] | 94 | echo "<td><input type=\"hidden\" name=\"id_comune2\" value=\"$id_comune2\">$id_comune2</td>";
|
---|
| 95 | else
|
---|
| 96 | echo "<td><input name=\"id_comune2\" value=\"$id_comune2\" size=\"4\"></td>";
|
---|
| 97 | echo "</tr>";
|
---|
| 98 | $sel[1]='';$sel[2]='';$sel[3]='';$sel[4]='';$sel[5]='';$sel[6]='';$sel[7]='';$sel[8]='';$sel[9]='';
|
---|
[96] | 99 | $sel[$fasciatmp]='selected';
|
---|
[2] | 100 | if($prov==1) $selpv='selected'; else $selpv='';
|
---|
| 101 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._PROV."</b></td><td><select name=\"prov\"> <option value=\"0\">No<option value=\"1\" $selpv>Si</select></td>";
|
---|
[125] | 102 | echo "<td bgcolor=\"$bgcolor1\"><b>"._DESCR."</b></td><td><input name=\"desc\" value=\"".stripslashes($desc)."\"></td></tr>";
|
---|
| 103 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._INDIRIZZO."</b></td><td><input name=\"indirizzo\" value=\"".stripslashes($indirizzo)."\"></td>";
|
---|
[2] | 104 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CENTRALINO."</b></td><td><input name=\"centralino\" value=\"$centralino\" size=\"6\"></td></tr>";
|
---|
[184] | 105 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._FASCIA."</b></td><td><select name=\"fascia\">";
|
---|
| 106 | $descr2="<";
|
---|
[257] | 107 | $sql="select id_fascia, abitanti from ".$prefix."_ele_fasce where id_conf=1 order by id_fascia";
|
---|
| 108 | $resopt1 = $dbi->prepare("$sql");
|
---|
| 109 | $resopt1->execute();
|
---|
| 110 | while(list($id,$descr)=$resopt1->fetch(PDO::FETCH_NUM)){
|
---|
[184] | 111 | $selid= ($id == $fasciatmp) ? "selected":"";
|
---|
| 112 |
|
---|
| 113 | echo "<option value=\"$id\" $selid>$descr2 $descr";
|
---|
| 114 | $descr2="$descr -";
|
---|
| 115 | }
|
---|
| 116 | echo "</select></td>";
|
---|
| 117 |
|
---|
[2] | 118 | echo "<td bgcolor=\"$bgcolor1\"><b>"._FAX."</b></td><td><input name=\"fax\" value=\"$fax\" size=\"6\"></td></tr>";
|
---|
| 119 | echo "<tr><td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td><td><input name=\"email\" value=\"$email\"></td>";
|
---|
[247] | 120 | echo "<td bgcolor=\"$bgcolor1\"><b>CAP</b></td><td><input name=\"cap\" value=\"$cap\" size=\"6\"> (<i>per googlemaps</i>) </td></tr>";
|
---|
| 121 | echo "<td></td><td></td><td></td><td><input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
|
---|
[2] | 122 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
[228] | 123 | if ($id_comune2) {
|
---|
[2] | 124 | echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
|
---|
| 125 | echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
|
---|
| 126 | }else{
|
---|
| 127 | echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
|
---|
| 128 | echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
|
---|
| 129 | }
|
---|
| 130 | $i=1;
|
---|
| 131 | ####
|
---|
| 132 | echo "</table><hr>";
|
---|
| 133 | echo "<table><tr><td bgcolor=\"$bgcolor1\"><b>"._STEMMA."</b></td>";
|
---|
| 134 | echo "<td bgcolor=\"$bgcolor1\"><b>"._CODICE."</b></td>";
|
---|
| 135 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._PROV."</b></td>";
|
---|
[247] | 136 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DESCR."</b></td>";
|
---|
| 137 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._INDIRIZZO."</b></td>";
|
---|
| 138 | //."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._CENTRALINO."</b></td>";
|
---|
| 139 | //echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FAX."</b></td>";
|
---|
[2] | 140 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._EMAIL."</b></td>";
|
---|
[247] | 141 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>CAP</b></td>";
|
---|
[2] | 142 | echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td></tr>";
|
---|
[247] | 143 |
|
---|
[2] | 144 |
|
---|
| 145 | ####
|
---|
[257] | 146 | while (list($id_comune2,$desc,$indirizzo,$centralino,$fax,$email,$fasciatmp,$prov,$simbolo,$cap) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti
|
---|
[2] | 147 | $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
|
---|
| 148 | if (!$simbolo) $simbolo="nulla.jpg";
|
---|
| 149 | $valprov= $prov==0 ? 'No':'Si';
|
---|
| 150 | echo "<form name=\"modello$i\" action=\"admin.php\">"
|
---|
| 151 | ."<input type=\"hidden\" name=\"op\" value=\"inscomuni\">";
|
---|
| 152 | echo "<input type=\"hidden\" name=\"do\" value=\"delete\">";
|
---|
| 153 | echo "<input type=\"hidden\" name=\"desc\" value=\"$desc\">";
|
---|
| 154 | echo "<tr align=\"left\" bgcolor=\"$bgcolor1\">";
|
---|
| 155 | echo "<td align=\"center\">
|
---|
| 156 | <img src=\"admin.php?op=foto&id_comune=$id_comune2&prefix=$prefix\" width=\"50\" heigth=\"50\"></td>";
|
---|
| 157 |
|
---|
| 158 | echo "<td width=\"32\"><b>$id_comune2</b></td>";
|
---|
| 159 | echo "<td width=\"32\"><b>$valprov</b></td>";
|
---|
| 160 | echo "<td><b>$desc</b></td>";
|
---|
| 161 | echo "<td><b>$indirizzo</b></td>";
|
---|
[247] | 162 | //echo "<td><b>$centralino</b></td>";
|
---|
| 163 | //echo "<td><b>$fax</b></td>";
|
---|
[2] | 164 | echo "<td><b>".substr($email,0,15)."...</b></td>";
|
---|
[247] | 165 | echo "<td><b>$cap</b></td>";
|
---|
[257] | 166 | $sql="select abitanti from ".$prefix."_ele_fasce where id_fascia=$fasciatmp and id_conf=$id_conf";
|
---|
| 167 | $resopt1 = $dbi->prepare("$sql");
|
---|
| 168 | $resopt1->execute();
|
---|
| 169 | list($tmpfascia)=$resopt1->fetch(PDO::FETCH_NUM);
|
---|
[184] | 170 | $fasciaref=$fasciatmp-1;
|
---|
[257] | 171 | $sql="select abitanti from ".$prefix."_ele_fasce where id_fascia=$fasciaref and id_conf=$id_conf";
|
---|
| 172 | $resopt1 = $dbi->prepare("$sql");
|
---|
| 173 | $resopt1->execute();
|
---|
| 174 | if($resopt1->rowCount()==0) $valfascia="< $tmpfascia";
|
---|
[184] | 175 | else
|
---|
| 176 | {
|
---|
[257] | 177 | list($tmp2fascia)=$resopt1->fetch(PDO::FETCH_NUM);
|
---|
[184] | 178 | $valfascia="$tmp2fascia - $tmpfascia";
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | /*
|
---|
[96] | 182 | switch ($fasciatmp) {
|
---|
[2] | 183 | case '0': $valfascia="-"; break;
|
---|
| 184 | case '1': $valfascia="< 3.000"; break;
|
---|
| 185 | case '2': $valfascia="3.001-10.000"; break;
|
---|
| 186 | case '3':$valfascia="10.001-15.000"; break;
|
---|
| 187 | case '4':$valfascia="15.001-30.000"; break;
|
---|
| 188 | case '5':$valfascia="30.001-100.000"; break;
|
---|
| 189 | case '6':$valfascia="100.001-250.000"; break;
|
---|
| 190 | case '7':$valfascia="250.001-500.000"; break;
|
---|
| 191 | case '8':$valfascia="500.001-1000.000"; break;
|
---|
| 192 | case '9': $valfascia=" >1.000.000"; break;
|
---|
[184] | 193 | } */
|
---|
[2] | 194 | echo "<td><b>$valfascia</b></td>";
|
---|
| 195 | echo "<input type=\"hidden\" name=\"ok\" value=0>";
|
---|
| 196 | echo "</td><td nowrap>[<a
|
---|
[247] | 197 | href=\"admin.php?op=inscomuni&desc=$desc&id_comune2=$id_comune2&indirizzo=$indirizzo&centralino=$centralino&fax=$fax&email=$email&fascia=$fasciatmp&prov=$prov&id_cons_gen=$id_cons_gen&cap=$cap\"><img align=\"center\" src=\"modules/Elezioni/images/edit.gif\"
|
---|
[2] | 198 | border=\"0\"> "._EDIT."</a>]";
|
---|
| 199 | echo "</tr></form>";
|
---|
| 200 | $i++;
|
---|
| 201 | }
|
---|
| 202 | echo "</table>";
|
---|
| 203 | CloseTable();
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[247] | 206 | function comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune,$fasciatmp,$prov,$simbolo,$cap) {
|
---|
[2] | 207 | global $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons_gen,$genere;
|
---|
| 208 | /* if ($do == "delete") {
|
---|
| 209 | if ($ok !="1") {
|
---|
| 210 | // ele($id_cons);operatori
|
---|
| 211 | echo "<center><br><br>"._DOMCANCELLA." "._COMUNE." $desc ?<br>";
|
---|
| 212 | echo "[ <a href=\"admin.php?op=inscomuni&id_comune=$id_comune&desc=$desc\">"._NO."</a> ] - [<a href=\"admin.php?op=inscomuni&do=delete&desc=$desc&id_comune=$id_comune&ok=1\">"._YES."</a> ]";
|
---|
| 213 | }else{
|
---|
| 214 | $result = sql_query("delete from ".$prefix."_ele_comuni where id_comune='$id_comune'", $dbi) || die("<br><br>Errore di eliminazione: ".mysql_error());
|
---|
| 215 | if (!$result) return;
|
---|
| 216 | Header("Location: admin.php?op=inscomuni&id_comune=$id_comune");
|
---|
| 217 | }
|
---|
| 218 | }else*/
|
---|
| 219 | $_SESSION['id_comune']=$id_comune;
|
---|
| 220 | if ($do == "add") {
|
---|
| 221 | if ($desc) {
|
---|
| 222 | $stemmablob='';
|
---|
| 223 | $stemmanome='';
|
---|
| 224 | $STEMM=$_FILES['stemma'];
|
---|
| 225 | $filestemma=$STEMM['tmp_name'];
|
---|
| 226 | $nomestemma=$STEMM['name'];
|
---|
| 227 | $sqlset='';
|
---|
| 228 | if ($filestemma){
|
---|
| 229 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
| 230 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
| 231 | fclose ($fdstemma);
|
---|
| 232 | $stemmablob=addslashes($stemmacontents);
|
---|
| 233 | $stemmanome=addslashes($nomestemma);
|
---|
| 234 | }
|
---|
[257] | 235 | $sql = "insert into ".$prefix."_ele_comuni (id_comune,descrizione,indirizzo,centralino,fax,email,fascia,capoluogo,simbolo,stemma,cap) values ('$id_comune','$desc','$indirizzo','$centralino','$fax','$email','$fasciatmp','$prov','$stemmanome','$stemmablob','$cap')";
|
---|
| 236 | $result = $dbi->prepare("$sql");
|
---|
| 237 | $result->execute();
|
---|
| 238 | Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
|
---|
[2] | 239 | } else {
|
---|
| 240 | OpenTable();
|
---|
| 241 | echo "<center>"._GESTIONE." "._OPERATORI." desc=$desc; ";
|
---|
| 242 | echo "<br><br><a href=\"admin.php?op=inscomuni&id_comune=$id_comune\">"._IMM." "._OPERATORI."</a></center>";
|
---|
| 243 | CloseTable();
|
---|
| 244 | }
|
---|
| 245 | }else if ($do == "update") {
|
---|
| 246 | $stemmablob='';
|
---|
| 247 | $stemmanome='';
|
---|
| 248 | $STEMM=$_FILES['stemma'];
|
---|
| 249 | $filestemma=$STEMM['tmp_name'];
|
---|
| 250 | $nomestemma=$STEMM['name'];
|
---|
| 251 | $sqlset='';
|
---|
| 252 | if ($filestemma){
|
---|
| 253 | $fdstemma = fopen ("$filestemma", "rb");
|
---|
| 254 | $stemmacontents = fread ($fdstemma, filesize ("$filestemma"));
|
---|
| 255 | fclose ($fdstemma);
|
---|
| 256 | $stemmablob=addslashes($stemmacontents);
|
---|
| 257 | $stemmanome=addslashes($nomestemma);
|
---|
| 258 | $cond=", simbolo='$stemmanome', stemma='$stemmablob'";
|
---|
| 259 | } else {$cond='';$stemmanome=''; $stemmablob='';}
|
---|
[257] | 260 | $sql = "update ".$prefix."_ele_comuni set descrizione='$desc' , indirizzo='$indirizzo', centralino='$centralino', fax='$fax' , cap='$cap' , email='$email', fascia='$fasciatmp',capoluogo='$prov' $cond where id_comune='$id_comune'";
|
---|
| 261 | $result = $dbi->prepare("$sql");
|
---|
| 262 | $result->execute();
|
---|
[2] | 263 | Header("Location: admin.php?op=inscomuni&id_cons_gen=$id_cons_gen");
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
[344] | 267 | if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
|
---|
[2] | 268 |
|
---|
| 269 | if ($do)
|
---|
[247] | 270 | comuni($ok, $do,$desc,$indirizzo,$centralino,$fax,$email,$id_comune2,$fasciatmp,$prov,$simbolo,$cap);
|
---|
[2] | 271 | ele();
|
---|
| 272 | all();
|
---|
| 273 | include("footer.php");
|
---|
| 274 |
|
---|
| 275 | ?>
|
---|
| 276 |
|
---|