This commit is contained in:
frederikpyt 2020-08-17 15:06:55 +02:00
commit 4a72493f9b
17 changed files with 428 additions and 109 deletions

View File

@ -61,7 +61,7 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't add it // If there already is a washing machine with that name, then don't add it
if (count($locations) > 0) if (count($locations) > 0)
return redirect()->route("locations.store")->with('NameExists', '<p><b>Der findes allerede en lokation med det navn!</b></p>'); return redirect()->route("locations.index");
else { // Else - Add it else { // Else - Add it
$location->save(); $location->save();
$locations = Location::query()->paginate($request->input("limit", 20)); $locations = Location::query()->paginate($request->input("limit", 20));
@ -111,7 +111,7 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't change it // If there already is a washing machine with that name, then don't change it
if (count($allMachines) > 0) if (count($allMachines) > 0)
return redirect()->route("locations.store")->with('NameExists', '<p><b>Der findes allerede en lokation med det navn!</b></p>'); return redirect()->route("locations.index");
else { // Else - Change the name else { // Else - Change the name
$location->update($data); $location->update($data);
$location->save(); $location->save();
@ -124,11 +124,28 @@ class LocationController extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param \App\Location $location * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy(Location $location) public function destroy($id)
{ {
$locations = Location::find($id);
$locations->delete();
return redirect()->route("locations.index");
}
public function nameCheck(Request $request){
$locations = Location::query()->where('name', 'LIKE',$request->nameCheck)->get();
if(count($locations) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
public function nameCheckUpdate(Request $request){
$locations = Location::query()->where('name', 'LIKE',$request->nameCheck)->where('id', '!=', $request->id)->get();
if(count($locations) > 0 && $request->nameCheck !== NULL){
return 1;
}
} }
} }

View File

@ -60,8 +60,11 @@ class MenuPlanController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$requestMenuPlanCreate = $request->validate([ $requestMenuPlanCreate = $request->validate([
"week" => "required|max:2", "week" => "required|max:255",
"menu" => "required", "monday" => "required|max:255",
"tuesday" => "required|max:255",
"wednesday" => "required|max:255",
"thursday" => "required|max:255",
]); ]);
$menuPlan = new MenuPlan($requestMenuPlanCreate); $menuPlan = new MenuPlan($requestMenuPlanCreate);
@ -74,12 +77,25 @@ class MenuPlanController extends Controller
$menuPlan->save(); $menuPlan->save();
$menuPlans = MenuPlan::query()->paginate($request->input("limit", 20)); $menuPlans = MenuPlan::query()->paginate($request->input("limit", 20));
$menuArray = [];
if($request->newsoption == true){ if($request->newsoption == true){
$news = new News(); $news = new News();
$news->name = "Ny menuplan"; $news->name = "Ny menuplan";
$news->subname = "Uge " . $menuPlan->week; $news->subname = "Uge " . $menuPlan->week;
$news->content = $menuPlan->menu; $news->content =
'<h2 class="ql-align-center"><strong>Mandag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->monday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Tirsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->tuesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Onsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->wednesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Torsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->thursday.'</p>';
$news->type_id = '2'; $news->type_id = '2';
$news->arrangement_id = $menuPlan->id; $news->arrangement_id = $menuPlan->id;
@ -148,7 +164,18 @@ class MenuPlanController extends Controller
$news->subname = "Uge " . $menuplan->week; $news->subname = "Uge " . $menuplan->week;
$news->arrangement_id = $menuplan->id; $news->arrangement_id = $menuplan->id;
$news->type_id = '2'; $news->type_id = '2';
$news->content = $menuplan->menu; $news->content =
'<h2 class="ql-align-center"><strong>Mandag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->monday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Tirsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->tuesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Onsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->wednesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Torsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->thursday.'</p>';
NewsController::storeAndGet($news); NewsController::storeAndGet($news);
@ -193,7 +220,17 @@ class MenuPlanController extends Controller
'<h1 style="font-size: 28px; text-align: center; color: white;">Uge '. $menuPlan->week. '</h1>'. '<h1 style="font-size: 28px; text-align: center; color: white;">Uge '. $menuPlan->week. '</h1>'.
'</div>'. '</div>'.
'<div style="text-align: center">'. '<div style="text-align: center">'.
$menuPlan->menu. '<h2 class="ql-align-center"><strong>Mandag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->monday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Tirsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->tuesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Onsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->wednesday.'</p><p class="ql-align-center"><br></p>'.
'<h2 class="ql-align-center"><strong>Torsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuPlan->thursday.'</p>';
'</div>'. '</div>'.
'</body>'. '</body>'.
'</html>'; '</html>';

View File

@ -71,7 +71,7 @@ class UserController extends Controller
"name_last" => "required|max:255", "name_last" => "required|max:255",
"email" => "required", "email" => "required",
"password" => "required|max:60", "password" => "required|max:60",
"phone" => "required", "phone" => "required|max:8|min:8",
]); ]);
$allUsersEmail = User::query()->where('email', '=', $request->email)->get(); $allUsersEmail = User::query()->where('email', '=', $request->email)->get();

