Autocomplete && User page && Bugs

Districts auto complete SOLVED!
User page hide divs SOLVED!
master
NoNameGuy 2017-06-12 15:31:55 +01:00
parent 24bbe925bc
commit 65567ecb25
3 changed files with 49 additions and 53 deletions

View File

@ -41,7 +41,12 @@ class LandingController extends BaseController
{
$districts = array();
$districtsName = array();
$brands = array();
$brandsName = array();
$coordinates = new \stdClass();
if(isset($request)){
$coordinates->latitude = $request->latitude;
$coordinates->longitude = $request->longitude;
@ -51,48 +56,21 @@ class LandingController extends BaseController
$coordinates->longitude = -8.1425;
}
$districts = DB::table('district')->orderBy('name')->get();
$districts = DB::table('district')->select('name')->distinct()->get();
for ($i=0; $i < $districts->count(); $i++) {
array_push($districtsName, $districts[$i]->name);
}
$brands = array();
$brandsName = array();
$brands = DB::table('station')->select('brand')->distinct()->get();
for ($i=0; $i < $brands->count(); $i++) {
array_push($brandsName, $brands[$i]->brand);
}
/*$coordinatesArray = array();
$ids = array();
$coordinate = new \stdClass();
$ids = DB::table('station')->select('location')->get();
for ($i=0;$i<count($ids);$i++) {
$coordinate->latitude = DB::table('location')->where('id', $ids[$i]->location)->select('latitude')->get();
$coordinate->longitude = DB::table('location')->where('id', $ids[$i]->location)->select('longitude')->get();
array_push($coordinatesArray,$coordinate);
}
if (array_key_exists('location', $_POST)) {
$this->fetchAllStations();
$coordinates = array();
$coordinates = $this->getCoordinatesByPlace(addslashes($_POST['location']));
if ( array_key_exists('radius', $_POST)) {
$this->searchStations($coordinates["latitude"], $coordinates["longitude"], $_POST['radius']);
} else {
$this->searchStations($coordinates["latitude"], $coordinates["longitude"]);
}
}*/
$stations = array();
$stations = $this->getStations($request->district, $request->brand, $request->fuelType);
//$this->apiStations($stations);
return View('landing_page', ['districts' => $districts, 'districtsName' => $districtsName, 'brandsName' => $brandsName, 'centerMapCoordinates' => $coordinates, 'stations' => $stations]);
}

View File

@ -16,6 +16,7 @@
<hr>
<h2 class="center">Pesquisar Postos:</h2>
<br><br><br>
<div class="row">
<!--Div esquerda-->
<div class="col-sm-6">
@ -29,45 +30,62 @@
<form method="post" action="{{route('home')}}">
{{csrf_field()}}
<div class="form-group">
<label for="inputdistrict">Distrito(s): </label>
<input class="form-control" id="inputdistrict" name="district" type="text">
<label for="districts">Distrito(s): </label>
<input class="form-control" id="districts" name="districts" type="text">
<script>
$( function() {
var districtsName = <?php echo json_encode($districtsName); ?>
$( "#districts" ).autocomplete({
source: districtsName
});
} );
</script>
</div>
<br>
<div class="checkbox" id="landingFuelType">
<div class="form-group">
<label style="font-weight:bold">Tipo de Combustível (Escolha 1): </label>
</div>
<label><input type="radio" name="fuelType" value="diesel">Gasóleo</label><br>
<label><input type="radio" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
<label><input type="radio" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
<label><input type="radio" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
<br><br>
<label><input type="radio" name="fuelType" value="petrol_95">Gasolina 95</label><br>
<label><input type="radio" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
<label><input type="radio" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
<br><br>
<label><input type="radio" name="fuelType" value="petrol_98">Gasolina 98</label><br>
<label><input type="radio" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
<label><input type="radio" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
<br><br>
<label><input type="radio" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
<label><input type="radio" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
<label><input type="radio" name="fuelType" value="gas_natural_liquified">GNL</label><br>
<label><input type="radio" name="fuelType" value="gpl">GPL</label><br>
<br>
<br>
<div class="col-sm-4">
<label><input type="radio" name="fuelType" value="diesel">Gasóleo</label><br>
<label><input type="radio" name="fuelType" value="diesel_simple">Gasóleo Simples</label><br>
<label><input type="radio" name="fuelType" value="diesel_colored">Gasóleo Colorido</label><br>
<label><input type="radio" name="fuelType" value="diesel_special">Gasóleo Especial</label><br>
<br><br>
<label><input type="radio" name="fuelType" value="petrol_95">Gasolina 95</label><br>
<label><input type="radio" name="fuelType" value="petrol_simple_95">Gasolina Simples 95</label><br>
<label><input type="radio" name="fuelType" value="petrol_special_95">Gasolina Especial 95</label><br>
<br><br>
</div>
<div class="col-sm-8">
<label><input type="radio" name="fuelType" value="gas_natural_compressed_kg">GNC KG</label><br>
<label><input type="radio" name="fuelType" value="gas_natural_compressed_m3">GNC M3</label><br>
<label><input type="radio" name="fuelType" value="gas_natural_liquified">GNL</label><br>
<label><input type="radio" name="fuelType" value="gpl">GPL</label><br>
<br><br>
<label><input type="radio" name="fuelType" value="petrol_98">Gasolina 98</label><br>
<label><input type="radio" name="fuelType" value="petrol_simple_98">Gasolina Simples 98</label><br>
<label><input type="radio" name="fuelType" value="petrol_special_98">Gasolina Especial 98</label><br>
<br><br>
</div>
</div>
<div class="form-group">
<label for="brand">Marca (Opcional): </label>
<input class="form-control" id="brand" name="brand" type="text">
<button id="landingSearch" type="submit">Search...</button>
<button id="landingSearch" type="submit">Search</button>
</div>
</form>
<br>
<script>
$( function() {
var brandsName = <?php echo json_encode($brandsName); ?>
//var availableTags = districtsName;
$( "#brand" ).autocomplete({
source: brandsName
});

View File

@ -87,7 +87,7 @@
</div>
</div>
<div id="divVeiculos">
<div id="divVeiculos" style="display:none">
<div class="col-sm-6">
<div class="list-group" id="vehicleList">
@if($vehicles)