Ekapp/skolehjem/resources/views/app/multiple-events/index.blade.php

155 lines
4.8 KiB
PHP

@extends("app.layout.base")
@section("title")
Ugenlige aktiviteter
@endsection
@section("content")
<style>
iframe, .ql-video {
width: 100%;
}
div.card {
margin-top: 1rem;
margin-bottom: 30px;
width: auto;
heigt: auto;
}
div.container {
padding: 8px;
text-align: justify;
line-height: 1.5;
}
.header > img {
border-radius: 2px 2px 2px 2px
}
/*Alert box*/
.alert {
opacity: 0.8;
padding: 20px;
background-color: #00788A;
color: white;
border-radius: 10px;
background: linear-gradient(to right, red, purple);
}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
alertBoxBackground {
margin-top: 1rem;
margin-bottom: 30px;
width: auto;
heigt: auto;
}
</style>
<?php
$Week = date('W'); //Current week
?>
<main>
<h1 class="text-center sde-blue mb-2rem">{{ __('msg.ugentligaktiviteter') }}</h1>
<!--Alert box, display when a event is delete: start-->
@if(count(\App\Notification::query()->where("user_id", "=", auth()->user()->id)->get()) > 0)
<div class="alertBoxBackground" id="notifications">
<div class="alert">
<span class="closebtn" onclick="deleteNotifications(document.getElementById('notifications'))">&times;</span>
<strong>{{__('msg.aktivitetaflyst')}}</strong>
@foreach(\App\Notification::query()->where("user_id", "=", auth()->user()->id)->get() as $notification)
<p>{{ $notification->message }}{{ __("msg.canceled") }}</p>
@endforeach
</div>
</div>
@endif
<!--Alert box, display when a event is delete: end -->
<!--If there is a images to the event do this: Start-->
@if(!$multiEvents->isEmpty())
@if($multiEvents->contains('week', $Week)) {{-- If any of the menues in the menu table has the number of the week in the 'week' column, do this --}}
@foreach($multiEvents as $multiEvent)
@if($multiEvent->week == $Week)
<p>{{$multiEvents->name}}</p>
<p>{{$multiEvents->accountable}}</p>
<p>{{$multiEvents->description}}</p>
<p>{{$multiEvents->date}}</p>
<p>{{$multiEvents->event}}</p>
@endif
@endforeach
@else
<p class="text-center">{{__('msg.dereringenugentligeaktiviteter')}}!</p>
@endif
@endif
</main>
@endsection
@section("scripts")
<script type="text/javascript">
function snackbar(data) {
var x = document.getElementById("snackbar");
x.innerHTML = data;
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
function ajaxCall(event_id, el) {
if(el.innerHTML === "{{__("msg.tilmeld")}}") {
axios.post("{{ route("userevents.createajax") }}",
{
event_id: event_id
}
).then(function (response) {
var data = response.data;
snackbar(data);
el.innerHTML = "{{__("msg.afmeld")}}";
}).catch(function (error) {
console.log(error);
});
} else if(el.innerHTML === "{{__("msg.afmeld")}}"){
axios.post("{{ route("userevents.createajaxcancel") }}",
{
event_id: event_id
}
).then(function (response) {
var data = response.data;
snackbar(data);
el.innerHTML = "{{__("msg.tilmeld")}}";
}).catch(function (error) {
console.log(error);
});
}
}
function deleteNotifications(el) {
el.remove();
}
window.onload = function () {
setMain();
axios({
method: 'delete',
url: '{{route("notifications.delete")}}',
data: {
user_id: {{ auth()->user()->id }}
}
});
};
</script>
@endsection