Ignore:
Timestamp:
Mar 2, 2014, 4:49:30 PM (10 years ago)
Author:
roby
Message:
  • modificato il db per gestire la modifica di fascia del comune per le elezioni comunali e per la rilevazione delle affluenze con distinzione per maschi e femmine.
File:
1 edited

Legend:

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

    r187 r189  
    3939if (isset($_GET['chiusa'])) $chiusa=intval($_GET['chiusa']); else $chiusa='';
    4040if (isset($_GET['id_conf'])) $id_conf=intval($_GET['id_conf']);  else $id_conf=0;
     41if (isset($_GET['idfascia'])) $idfascia=intval($_GET['idfascia']);  else $idfascia=0;
    4142if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0;
    4243if (isset($_GET['help'])) $help=intval($_GET['help']);
    4344if (isset($_GET['pwd4'])) $pwd4=intval($_GET['pwd4']);
    4445if (isset($_GET['preferenze'])) $preferenze=intval($_GET['preferenze']); else $preferenze=1;
     46if (isset($_GET['vismf'])) $vismf=intval($_GET['vismf']); else $vismf=0;
    4547
    4648$offset=15;
     
    5355        //
    5456        function all() {
    55         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;
     57        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;
    5658$aid=$_SESSION['aid'];
    5759$dbi=$_SESSION['dbi'];
     
    9496        echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
    9597        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
    96         echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td><td bgcolor=\"$bgcolor1\">";
    97         if($tipo_cons==3)
    98                 echo "<b>"._CONF."</b>";
     98        echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
     99        if($tipo_cons==3){
     100                echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
     101                echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
     102                }
     103        echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
     104#       echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
     105        echo "</tr>";
     106        echo "<tr align=\"center\"><td>";
    99107        echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
    100 #       echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
    101         echo "</td></tr>";
    102         echo "<tr align=\"center\"><td>";
    103108        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
    104109#       $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
     
    144149        echo "</select></td>";
    145150        if($tipo_cons==3){
     151                if($idcomune) {
     152                        $rescomu = mysql_query("SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'", $dbi);
     153                        if($rescomu)
     154                                list($fasciacom)=mysql_fetch_row($rescomu);
     155                } else $fasciacom=0;
    146156                $rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by descrizione asc", $dbi);
    147                 echo "<td><select name=\"id_conf\">";
     157                echo "<td><select name=\"id_conf\" id=\"id_conf\" onchange=\"javascript:showdate('modules/Elezioni/ele_desc_fasce.php?fascia=$fasciacom&id_conf=' + model.id_conf.options[model.id_conf.selectedIndex].value,'fasceconf');\">";
    148158                echo "<option value=\"0\"> ";
    149159                while(list($id,$descr_conf)=mysql_fetch_row($rescomu)){
     
    153163                }
    154164                echo "</select></td>";
     165                if(!$id_conf) $id_conf=1;
     166                $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
     167               
     168                echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
     169                echo "<option value=\"0\"> ";
     170                $inffascia=0;
     171                while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
     172                        $sel='';
     173                        if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
     174                        echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
     175                        $inffascia=$abitanti;
     176                }
     177                echo "</select></td>";
     178               
     179               
    155180        }
    156181        unset($sel);
     182        $rescomu = mysql_query("SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
     183        list($vismf)=mysql_fetch_row($rescomu);
     184        echo "<td><select name=\"vismf\">";
     185        if ($vismf==0) $sel="selected"; else $sel="";
     186        echo "<option value=\"0\" $sel>No";
     187        if ($vismf==1) $sel="selected"; else $sel="";
     188        echo "<option value=\"1\" $sel>Si";
     189        echo "</select></td>";
     190
    157191        echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
    158192        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
     
    172206############
    173207        echo "<hr><br><table width=\"100%\" border=\"3\">";
    174         echo "<tr align=\"center\"><td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
     208        echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
    175209#       echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
    176         echo "<td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
     210        echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
    177211        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
    178212        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
    179         if($tipo_cons==3)
    180                 echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
     213        if($tipo_cons==3){
     214                echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
     215                echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
     216                }
     217        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
    181218        echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</td></tr>";
    182219###############
     
    185222#       $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);
    186223#       else
    187         $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze 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", $dbi);
    188         while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
     224        $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf 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", $dbi);
     225        while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
    189226                $resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
    190227                list($descr_conf) = mysql_fetch_row($resconf);
    191228                $i++;
    192229                $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
    193                 echo "<tr><td colspan=\"6\">";
     230                if($tipo_cons==3) echo "<tr><td colspan=\"8\">"; else echo "<tr><td colspan=\"6\">";
    194231                echo "<form name=\"modello$i\" action=\"admin.php\">"
    195232                        ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
     
    203240                echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
    204241                echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
    205                 echo "<td width=\"27%\"><b>$descr_cons</b></td>";
    206                 echo "<td width=\"27%\"><b>$descr_comu</b></td>";
    207                 echo "<td width=\"12%\"><b>$preferenze2</b></td>";
     242                echo "<td width=\"15%\"><b>$descr_cons</b></td>";
     243                echo "<td width=\"20%\"><b>$descr_comu</b></td>";
     244                echo "<td width=\"10%\"><b>$preferenze2</b></td>";
    208245                $stato['0']=_ATTIVA;
    209246                $stato['1']=_CHIUSA;
    210247                $stato['2']=_NULLA;
    211                 echo "<td  width=\"11%\"><b>".$stato[$chiusa]."</b></td>";
    212                 if($tipo_cons==3)
    213                         echo "<td  width=\"25%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
     248                echo "<td  width=\"10%\"><b>".$stato[$chiusa]."</b></td>";
     249                if($tipo_cons==3){
     250                        echo "<td width=\"20%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
     251                        $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
     252                        $inffascia=0;
     253                        while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
     254                                $sel='';
     255                                if ($id == $fasciacom)
     256                                        echo "<td width=\"20%\">$inffascia - $abitanti</td>";
     257                                $inffascia=$abitanti;
     258                        }
     259
     260                }
     261                if ($vismf==0) $sel=_NO; else $sel=_SI;
     262                echo "<td width=\"10%\">$sel</td>";
    214263                echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
    215264                        ."</td></tr></table></form></td></tr>\n";
     
    222271
    223272function associazioni($ok, $do,$descr_comu,$id_cons_comu,$id_collegio,$id_comune,$chiusa,$id_conf,$preferenze) {
    224         global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4;
     273        global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf;
    225274        $delcons=0;
    226275        if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
     
    229278                        list($delcons)=mysql_fetch_row($rescomu);
    230279                        if (!$max){                     //se no la inserisce
    231                         $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
     280                        $result = mysql_query("insert into ".$prefix."_ele_cons_comune (chiusa,id_comune,id_cons_gen,id_conf,preferenze,id_fascia,vismf) values ('0','$idcomunenew','$id_cons_gen','$id_conf','$preferenze','$idfascia','$vismf')", $dbi) || die("<br><br>Errore di inserimento: ".mysql_error());
    232281                        $rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
    233282                list($id_cons_comu)=mysql_fetch_row($rescomu);
     
    243292                        $result = mysql_query("update ".$prefix."_ele_comu_collegi set id_collegio= '$id_collegio' $newid where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi) || die(mysql_error());
    244293                        if (!$result) return;
    245                         $result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
     294                        $result = mysql_query("update ".$prefix."_ele_cons_comune set id_conf='$id_conf', chiusa= '$chiusa', preferenze='$preferenze',id_fascia='$idfascia',vismf='$vismf' where id_comune='$id_comune' and id_cons_gen='$id_cons_gen'", $dbi)|| die(mysql_error());
    246295                        Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
    247296                }elseif ($do == "add") {
Note: See TracChangeset for help on using the changeset viewer.