v0.10.12a - Made filter for washing machines done
This commit is contained in:
parent
e35c8ae491
commit
522cf9cdf7
|
@ -7,6 +7,8 @@ use App\WashingMachine;
|
||||||
use App\WashingReservation;
|
use App\WashingReservation;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use function GuzzleHttp\Promise\all;
|
||||||
|
|
||||||
class LocationController extends Controller
|
class LocationController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -176,23 +178,20 @@ class LocationController extends Controller
|
||||||
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
|
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
|
||||||
"</tr>";
|
"</tr>";
|
||||||
|
|
||||||
if($request) {
|
if($request->option !== 'all') {
|
||||||
$locations = Location::query()->orderBy('created_at', 'desc')->where('name', '=', $request->option)->get();
|
$locations = DB::table('washing_machines')
|
||||||
//$machines = WashingMachine::query()->where('created_at', '=', $locations->created_at)->get();
|
->join('locations', 'washing_machines.location_id','=', 'locations.id')
|
||||||
}
|
->select(DB::raw('washing_machines.name as washing_name, locations.name as location_name, locations.id as id'))
|
||||||
elseif($request->option == "all"){
|
->where('locations.id', '=', $request->option)
|
||||||
$locations = Location::all();
|
->get();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(count($locations) !== 0){
|
if(count($locations) !== 0){
|
||||||
foreach ($locations as $key => $location){
|
foreach ($locations as $key => $location){
|
||||||
$output.='<tr>'.
|
$output.='<tr>'.
|
||||||
//'<td>' . $location->name . '</td>'.
|
'<td>' . $location->washing_name . '</td>'.
|
||||||
'<td><p>Test data</p></td>'.
|
'<td>' . $location->location_name . '</td>'.
|
||||||
'<td>' . $location->name . '</td>'.
|
'<td><form method="post" action="' .route("locations.destroy", [ "location" => $location->id ]). '" class="w-100 nostyle">'.
|
||||||
'<td><form method="post" action="' .route("locations.destroy", [ "location" => $location ]). '" class="w-100 nostyle">'.
|
'<td><form method="post" action="' .route("locations.edit", [ "location" => $location->id ]). '" class="w-100 nostyle">'.
|
||||||
'<td><form method="post" action="' .route("locations.edit", [ "location" => $location ]). '" class="w-100 nostyle">'.
|
|
||||||
csrf_field().
|
csrf_field().
|
||||||
method_field("delete").
|
method_field("delete").
|
||||||
|
|
||||||
|
@ -209,6 +208,37 @@ class LocationController extends Controller
|
||||||
'<td></td>'.
|
'<td></td>'.
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
elseif($request->option === "all"){
|
||||||
|
$machines = WashingMachine::all();
|
||||||
|
|
||||||
|
if(count($machines) !== 0){
|
||||||
|
foreach($machines as $machine) {
|
||||||
|
$output.= '<tr>'.
|
||||||
|
'<td>'.$machine->name.'</td>'.
|
||||||
|
'<td>'.Location::query()->where("id", "=", $machine->location_id)->first()->name.'</td>'.
|
||||||
|
'<td><a href="'. route("washing-machines.edit", [ "washing_machine" => $machine->id]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'.
|
||||||
|
'<td><form method="post" action="'. route('washing-machines.destroy', [ 'washing_machine' => $machine->id ]) .'" class="w-100 nostyle">'.
|
||||||
|
csrf_field().
|
||||||
|
method_field("delete").
|
||||||
|
'<button class="w-100 nostyle" onclick="return confirm('."'Are you sure you want to delete?'".');" type="submit"><img class="w-100 cursor-pointer" src="'. asset('/images/icons/trashcan-dark.svg'). '" alt="Delete"></button>'.
|
||||||
|
'</form>'.
|
||||||
|
'</td>'.
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$output.='<tr>'.
|
||||||
|
'<td>Det er ikke blivet oprettet nogen vaskmaskine på denne lokation i nu</td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Response($output);
|
return Response($output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<select name="risRosName" id="locationID">
|
<select name="risRosName" id="locationID">
|
||||||
<option selected="selected" name="all" value="all">Alle</option>
|
<option selected="selected" name="all" value="all">Alle</option>
|
||||||
@foreach(\App\Location::query()->get() as $location)
|
@foreach(\App\Location::query()->get() as $location)
|
||||||
<option value="{{$location->name}}">{{$location->name}}</option>
|
<option value="{{$location->id}}">{{$location->name}}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select> <label>Vælg bygning</label>
|
</select> <label>Vælg bygning</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,12 +46,13 @@
|
||||||
<script>
|
<script>
|
||||||
$('#locationID').change(function () {
|
$('#locationID').change(function () {
|
||||||
$value = $('#locationID').find(":selected").val();
|
$value = $('#locationID').find(":selected").val();
|
||||||
// alert($value);
|
console.log($value);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'get',
|
type: 'get',
|
||||||
url: '{{route('locations.search')}}',
|
url: '{{route('locations.search')}}',
|
||||||
data: {'option':$value},
|
data: {'option':$value},
|
||||||
success:function (data) {
|
success:function (data) {
|
||||||
|
console.log($value);
|
||||||
$('tbody').html(data);
|
$('tbody').html(data);
|
||||||
},
|
},
|
||||||
error:function (data) {
|
error:function (data) {
|
||||||
|
|
Loading…
Reference in New Issue