"; /******************************************************/ /*Funzione di visualizzazione globale */ /*****************************************************/ function all() { global $bgcolor1, $bgcolor2, $bgcolor6, $prefix, $dbi, $offset, $min, $id_cons,$id_cons2, $id_comune,$descr_cons,$id_cons_gen,$perms,$language,$help; if (isset($help)) include("language/$language/ele_cons_comuni.html"); $row=descr_comune(); $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi); if (count($row)) $idpred = $row[2]; else $idpred=''; # $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi); $row=elenco_cons_comune(); $max = count($row); echo "
"; echo "
"; echo ""; echo "
" ." "._CONSPRED." "; echo ""; echo ""; echo ""; echo "

"; echo "

"._COPIA." "._LA." "._STRUTTURA." "._DA." $descr_cons


" ."" ."" ."" ."" .""; $sql = "select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetchAll(); $i=0; foreach($row as $arr) { $chiusa=$arr[0];$id_cons2=$arr[1];$idconsgen2=$arr[2]; $descr_cons=$arr[3]; $data_inizio=$arr[4]; $data_fine=$arr[5];$tipo=$arr[6]; $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; $sql = "select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $somma=$row[0]; $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine); echo "" ."" .""; if ($somma==0){ $i++; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; }elseif($perms==256){ $i++; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; } echo "
 "._DESCR."  "._DATAIN." "._DATAFINE.""._COPIA." "._NUM." "._ELETTORI.""._FUNZIONI."
$descr_cons$data_inizio$data_fine
Aggiorna il numero elettori
"; #'Pagina precedente' e 'Pagina Successiva' 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."

"; } function cons_comuni($ok, $id_cons2,$do, $duplica,$elettori) { global $prefix, $dbi,$id_comune,$id_cons_gen,$perms,$predefinita; if ($perms>32) { $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $id_consulta=$row[0]; $sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $descr_cons2=$row[0]; if ($do == "add") { if ($id_cons2) { // copia circoscrizione $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetchAll(); foreach($row as $arr){ $id=$arr[0];$idcirc=$arr[1];$num=$arr[2];$des2=$arr[3]; $des=addslashes($des2); $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $contr_circ=$row[0]; if (! $contr_circ){ sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')"; $sth = $dbi->prepare("$sql"); $sth->execute(); } $sql="select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $id_circ=$row[0]; // copia sede $sql="select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetchAll(); foreach($row as $row2) { $id1=$row2[0];$idsede1=$row2[1];$idcirc1=$row2[2];$ind2=$row2[3];$tel=$row2[4];$tel2=$row2[5];$fax=$row2[6];$resp=$row2[7];$mappa2=$row2[8];$filemappa2=$row2[9]; $filemappa=addslashes($filemappa2); $mappa=addslashes($mappa2); $ind=addslashes($ind2); $sql="select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $contr_sed=$row[0]; if (! $contr_sed){ $sql="insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')"; $sth = $dbi->prepare("$sql"); $sth->execute(); } $sql"select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'"; list($id_sede)=mysql_fetch_row($res2); $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $id_sede=$row[0]; //copia sezione $sql="select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1"; $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetchAll(); foreach($row as $arr2) { $id3=$arr2[0];$idsez3=$arr2[1];$idsede3=$arr2[2];$numero=$arr2[3];$maschi3=$arr2[4];$femmine3=$arr2[5];$validi3=$arr2[6];$nulli3=$arr2[7]; $bianchi3=$arr2[8];$contest3=$arr2[9];$sg3,$aut_m=$arr2[10];$aut_f=$arr2[11]; if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')"; else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')"; $sth = $dbi->prepare("$sql"); $sth->execute(); } } } # Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); } } if ($do == "elettori") { if ($ok !="1") { ele(); echo "


"._DOMAGGIORNA." Consultazione $descr_cons2 ?
"; echo "[ "._NO." ] - ["._YES." ]";exit; }else{ $sql="update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez"; $sth = $dbi->prepare("$sql"); $result=$sth->execute(); if (!$result) return; Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); } } if ($do == "update") { if ($predefinita) { $sql="update ".$prefix."_ele_comuni set id_cons='$predefinita' WHERE id_comune='$id_comune'"; $sth = $dbi->prepare("$sql"); $result=$sth->execute(); }else{ $sql"update ".$prefix."_ele_cons_comune set chiusa='$chiusa' WHERE id_cons2='$id_cons2'"; $sth = $dbi->prepare("$sql"); $result=$sth->execute(); } if (!$result) return; Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen"); } } } function help_cons() { //da mettere } if ($do) { cons_comuni($ok, $id_cons2,$do, $duplica, $elettori); } ele(); //OpenTable(); all(); CloseTable(); include("footer.php"); ?>