@extends('layout.base')

@section('content')
<div class="panel panel-default">
	<div class="panel-heading">Buscar</div>
	<div class="panel-body">
	<form action="{{url('', ['p' => 'buscar'])}}" method="get" class="form form-horizontal">
	<input type="hidden" name="p" value="buscar" />
	<div class="form-group">
		<div class="col-md-6"><input type="text" name="q" class="form-control"
			@if (get('q'))
				value="{!!urldecode(get('q'))!!}"
			@elseif (get('query'))
				value="{!!urldecode(get('query'))!!}"
			@endif
		/></div>
		<div class="col-md-2"><input type="submit" value="Buscar" class="form-control" /></div>
		<div class="col-md-4">
			<div class="col-md-12 text-center">
				<input type="radio" name="tipo" value="{{urlencode($tipos[0])}}"
					@if (get('tipo') == null or get('tipo') == $tipos[0])
						checked="checked"
					@endif
				/>
				{{ucwords($tipos[0])}}
			</div>
			@foreach ($tipos as $i => $tipo)
				@if ($tipo == 'cualquiera')
					@continue
				@endif
				<div class="col-md-6">
					<input type="radio" name="tipo" value="{{urlencode($tipo)}}"
						@if (get('tipo') != null)
							@if ($tipo == get('tipo'))
								checked="checked"
							@endif
						@else
							@if ($tipo == 'cualquiera')
								checked="checked"
							@endif
						@endif
						/>
					{{ucwords($tipo)}}
				</div>
			@endforeach
		</div>
	</div>
	</form>
	</div>
</div>
@if ($results != null)
<div class="panel panel-default">
	<div class="panel-heading">Resultados</div>
	<div class="panel-body">
		<table class="table table-striped">
		<thead>
		<tr>
			<th>Proyecto</th>
			<th>Departamento</th>
			<th>Propietario</th>
			<th>Tipo</th>
			<th>m&#0178;</th>
			<th>Valor [UF]</th>
			<th>Fecha Venta</th>
			<th>Fecha Entrega</th>
		</tr>
		</thead>
		<tbody>
		@if (isset($results) and is_array($results) and count($results) > 0)
		@foreach ($results as $resultado)
			@include('buscar.resultado', ['resultado' => $resultado])
		@endforeach
		@endif
		</tbody>
		</table>
	</div>
</div>
@endif
@endsection
