<div class="modal-dialog" role="document">
    <div class="modal-content">
        {!! Form::open(['route' => ['meddoc.shares.store', $document->id], 'class' => 'meddoc-form']) !!}
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">@lang('meddocuments::lang.share_document') — {{ $document->title }}</h4>
        </div>
        <div class="modal-body">
            <p class="text-muted">@lang('meddocuments::lang.share_help')</p>
            <div class="form-group">
                {!! Form::label('days', __('meddocuments::lang.expires_in_days') . ':') !!}
                {!! Form::number('days', 7, ['class' => 'form-control', 'min' => 1, 'max' => 365, 'placeholder' => __('meddocuments::lang.no_expiry')]) !!}
                <p class="help-block">@lang('meddocuments::lang.expiry_help')</p>
            </div>
            <div class="form-group" style="display:none;">
                {!! Form::label('share_url', __('meddocuments::lang.share_link') . ':') !!}
                <input type="text" class="form-control meddoc-share-url" readonly onclick="this.select();">
            </div>

            @if($shares->count())
                <hr>
                <h5>@lang('meddocuments::lang.existing_links')</h5>
                <table class="table table-condensed">
                    <thead><tr><th>@lang('meddocuments::lang.expires')</th><th>@lang('meddocuments::lang.opens')</th><th>@lang('meddocuments::lang.status')</th><th></th></tr></thead>
                    <tbody>
                    @foreach($shares as $s)
                        <tr>
                            <td>{{ $s->expires_at ? $s->expires_at->format('Y-m-d H:i') : __('meddocuments::lang.no_expiry') }}</td>
                            <td>{{ $s->access_count }}</td>
                            <td>
                                @if($s->isRevoked())<span class="label label-danger">@lang('meddocuments::lang.revoked')</span>
                                @elseif($s->isExpired())<span class="label label-default">@lang('meddocuments::lang.expired')</span>
                                @else<span class="label label-success">@lang('meddocuments::lang.active')</span>@endif
                            </td>
                            <td>
                                @if($s->isValid())
                                <button type="button" class="btn btn-xs btn-danger meddoc-post" data-href="{{ route('meddoc.shares.revoke', $s->id) }}">@lang('meddocuments::lang.revoke')</button>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            @endif
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-warning"><i class="fa fa-share-alt"></i> @lang('meddocuments::lang.create_link')</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">@lang('messages.close')</button>
        </div>
        {!! Form::close() !!}
    </div>
</div>