View File

@ -70,7 +70,7 @@ class WashingMachineController extends Controller
// If there already is a washing machine with that name, then don't add it // If there already is a washing machine with that name, then don't add it
if (count($allMachines) > 0) if (count($allMachines) > 0)
return redirect()->route("washing-machines.store")->with('WashingNameExists', '<p><b>Der findes allerede en vaskemaskine med det navn!</b></p>'); return redirect()->route("washing-machines.store");
else { // Else - Add it else { // Else - Add it
$machine->save(); $machine->save();
$machines = WashingMachine::query()->paginate($request->input("limit", 20)); $machines = WashingMachine::query()->paginate($request->input("limit", 20));
@ -127,7 +127,7 @@ class WashingMachineController extends Controller
// If there already is a washing machine with that name, then don't change it // If there already is a washing machine with that name, then don't change it
if (count($allMachines) > 0) if (count($allMachines) > 0)
return redirect()->route("washing-machines.store")->with('WashingNameExists', '<p><b>Der findes allerede en vaskemaskine med det navn!</b></p>'); return redirect()->route("washing-machines.store");
else { // Else - Change the name else { // Else - Change the name
$machine->update($data); $machine->update($data);
$machine->save(); $machine->save();
@ -153,4 +153,18 @@ class WashingMachineController extends Controller
return redirect()->route("washing-machines.index"); return redirect()->route("washing-machines.index");
} }
public function nameCheck(Request $request){
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->get();
if(count($washing) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
public function nameCheckUpdate(Request $request){
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->where('id', '!=', $request->id)->get();
if(count($washing) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
} }

View File

@ -15,6 +15,6 @@ class MenuPlan extends Model
{ {
//protected variable which contains name of database field(s) to be filled. //protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'week', 'menu' 'week', 'monday', "tuesday", 'wednesday', 'thursday'
]; ];
} }

View File

@ -26,7 +26,7 @@ class CreateUsersTable extends Migration
$table->string('email')->unique(); $table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable(); $table->timestamp('email_verified_at')->nullable();
$table->string('password'); $table->string('password');
$table->integer("phone")->unique(); $table->string("phone", 8)->unique();
$table->rememberToken(); $table->rememberToken();
$table->foreignId("resource_id")->nullable()->constrained("resources", "id"); $table->foreignId("resource_id")->nullable()->constrained("resources", "id");
$table->boolean("wants_emails")->default(true); $table->boolean("wants_emails")->default(true);

View File

