eOSP2/resources/views/equipment.blade.php

97 lines
2.8 KiB
PHP

@extends('layout.app')
<meta name="csrf-token" content="{{ csrf_token() }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent
<ul>
<a href="sprzet/add"><li>Dodaj<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@stop
@section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<p align='center'>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Nazwa</th>
<th>Ilość</th>
<th>Param. charakterystyczny</th>
<th>Operacja</th>
</tr>
</thead>
@php
$i=1;
@endphp
@foreach($equipment as $item)
<tr>
<th>{{$i}}</th>
<td id="name{{ $item->id }}">{{ $item->name }}</td>
<td id="amount{{ $item->id }}">{{ $item->amount }}</td>
<td id="parameter{{ $item->id }}">{{ $item->parameter }}</td>
<td>
<a href="{{ URL::asset('sprzet/edit/'.$item->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$item->id}}" onclick="deleteButton('{{$item->id}}')">Usuń</button>
</td>
</tr>
@php
$i++;
@endphp
@endforeach
</table>
{{ $equipment->links() }}
</p>
@endif
@else
Brak autoryzacji
@endif
@stop
<script>
function deleteButton(itemID){
swal.fire({
title: "Czy chcesz usunąć sprzęt?",
width: 'auto',
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
showCancelButton: true,
}).then((result) => {
if(result.value){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "sprzet/"+itemID,
type: 'DELETE',
data: {
"id": itemID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
</script>