<?

	include("../adm/conexao_e_agenda.php");

	include("../adm/funcoes.php");

	//include("/mostradata.php");

//...............................

  $_parametro = "";

    if($_GET['tipo'] != '0'){  

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");

  $_parametro .= "tipo = '$_GET[tipo]'";

  }

  if($_GET['cidade'] != '0'){

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");  

  $_parametro .= "cidade = '$_GET[cidade]'";

  }

  if($_GET['bairro'] != '0'){

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");  

  $_parametro .= "bairro = '$_GET[bairro]'";

  }

  if($_GET['valor'] != '0'){  

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");

  $_parametro .= "filtro_valor = '$_GET[valor]'";

  }

  if($_GET['quartos'] != '0'){  

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");

  $_parametro .= "quarto = '$_GET[quartos]'";

  }

  if($_GET['lancamento'] != '0'){  

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");

  $_parametro .= "lancamento = '1'";

  } 

  if($_GET['objetivo'] != '0'){  

  $_parametro .= ($_parametro == "" ? " WHERE " : " AND ");

  $_parametro .= "objetivo = '$_GET[objetivo]'";

  }   





  $order = ($_GET["ordem"] == "" ? "ORDER BY filtro_valor ASC" : "ORDER BY filtro_valor ".$_GET["ordem"]);

  $totregpag = ($_GET["regpags"] == "" ? "50" : $_GET["regpags"]);



   

  $select_cad = "SELECT * FROM imoveis $_parametro $order";    

  //$select_cad = "SELECT * FROM imoveis order by id desc"; 

 

  $result_cad = mysqli_query($conexao,$select_cad) or die($select_cad." = ".mysqli_error($conexao));

//-----------------------------------------------------------------------



$mostrar = $totregpag;//"50"; // total por pagina

if (!($_GET['pagina'])) {

  $pc=1; 

}

else {

  $pc = $_GET['pagina']; 

}



$inicio = $pc - 1; 

$inicio = $inicio * $mostrar;

$result_cad = mysqli_query($conexao,"$select_cad LIMIT $inicio, $mostrar") or die(mysqli_error($conexao));

$result_cad_total = mysqli_query($conexao,"$select_cad") or die(mysqli_error($conexao));

$tr = mysqli_num_rows($result_cad_total); // verifica o número total de registros 

$tp = ceil($tr / $mostrar);  // verifica o número total de páginas 



//------------------------------------------

$variaveis_get = "";

if (!empty($_GET)){	

  foreach($_GET as $chave=>$valor){

    if ($chave != "pagina" && $chave != "ger")      // para não ficar duplicada a variável 'pagina'

      $variaveis_get = $variaveis_get."&$chave=$valor";

  }

}	



//------------------------------------------

$_SESSION['voltando'] = $_SERVER['REQUEST_URI'];	

	?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Adriano Souto Imóveis - Mobile</title>

 <!--<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1;">-->

 <meta name="viewport" content="width=320, initial-scale=-1">

		<!-- CSS

  	================================================== -->

	<link rel="stylesheet" href="css/base.css">

	<link rel="stylesheet" href="css/grid.css">

	<link rel="stylesheet" href="css/mobile.css">

    

	<!-- Ícones

	================================================== -->

		

    <!-- JS

  	================================================== -->

	<script src="js/jquery_002.js"></script>

	<script src="js/jquery-migrate.js"></script>

	<script src="js/jquery.js"></script>

    <script src="js/selectivizr.js"></script>  

    <script src="js/functions.js"></script>

       

	<!--[if lt IE 9]>

		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

	<![endif]-->

    

</head>

<body>

<? include("menu_iniciar_adm_boss.php"); ?>

	

	

	<div class="cols full" id="logo">

		<img src="logo_adriano_creci_nabase_la224_adm_boss.png" width="322">	</div>    