@ -17,9 +17,11 @@ class CreateMenuPlans extends Migration
{ {
Schema::create('menu_plans', function (Blueprint $table) { Schema::create('menu_plans', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('week', 2); $table->integer('week')->unique();
$table->longText('menu'); $table->string('monday', 255);
$table->unique('week'); $table->string('tuesday', 255);
$table->string('wednesday', 255);
$table->string('thursday', 255);
$table->timestamps(); $table->timestamps();
//$table->text('description'); //$table->text('description');
}); });

View File

@ -59,7 +59,7 @@
<tr> <tr>
<th class="text-white text-center" style="background-color: orange;">Nyeste brugere</th> <th class="text-white text-center" style="background-color: orange;">Nyeste brugere</th>
</tr> </tr>
@for($i = 0; $i < 5 && $i < count(\App\User::query()->orderByDesc("id")->get()); $i++) @for($i = 0; $i < 10 && $i < count(\App\User::query()->orderByDesc("id")->get()); $i++)
<tr> <tr>
<td>{{ ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_first)) . ' ' . ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_last)) }}</td> <td>{{ ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_first)) . ' ' . ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_last)) }}</td>
</tr> </tr>
@ -83,10 +83,21 @@
@if(\App\Event::query()->orderByDesc("date")->first() !== null) @if(\App\Event::query()->orderByDesc("date")->first() !== null)
<div class="event_card"> <div class="event_card">
@if(\App\Event::query()->orderByDesc("date")->first()->resource_id !== null) @if(\App\Event::query()->orderByDesc("date")->first()->resource_id !== null)
<div class="header" style="background-size: cover; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", \App\Event::query()->orderByDesc("date")->first()->resource_id)->first()->filename) }}');"> <div class="header" style="padding-top: 0">
<h3 style="text-shadow: 2px 2px 2px #00788A;" class="text-white text-center">{{ \App\Event::query()->orderByDesc("date")->first()->name }}</h3> <table class="tbl mt-0">
<p style="text-shadow: 2px 2px 2px #00788A"; class="text-white text-center mt-0">{{__('msg.af')}}: {{ \App\Event::query()->orderByDesc("date")->first()->accountable }}</p> <tr>
<p style="text-shadow: 2px 2px 2px #00788A"; class="text-white text-center mt-0">{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime(\App\Event::query()->orderByDesc("date")->first()->date))->format('d/m/Y \k\l\. H:i') }}</p> <td><label>Event navn</label></td>
<td>{{ \App\Event::query()->orderByDesc("date")->first()->name }}</td>
</tr>
<tr>
<td><label>Event ansvarlig</label></td>
<td>{{__('msg.af')}}: {{ \App\Event::query()->orderByDesc("date")->first()->accountable }}</td>
</tr>
<tr>
<td><label>Tidspunkt</label></td>
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime(\App\Event::query()->orderByDesc("date")->first()->date))->format('d/m/Y \k\l\. H:i') }}</td>
</tr>
</table>
</div> </div>
@else @else
<div class="header"> <div class="header">
@ -97,10 +108,14 @@
@endif @endif
<div class="container" style="margin-top: 8px;"> <div class="container" style="margin-top: 8px;">
{!! \App\Helpers::closetags(substr(\App\Event::query()->orderByDesc("date")->first()->description, 0, 300) )!!} <table style="border: 1px solid lightgrey; width: 100%;">
<tr>
<td> {!! \App\Helpers::closetags(substr(\App\Event::query()->orderByDesc("date")->first()->description, 0, 300) )!!}</td>
</tr>
</table>
<input type="hidden" name="event_id" value="{{ \App\Event::query()->orderByDesc("date")->first()->id }}"> <input type="hidden" name="event_id" value="{{ \App\Event::query()->orderByDesc("date")->first()->id }}">
<div class="row" style="justify-content: space-between; margin-top: 16px;"> <div class="row" style="justify-content: space-between; margin-top: 16px;">
<a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="{{route("events.accountsignups", ["event" => \App\Event::query()->orderByDesc("date")->first()->id ])}}">{{__('msg.sedeltagere')}}</a> <a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="{{route("events.signups", ["event" => \App\Event::query()->orderByDesc("date")->first()->id ])}}">{{__('msg.sedeltagere')}}</a>
</div> </div>
</div> </div>
</div> </div>
@ -122,7 +137,7 @@
<th class="text-white text-center" style="background-color: deepskyblue;">Seneste Vejledninger</th> <th class="text-white text-center" style="background-color: deepskyblue;">Seneste Vejledninger</th>
</tr> </tr>
@if(count(\App\Guide::all()) > 0) @if(count(\App\Guide::all()) > 0)
@for($i = 0; $i < 5 && $i < count(\App\Guide::query()->orderByDesc("id")->get()); $i++) @for($i = 0; $i < 10 && $i < count(\App\Guide::query()->orderByDesc("id")->get()); $i++)
<tr> <tr>
<td>{{ ucfirst(strtolower(\App\Guide::query()->orderByDesc("id")->get()[$i]->name)) }}</td> <td>{{ ucfirst(strtolower(\App\Guide::query()->orderByDesc("id")->get()[$i]->name)) }}</td>
</tr> </tr>
@ -145,14 +160,28 @@
</div> </div>
<table class="tbl mt-1"> <table class="tbl mt-1">
<tr> <tr>
<th class="text-white text-center" style="background-color: lightseagreen;">Ugens Menuplan</th> <th class="text-white text-center" style="background-color: lightseagreen; border-right: unset;">Ugens Menuplan</th>
<th class="text-white text-center" style="background-color: lightseagreen; border-left: unset;"></th> <!--Maybe fix ?-->
</tr> </tr>
</table>
@if(\App\MenuPlan::query()->where("week", "=", date('W'))->first() !== null) @if(\App\MenuPlan::query()->where("week", "=", date('W'))->first() !== null)
{!! \App\MenuPlan::query()->where("week", "=", date('W'))->first()->menu !!} {{-- \App\MenuPlan::query()->where("week", "=", date('W'))->first() --}}
<tr>
<td><label>Mandag </label></td>
<td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->monday }}</td>
</tr>
<td><label>Tirsdag</label></td>
<td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->tuesday }}</td>
</tr>
<td><label>Onsdag</label></td>
<td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->wednesday }}</td>
</tr>
<td><label>Torsdag</label></td>
<td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->thursday }}</td>
</tr>
@else @else
</table>
<p class="text-center">Der er ingen menuplan for denne uge</p> <p class="text-center">Der er ingen menuplan for denne uge</p>
@endif @endif
</table>
</div> </div>
@endsection @endsection

