@extends('layouts.app')
@section('title', $document->title)
@section('content')
<section class="content-header">
    <h1>{{ $document->title }}<small> {{ optional($document->type)->label }}</small></h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-4">
            @component('components.widget', ['title' => __('meddocuments::lang.details')])
                <dl class="dl-horizontal">
                    <dt>@lang('meddocuments::lang.doc_type')</dt><dd>{{ optional($document->type)->label }}</dd>
                    <dt>@lang('meddocuments::lang.status')</dt><dd>@lang('meddocuments::lang.status_' . $document->status)</dd>
                    <dt>@lang('meddocuments::lang.patient')</dt><dd>{{ $document->contact_id ? '#' . $document->contact_id : '—' }}</dd>
                    <dt>@lang('meddocuments::lang.entity')</dt><dd>{{ $document->entity_type ? class_basename($document->entity_type) . ' #' . $document->entity_id : '—' }}</dd>
                    <dt>@lang('meddocuments::lang.tags')</dt><dd>{{ is_array($document->tags) ? implode(', ', $document->tags) : '—' }}</dd>
                    <dt>@lang('meddocuments::lang.updated')</dt><dd>{{ optional($document->updated_at)->format('Y-m-d H:i') }}</dd>
                </dl>
                <a href="{{ route('meddoc.documents.view', $document->id) }}" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-eye"></i> @lang('meddocuments::lang.view')</a>
                <a href="{{ route('meddoc.documents.print', $document->id) }}" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-print"></i> @lang('meddocuments::lang.print')</a>
                <a href="{{ route('meddoc.documents.download', $document->id) }}" class="btn btn-default btn-sm"><i class="fa fa-download"></i> @lang('meddocuments::lang.download')</a>
            @endcomponent
        </div>
        <div class="col-md-8">
            @component('components.widget', ['title' => __('meddocuments::lang.version_history')])
                <table class="table table-bordered table-striped">
                    <thead><tr><th>#</th><th>@lang('meddocuments::lang.file')</th><th>@lang('meddocuments::lang.size')</th><th>@lang('meddocuments::lang.uploaded')</th></tr></thead>
                    <tbody>
                    @foreach($document->versions as $v)
                        <tr @if($v->id == $document->current_version_id) class="success" @endif>
                            <td>v{{ $v->version_no }}</td>
                            <td><a href="{{ route('meddoc.documents.view', [$document->id, 'version' => $v->id]) }}" target="_blank">{{ $v->original_name }}</a></td>
                            <td>{{ $v->humanSize() }}</td>
                            <td>{{ optional($v->created_at)->format('Y-m-d H:i') }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            @endcomponent
        </div>
    </div>
</section>
@endsection
