eOSP2/resources/views/equipment.blade.php

96 lines
2.7 KiB
PHP
Raw Normal View History

@extends('layout.app')
<meta name="csrf-token" content="{{ csrf_token() }}">
@section('left-menu')
@parent
<ul>
2020-01-05 14:36:21 +01:00
<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
2020-01-05 14:36:21 +01:00
@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>