16) { $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'"; $res = $dbi->prepare("$sql"); $res->execute(); list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM); include("modules/Elezioni/funzionidata.php"); include("modules/Elezioni/ele.php"); if (isset($param['do'])) $do=addslashes($param['do']); else $do=''; if (isset($param['descr_circ'])) $descr_circ=addslashes($param['descr_circ']); else $descr_circ=''; if (isset($param['min'])) $min=intval($param['min']); else $min=0; if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede=''; if (isset($param['ok'])) $ok=intval($param['ok']); else $ok=''; if (isset($param['num_circ'])) $num_circ=intval($param['num_circ']); else $num_circ=''; if (isset($param['id_circ'])) $id_circ=intval($param['id_circ']); else $id_circ=''; if (isset($param['id_sede2'])) $id_sede2=intval($param['id_sede2']); else $id_sede2=''; if (isset($param['indir'])) $indir=addslashes($param['indir']); else $indir=''; if (isset($param['tel1'])) $tel1=addslashes($param['tel1']); else $tel1=''; if (isset($param['tel2'])) $tel2=addslashes($param['tel2']); else $tel2=''; if (isset($param['fax'])) $fax=addslashes($param['fax']); else $fax=''; if (isset($param['resp'])) $resp=addslashes($param['resp']); else $resp=''; if (isset($param['filemappa'])) $filemappa=addslashes($param['filemappa']); else $filemappa=''; if (isset($param['mappa'])) $mappa=addslashes($param['mappa']); else $mappa=''; // Offset - visualizza il numero di elementi per pagina $offset=15; $hiddenInfo = ""; /******************************************************/ /*Funzione di visualizzazione globale */ /*****************************************************/ function all() { global $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min,$id_cons,$id_cons_gen,$do,$id_sede,$id_circ; echo "

"._SEDE."


"; echo "
" ."" .""; echo "" ."" ."" ."" ."" ."" ."" .""; if ($id_sede){ $sql = "SELECT * FROM ".$prefix."_ele_sede where id_sede='$id_sede'"; $res = $dbi->prepare("$sql"); $res->execute(); $pro= $res->fetch(PDO::FETCH_BOTH); }else{ $pro['indirizzo']='';$pro['filemappa']='';$pro['telefono1']='';$pro['fax']=''; $pro['responsabile']='';$pro['id_circ']=''; } echo ""; echo ""; echo "" ."" ."" ."" .""; if ($do == "modify"){ echo ""; } else { echo ""; } # echo "
"._CIRCO.""._INDIRIZZO.""._MAPPA.""._TEL.""._FAX." "._RESP." "._FUNZIONI."
" .""; echo "
"; $sql = "SELECT * FROM ".$prefix."_ele_sede where id_cons='$id_cons' "; $res = $dbi->prepare("$sql"); $res->execute(); $max = $res->rowCount(); $sql = "select * from ".$prefix."_ele_sede where id_cons='$id_cons' ORDER BY id_circ LIMIT $min,$offset"; $result = $dbi->prepare("$sql"); $result->execute(); while(list($id_cons2,$id_sede,$id_circ,$indir, $tel1, $tel2, $fax, $resp,$mappabin, $filemappa) = $result->fetch(PDO::FETCH_NUM)) { // dati circoscrizione $sql = "select count(0) from ".$prefix."_ele_sezioni where id_sede='$id_sede'"; $restemp = $dbi->prepare("$sql"); $restemp->execute(); list($numtemp)=$restemp->fetch(PDO::FETCH_NUM); $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; $sql="select descrizione from ".$prefix."_ele_circoscrizione where id_circ='$id_circ'"; $result1 = $dbi->prepare("$sql"); $result1->execute(); list($descr_circ)=$result1->fetch(PDO::FETCH_NUM); echo ""; } echo "
$descr_circ" ."$indir" ."$filemappa" ."$tel1" ."$fax" ."$resp" ."[\"edit\" "._EDIT."]"; if (!$numtemp) echo "["._DELETE." \"delete\"]"; else echo "["._DELETE." \"delete\"]"; echo "
"; #'Pagina precedente' e 'Pagina Successiva' if ($max>$offset){ echo""; $prev=$min-$offset; if ($prev>=0) { echo ""; } $next=$min+$offset; if ($next>=($offset-1)) { if($next>=$max) $next = $max; else { echo ""; } } echo "
"; echo "$offset "._PREV_MATCH.""; echo "$offset "._NEXT_MATCH."

"; } } //*********************************** // Consultazione // ricordarsi di aggiungere l'eliminazione di tutti // i dati della consultazione nelle altre tabelle // hai capito? //*********************************** function sede($ok, $do,$id_circ, $id_sede,$indir, $tel1, $tel2, $fax, $resp, $mappa, $filemappa, $id_sede2) { global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons, $id_cons,$id_cons_gen,$id_comune; $perms=ChiSei(0); if ($perms>16) { if ($do == "delete") { if ($ok !="1") { ele(); echo "


"._DOMCANCELLA." $indir ?
"; echo "[ "._NO." ] - ["._YES." ]"; include("footer.php"); die(); }else{ $sql="delete from ".$prefix."_ele_sede where id_sede='$id_sede'"; $res = $dbi->prepare("$sql"); $res->execute(); if (!$res->rowCount())return; Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen"); } }elseif ($do == "add") { if ($indir) { $mappablob=''; $mappanome=''; $MAPP=$_FILES['mappa']; $filesmappa=$MAPP['tmp_name']; $nomemappa=$MAPP['name']; $sqlset=''; if ($filesmappa){ $fdmappa = fopen ("$filesmappa", "rb"); $mappacontents = fread ($fdmappa, filesize ("$filesmappa")); fclose ($fdmappa); $mappablob=addslashes($mappacontents); $mappanome=addslashes($nomemappa); } // echo "IDCIRC=$id_circ"; $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')"; $res = $dbi->prepare("$sql"); $res->execute(); if (!$res->rowCount()) return; Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen"); } else { ele($id_cons); OpenTable(); echo "
"._GESTIONE." "._SEDE." "; echo "

"._IMM." "._SEDE."
"; CloseTable(); } }elseif ($do == "update") { $mappablob=''; $mappanome=''; $MAPPA=$_FILES['mappa']; $filesmappa=$MAPPA['tmp_name']; $nomemappa=$MAPPA['name']; $sqlset=''; if ($filesmappa){ $fdmappa = fopen ("$filesmappa", "rb"); $mappacontents = fread ($fdmappa, filesize ("$filesmappa")); fclose ($fdmappa); $mappablob=addslashes($mappacontents); $mappanome=addslashes($nomemappa); $cond=", mappa='$mappablob', filemappa='$mappanome'"; } else {$cond='';} $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' "; $res = $dbi->prepare("$sql"); $res->execute(); if (!$res->rowCount()) return; Header("Location: admin.php?op=sede&id_cons_gen=$id_cons_gen&id_comune=$id_comune"); } } } if($do and $do!="modify") sede($ok, $do,$id_circ, $id_sede,$indir, $tel1, $tel2, $fax, $resp,$mappa, $filemappa,$id_sede); ele(); all(); echo""; include("footer.php"); } else { echo "Access Denied"; } ?>