Ignore:
Timestamp:
Apr 15, 2010, 1:52:15 PM (14 years ago)
Author:
roby
Message:

admin - inserita la funzione di eliminazione delle consultazioni a livello di singolo comune.
client - risolti altri "notice"

File:
1 edited

Legend:

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

    r54 r77  
    4949        /*Funzione di visualizzazione globale                 */
    5050        /*****************************************************/
    51         //crea la pagina delle affluenze
     51        //
    5252        function all() {
    5353        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;
     
    5555$dbi=$_SESSION['dbi'];
    5656$prefix=$_SESSION['prefix'];
    57 
     57############# Controllo flag per cancellazione consultazione
     58        echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n"
     59        ."//-->\n";
     60        echo "function del_cons() {\n";
     61        echo "if (document.model.pwd3.checked==false) {\n";
     62        echo "document.model.chiusa.options[3].selected=false \n";
     63        echo "} \n";
     64        echo "if (document.model.chiusa.options[3].selected==false) {
     65         \n";
     66        echo "document.model.add.value=\""._MODIFY."\" \n";
     67        echo "document.model.do.value=\"update\" \n";
     68        echo "}else{\n";
     69        echo "document.model.add.value=\""._DELETE." "._CONSULTA."\" \n";
     70        echo "document.model.do.value=\"delete\" \n";
     71        echo "} \n";   
     72        echo "} \n";
     73        echo "</script>\n";
     74#########################
    5875        if (isset($help)) include("language/$language/ele_associazioni.html");
    5976        OpenTable();
    60         echo "<hr><br>";       
     77        echo "<tr><td><hr><br>";       
    6178        $res = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'" , $dbi);
    6279        list ($descr_cons) = mysql_fetch_row($res);
    6380//inserire avviso su mancanza dei permessi
    6481        echo "<form name=\"model\" action=\"admin.php\">";
    65         echo "<table>";
     82        echo "<table width=\"100%\" border=\"3\">";
    6683        echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
    6784#       echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
    6885        echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
    69         echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
     86        echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td><td bgcolor=\"$bgcolor1\">";
    7087        if($tipo_cons==3)
    71         echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
    72         echo "</tr>";
     88                echo "<b>"._CONF."</b>";
    7389        echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
    74         echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
    75         echo "<tr align=\"center\">";
    76         echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\"><td>$descr_cons</td>";
     90#       echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
     91        echo "</td></tr>";
     92        echo "<tr align=\"center\"><td>";
     93        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
    7794#       $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
    7895#       if ($num_coll=mysql_num_rows($ressede)){
     
    85102#       } else echo "<td></td>";
    86103        $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
    87         echo "<td><select name=\"idcomunenew\">";
     104        echo "<td>";
     105        if($idcomune) {
     106                while ($listele=mysql_fetch_array($rescomu))
     107                        if($listele['id_comune']==$idcomune) {
     108                                echo $listele['descrizione'];
     109                                echo "<input type=\"hidden\" name=\"idcomunenew\" value=\"$idcomune\">";
     110                        }
     111               
     112        }else{
     113        echo "<select name=\"idcomunenew\">";
    88114        echo "<option value=\"0\"> ";
    89115        while(list($id,$descr_comu)=mysql_fetch_row($rescomu)){
     
    91117                echo "<option value=\"$id\" $sel>$descr_comu";
    92118        }
    93         echo "</select></td>";
     119        echo "</select>";
     120        }
     121        echo "</td>";
    94122        $selez['0']='';
    95123        $selez['1']='';
    96124        $selez['2']='';
     125        $selez['3']='';
    97126        $selez[$chiusa]="selected";
    98         echo "<td><select name=\"chiusa\">";
     127        echo "<td><select name=\"chiusa\" onChange=\"del_cons()\">";
    99128                echo "<option value=\"0\" ".$selez[0].">"._ATTIVA;
    100129                echo "<option value=\"1\" ".$selez[1].">"._CHIUSA;
    101130                echo "<option value=\"2\" ".$selez[2].">"._NULLA;
     131
     132                if($idcomune) echo "<option value=\"3\" ".$selez[3].">"._ELIMINA;
    102133        echo "</select></td>";
    103134        if($tipo_cons==3){
     
    113144        }
    114145        unset($sel);
    115         echo "<input type=\"hidden\" name=\"ok\" value=0>";
     146        echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
    116147        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
    117148        if ($idcomune) {
    118149                echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
    119150                echo "<input type=\"hidden\" name=\"idcomune\" value=\"$idcomune\">";
    120                 echo "<td><input type=\"submit\" name=\"add\" value=\""._MODIFY."\"></td></tr></form>";
     151                echo "<input type=\"submit\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
     152                echo "<tr><td colspan=\"4\"><fieldset><legend>Abilita la cancellazione</legend><label id=\"prov\">Metti la spunta per poter eliminare la consultazione: <input type=\"checkbox\" name=\"pwd3\" value=\"\" onchange=\"del_cons()\"></label></fieldset>";
    121153        }else{
    122154                echo "<input type=\"hidden\" name=\"do\" value=\"add\">";
    123                 echo "<td><input type=\"submit\" name=\"add\" value=\""._ADD."\"></td></tr></form>";
     155                echo "<input type=\"submit\" name=\"add\" value=\""._ADD."\">";
    124156        }
    125157        $i=0;
     158        echo "</td></tr></table></form>";
     159############
     160        echo "<hr><br><table width=\"100%\" border=\"3\">";
     161        echo "<tr align=\"center\"><td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
     162#       echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
     163        echo "<td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
     164        echo "<td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
     165        if($tipo_cons==3)
     166                echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
     167        echo "<td></td></tr>";
     168###############
     169
    126170#       if ($num_coll>0)
    127171#       $resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
     
    133177                $i++;
    134178                $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
     179                echo "<tr><td colspan=\"5\">";
    135180                echo "<form name=\"modello$i\" action=\"admin.php\">"
    136181                        ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
    137182//              echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
    138                 echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
     183#               echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
    139184                echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
    140185                echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
     
    142187                echo "<input type=\"hidden\" name=\"desc\" value=\"$descr_cons\">";
    143188                echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
    144                 echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
    145                 echo "<td width=\"32\"><b>$descr_coll</b></td>";
    146                 echo "<td width=\"32\"><b>$descr_comu</b></td>";
     189                echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
     190                echo "<td width=\"25%\"><b>$descr_coll</b></td>";
     191                echo "<td width=\"25%\"><b>$descr_comu</b></td>";
    147192                $stato['0']=_ATTIVA;
    148193                $stato['1']=_CHIUSA;
    149194                $stato['2']=_NULLA;
    150                 echo "<td width=\"32\"><b>".$stato[$chiusa]."</b></td>";
     195                echo "<td  width=\"15%\"><b>".$stato[$chiusa]."</b></td>";
    151196                if($tipo_cons==3)
    152                         echo "<td width=\"32\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
    153                 echo "<input type=\"hidden\" name=\"ok\" value=0>";
    154                 echo "</td>";
    155                 echo "<td><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
    156                         ."</td></tr></form>";
    157         }
    158                 echo "</table>";
     197                        echo "<td  width=\"25%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
     198                echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
     199                        ."</td></tr></table></form></td></tr>\n";
     200        }
     201                echo "</table></td></tr>";
     202                echo "</table></td></tr>";
    159203        CloseTable();
     204        echo "</div>";
    160205        }
    161206
    162207function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf) {
    163208        global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew;
     209        $delcons=0;
    164210        if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
    165                 $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
     211                $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi); 
    166212                $max = mysql_num_rows($rescomu); //esiste autorizzazione?
    167                 if (!$max){                     //se no la inserisce
     213                        list($delcons)=mysql_fetch_row($rescomu);
     214                        if (!$max){                     //se no la inserisce
    168215                        $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf) values ('0','$idcomunenew','$id_cons_gen','$id_conf')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
    169216                        $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
     
    181228                                $result = mysql_query("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')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
    182229                        Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
     230                }elseif ($do == "delete" and $delcons>0) {
     231                        $idcns=$delcons;
     232                        $res_del = mysql_query("delete from ".$prefix."_ele_voti_ref where id_cons=$idcns" ,$dbi);
     233                        $res_del = mysql_query("delete from ".$prefix."_ele_voti_candidati where id_cons=$idcns" ,$dbi);
     234                        $res_del = mysql_query("delete from ".$prefix."_ele_voti_lista where id_cons=$idcns" ,$dbi);
     235                        $res_del = mysql_query("delete from ".$prefix."_ele_voti_gruppo where id_cons=$idcns" ,$dbi);
     236                        $res_del = mysql_query("delete from ".$prefix."_ele_voti_parziale where id_cons=$idcns" ,$dbi);
     237                        $res_del = mysql_query("delete from ".$prefix."_ele_candidati where id_cons=$idcns" ,$dbi);
     238                        $res_del = mysql_query("delete from ".$prefix."_ele_lista where id_cons=$idcns" ,$dbi);
     239                        $res_del = mysql_query("delete from ".$prefix."_ele_gruppo where id_cons=$idcns" ,$dbi);
     240                        $res_del = mysql_query("delete from ".$prefix."_ele_sezioni where id_cons=$idcns" ,$dbi);
     241                        $res_del = mysql_query("delete from ".$prefix."_ele_cons_comune where id_cons=$idcns" ,$dbi);
     242                       
     243                        Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
    183244                }
    184245        }
    185246}
    186247
     248
     249
     250
     251#       die ("do:$do - id_cons:$id_cons_comu - idcomune:$id_comune - new: $idcomunenew");
    187252       
    188253//****************************
Note: See TracChangeset for help on using the changeset viewer.