207 lines
7.9 KiB
PHP
207 lines
7.9 KiB
PHP
@extends("admin.layout.base")
|
|
@extends("admin.layout.header")
|
|
|
|
@section("title")
|
|
Rediger ugentligt aktivitet - Vis
|
|
@endsection
|
|
|
|
@section("path")
|
|
<a href="{{ route('multiple-events.create') }}" class="text-white">Opret ugentligt aktivitet</a> /
|
|
@endsection
|
|
|
|
@section("content")
|
|
<style>
|
|
.toggle__label::before, .toggle__label::after {
|
|
border-color: black;
|
|
}
|
|
.toggle__text::before {
|
|
border-color: black;
|
|
}
|
|
|
|
table {
|
|
font-family: arial, sans-serif;
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
}
|
|
|
|
td, th {
|
|
|
|
text-align: left;
|
|
padding: 8px;
|
|
}
|
|
|
|
.pointer {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.bg-red {
|
|
background: #B20000FF;
|
|
color: white;
|
|
}
|
|
</style>
|
|
<link href="{{ asset("/css/quill/quill.snow.css") }}" rel="stylesheet">
|
|
<h1 id="errormesseages" >Opret ugentligt aktivitet: [Vi er i uge <?php echo date('W'); ?>]</h1>
|
|
<form method="post" action="{{ route("multiple-events.update", $parentEvent) }}" enctype="multipart/form-data">
|
|
@csrf
|
|
@method("PUT")
|
|
<input type="number" name="week" placeholder="Uge" max="53" maxlength="2" value="{{$parentEvent->week}}" required>
|
|
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Forbliv tom hvis billede ikke skal ændres):</label>
|
|
<input id="fileuploade" type="file" name="resource" accept="image/*" value="{{$parentEvent->resource_id}}">
|
|
<table id="table">
|
|
<tr>
|
|
<th>Aktivitets navn</th>
|
|
<th>Aktivitets beskrivelse</th>
|
|
<th>Tovholder</th>
|
|
<th>Tidsrum (Start)</th>
|
|
<th><button type="button" class="btn btn-inline btn-sde-blue" id="add2">Tilføj Række</button></th>
|
|
</tr>
|
|
@foreach($multiEvents as $multiEvent)
|
|
<tr id="{{ $multiEvent->id }}">
|
|
<td><input type="text" name="name[{{ $multiEvent->id }}][]" maxlength="255" value="{{ $multiEvent->name }}"></td>
|
|
<td><input type="text" name="description[{{ $multiEvent->id }}][]" value="{{ $multiEvent->description }}"></td>
|
|
<td><input type="text" name="accountable[{{ $multiEvent->id }}][]" maxlength="255" value="{{ $multiEvent->accountable }}"></td>
|
|
<td><input type="datetime-local" name="date[{{ $multiEvent->id }}][]" value="{{ strftime("%Y-%m-%dT%H:%M:%S", strtotime($multiEvent->date)) }}"></td>
|
|
<td><button type="button" onclick="removeRow(this)" class="btn btn-inline bg-red">Fjern Række</button></td>
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
|
|
<label class="toggle">
|
|
<input id="isNews" class="toggle__input" type="checkbox" name="newsoption" onclick="change()">
|
|
<span class="toggle__label">
|
|
<span class="toggle__text">Opret som nyhed</span>
|
|
</span>
|
|
</label>
|
|
|
|
<input id="disable" type="submit" class="btn btn-dark text-white" value="Rediger">
|
|
</form>
|
|
@endsection
|
|
@section("scripts")
|
|
<script>
|
|
$(function() {
|
|
$('form').areYouSure(
|
|
{
|
|
message: 'It looks like you have been editing something. '
|
|
+ 'If you leave before saving, your changes will be lost.'
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$value = $('#name').val();
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '{{route('events.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);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#name').on('keyup', function () {
|
|
$value = $(this).val();
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '{{route('events.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);
|
|
}
|
|
});
|
|
})
|
|
|
|
|
|
$(document).ready(function (){
|
|
$("#add2").click(function(){
|
|
$( "#table" ).append( "<tr>" +
|
|
"<td><input type='text' name='name[new][]'></td>" +
|
|
"<td><input type='text' name='description[new][]'></td>" +
|
|
"<td><input type='text' name='accountable[new][]'></td>" +
|
|
"<td><input type='datetime-local' name='date[new][]'></td>" +
|
|
"<td><button type='button' onclick='removeRow(this)' class='btn btn-inline bg-red'>Fjern Række</button></td>" +
|
|
"</tr>" );
|
|
});
|
|
});
|
|
|
|
function removeRow(el) {
|
|
var token = $("input[name='_token']").val();
|
|
|
|
if ($(el).parent().parent().attr("id") == null) {
|
|
Swal.fire({
|
|
title: 'Er du sikker?',
|
|
text: "Dette kan ikke blive ændret tilbage!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Fjern Række',
|
|
cancelButtonText: 'Annuller'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$(el).parent().parent().remove();
|
|
}
|
|
})
|
|
} else {
|
|
Swal.fire({
|
|
title: 'Er du sikker?',
|
|
text: "Dette kan ikke blive ændret tilbage!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Fjern række & aktivitet',
|
|
cancelButtonText: 'Annuller'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/multiple-events/"+$(el).parent().parent().attr("id"),
|
|
data:{'_token':token, _method: 'DELETE', 'onlyMultiEvent': true},
|
|
success: function () {
|
|
$(el).parent().parent().remove();
|
|
|
|
Swal.fire(
|
|
'Aktiviteten og rækken er fjernet!',
|
|
'',
|
|
'success'
|
|
)
|
|
},
|
|
error:function (data) {
|
|
console.log(data);
|
|
}
|
|
});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
</script>
|
|
@endsection
|