@extends('adminlte::page')

@section('content_header')
<h1>Lista Documenti</h1>
@endsection


@section('content')

	<div class="container">
    	<!-- Content here -->
    	<div class="row">
            <div class="col-lg-12">
            	<form action="" method="POST" enctype='multipart/form-data'>
                	@csrf
                	<div class="mb-3">
                		<label for="descrizione" class="form-label">Descrizione</label>
                		<input type="text" class="form-control" id="descrizione" name="descrizione">
                	</div>
                	<div class="mb-3">
                		<label for="file" class="form-label">File</label>
                		<input type="file" class="form-control" id="file" name="filename">
                	</div>
                	<div class="mb-3">

						<!-- {issue #5} -->
						<input type="hidden" name="entity" value="{{$entity}}">
						<input type="hidden" name="entity_id" value="{{$id}}">
						<!-- {issue #5} END -->
                		<button type="submit" class="btn btn-primary">Submit</button>
                	</div>
            	</form>
    		</div>
    	</div>
<div class="row">
 	<div class="col-lg-12">
    	<div class="panel panel-default">
        	<div class="panel-heading">
                Lista dei documenti
            </div>
            <div class="panel-body">
    			<div class="table-responsive" >
           			<table class="table table-striped table-bordered table-hover" id="listadoc">
                		<thead>
            			<tr>
            				<th>Descrizione</th>
            				<th>Azione</th>
            			</tr>
    					</thead>
    					<tbody>
    					@foreach($documenti as $documento)
    					<tr>

    						<td><a href="{{ asset('storage/'.$documento->filename) }}"><i class="fas fa-fw fa-file"></i>&nbsp;{{ $documento->descrizione }}</a></td>

    						<td>
                				<a class="btn btn-primary" href="/admin/doc_update?id={{ $documento->id }}">Edit</a>&nbsp;
                				<a class="btn btn-danger" href="/admin/doc_delete?id={{ $documento->id }}">Elimina</a>&nbsp;
            				</td>
    					</tr>
    					@endforeach
    					</tbody>
                	</table>
    			</div>
    		</div>
		</div>
	</div>
</div>

 <!-- /.col-lg-12 -->

@endsection
@section('js')
<script src="/js/app/listadoc.js"></script>
@endsection
