prepare("$sql"); $res->execute(); # $gru = $sth->fetch(PDO::FETCH_BOTH); list($tipo_cons,$descr_cons,$id_cons,$id_conf) = $res->fetch(PDO::FETCH_NUM); $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' "; $res = $dbi->prepare("$sql"); $res->execute(); list($genere) = $res->fetch(PDO::FETCH_NUM); include("modules/Elezioni/funzionidata.php"); include("modules/Elezioni/ele.php"); if (isset($_GET['descr_comu'])) get_magic_quotes_gpc() ? $descr_comu=$param['descr_comu']:$descr_comu=addslashes($param['descr_comu']); else $descr_comu=''; if (isset($_GET['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do=''; if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok=''; if (isset($_GET['id_cons_comu'])) $id_cons_comu=intval($_GET['id_cons_comu']); else $id_cons_comu=''; if (isset($_GET['id_collegio'])) $id_collegio=intval($_GET['id_collegio']); else $id_collegio=''; if (isset($_GET['idcomune'])) $idcomune=intval($_GET['idcomune']); else $idcomune=''; if (isset($_GET['idcomunenew'])) $idcomunenew=intval($_GET['idcomunenew']); else $idcomunenew=''; if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa=''; if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']); else $id_conf=0; if (isset($_GET['idfascia'])) $idfascia=intval($_GET['idfascia']); else $idfascia=0; if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0; if (isset($_GET['help'])) $help=intval($_GET['help']); if (isset($_GET['pwd4'])) $pwd4=intval($_GET['pwd4']); if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1; if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0; if (isset($_GET['sg'])) $sg=intval($_GET['sg']); else $sg=0; if (isset($_GET['disgiunto'])) $disgiunto=intval($_GET['disgiunto']); else $disgiunto=0; $offset=15; $hiddenInfo = ""; /******************************************************/ /*Funzione di visualizzazione globale */ /*****************************************************/ // function all() { global $user, $admin, $bgcolor1, $bgcolor2, $prefix,$descr_cons, $dbi,$id_cons,$desc,$indirizzo,$centralino,$fax,$id_cons_gen,$id_collegio,$idcomune,$chiusa,$id_conf,$tipo_cons,$language,$help,$preferenze,$idfascia,$vismf,$sg,$disgiunto,$id_cons_comu; $aid=$_SESSION['aid']; $prefix=$_SESSION['prefix']; ############# Controllo flag per cancellazione consultazione echo "\n"; echo "\n"; ######################### if (isset($help)) include("language/$language/ele_associazioni.html"); OpenTable(); echo "

"; $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'"; $res = $dbi->prepare("$sql"); $res->execute(); list ($descr_cons) = $res->fetch(PDO::FETCH_NUM); //inserire avviso su mancanza dei permessi echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; if($tipo_cons==3){ echo ""; echo ""; } echo ""; echo ""; echo ""; echo ""; echo ""; $sql = "SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); echo ""; echo ""; $selez['0']=''; $selez['1']=''; $selez['2']=''; $selez['3']=''; $selez[$chiusa]="selected"; echo ""; if($tipo_cons==3){ if($idcomune) { $sql="SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); if($rescomu->rowCount()) list($fasciacom)=$rescomu->fetch(PDO::FETCH_NUM); } else $fasciacom=0; $sql="SELECT id_conf, descrizione from ".$prefix."_ele_conf order by id_conf desc"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); echo ""; if(!$id_conf) $id_conf=1; $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); echo ""; } unset($sel); $sql = "SELECT vismf,vismf,solo_gruppo,disgiunto from ".$prefix."_ele_cons_comune where id_cons='$id_cons_comu'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); list($vismf,$sg,$disgiunto)=$rescomu->fetch(PDO::FETCH_NUM); echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"._CONSULTA.""._DEFCOMUNE.""._PREFERENZE.""._STATO.""._CONF.""._FASCIA.""._VISAFFMF.""._ASOLO_GRUPPO.""._DISGIUNTO."
"; echo ""; echo "$descr_cons"; if($idcomune) { while ($listele=$rescomu->fetch(PDO::FETCH_BOTH)) if($listele['id_comune']==$idcomune) { echo $listele['descrizione']; echo ""; } }else{ echo ""; } echo ""; echo ""; if ($idcomune) { echo ""; echo ""; echo "
"._SPUNTALABEL1."
"._SPUNTALABEL2."
"; }else{ echo ""; echo ""; } $i=0; echo "
"; echo "