View File

@ -10,12 +10,13 @@
@endsection @endsection
@section("content") @section("content")
<h1>Opret Lokation</h1> <h1 id="errormesseages" >Opret Lokation</h1>
<form method="post" action="{{ route("locations.store") }}"> <form method="post" action="{{ route("locations.store") }}">
@csrf @csrf
<label for="name">Lokationsnavn:</label> <label for="name">Lokationsnavn:</label>
<label hidden id="error" for="errormesseages">Lokation findes allerede</label>
<input type="text" name="name" id="name" placeholder="Bygning A" required> <input type="text" name="name" id="name" placeholder="Bygning A" required>
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form> </form>
@endsection @endsection
@section("scripts") @section("scripts")
@ -28,5 +29,57 @@
} }
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('locations.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('locations.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script> </script>
@endsection @endsection

View File

@ -15,8 +15,9 @@
@csrf @csrf
@method("put") @method("put")
<label for="name">Lokationsnavn:</label> <label for="name">Lokationsnavn:</label>
<label hidden id="error" for="errormesseages">Lokation findes allerede</label>
<input type="text" name="name" id="name" value="{{ $location->name }}" required> <input type="text" name="name" id="name" value="{{ $location->name }}" required>
<input type="submit" class="btn btn-dark text-white" value="Rediger"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
</form> </form>
@endsection @endsection
@section("scripts") @section("scripts")
@ -29,5 +30,57 @@
} }
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('locations.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$location->id}}},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('locations.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$location->id}}},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script> </script>
@endsection @endsection

View File

