1
0
forked from s421507/eOSP2
eOSP2/resources/views/equipment.blade.php

114 lines
3.6 KiB
PHP
Raw Normal View History

@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
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
<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>
2020-02-01 06:24:15 +01:00
@if(auth()->user()->accessLevel() == 50)
<form id="myForm" action="{{ route('equipment.pdfALL') }}" method="post" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="fireStationID" value="{{auth()->user()->fireStationID}}">
<li onclick="myForm.submit();">Drukuj sprzęt</li>
</form>
@endif
</ul>
@endif
@endif
@endif
@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>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
@endif
</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>
@if(auth()->user()->accessLevel() == 50)
<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>
@endif
</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>