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

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

@section('contentheader_title')
	Photo #{{ $o->id }}
@endsection
@section('contentheader_description')
	@if($o->duplicate)<button class="btn btn-sm btn-warning">DUPLICATE</button>@endif @if($o->remove)<button class="btn btn-sm btn-danger">PENDING DELETE</button>@endif
@endsection
@section('page_title')
	#{{ $o->id }}
@endsection

@section('main-content')
	<div class="row">
		<div class="col-3">
			<a href="{{ url('p/view',$o->id) }}"><img class="p-3" src="{{ url('p/thumbnail',$o->id) }}"></a>

			<span class="pagination justify-content-center">
				<nav>
				<ul class="pagination">
					<li class="page-item @if(! $x=$o->previous())disabled @endif" aria-disabled="@if(! $x)true @else false @endif" aria-label="&laquo; Previous">
						<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}">&lt;&lt;</a>
					</li>

					<li class="page-item active" aria-current="page"><span class="page-link">{{ $o->id }}</span></li>

					<li class="page-item @if(! $x=$o->next())disabled @endif" aria-disabled="@if(! $x)true @else false @endif" aria-label="&laquo; Previous">
						<a class="page-link" href="{{ $x ? url('p/info',$x->id) : '#' }}">&gt;&gt;</a>
					</li>
				</ul>
				</nav>
			</span>
		</div>

		<div class="col-9">
			<div class="dl-horizontal">
				<dt>Signature</dt><dd>{{ $o->signature(TRUE) }}</dd>
				<dt>Filename</dt><dd>{{ $o->file_path(TRUE) }}<dd>

				@if ($o->shouldMove())
					<dt>NEW Filename</dt><dd>{{ $o->file_path(TRUE,TRUE) }}<dd>
				@endif

				<dt>Size</dt><dd>{{ $o->file_size() }}<dd>
				<dt>Dimensions</dt><dd>{{ $o->dimensions }} @ {{ $o->orientation }}<dd>
				<hr>
				<dt>Date Taken</dt><dd>{{ $o->date_taken() }}<dd>
				<dt>Camera</dt><dd>{{ $o->device() }}<dd>
				<hr>
				<dt>Location</dt><dd>
				@if($o->gps() == 'UNKNOWN')
					UNKNOWN
				@else
					<div id="map" style="width: 400px; height: 300px"></div>
				@endif

				</dd>
				<br/>
				<dt>Exif Data</dt><dd>
					<table>
						@foreach ($o->properties() as $k => $v)
							<tr><th>{{ $k }}<><td>{{ $v }}<td></tr>
						@endforeach
					</table>
				</dd>
			</div>

			@if ($o->remove)
				<form action="{{ url('p/undelete',$o->id) }}" method="POST">
					{{ csrf_field() }}

					<button class="btn btn-primary">Undelete</button>
			@else
				<form action="{{ url('p/delete',$o->id) }}" method="POST">
					{{ csrf_field() }}

					<button class="btn btn-danger">Delete</button>
			@endif
				</form>
		</div>
	</div>
@endsection

@section('page-scripts')
	@if($o->gps() !== 'UNKNOWN')
		@js('//maps.google.com/maps/api/js?sensor=false')

		<script type="text/javascript">
			var myLatLng = {lat: {{ $o->gps_lat }}, lng: {{ $o->gps_lon }}};
			var map = new google.maps.Map(document.getElementById("map"), {
				zoom: 16,
				center: myLatLng,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			});
			var marker = new google.maps.Marker({
				map: map,
				position: myLatLng,
			});
		</script>
	@endif
@append