prepare("$sql");
$res->execute();
list($tipo_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM);
if (isset($param['aid2'])) $aid2=addslashes($param['aid2']); else $aid2='';
if (isset($param['id_sede'])) $id_sede=intval($param['id_sede']); else $id_sede=0;
if (isset($param['do'])) $do=addslashes($param['do']); else $do='';
if (isset($param['permessi'])) $permessi=addslashes($param['permessi']); else $permessi='';
if (isset($param['id_comune2'])) $id_comune2=intval($param['id_comune2']); else $id_comune2='';
if (isset($param['ok'])) $ok=intval($param['ok']); else $ok='';
if (isset($param['mex'])) $mex=addslashes($param['mex']); else $mex='';
if (isset($param['id_sez'])) $id_sez=intval($param['id_sez']); else $id_sez=0;
include("modules/Elezioni/funzionidata.php");
include("modules/Elezioni/ele.php");
/******************************************************/
/*Funzione di visualizzazione globale */
/*****************************************************/
//crea la pagina delle affluenze
function all() {
global $adminop,$adminsuper,$admincomune,$aid, $offset, $prefix, $dbi,$id_cons,$aid2,$permessi,$id_sede,$id_cons_gen,$id_comune,$mex,$id_sez;
$bgcolor1=$_SESSION['bgcolor1'];
echo "\n";
if (isset($mex)){
echo "
";
}
OpenTable();
$sql="SELECT * FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid";
$resmod = $dbi->prepare("$sql");
$resmod->execute();
echo "
";
echo ""._UTENTE." | "
.""._SEDE." | "
.""._SEZIONE." | "
.""._PERMESSI." | ";
echo ""._FUNZIONI." |
";
$sql="SELECT aid FROM ".$prefix."_ele_operatori where id_cons=$id_cons and permessi<64 order by aid";
$restmp = $dbi->prepare("$sql");
$restmp->execute();
if($restmp) {
$listmp='';$virg='';
while (list($artmp) = $restmp->fetch(PDO::FETCH_NUM)){ //elenco degli operatori gia' autorizzati
$listmp .= $virg."'".$artmp."'";
$virg=',';
}
}
if (!$listmp) $listmp="''";
$sql="select aid from ".$prefix."_authors where id_comune=$id_comune and (admincomune=0 and adminop=0 and aid not in ($listmp)) order by aid"; // operatori registrati ma non ancora autorizzati
$resins = $dbi->prepare("$sql");
$resins->execute();
echo "
";
echo "
";
if($resmod->rowCount()){
$i=1;
while (list($id_cons2,$id_sede2,$id_comunetemp,$perm,$utente,$id_circ2,$id_sez2) = $resmod->fetch(PDO::FETCH_NUM)){
$bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
echo "";
$i++;
}
}
echo "
";
CloseTable();
}
function permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez) {
global $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
$perms=ChiSei($id_cons_gen);
if ($perms!=256) $id_comune=$_SESSION['id_comune'];
if ($perms>32 and $permessi<$perms and $aid2) {
if ($do == "autorizza") {
$sql="select num_sez from ".$prefix."_ele_sezioni where id_sez='$id_sez'";
$res = $dbi->prepare("$sql");
$res->execute();
list ($num_sez)=$res->fetch(PDO::FETCH_NUM);
$sql="select data_inizio from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'";
$compl = $dbi->prepare("$sql");
$compl->execute();
list ($datarif)= $compl->fetch(PDO::FETCH_NUM);
$sql="select id_cons from ".$prefix."_ele_cons_comune where id_comune='$id_comune' and id_cons_gen in (select id_cons_gen from ".$prefix."_ele_consultazione where data_inizio='$datarif')";
$compl = $dbi->prepare("$sql");
$compl->execute();
while(list ($id_cons)= $compl->fetch(PDO::FETCH_NUM)){
$sql="select id_sez, id_sede from ".$prefix."_ele_sezioni where id_cons='$id_cons' and num_sez='$num_sez'";
$res = $dbi->prepare("$sql");
$res->execute();
if(!$res->rowCount()) continue;
list ($id_sez,$id_sede)=$res->fetch(PDO::FETCH_NUM);
$sql="select aid from ".$prefix."_ele_operatori where id_cons='$id_cons' and aid='$aid2'";
$res = $dbi->prepare("$sql");
$res->execute();
if($res->rowCount()) continue;
$sql="insert into ".$prefix."_ele_operatori (id_cons,id_sede,id_comune,permessi,aid,id_sez) values ('$id_cons','$id_sede','$id_comune','$permessi','$aid2','$id_sez')";
$res = $dbi->prepare("$sql");
$res->execute();
}
Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
} elseif ($do == "update") {
$sql="update ".$prefix."_ele_operatori set id_sede='$id_sede', permessi='$permessi', id_sez='$id_sez' where id_cons='$id_cons' and aid='$aid2' ";
$res = $dbi->prepare("$sql");
$res->execute();
$result=$res->rowCount();
if (!$result) return;
Header("Location: admin.php?op=permessi&id_cons_gen=$id_cons_gen");
}
}
}
//****************************
// switch
//****************************
if ($do) permessi($ok, $do,$aid2,$id_sede,$permessi,$id_comune,$id_sez);
ele();
all();
include("footer.php");
?>