@ -29,20 +29,14 @@
<label for="week">Uge nr.</label> <label for="week">Uge nr.</label>
<label hidden id="error" for="errormesseages">Menuplan findes allerede</label> <label hidden id="error" for="errormesseages">Menuplan findes allerede</label>
<input type="number" name="week" id="week" min="1" max="53" placeholder="1" required> <input type="number" name="week" id="week" min="1" max="53" placeholder="1" required>
<div id="editor"> <label for="monday">Mandag:</label>
<h2 class="ql-align-center"><strong>Mandag:</strong></h2> <input type="text" name="monday" id="monday" placeholder="Hawaii Pizza" required>
<p class="ql-align-center">{Mandag}</p> <label for="tuesday">Tirsdag:</label>
<p class="ql-align-center"><br></p> <input type="text" name="tuesday" id="tuesday" placeholder="Pasta Bolognese" required>
<h2 class="ql-align-center"><strong>Tirsdag:</strong></h2> <label for="wednesday">Onsdag:</label>
<p class="ql-align-center">{Tirsdag}</p> <input type="text" name="wednesday" id="wednesday" placeholder="Pandekager" required>
<p class="ql-align-center"><br></p> <label for="thursday">Torsdag:</label>
<h2 class="ql-align-center"><strong>Onsdag:</strong></h2> <input type="text" name="thursday" id="thursday" placeholder="Bøf med løg" required>
<p class="ql-align-center">{Onsdag}</p>
<p class="ql-align-center"><br></p>
<h2 class="ql-align-center"><strong>Torsdag:</strong></h2>
<p class="ql-align-center">{Torsdag}</p>
</div>
<textarea name="menu" class="d-none" id="hiddenArea"></textarea>
<label class="toggle"> <label class="toggle">
<input class="toggle__input" id="isNews" type="checkbox" name="newsoption" onclick="change()"> <input class="toggle__input" id="isNews" type="checkbox" name="newsoption" onclick="change()">
<span class="toggle__label"> <span class="toggle__label">
@ -56,34 +50,6 @@
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret Menuplan"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret Menuplan">
</form> </form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
var container = document.getElementById("editor");
var fullEditor = new Quill(container, {
modules: {
'toolbar': [
[ 'bold', 'italic', 'underline', 'strike' ],
[{ 'color': [] }],
[{ 'script': 'super' }, { 'script': 'sub' }],
[{ 'header': '1' }, { 'header': '2' }, 'blockquote' ],
[{ 'list': 'ordered' }, { 'list': 'bullet'}, { 'indent': '-1' }, { 'indent': '+1' }],
[ {'direction': 'rtl'}, { 'align': [] }],
[ 'link' ],
[ 'clean' ]
],
},
theme: 'snow'
});
</script>
<script>
var form = document.querySelector('form');
form.onsubmit = function() {
var myEditor = document.getElementById('editor');
var html = myEditor.children[0].innerHTML;
document.getElementById('hiddenArea').innerText = html;
}
</script>
@endsection @endsection
@section("scripts") @section("scripts")
<script> <script>

View File

