@extends("layout.main")
@section("content")

@if (Auth::can_moderate())
    <jobdisplay source="revision:{{ $rev->id }}"></jobdisplay>
@endif


	<pdf rev="{{ $rev->id }}"></pdf>
<div class="row">
	@component("thumbnail", ["rev" => $rev])
	@endcomponent

	<div class="col-lg-9 col-12">
		@if (Auth::can_moderate())
			<div class="text-end btn-group">
				<a class="btn btn-primary" href='/purge/revision/{{ $rev->id }}'><i class='fa fa-images'></i></a>
				<a class="btn btn-primary" href='/redownload/revision/{{ $rev->id }}'><i class='fa fa-recycle'></i></a>
				<a class="btn btn-danger" href='/delete/revision/{{ $rev->id }}'><i class='fa fa-trash'></i></a>
			</div>
		@endif
		<table class="table">
			@if ($rev->document)
				<tr>
					<td>
						<b>Document:</b>
					</td>
					<td>
						<a href='/document/{{ $rev->document->id }}'>
							<strong>{{ $rev->document->title }}</strong>
							{{ $rev->document->subtitle }}
							<small>{{ $rev->document->subsubtitle }}</small>
						</a>
					</td>
				</tr>

				<tr>
					<td>
						<b>Order Number:</b>
					</td>
					<td>
						{{ $rev->document->internal_id }}
					</td>
				</tr>
			@endif

			<tr>
				<td>
					<span class="my-auto align-middle"><b>Revision:</b></span>
				</td>
				<td>
					@if (Auth::can_moderate())
						<inlineedit value="{{ $rev->revno }}" url="/api/revision/{{ $rev->id }}" field="revno"/>
					@else
						{{ $rev->revno }}
					@endif
				</td>
			</tr>

			<tr>
				<td>
					<b>Pages:</b>
				</td>
				<td>
					@isset ($rev->info->Pages)
					{{ $rev->info->Pages }}
					@else
					Unknown
					@endisset
				</td>
			</tr>

			<tr>
				<td>
					<b>Original Filename:</b>
				</td>
				<td>
					{{ $rev->origtitle }}
				</td>
			</tr>

		</table>

		@if (Auth::can_moderate())
			<form action='/update_ocr_text/{{ $rev->id }}' method="POST">
		@endif
		<label for="body">OCR Text</label>
		<textarea class="form-control w-100" rows=15 name="body" 
		@if (!Auth::can_moderate())
			disabled
		@endif
		>{{ $rev->body }}</textarea>
		@if (Auth::can_moderate())
			{!! Form::submit("Update") !!}
			</form>
		@endif
	</div>
</div>
@endsection
