Index: trunk/admin/modules/Elezioni/ele_associazioni.php
===================================================================
--- trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 187)
+++ trunk/admin/modules/Elezioni/ele_associazioni.php	(revision 189)
@@ -39,8 +39,10 @@
 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;
 
 $offset=15;
@@ -53,5 +55,5 @@
 	//
 	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;
+	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;
 $aid=$_SESSION['aid'];
 $dbi=$_SESSION['dbi'];
@@ -94,11 +96,14 @@
 	echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
-	echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td><td bgcolor=\"$bgcolor1\">";
-	if($tipo_cons==3)
-		echo "<b>"._CONF."</b>";
+	echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
+	if($tipo_cons==3){
+		echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
+		echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
+		}
+	echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
+#	echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
+	echo "</tr>";
+	echo "<tr align=\"center\"><td>";
 	echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
-#	echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
-	echo "</td></tr>";
-	echo "<tr align=\"center\"><td>";
 	echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
 #	$ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
@@ -144,6 +149,11 @@
 	echo "</select></td>";
 	if($tipo_cons==3){
+		if($idcomune) {
+			$rescomu = mysql_query("SELECT id_fascia from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomune'", $dbi);
+			if($rescomu)
+				list($fasciacom)=mysql_fetch_row($rescomu);
+		} else $fasciacom=0;
 		$rescomu = mysql_query("SELECT id_conf, descrizione from ".$prefix."_ele_conf order by descrizione asc", $dbi);
-		echo "<td><select name=\"id_conf\">";
+		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');\">";
 		echo "<option value=\"0\"> ";
 		while(list($id,$descr_conf)=mysql_fetch_row($rescomu)){
@@ -153,6 +163,30 @@
 		}
 		echo "</select></td>";
+		if(!$id_conf) $id_conf=1;
+		$rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
+		
+		echo "<td id=\"fasceconf\"><select name=\"idfascia\">";
+		echo "<option value=\"0\"> ";
+		$inffascia=0;
+		while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
+			$sel='';
+			if ($idcomune and $id == $fasciacom) $sel="selected"; elseif ($id==1) $sel="selected";
+			echo "<option value=\"$id\" $sel>$inffascia - $abitanti";
+			$inffascia=$abitanti;
+		}
+		echo "</select></td>";
+		
+		
 	}
 	unset($sel);
+	$rescomu = mysql_query("SELECT vismf from ".$prefix."_ele_cons_comune where id_cons='$id_cons'", $dbi);
+	list($vismf)=mysql_fetch_row($rescomu);
+	echo "<td><select name=\"vismf\">";
+	if ($vismf==0) $sel="selected"; else $sel="";
+	echo "<option value=\"0\" $sel>No";
+	if ($vismf==1) $sel="selected"; else $sel="";
+	echo "<option value=\"1\" $sel>Si";
+	echo "</select></td>";
+
 	echo "<td><input type=\"hidden\" name=\"ok\" value=0>";
 	echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">";
@@ -172,11 +206,14 @@
 ############
 	echo "<hr><br><table width=\"100%\" border=\"3\">";
-	echo "<tr align=\"center\"><td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
+	echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
 #	echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
-	echo "<td width=\"25%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
+	echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
 	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>";
-	if($tipo_cons==3)
-		echo "<td bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
+	if($tipo_cons==3){
+		echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._CONF."</b></td>";
+		echo "<td width=\"20%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FASCIA."</b></td>";
+		}
+	echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._VISAFFMF."</b></td>";
 	echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</td></tr>";
 ###############
@@ -185,11 +222,11 @@
 #	$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);
 #	else
-	$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);
-	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
+	$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);
+	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
 		$resconf = mysql_query("SELECT descrizione FROM ".$prefix."_ele_conf where id_conf='$id_conf'", $dbi);
 		list($descr_conf) = mysql_fetch_row($resconf);
 		$i++;
 		$bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
-		echo "<tr><td colspan=\"6\">";
+		if($tipo_cons==3) echo "<tr><td colspan=\"8\">"; else echo "<tr><td colspan=\"6\">";
 		echo "<form name=\"modello$i\" action=\"admin.php\">"
 			."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
@@ -203,13 +240,25 @@
 		echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
 		echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
-		echo "<td width=\"27%\"><b>$descr_cons</b></td>";
-		echo "<td width=\"27%\"><b>$descr_comu</b></td>";
-		echo "<td width=\"12%\"><b>$preferenze2</b></td>";
+		echo "<td width=\"15%\"><b>$descr_cons</b></td>";
+		echo "<td width=\"20%\"><b>$descr_comu</b></td>";
+		echo "<td width=\"10%\"><b>$preferenze2</b></td>";
 		$stato['0']=_ATTIVA;
 		$stato['1']=_CHIUSA;
 		$stato['2']=_NULLA;
-		echo "<td  width=\"11%\"><b>".$stato[$chiusa]."</b></td>";
-		if($tipo_cons==3)
-			echo "<td  width=\"25%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
+		echo "<td  width=\"10%\"><b>".$stato[$chiusa]."</b></td>";
+		if($tipo_cons==3){
+			echo "<td width=\"20%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
+			$rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
+			$inffascia=0;
+			while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
+				$sel='';
+				if ($id == $fasciacom) 
+					echo "<td width=\"20%\">$inffascia - $abitanti</td>";
+				$inffascia=$abitanti;
+			}
+
+		}
+		if ($vismf==0) $sel=_NO; else $sel=_SI;
+		echo "<td width=\"10%\">$sel</td>";
 		echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
 			."</td></tr></table></form></td></tr>\n";
@@ -222,5 +271,5 @@
 
 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;
+	global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $descr_cons,$genere,$id_cons_gen,$idcomunenew,$pwd4,$idfascia,$vismf;
 	$delcons=0;
 	if ($do !="" and $id_cons_gen>0 and $idcomunenew>0) {
@@ -229,5 +278,5 @@
 			list($delcons)=mysql_fetch_row($rescomu);
 			if (!$max){			//se no la inserisce
-			$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());
+			$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());
 			$rescomu = mysql_query("SELECT id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune='$idcomunenew'", $dbi);
 		list($id_cons_comu)=mysql_fetch_row($rescomu);
@@ -243,5 +292,5 @@
 			$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());
 			if (!$result) return;
-			$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());
+			$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());
 			Header("Location: admin.php?op=associazioni&id_cons_gen=$id_cons_gen");
 		}elseif ($do == "add") {
