This commit is contained in:
Neerholt 2020-08-03 13:21:56 +02:00
commit e8f6c2242a
8 changed files with 31 additions and 35 deletions

View File

@ -164,7 +164,10 @@ class WashingReservationController extends Controller
$machines = WashingMachine::all();
$reservations = WashingReservation::query()->where("time", "LIKE", substr($date, 1, strpos($date, "T"))."%")->get();
if($request->machine_id == 0)
$request->machine_id = WashingMachine::all()->first()->id;
$reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", substr($date, 1, strpos($date, "T"))."%")->get();
$times = [];

View File

@ -37,6 +37,7 @@ class CreatePermissionTables extends Migration
Schema::create($tableNames['roles'], function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->unique('name');
$table->string('description');
$table->string('guard_name');
$table->timestamps();

View File

@ -1,29 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterWashingReservations extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -22,6 +22,7 @@ class CreateMenuPlans extends Migration
$table->string('tuesday', 255);
$table->string('wednesday', 255);
$table->string('thursday', 255);
$table->unique('week');
$table->timestamps();
//$table->text('description');
});

View File

@ -11,7 +11,7 @@
@section("content")
<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("washing-reservations.store") }}">
@csrf

View File

@ -26,7 +26,7 @@
<img src="{{URL::asset('/images/icons/Aktiviteter.svg')}}" alt="Aktiviteter">
Aktiviteter
</a>
<a href="{{ route("washing-reservations.index") }}">
<a href="{{ route("washing-reservations.appindex") }}">
<img src="{{URL::asset('/images/icons/Vaske booking liste.svg')}}" alt="Reservationer">
Reservationer
</a>

View File

@ -92,13 +92,14 @@
}
function onDateSelect(date, dayHolder) {
console.log("Opdaterer selects");
let events;
let machinez;
let buttonz;
let container = document.getElementById("event-container");
NodeList.prototype.forEach = Array.prototype.forEach
NodeList.prototype.forEach = Array.prototype.forEach;
var children = document.getElementById("calenderRow").childNodes;
children.forEach(function(item){
@ -107,11 +108,19 @@
dayHolder.classList.add("selected");
let machine_id;
if(document.getElementById('washing-machines'))
machine_id = document.getElementById('washing-machines').value;
else
machine_id = 0;
axios({
method: 'get',
url: '{{ route("washing-reservations.api") }}',
params: { 'date': date }
params: { 'date': date, 'machine_id': machine_id }
}).then(function (response) {
console.log(response.data["unavailable_times"]);
var data = response.data;
if(document.getElementById("washing-machines") != undefined)
@ -126,6 +135,10 @@
select.id = "washing-machines";
select.name = "machine_id";
select.onchange = function() {
onDateSelect(date, dayHolder);
}
container.appendChild(span);
container.appendChild(select);
@ -165,11 +178,18 @@
let machines = data["washingmachines"];
machinez.innerHTML = "";
machinez.onchange = function () {
onDateSelect(date, dayHolder);
}
for (let i = 0; i < machines.length; i++) {
let option = document.createElement("option");
option.text = machines[i]["name"];
option.value = machines[i]["id"];
if(machine_id == machines[i]["id"])
option.selected = "selected";
machinez.appendChild(option);
}
@ -187,7 +207,6 @@
let unavailable_times = data["unavailable_times"];
unavailable_times.forEach(function (item, index) {
console.log(item);
document.getElementById(item).remove();
});

View File

@ -28,6 +28,7 @@ Route::put("/account/update", "UserController@accountupdate")->name("users.accou
Route::get("/events/signups", "EventController@signups")->name("events.signups");
Route::get("phones", "PhoneController@index")->name("phones.index");
Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
Route::get("/app/washing-reservations", "WashingReservationController@appindex")->name("washing-reservations.appindex");
//Search/Filter
Route::get("/contactsapi", "ContactController@search")->name("contacts.search");