@ -30,8 +30,14 @@
<label for="mandag">Uge:</label> <label for="mandag">Uge:</label>
<label hidden id="error" for="errormesseages">Menuplan findes allerede</label> <label hidden id="error" for="errormesseages">Menuplan findes allerede</label>
<input type="number" name="week" id="week" min="1" max="53" value="{{ $menuplan->week }}" required> <input type="number" name="week" id="week" min="1" max="53" value="{{ $menuplan->week }}" required>
<div id="editor">{!! $menuplan->menu !!}</div> <label for="monday">Mandag:</label>
<textarea name="menu" class="d-none" id="hiddenArea"></textarea> <input type="text" name="monday" id="monday" placeholder="Hawaii Pizza" required value="{{ $menuplan->monday }}">
<label for="tuesday">Tirsdag:</label>
<input type="text" name="tuesday" id="tuesday" placeholder="Pasta Bolognese" required value="{{ $menuplan->tuesday }}">
<label for="wednesday">Onsdag:</label>
<input type="text" name="wednesday" id="wednesday" placeholder="Pandekager" required value="{{ $menuplan->wednesday }}">
<label for="thursday">Torsdag:</label>
<input type="text" name="thursday" id="thursday" placeholder="Bøf med løg" required value="{{ $menuplan->thursday }}">
<label class="toggle"> <label class="toggle">
<input class="toggle__input" type="checkbox" name="newsoption"> <input class="toggle__input" type="checkbox" name="newsoption">
<span class="toggle__label"> <span class="toggle__label">
@ -40,34 +46,6 @@
</label> </label>
<input id="disable" type="submit" class="btn btn-dark text-white" value="Rediger Menuplan"> <input id="disable" type="submit" class="btn btn-dark text-white" value="Rediger Menuplan">
</form> </form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
var container = document.getElementById("editor");
var fullEditor = new Quill(container, {
modules: {
'toolbar': [
[ 'bold', 'italic', 'underline', 'strike' ],
[{ 'color': [] }],
[{ 'script': 'super' }, { 'script': 'sub' }],
[{ 'header': '1' }, { 'header': '2' }, 'blockquote' ],
[{ 'list': 'ordered' }, { 'list': 'bullet'}, { 'indent': '-1' }, { 'indent': '+1' }],
[ {'direction': 'rtl'}, { 'align': [] }],
[ 'link' ],
[ 'clean' ]
],
},
theme: 'snow'
});
</script>
<script>
var form = document.querySelector('form');
form.onsubmit = function() {
var myEditor = document.getElementById('editor');
var html = myEditor.children[0].innerHTML;
document.getElementById('hiddenArea').innerText = html;
}
</script>
@endsection @endsection
@section("scripts") @section("scripts")
<script> <script>

View File

