Made washing-reservations search
This commit is contained in:
parent
0dd262d50c
commit
4826725e07
|
@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
use App\WashingReservation;
|
use App\WashingReservation;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class WashingReservationController extends Controller
|
class WashingReservationController extends Controller
|
||||||
|
@ -175,5 +176,66 @@ class WashingReservationController extends Controller
|
||||||
return Response($output);
|
return Response($output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function search(Request $request){
|
||||||
|
if($request->ajax()){
|
||||||
|
$output = "<tr>".
|
||||||
|
"<th>Vaskemaskine</th>".
|
||||||
|
"<th>Tidspunkt</th>".
|
||||||
|
"<th>Bruger</th>".
|
||||||
|
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>".
|
||||||
|
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
|
||||||
|
"</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
//Kan ikke søge på vaskemaskine da det er en foreign key
|
||||||
|
|
||||||
|
//filter search
|
||||||
|
if($request->isCheck === "vaskemaskine")
|
||||||
|
$users = WashingReservation::query()->where('machine_id', 'LIKE',$request->search.'%')->get();
|
||||||
|
elseif ($request->isCheck === "tidspunkt")
|
||||||
|
$users = WashingReservation::query()->where('time', 'LIKE',$request->search.'%')->get();
|
||||||
|
else
|
||||||
|
$users = WashingReservation::query()->where('time', 'LIKE',$request->search.'%')
|
||||||
|
->orWhere('machine','LIKE', $request->search.'%')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(count($users) !== 0){
|
||||||
|
foreach ($users as $key => $user){
|
||||||
|
$output.='<tr>'.
|
||||||
|
'<td>' . WashingMachine::query()->find($user->machine_id)->name . '</td>'.
|
||||||
|
'<td>' . $user->time . '</td>'.
|
||||||
|
'<td>' . ucfirst(User::query()->find($user->user_id)->name_first) . ' ' . ucfirst(User::query()->find($user->user_id)->name_last) . '</td>'.
|
||||||
|
'<td><a href="'. route("washing-reservations.edit", [ "washing_reservation" => $user->id ]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'.
|
||||||
|
'<td><form method="post" action="' .route("washing-reservations.destroy", [ "washing_reservation" => $user->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>Intet match</td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'<td></td>'.
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
return Response($output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,20 @@
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-reservations.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Reservation</a>
|
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-reservations.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Reservation</a>
|
||||||
|
|
||||||
<form method="post" action="{{ route("users.store") }}">
|
<form method="post" action="{{ route("washing-reservations.store") }}">
|
||||||
@csrf
|
@csrf
|
||||||
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på Navn, Telefon"></input>
|
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på Navn, Telefon"></input>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<input class="checkbox-inline" type="checkbox" name="checkbox" id="vaskemaskine" value="vaskemaskine">
|
||||||
|
<label for="navn">Vaskemaskine</label>
|
||||||
|
<input class="checkbox-inline" type="checkbox" name="checkbox" id="tidspunkt" value="tidspunkt">
|
||||||
|
<label for="efternavn">Tispunkt</label>
|
||||||
|
<input class="checkbox-inline" type="checkbox" name="checkbox" id="bruger" value="bruger">
|
||||||
|
<label for="email">Bruger</label>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<table class="tbl mt-2">
|
<table class="tbl mt-2">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -45,4 +54,45 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{{ $reservations->links() }}
|
{{ $reservations->links() }}
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#search').on('keyup', function () {
|
||||||
|
$value = $(this).val();
|
||||||
|
$checkboxValue = $( "input:checked" ).val();
|
||||||
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '{{route('washing-reservations.search')}}',
|
||||||
|
data: {'search':$value, 'isCheck': $checkboxValue},
|
||||||
|
success:function (data) {
|
||||||
|
console.log($checkboxValue);
|
||||||
|
$('tbody').html(data);
|
||||||
|
},
|
||||||
|
error:function (data) {
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("input:checkbox").on('click', function() {
|
||||||
|
var $box = $(this);
|
||||||
|
if ($box.is(":checked")) {
|
||||||
|
var group = "input:checkbox[name='" + $box.attr("name") + "']";
|
||||||
|
$(group).prop("checked", false);
|
||||||
|
$box.prop("checked", true);
|
||||||
|
} else {
|
||||||
|
$box.prop("checked", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
@ -36,6 +36,7 @@ Route::get("/eventsapi", "EventController@search")->name("events.search");
|
||||||
Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search");
|
Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search");
|
||||||
Route::get("/rolesapi", "RolesController@search")->name("roles.search");
|
Route::get("/rolesapi", "RolesController@search")->name("roles.search");
|
||||||
Route::get("/userapi", "UserController@search")->name("users.search");
|
Route::get("/userapi", "UserController@search")->name("users.search");
|
||||||
|
Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search");
|
||||||
Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
|
Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue