function tornaHabitacions() {
prmHabitacions = "";
i = 0;
$(".numHabitacions").each(function() {
if (this.checked) {
if (prmHabitacions == "")
prmHabitacions = "(";
else
prmHabitacions += " or ";
prmHabitacions += "U.habitaciones " + habitacions[i];
};
i++;
});
if (prmHabitacions != "")
prmHabitacions += ")";
}
function tornaPreu() {
prmPreu = "";
minim = $("#selectPreuMinPC").find("option:selected").val();
maxim = $("#selectPreuMaxPC").find("option:selected").val();
if ((minim != "") && (maxim != ""))
prmPreu = "(U.precio >= " + minim*1000 + " AND U.precio <= " + maxim*1000 + ")";
else if (minim != "")
prmPreu = "U.precio >= " + minim*1000;
else if (maxim != "")
prmPreu = "U.precio <= " +maxim*1000;
}
function tornaMetres() {
prmMetres = "";
minim = $("#selectMinMetresPC").find("option:selected").val();
maxim = $("#selectMaxMetresPC").find("option:selected").val();
if ((minim != "") && (maxim != ""))
prmMetres = "(U.metros >= " + minim + " AND U.metros <= " + maxim + ")";
else if (minim != "")
prmMetres = "U.metros >= " + minim;
else if (maxim != "")
prmMetres = "U.metros <= " +maxim;
}
function tornaTipusLO() {
prmTipus = "";
i = 0;
$(".subIndexLO").each(function() {
if (this.checked) {
if (prmTipus == "")
prmTipus = "(";
else
prmTipus += " or ";
prmTipus += "U.tipo = " + localsOficines[i];
};
i++;
});
if (prmTipus != "")
prmTipus += ")";
else
prmTipus = "U.familia = 7";
}
function tornaTipusSP() {
prmTipus = "";
i = 0;
$(".subIndexSP").each(function() {
if (this.checked) {
if (prmTipus == "")
prmTipus = "(";
else
prmTipus += " or ";
prmTipus += "U.tipo = " + solarsParceles[i];
};
i++;
});
if (prmTipus != "")
prmTipus += ")";
else
prmTipus = "U.familia = 5";
}
function tornaBarris() {
prmBarris = "";
i = 0;
arrayBarris = new Array();
$(".barris").each(function() {
if (this.checked)
arrayBarris.push($(this).val());
});
arrayBarris.unique().forEach(function(cp, i) {
if (prmBarris == "")
prmBarris = "'(";
else
prmBarris += ",";
prmBarris += cp;
});
if (prmBarris != "")
prmBarris += ")'";
}
function refresca(op, ob) {
if (prmBarris == "")
barris = "''";
else
barris = prmBarris;
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"3"+"-"+op+"-"+ob+"-"+""+"-"+barris}, function(data){$("#totalPisosCases").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"4"+"-"+op+"-"+ob+"-"+"7"+"-"+barris}, function(data){$("#totalLocalsOficines").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"4"+"-"+op+"-"+ob+"-"+"6"+"-"+barris}, function(data){$("#totalNausIndustrials").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"4"+"-"+op+"-"+ob+"-"+"5"+"-"+barris}, function(data){$("#totalSolarsParceles").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"4"+"-"+op+"-"+ob+"-"+"8"+"-"+barris}, function(data){$("#totalParquings").html("("+data+")");});
if ($("#selPisosCases").prop('checked')) {
refrescaDetall(0);
}
else if ($("#selLocalsOficines").prop('checked')) {
refrescaDetall(1);
}
else if ($("#selSolarsParceles").prop('checked')) {
refrescaDetall(2);
}
}
function refrescaDetall(opcio) {
switch (opcio) {
case 0:
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"908119896.50019"+"-"+barris}, function(data){$("#totalAtics").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"897431778.50019"+"-"+barris}, function(data){$("#totalDuplexs").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"935651163.50019"+"-"+barris}, function(data){$("#totalLofts").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"3"+"-"+barris}, function(data){$("#totalPisos").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"949016947.50019"+"-"+barris}, function(data){$("#totalPbs").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"900892021.50019"+"-"+barris}, function(data){$("#totalTriplexs").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"4"+"-"+barris}, function(data){$("#totalCases").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"299136542.50019"+"-"+barris}, function(data){$("#totalCasesC").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"935170816.50019"+"-"+barris}, function(data){$("#totalCasesI").html("("+data+")");});
break;
case 1:
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"7"+"-"+barris}, function(data){$("#totalLocalC").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"218592849.50019"+"-"+barris}, function(data){$("#totalLocalI").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"877918607.50019"+"-"+barris}, function(data){$("#totalOficina").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"329189847.50019"+"-"+barris}, function(data){$("#totalRestaurant").html("("+data+")");});
break;
case 2:
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"5"+"-"+barris}, function(data){$("#totalSolar").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"880782203.50019"+"-"+barris}, function(data){$("#totalSolarI").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"884930416.50019"+"-"+barris}, function(data){$("#totalSolarO").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"932673848.50019"+"-"+barris}, function(data){$("#totalSolarP").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"463133863.50019"+"-"+barris}, function(data){$("#totalSolarPR").html("("+data+")");});
$.post("<?php echo URL.'includes/inc_getInfo.php'?>", {prm:"5"+"-"+op+"-"+ob+"-"+"954401543.50019"+"-"+barris}, function(data){$("#totalSolarR").html("("+data+")");});
break;
}
}
function netejaDetall() {
prmTipus = ""; prmCiutat = ""; prmPreu = ""; prmHabitacions = ""; prmMetres = "";
$('.subIndexPC').each(function() {
$(this).prop("checked", false);
});
$('.subIndexLO').each(function() {
$(this).prop("checked", false);
});
$('.subIndexSP').each(function() {
$(this).prop("checked", false);
});
$('.selectCiutat').val('');
$('.selectMin').val('');
$('.selectMax').val('');
}
function netejaSelectOrdre(ordre) {
if (ordre != "#selectOrdrePreu") {
$("#selectOrdrePreu").val(0);
$("#selectOrdrePreu").css('width', '30px');
}
if (ordre != "#selectOrdreM2") {
$("#selectOrdreM2").val(0);
$("#selectOrdreM2").css('width', '30px');
}
if (ordre != "#selectOrdreHabitacions") {
$("#selectOrdreHabitacions").val(0);
$("#selectOrdreHabitacions").css('width', '30px');
}
if (ordre != "#selectOrdreCiutat") {
$("#selectOrdreCiutat").val(0);
$("#selectOrdreCiutat").css('width', '30px');
}
}
});
</script>