@extends('pro.clients.view')
@section('content-inner')

    <div class="form-contents"><div class="failed-form-contents">

    <h4 class="d-flex m-0 p-3 stag-heading stag-heading-modal">
        <div>Edit Source</div>
        <div class="ml-auto">
            <a class="text-secondary" href="#" up-close>
                <i class="fa fa-times"></i>
            </a>
        </div>
    </h4>

    <form action="/post-to-api"
          up-target="#main-content" up-history="false" up-fail-target=".failed-form-contents" up-reveal="false"
          method="post" enctype="multipart/form-data"
          class="border-top px-3 pt-3 pb-1 custom-submit">
        @csrf

        @if (session('message'))
            <div class="alert alert-danger">{{ session('message') }}</div>
        @endif

        <input type="hidden" name="_uid" value="{{ $record->uid }}">
        <input type="hidden" name="_api" value="/api/client/editSource">
        <input type="hidden" name="_success" value="{{route('clients-view', ['uid' => $record->uid])}}">
        <input type="hidden" name="_return" value="{{route('clients_SINGLE-ACTION_editSource', ['uid' => $record->uid])}}">
        <div class='form-group mb-3'>
<label class='control-label'>Source *</label>
<input class='form-control' type='text' name='source' value='{{ old('source') ? old('source') : $record->source }}' required>
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source Memo </label>
<input class='form-control' type='text' name='sourceMemo' value='{{ old('sourceMemo') ? old('sourceMemo') : $record->source_memo }}' >
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source At </label>
<input class='form-control' type='date' name='sourceAt' value='{{ old('sourceAt') ? old('sourceAt') : $record->source_at }}' >
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source Detail </label>
<input class='form-control' type='text' name='sourceDetail' value='{{ old('sourceDetail') ? old('sourceDetail') : $record->source_detail }}' >
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source Client </label>
<select class='form-control' name='sourceClientUid' value='{{ old('sourceClientUid') ? old('sourceClientUid') : '' }}' >
<option value=''>-- Select --</option>
<?php $dbOptions = \Illuminate\Support\Facades\DB::table('client')->get(); ?>
<?php foreach($dbOptions as $o): ?>
<option <?= $o->uid === (old('sourceClientUid') ? old('sourceClientUid') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->name_first ?> (<?= $o->uid ?>)</option>
<?php endforeach; ?>
</select>
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source Pro </label>
<select class='form-control' name='sourceProUid' value='{{ old('sourceProUid') ? old('sourceProUid') : '' }}' >
<option value=''>-- Select --</option>
<?php $dbOptions = \Illuminate\Support\Facades\DB::table('pro')->get(); ?>
<?php foreach($dbOptions as $o): ?>
<option <?= $o->uid === (old('sourceProUid') ? old('sourceProUid') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
<?php endforeach; ?>
</select>
</div>
<div class='form-group mb-3'>
<label class='control-label'>Source Facility </label>
<select class='form-control' name='sourceFacilityUid' value='{{ old('sourceFacilityUid') ? old('sourceFacilityUid') : '' }}' >
<option value=''>-- Select --</option>
<?php $dbOptions = \Illuminate\Support\Facades\DB::table('facility')->get(); ?>
<?php foreach($dbOptions as $o): ?>
<option <?= $o->uid === (old('sourceFacilityUid') ? old('sourceFacilityUid') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->name ?> (<?= $o->uid ?>)</option>
<?php endforeach; ?>
</select>
</div>
        <div class="form-group mb-3 d-flex justify-content-center">
            <button class="btn btn-sm btn-primary mr-3 px-5">Submit</button>
            <a href="{{route('clients-view', ['uid' => $record->uid])}}" class="btn btn-sm btn-default px-5" up-close>Cancel</a>
        </div>
    </form>

    </div></div>

@endsection