"; echo ""; echo ""; echo ""; echo ""; if($tipo_cons==3){ echo ""; echo ""; } echo ""; echo ""; echo ""; echo ""; $sql="SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione"; $resmod = $dbi->prepare("$sql"); $resmod->execute(); while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = $resmod->fetch(PDO::FETCH_NUM)){ //elenco dei modelli inseriti $sql="SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'"; $resconf = $dbi->prepare("$sql"); $resconf->execute(); list($descr_conf) = $resconf->fetch(PDO::FETCH_NUM); $i++; $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; echo ""; echo ""; echo ""; echo ""; $stato['0']=_ATTIVA; $stato['1']=_CHIUSA; $stato['2']=_NULLA; echo ""; if($tipo_cons==3){ echo ""; $sql="SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); $inffascia=0; if ($rescomu->rowCount()==0) echo ""; while(list($id,$abitanti)=$rescomu->fetch(PDO::FETCH_NUM)){ $sel=''; if ($id == $fasciacom) echo ""; $inffascia=$abitanti; } } if ($vismf2==0) $sel=_NO; else $sel=_SI; echo ""; if ($sg2==0) $sel=_NO; else $sel=_SI; echo ""; if ($disgiunto2==0) $sel=_NO; else $sel=_SI; echo ""; echo "\n"; } echo "
"._CONSULTA.""._DEFCOMUNE.""._PREFERENZE.""._STATO.""._CONF.""._FASCIA.""._VISAFFMF.""._ASOLO_GRUPPO.""._DISGIUNTO." "._FUNZIONI."
$descr_cons$descr_comu$preferenze2".$stato[$chiusa]."".$descr_conf."$inffascia - $abitanti$sel$sel$sel"; echo "
" .""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "" ."
"; CloseTable(); } function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) { global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf,$sg,$disgiunto; $delcons=0; if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) { $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); $max = $rescomu->rowCount(); //esiste autorizzazione? list($delcons)=$rescomu->fetch(PDO::FETCH_NUM); if (!$max){ //se no la inserisce $sql="insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf,solo_gruppo,disgiunto) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf','$sg','$disgiunto')"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'"; $rescomu = $dbi->prepare("$sql"); $rescomu->execute(); list($id_cons_comu)=$rescomu->fetch(PDO::FETCH_NUM); $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$idcomunenew' "; $res = $dbi->prepare("$sql"); $res->execute(); list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); if (!$id_cons_pred) { $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_comu' where id_comune='$idcomunenew' "; $res = $dbi->prepare("$sql"); $res->execute(); } } if ($do == "update") { if ($idcomunenew>0) $newid=", id_comune = $idcomunenew "; else $newid=''; $sql="update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf',solo_gruppo='$sg',disgiunto='$disgiunto' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'"; $result = $dbi->prepare("$sql"); $result->execute(); Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen"); }elseif ($do == "add") { if ($id_collegio){ $sql="insert into ".$prefix."_ele_comu_collegi (id_collegio,id_cons,id_comune,id_cons_gen) values ('$id_collegio','$id_cons_comu','$idcomunenew','$id_cons_gen')"; $result = $dbi->prepare("$sql"); $result->execute(); } Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen"); }elseif ($do == "delete" and $delcons>0) { $idcns=$delcons; $sql="delete from ".$prefix."_ele_voti_ref where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_voti_lista where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_controllosez where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); if ($pwd4==1){ $sql="delete from ".$prefix."_ele_candidati where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_lista where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_gruppo where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_sezioni where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="delete from ".$prefix."_ele_cons_comune where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune='$id_comune' "; $res = $dbi->prepare("$sql"); $res->execute(); list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); if ($idcns==$id_cons_pred) { $sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune=$id_comune order by id_cons desc limit 0,1"; $res = $dbi->prepare("$sql"); $res->execute(); list($id_cons_pred)=$res->fetch(PDO::FETCH_NUM); $sql="update ".$prefix."_ele_comuni set id_cons='$id_cons_pred' where id_comune='$id_comune' "; $res = $dbi->prepare("$sql"); $res->execute(); } }else{ $sql="update ".$prefix."_ele_sezioni set validi='0', nulli='0', bianchi='0', contestati='0', solo_gruppo='0', autorizzati_m='0', autorizzati_f='0', voti_nulli='0', validi_lista='0', contestati_lista='0', voti_nulli_lista='0' where id_cons=$idcns"; $result = $dbi->prepare("$sql"); $result->execute(); } Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen"); } } } //**************************** // switch //**************************** if ($op=="associazioni"){ associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$idcomune,$chiusa,$id_conf,$preferenze); } ele(); if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']); else $id_cons_gen='0'; all(); include("footer.php"); ?>