v0.5.4 - Created the "reservations in location" screen and added a location option when creating reservations.
This commit is contained in:
parent
358e47b703
commit
4b0ad949ba
|
@ -72,11 +72,11 @@ class LocationController extends Controller
|
|||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Location $location
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show(Location $location)
|
||||
{
|
||||
|
||||
return view("admin.locations.show", [ "location" => $location]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Location;
|
||||
use App\WashingMachine;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
|
@ -142,10 +143,13 @@ class WashingReservationController extends Controller
|
|||
$date = $request->date;
|
||||
$datetext = $request->datetext;
|
||||
|
||||
$machines = WashingMachine::all();
|
||||
if($request->location_id == 0)
|
||||
$request->location_id = Location::all()->first()->id;
|
||||
|
||||
$machines = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->get();
|
||||
|
||||
if($request->machine_id == 0)
|
||||
$request->machine_id = WashingMachine::all()->first()->id;
|
||||
$request->machine_id = WashingMachine::query()->orderBy("name", "asc")->first()->id;
|
||||
|
||||
$reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", $datetext."%")->get();
|
||||
|
||||
|
@ -155,7 +159,9 @@ class WashingReservationController extends Controller
|
|||
array_push($times, $reservation->time);
|
||||
}
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times ]);
|
||||
$locations = Location::query()->orderBy("name", "asc")->get();
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times, "locations" => $locations ]);
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<th>Event Navn</th>
|
||||
<th>Event Beskrivelse</th>
|
||||
<th>Event Dato</th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/eye.svg') }}" alt="Update"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/eye.svg') }}" alt="Show"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
||||
</tr>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<td>{{ $event->name }}</td>
|
||||
<td>{{ $event->description }}</td>
|
||||
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($event->date))->format('d/m/Y \k\l\. H:i') }}</td>
|
||||
<td><a href="{{ route("events.signups", [ "event" => $event ]) }}"><img class="w-100" src="{{ asset('/images/icons/eye-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><a href="{{ route("events.signups", [ "event" => $event ]) }}"><img class="w-100" src="{{ asset('/images/icons/eye-dark.svg') }}" alt="Show"></a></td>
|
||||
<td><a href="{{ route("events.edit", [ "event" => $event ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><form method="post" action="{{ route("events.destroy", [ "event" => $event ]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
<table class="tbl mt-2">
|
||||
<tr>
|
||||
<th>Navn</th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/eye.svg') }}" alt="Show"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
||||
</tr>
|
||||
@foreach($locations as $location)
|
||||
<tr>
|
||||
<td>{{$location->name}}</td>
|
||||
<td><a href="{{ route("locations.show", [ "location" => $location ]) }}"><img class="w-100" src="{{ asset('/images/icons/eye-dark.svg') }}" alt="Show"></a></td>
|
||||
<td><a href="{{ route("locations.edit", [ "location" => $location ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><form method="post" action="{{ route("locations.destroy", [ "location" => $location ]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>@yield("title")</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="{{ mix("/css/admin.css") }}">
|
||||
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="row align-items-center" style="background-color: #00788a;">
|
||||
<img src="{{ URL::asset('/images/logos/Logo-hvid.svg') }}" class="brand" alt="Syddansk Erhvervsskole">
|
||||
<p class="text-white" style="margin-left: auto; padding-right: 24px">Lokation: {{ $location->name }}</p>
|
||||
</header>
|
||||
<main style="min-height: calc(100% - 72px); background-color: #ffffff;">
|
||||
<?php $i = 1; ?>
|
||||
<div class="row">
|
||||
@foreach(\App\WashingMachine::query()->where("location_id", "=", $location->id)->get() as $machine)
|
||||
@foreach(\App\WashingReservation::query()->where("machine_id", "=", $machine->id)->where("time", "LIKE", date("Y-m-d"). "%")->orderBy("time", "asc")->get() as $reservation)
|
||||
@if($i % 3 == 1)
|
||||
</div>
|
||||
<div class="row w-100">
|
||||
@endif
|
||||
<div class="reservation col align-items-center" style="margin: 0 32px 1.75rem 32px; width: calc(33% - 64px);">
|
||||
<h2 style="font-size: 2vw">{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</h2>
|
||||
<div class="col align-items-center">
|
||||
<span style="font-size: 1vw"><b>Dato:</b> {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y') }}</span>
|
||||
<span style="font-size: 2vw"><b>Tid:</b> {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('\k\l\. H:i') }} - {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_first }} {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_last }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; ?>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="{{ mix("/js/app.js") }}"></script>
|
||||
@yield("scripts")
|
||||
</body>
|
||||
</html>
|
|
@ -97,8 +97,8 @@
|
|||
}
|
||||
|
||||
function onDateSelect(date, dayHolder, datetext) {
|
||||
console.log("Opdaterer selects");
|
||||
let events;
|
||||
let locationz;
|
||||
let machinez;
|
||||
let buttonz;
|
||||
|
||||
|
@ -114,20 +114,47 @@
|
|||
dayHolder.classList.add("selected");
|
||||
|
||||
let machine_id;
|
||||
let location_id;
|
||||
|
||||
if(document.getElementById('washing-machines'))
|
||||
machine_id = document.getElementById('washing-machines').value;
|
||||
else
|
||||
machine_id = 0;
|
||||
|
||||
if(document.getElementById('locations'))
|
||||
location_id = document.getElementById('locations').value;
|
||||
else
|
||||
location_id = 0;
|
||||
|
||||
axios({
|
||||
method: 'get',
|
||||
url: '{{ route("washing-reservations.api") }}',
|
||||
params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext }
|
||||
params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext, 'location_id': location_id }
|
||||
}).then(function (response) {
|
||||
console.log(response.data["unavailable_times"]);
|
||||
var data = response.data;
|
||||
|
||||
|
||||
if(document.getElementById("locations") != undefined)
|
||||
locationz = document.getElementById("locations");
|
||||
else {
|
||||
let span = document.createElement("span");
|
||||
span.classList.add("events__title");
|
||||
span.innerText = "Lokation";
|
||||
|
||||
let select = document.createElement("select");
|
||||
select.classList.add("events__title");
|
||||
select.id = "locations";
|
||||
select.name = "location_id";
|
||||
|
||||
select.onchange = function() {
|
||||
onDateSelect(date, dayHolder, datetext);
|
||||
}
|
||||
|
||||
container.appendChild(span);
|
||||
container.appendChild(select);
|
||||
|
||||
locationz = document.getElementById("locations");
|
||||
}
|
||||
if(document.getElementById("washing-machines") != undefined)
|
||||
machinez = document.getElementById("washing-machines");
|
||||
else {
|
||||
|
@ -180,6 +207,24 @@
|
|||
buttonz = document.getElementById("events");
|
||||
}
|
||||
|
||||
let locations = data["locations"];
|
||||
|
||||
locationz.innerHTML = "";
|
||||
locationz.onchange = function () {
|
||||
onDateSelect(date, dayHolder, datetext);
|
||||
}
|
||||
|
||||
for (let i = 0; i < locations.length; i++) {
|
||||
let option = document.createElement("option");
|
||||
option.text = locations[i]["name"];
|
||||
option.value = locations[i]["id"];
|
||||
|
||||
if(location_id == locations[i]["id"])
|
||||
option.selected = "selected";
|
||||
|
||||
locationz.appendChild(option);
|
||||
}
|
||||
|
||||
let machines = data["washingmachines"];
|
||||
|
||||
machinez.innerHTML = "";
|
||||
|
@ -213,7 +258,6 @@
|
|||
let unavailable_times = data["unavailable_times"];
|
||||
|
||||
unavailable_times.forEach(function (item, index) {
|
||||
console.log(item);
|
||||
document.getElementById(item).remove();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue