@extends('adminlte::page')

@section('content_header')
<h1> Dettaglio contratto</h1>
@endsection

@section('content')
<div class="container">
	<div class="row">
		<div class="col">
			<div class="card card-outline card-primary">
				<div class="card-header">
					<h3 class="card-title">Dati del contratto</h3>
				<div class="card-tools">
					<button type="button" class="btn btn-tool" data-card-widget="collapse">
						<i class="fas fa-minus"></i>
					</button>
				</div>
			</div>
			<div class="card-body">
				@foreach($contratto as $contr)
				<div class="panel-body">
					<div class="row">
						<div class="col-xs-2 p-3">Nome:</div>
						<div class="col-xs-8 p-3">
							<b>{{$contr->nome }}</b>
						</div>
					</div>

					<div class="row" hidable="">
						<div class="col-xs-2 p-3">Fornitore</div>
						<div class="col-xs-8 p-3">
							<b>{{$contr->fornitore }}</b>
						</div>
					</div>
					<div class="row" hidable="">
						<div class="col-xs-2 p-3">Data Inizio</div>
						<div class="col-xs-3 p-3">
							<b>{{ date('d/m/Y',strtotime($contr->datainizio)) }}</b>
						</div>
						<div class="col-xs-2 p-3">Data Termine</div>
						<div class="col-xs-3 p-3">
							<b>{{ date('d/m/Y',strtotime($contr->datatermine)) }}</b>
						</div>
					</div>
					<div class="row" hidable="">
						<div class="col-xs-2 p-3">Stato</div>
						<div class="col-xs-3 p-3">
							<b>{{$contr->stato }}</b>
						</div>
						<div class="col-xs-2 p-3">Scadenza pagamento</div>
						<div class="col-xs-3 p-3">
							<b>{{ date('d/m/Y',strtotime($contr->scadenzapagamento)) }}</b>
						</div>
					</div>
					<div class="row" hidable="">
						<div class="col-xs-1 p-3">Importo</div>
						<div class="col-xs-1 p-3">
							<b>{{$contr->importo }}</b>
						</div>
						
						<div class="col-xs-2 p-3">Note</div>
						<div class="col-xs-8 p-3">
							<b>{{$contr->note }}</b>
						</div>
					</div>
					{{ $contratto_id=$contr->id}}
				</div>
				@endforeach
			</div>
		</div>
		<div class="col">
			<div class="card card-outline card-primary">
				<div class="card-header">
					<h3 class="card-title">Documenti caricati</h3>
				<div class="card-tools">
					<button type="button" class="btn btn-tool" data-card-widget="collapse">
						<i class="fas fa-minus"></i>
					</button>
				</div>
			</div>
			<div class="card-body">
				<table class="table table-striped table-bordered table-hover" id="contratti" data-page-length='10'>
					<thead>
						<tr>
							<th>Descrizione</th>
							<th>Documento</th>
							<th>Azione</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($docs as $doc)
						<tr>
							<td>{{$doc->descrizione}}</td>
							<td><a href="/storage/{{$doc->filename}}" target="_new"><i class="fa-regular fa-file"></i></td>
							<td><a href="/admin/contrattidoc/doc?id={{$doc->id}}&entity_id={{ $contr->id }}" class="button">Canc</a></td>
						</tr>
						@endforeach
					</tbody>
				</table>
		</div>
	</div>
	
	<div class="row p-2">
		<a href="/admin/movimenti/docs?entity=1&entity_id={{ $contr->id }}" class="button">Nuovo documento</a>
	</div>
	<div class="row p-2">
		<div class="col">
		
		</div>
	</div>
		
</div>


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