Ignore:
Timestamp:
Feb 22, 2022, 10:40:08 PM (2 years ago)
Author:
roby
Message:

Admin: aggiunta la funzione di gestione dello spoglio per la singola sezione tramite tema per cellulari

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/modules/Elezioni/ele_operatori.php

    r344 r358  
    2626if (isset($_GET['passwd'])) $passwd=addslashes($param['passwd']); else $passwd='';
    2727if (isset($_GET['passwd2'])) $passwd2=addslashes($param['passwd2']); else $passwd2='';
     28if (isset($_GET['stato']) && $aid2!='admin') $stato=intval($param['stato']); else $stato=0;
    2829
    2930include("modules/Elezioni/funzionidata.php");
     
    3738        global $aid, $offset, $prefix, $dbi,$id_cons,$aid2,$id_sede,$id_cons_gen,$mex,$perms;
    3839        //echo $perms;die();
     40
    3941        $bgcolor1=$_SESSION['bgcolor1'];
    4042        $id_comune=$_SESSION['id_comune'];
     
    4446        $rescom->execute();     
    4547        list($descr_com) = $rescom->fetch(PDO::FETCH_NUM);
    46         $sql="SELECT aid,name,email FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";
     48        $sql="SELECT aid,name,email,adminop FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";
    4749        $resmod = $dbi->prepare("$sql");
    4850        $resmod->execute();     
    49         list ($aid2,$name,$email) = $resmod->fetch(PDO::FETCH_NUM);
     51        list ($aid2,$name,$email,$attivo) = $resmod->fetch(PDO::FETCH_NUM);
    5052        if (isset($_GET['mex'])){
    5153                echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">";
     
    6567        echo "</tr><tr align=\"center\">";
    6668        echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&amp;id_cons_gen=$id_cons_gen&amp;aid2=\">";
    67         echo "<select name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
    68         echo "<option value=\"\">";
     69        echo "<select id=\"aid2\" name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";
     70        echo "<option value=\"\">Nuovo Utente";
    6971        while(list($utente)=$resins->fetch(PDO::FETCH_NUM)){
    7072                $sel= ($utente == $aid2) ? "selected":"";
     
    8688        echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>"
    8789        ."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>";
     90        echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
     91       
     92
    8893        echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>";
    8994        echo "<tr align=\"center\"><td>";
     
    98103        echo "<td  align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>";
    99104        echo "<td><input name=\"name\" value=\"$name\"></td>";
    100         echo "<td><input name=\"email\" value=\"$email\">";
     105        echo "<td><input name=\"email\" value=\"$email\"></td>";
     106        if($attivo==0) {$sel2="selected"; $sel3='';} else {$sel2=''; $sel3="selected";}
     107        echo "<td><select name=\"stato\"><option value=\"0\" $sel2>Attivo<option value=\"1\" $sel3>Disattivo<option value=\"2\" >Elimina</select>";
    101108        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
    102109        echo "<input type=\"hidden\" name=\"ok\" value=0></td>";
     
    113120}
    114121
    115 function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune) {
     122function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato) {
    116123        global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang;
    117124        $perms=ChiSei($id_cons_gen);
     125        if($passwd!=$passwd2) {
     126                $mex="- Le password non coincidono! -<br>";
     127                header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex&stato=$stato");
     128        }
    118129       
    119130        if ($perms!=256) $id_comune=$_SESSION['id_comune'];
     
    124135                        $res->execute();       
    125136                        $max=$res->rowCount();
    126                         if ($passwd==$passwd2 and $max==0){
    127                                 if ($aid2=='admin') $super='1,0,0,'; else $super = '0,1,0,';
    128                                 $sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."',0,$super'$currentlang')";
     137                        if ($max==0){
     138                                if ($aid2=='admin') $super='0,1,0,'; else $super = '0,0,0,';
     139                                $sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."','0',$super'$currentlang')";
    129140                                $res = $dbi->prepare("$sql");
    130141                                $res->execute();       
     
    133144                                        $res = $dbi->prepare("$sql");
    134145                                        $res->execute();       
    135                                 }
    136                         Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen");
     146                        }
     147                        Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2");
    137148                        }else{
    138149                                $mex='';
    139                                 if($passwd!=$passwd2) $mex="- Le password non coincidono! -<br>";
    140150                                if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - ";
    141                                 header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex");
    142151                        }
    143152                } elseif ($do == "update") {
    144                         $sql="update  ".$prefix."_authors set name='$name',pwd='".md5($passwd)."', email='$email' where id_comune='$id_comune' and aid='$aid2' ";
    145                         $res = $dbi->prepare("$sql");
    146                         $res->execute();
     153                        if($passwd!='') $mexpwd="pwd='".md5($passwd)."',"; else $mexpwd='';
     154                        if($stato==2){
     155                                $sql="delete from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune";
     156                                $res = $dbi->prepare("$sql");
     157                                $res->execute();                                       
     158                        }else{
     159                                $sql="update  ".$prefix."_authors set name='$name', $mexpwd email='$email', adminop='$stato' where id_comune='$id_comune' and aid='$aid2' ";
     160                                $res = $dbi->prepare("$sql");
     161                                $res->execute();
     162                        }
    147163                        $result=$res->rowCount();
     164                        if($stato!=0){
     165                                $sql="delete from ".$prefix."_ele_operatori where id_comune='$id_comune' and aid='$aid2' ";
     166                                $res = $dbi->prepare("$sql");
     167                                $res->execute();
     168                        }
    148169                        if (!$result) return;
    149170                        if ($aid2==$aid) $_SESSION['pwd']=md5($passwd);
     
    157178// switch
    158179//****************************
    159         if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune);
     180        if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato);
    160181        ele();
    161182        all();
Note: See TracChangeset for help on using the changeset viewer.