<div class="full" id="content">

		

		<div class="container" id="home">           

			

            <!-- nova pesquisa rapida -->      

             

			<h1>Selecionar os Imóveis</h1>

            

            <div class="full cols">

                <script type="text/javascript" src="js/pesquisa.js"></script>

                <script type="text/javascript">

                    var valorbus = '';

                    var valorcod = '33';

                    var valorneg = '';

                    var valortip = '';

                    var valormin = '';

                    var valormax = '';

                    var valorest = '';

                    var valorcid = '';

                    var valorbai = '';

                    var valormap = '';

                </script>

                                <form id="form2" name="form2" method="get" action="lista_imoveis_mobile_boss.php">

                

					<div class="c5 cols">

                    	<label for="b_negocio">Faixa de Valor</label>

                        						<select name="valor" id="select5" class="form2"  style="width:280px">

				                 <option value="0"<?  if ($_GET['valor'] == "0") echo "selected"; ?>>Escolher</option>

                                 <option value="100-300"<?  if ($_GET['valor'] == "100-300") echo "selected"; ?>>R$ 100,00 - R$ 300,00</option>

				                 <option value="301-500"<?  if ($_GET['valor'] == "301-500") echo "selected"; ?>>R$ 301,00 - R$ 500,00</option>

				                 <option value="501-800"<?  if ($_GET['valor'] == "501-800") echo "selected"; ?>>R$ 501,00 - R$ 800,00</option>

				                 <option value="801-1000"<?  if ($_GET['valor'] == "801-1000") echo "selected"; ?>>R$ 801,00 - R$ 1.000,00</option>

				                 <option value="1001-1500"<?  if ($_GET['valor'] == "1001-1500") echo "selected"; ?>>R$ 1.001,00 - R$ 1.500,00</option>

				                 <option value="1501-2000"<?  if ($_GET['valor'] == "1501-2000") echo "selected"; ?>>R$ 1.501,00 - R$ 2.000,00</option>

				                 <option value="2001-3000"<?  if ($_GET['valor'] == "2001-3000") echo "selected"; ?>>R$ 2.001,00 - R$ 3.000,00</option>

				                 <option value="3000-50000"<?  if ($_GET['valor'] == "3000-50000") echo "selected"; ?>>R$ 3.001,00 - R$ 50.000,00</option>

				                 <option value="0">Todas as Faixas</option>

				                 <option value="50001-100000"<?  if ($_GET['valor'] == "50001-100000") echo "selected"; ?>>R$ 50.001,00 - R$ 100.000,00</option>

				                 <option value="100001-200000"<?  if ($_GET['valor'] == "100001-200000") echo "selected"; ?>>R$ 100.001,00 - R$ 200.000,00</option>

				                 <option value="200001-300000"<?  if ($_GET['valor'] == "200001-300000") echo "selected"; ?>>R$ 200.001,00 - R$ 300.000,00</option>

				                 <option value="300001-400000"<?  if ($_GET['valor'] == "300001-400000") echo "selected"; ?>>R$ 300.001,00 - R$ 400.000,00</option>

				                 <option value="400001-500000"<?  if ($_GET['valor'] == "400001-500000") echo "selected"; ?>>R$ 400.001,00 - R$ 500.000,00</option>

				                 <option value="500001-600000"<?  if ($_GET['valor'] == "500001-600000") echo "selected"; ?>>R$ 500.001,00 - R$ 600.000,00</option>

				                 <option value="600001-700000"<?  if ($_GET['valor'] == "600001-700000") echo "selected"; ?>>R$ 600.001,00 - R$ 700.000,00</option>

				                 <option value="700001-800000"<?  if ($_GET['valor'] == "700001-800000") echo "selected"; ?>>R$ 700.001,00 - R$ 800.000,00</option>

				                 <option value="800001-900000"<?  if ($_GET['valor'] == "800001-900000") echo "selected"; ?>>R$ 800.001,00 - R$ 900.000,00</option>

				                 <option value="900001-1000000"<?  if ($_GET['valor'] == "900001-1000000") echo "selected"; ?>>R$ 900.001,00 - R$ 1.000.000,00</option>

				                 <option value="1000001-1000000000000"<?  if ($_GET['valor'] == "1000001-1000000000000") echo "selected"; ?>>Acima de R$ 1.000.000,00</option>

			                   </select>						

					</div>

                    

					<div class="c5 cols">

                        <label for="b_tipo">Tipo</label>

                        <? $sql_f="select * from tipos order by desc_tipo asc";

	              $result_f = mysqli_query($conexao,$sql_f);

	          ?>

              <select id="tipo" name="tipo">

              <option value="0" selected>Todos os Tipos</option>

    <? while ($linha_f = mysqli_fetch_array($result_f)){ ?>

    <option value="<? echo $linha_f['id'] ?>" <? if ($linha_f['id'] == $_GET['tipo']) echo "selected"; ?>><? echo minusc_inicia_maiusc($linha_f['desc_tipo']); ?></option>

    <? } ?>

              </select>

					</div>

   

                    <div class="c25 cols">

						<label for="b_valor_min">Imóvel</label>

						<select name="objetivo" id="select" class="form2">

                                <option value="0" selected="selected">Todos</option>				                 

                                <option value="2" <? if ($_GET['objetivo'] == "2") echo "selected"; ?>>À Venda</option>

				                <option value="1" <? if ($_GET['objetivo'] == "1") echo "selected"; ?>>Para Adesão</option>

                      </select>



					</div>  

                    

                     <div class="c25 cols">

						<label for="b_valor_min">Lançamento</label>

                        <select name="lancamento" id="select" class="form2">

                                <option value="0" selected="selected">Todos</option>				                 

                                <option value="2" <? if ($_GET['lancamento'] == "2") echo "selected"; ?>>Não</option>

				                <option value="1" <? if ($_GET['lancamento'] == "1") echo "selected"; ?>>Sim</option>

                      </select>

					</div> 

                  

                    

                    <div class="c25 cols">

						<label for="b_valor_min">Ordem</label>

						<select name="ordem" id="select" class="form2">				                 

                                <option value="DESC" <? if ($_GET['ordem'] == "DESC") echo "selected"; ?>>Maior Valor</option>

				                <option value="ASC" <? if ($_GET['ordem'] == "ASC") echo "selected"; ?>>Menor Valor</option>

                      </select>



					</div>                       

                    

              <div class="cols c5 fist">

						<label>&nbsp;</label>

                    	<input value="PESQUISAR" class="button cols c5 first last" id="pesquisa_botao" type="submit">

                    </div>

                    

                </form>



            </div>

		</div>

	</div>

    

		<div class="full" id="footer">    

    

    	<div class="container">



			<p class="address imobiliaria">

                <strong>Adriano Theodoro Imóveis</strong>                

            </p>

            

<span class="copyright">Adriano Theodoro Imóveis © 2016. <br>

            	Todos os direitos reservados.

            </span>

                        

        </div>

        

	</div>        



</body></html>

