@extends('layouts.app')

@section('title', __('bms::lang.visit') . ' #' . $visit->id)

@section('content')
<section class="content-header">
    <h1><i class="fa fas fa-walking"></i> @lang('bms::lang.visit') <small>{{ optional($visit->contact)->name }}</small></h1>
    <a href="{{ route('bms.calendar.index') }}" class="tw-dw-btn tw-dw-btn-xs tw-dw-btn-outline" style="margin-top:6px;">
        <i class="fa fa-arrow-left"></i> @lang('bms::lang.activities_calendar')
    </a>
</section>

<section class="content">
    @if (session('status'))<div class="alert alert-success">{{ session('status') }}</div>@endif
    @if (session('error'))<div class="alert alert-danger">{{ session('error') }}</div>@endif

    <div class="row">
        <div class="col-md-4">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('bms::lang.client')])
                <p><strong>{{ optional($visit->contact)->name ?: '—' }}</strong></p>
                @if (optional($visit->contact)->mobile)<p><i class="fa fa-phone"></i> {{ $visit->contact->mobile }}</p>@endif
                @if (optional($visit->contact)->email)<p><i class="fa fa-envelope"></i> {{ $visit->contact->email }}</p>@endif
            @endcomponent
        </div>

        <div class="col-md-8">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('bms::lang.visit')])
                {!! Form::open(['route' => ['bms.visits.update', $visit->id], 'method' => 'PUT']) !!}
                <fieldset @if(!$canManage) disabled @endif>
                    <div class="row">
                        <div class="col-sm-6 form-group">
                            {!! Form::label('status', __('messages.status') . ':') !!}
                            {!! Form::select('status', $statuses, $visit->status, ['class' => 'form-control']) !!}
                        </div>
                        <div class="col-sm-6 form-group">
                            {!! Form::label('location_id', __('business.business_location') . ':') !!}
                            {!! Form::select('location_id', $locations, $visit->location_id, ['class' => 'form-control', 'placeholder' => __('messages.please_select')]) !!}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6 form-group">
                            {!! Form::label('visit_date', __('bms::lang.event_date') . ':') !!}
                            {!! Form::date('visit_date', optional($visit->visit_date)->format('Y-m-d'), ['class' => 'form-control']) !!}
                        </div>
                        <div class="col-sm-6 form-group">
                            {!! Form::label('visit_time', __('bms::lang.open_time') . ':') !!}
                            {!! Form::time('visit_time', $visit->visit_time, ['class' => 'form-control']) !!}
                        </div>
                    </div>
                    <div class="form-group">
                        {!! Form::label('notes', __('bms::lang.notes') . ':') !!}
                        {!! Form::textarea('notes', $visit->notes, ['class' => 'form-control', 'rows' => 2]) !!}
                    </div>
                    @if ($canManage)
                        <button type="submit" class="tw-dw-btn tw-dw-btn-primary tw-text-white">
                            <i class="fa fa-save"></i> @lang('messages.update')
                        </button>
                    @endif
                </fieldset>
                {!! Form::close() !!}
            @endcomponent
        </div>
    </div>
</section>
@endsection
