@extends('adminlte::layouts.app')

@section('htmlheader_title')
	Photo - {{ $po->id }}
@endsection

@section('contentheader_title')
	Photo #{{ $po->id }}
@endsection
@section('contentheader_description')
@endsection
@section('page_title')
	#{{ $po->id }}
@endsection

@section('main-content')
	<div class="row">
		<div class="col-3">
			<x-photo.thumbnail :id="$po->id"/>

			<div class="pagination justify-content-center">
				<x-pagination.nav :o="$po" pre="p"/>
			</div>
		</div>

		<div class="col-9">
			<div class="card">
				<div class="card-body">
					<div class="float-right">
						@if(! $po->scanned)<button class="btn btn-sm btn-info">TO SCAN</button>@endif
						@if($po->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif
						@if($po->ignore_duplicate)<button class="btn btn-sm btn-secondary">DUPLICATE IGNORE</button>@endif
						@if($po->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
					</div>
					<div class="dl-horizontal">
						<dt>Signature</dt><dd>{{ $po->signature(TRUE) }}</dd>
						<dt>Filename</dt><dd>{{ $po->filename }}<dd>

						@if($po->shouldMove())
							<dt>NEW Filename</dt><dd>{{ $po->file_name() }}<dd>
						@endif

						<dt>Size</dt><dd>{{ number_format($po->file_size) }}<dd>
						<dt>Dimensions</dt><dd>{{ $po->dimensions }} @ {{ $po->orientation }}<dd>
						<hr>
						<dt>Date Taken</dt><dd>{{ $po->created?->format('Y-m-d H:i:s') }}<dd>

						@if($po->scanned)
							<dt>Camera</dt><dd>{{ $po->device}}<dd>
							<hr>
							<dt>Location</dt>
							<dd>
								@if(! $po->gps)
									UNKNOWN
								@else
									<x-map :o="$po"/>
								@endif
							</dd>
						@endif

						@if($x=$po->Imagick_getImageProperties())
							<hr>

							<dt>Exif Data</dt><dd>
								<table class="table table-sm table-striped">
									@foreach($x as $k => $v)
										<tr>
											<th>{{ $k }}</th><td>{{ $v }}<td>
										</tr>
									@endforeach
								</table>
							</dd>
						@endif

						@if(($x=$po->myduplicates()->get())->count())
							<hr>
							<dt>Duplicates</dt>
							<dd>
								@foreach($x as $oo)
									@if(! $loop->first)| @endif
									<x-info :id="$oo->id"/>
								@endforeach
							</dd>
						@endif
					</div>
				</div>
			</div>

			@if($po->remove)
				<form action="{{ url('p/undelete',$po->id) }}" method="POST">
					<button class="btn btn-primary">Undelete</button>

			@else
				<form action="{{ url('p/delete',$po->id) }}" method="POST">
					<button class="btn btn-danger">Delete</button>

			@endif
					@csrf
				</form>
		</div>
	</div>
@endsection