@ -10,10 +10,11 @@
@endsection @endsection
@section("content") @section("content")
<h1>Opret Vaskemaskine:</h1> <h1 id="errormesseages" >Opret Vaskemaskine:</h1>
<form method="post" action="{{ route("washing-machines.store") }}"> <form method="post" action="{{ route("washing-machines.store") }}">
@csrf @csrf
<label for="name_first">Vaskemaskine Navn:</label> <label for="name_first">Vaskemaskine Navn:</label>
<label hidden id="error" for="errormesseages">Vaskemaskinen med den lokation findes allerede</label>
<input type="text" name="name" id="name" max="60" placeholder="Vaskemaskine nr. 1" required> <input type="text" name="name" id="name" max="60" placeholder="Vaskemaskine nr. 1" required>
<label for="location_id">Lokation:</label> <label for="location_id">Lokation:</label>
<select name="location_id" id="location_id" class="mb-2" required> <select name="location_id" id="location_id" class="mb-2" required>
@ -26,7 +27,7 @@
<option disabled> Der er ingen lokationer oprettet!</option> <option disabled> Der er ingen lokationer oprettet!</option>
@endif @endif
</select> </select>
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form> </form>
@endsection @endsection
@section("scripts") @section("scripts")
@ -39,5 +40,82 @@
} }
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheck')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val()},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheck')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val()},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
$('#location_id').on('change', function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheck')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val()},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script> </script>
@endsection @endsection

View File

@ -14,6 +14,7 @@
@csrf @csrf
@method("put") @method("put")
<label for="name_first">Vaskemaskine Navn:</label> <label for="name_first">Vaskemaskine Navn:</label>
<label hidden id="error" for="errormesseages">Vaskemaskinen med den lokation findes allerede</label>
<input type="text" name="name" id="name" max="60" value="{{$machine->name}}" required> <input type="text" name="name" id="name" max="60" value="{{$machine->name}}" required>
<select class="w-100" name="location_id" id="location_id" class="mb-2" required> <select class="w-100" name="location_id" id="location_id" class="mb-2" required>
<option disabled> -- Vælg Lokation -- </option> <option disabled> -- Vælg Lokation -- </option>
@ -25,7 +26,7 @@
<option {{ $selected }} value="{{ $location->id }}">{{ $location->name }}</option> <option {{ $selected }} value="{{ $location->id }}">{{ $location->name }}</option>
@endforeach @endforeach
</select> </select>
<input type="submit" class="btn btn-dark text-white" value="Rediger"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
</form> </form>
@endsection @endsection
@section("scripts") @section("scripts")
@ -38,5 +39,82 @@
} }
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
$('#location_id').on('change', function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('washing-machines.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script> </script>
@endsection @endsection

View File

@ -13,7 +13,6 @@
<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-machines.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Vaskemaskine</a> <a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-machines.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Vaskemaskine</a>
</div> </div>
{!! session()->get('WashingNameExists') !!}
<table class="tbl mt-2"> <table class="tbl mt-2">
<tr> <tr>
<th>Navn</th> <th>Navn</th>

View File

@ -18,7 +18,17 @@
<span class="text-center text-white bold">{{ __('msg.ugestor') }}: {{$menuplan->week}}</span> <span class="text-center text-white bold">{{ __('msg.ugestor') }}: {{$menuplan->week}}</span>
@endif @endif
<div class="col w-100 mt-1"> <div class="col w-100 mt-1">
{!! $menuplan->menu !!} {!! '<h2 class="ql-align-center"><strong>Mandag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->monday.'</p><p class="ql-align-center"></p>'.
'<h2 class="ql-align-center"><strong>Tirsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->tuesday.'</p><p class="ql-align-center"></p>'.
'<h2 class="ql-align-center"><strong>Onsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->wednesday.'</p><p class="ql-align-center"></p>'.
'<h2 class="ql-align-center"><strong>Torsdag:</strong></h2>'.
'<p class="ql-align-center">'.$menuplan->thursday.'</p>' !!}
</div> </div>
@endif @endif
@endforeach @endforeach

View File

@ -62,6 +62,9 @@ Route::get("/usersCheck", "UserController@nameCheck")->name("users.nameCheck");
Route::get("/guidesCheck", "GuideController@nameCheck")->name("guides.nameCheck"); Route::get("/guidesCheck", "GuideController@nameCheck")->name("guides.nameCheck");
Route::get("/newsCheck", "NewsController@nameCheck")->name("news.nameCheck"); Route::get("/newsCheck", "NewsController@nameCheck")->name("news.nameCheck");
Route::get("/menuplanCheck", "MenuPlanController@nameCheck")->name("menuplans.nameCheck"); Route::get("/menuplanCheck", "MenuPlanController@nameCheck")->name("menuplans.nameCheck");
Route::get("/locationsCheck", "LocationController@nameCheck")->name("locations.nameCheck");
Route::get("/washingCheck", "WashingMachineController@nameCheck")->name("washing-machines.nameCheck");
//Check name update adminpanel //Check name update adminpanel
Route::get("/eventCheckUpdate", "EventController@nameCheckUpdate")->name("events.nameCheckUpdate"); Route::get("/eventCheckUpdate", "EventController@nameCheckUpdate")->name("events.nameCheckUpdate");
@ -69,6 +72,8 @@ Route::get("/roleCheckUpdate", "RolesController@nameCheckUpdate")->name("roles.n
Route::get("/guidesCheckUpdate", "GuideController@nameCheckUpdate")->name("guides.nameCheckUpdate"); Route::get("/guidesCheckUpdate", "GuideController@nameCheckUpdate")->name("guides.nameCheckUpdate");
Route::get("/newsCheckUpdate", "NewsController@nameCheckUpdate")->name("news.nameCheckUpdate"); Route::get("/newsCheckUpdate", "NewsController@nameCheckUpdate")->name("news.nameCheckUpdate");
Route::get("/menuplanCheckUpdate", "MenuPlanController@nameCheckUpdate")->name("menuplans.nameCheckUpdate"); Route::get("/menuplanCheckUpdate", "MenuPlanController@nameCheckUpdate")->name("menuplans.nameCheckUpdate");
Route::get("/locationsCheckUpdate", "LocationController@nameCheckUpdate")->name("locations.nameCheckUpdate");
Route::get("/washingCheckUpdate", "WashingMachineController@nameCheckUpdate")->name("washing-machines.nameCheckUpdate");