<script>
    $(document).ready(function (){

        $('#unit-manager-list').select2();
        $('#select-list').select2();
        $('#select-file-no').select2();
        $('#select-phone-no').select2();
        $('#select-id-no').select2();

        $('input[name="search-parameter"]').on('change', function (){
            var type = $('input[name="search-parameter"]:checked').val();

            if(type == 1){
                $('#client-name').show();
                $('#client-file-no').hide();
                $('#client-phone-no').hide();
                $('#client-id-no').hide();
            }else if(type == 2){
                $('#client-name').hide();
                $('#client-file-no').show();
                $('#client-phone-no').hide();
                $('#client-id-no').hide();
            }else if(type == 3){
                $('#client-name').hide();
                $('#client-file-no').hide();
                $('#client-phone-no').show();
                $('#client-id-no').hide();
            }else if(type == 4){
                $('#client-name').hide();
                $('#client-file-no').hide();
                $('#client-phone-no').hide();
                $('#client-id-no').show();
            }
        })

    })
</script>
{!! Form::model(isset($clients) ?? [], ['method'=>'POST']) !!}
<div class="error" style="text-align: center;">On this Window, You can Search a Client Using Different Parameters Below</div>
<div class="guestDetails_inputDivider"></div>
<div id="search-client-modal">
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel">
            Client Name
            {!! Form::radio('search-parameter', '1', true, ['id'=>'name']) !!}
        </div>
    </div>
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel">
            Client File Number
            {!! Form::radio('search-parameter', '2', false,['id'=>'file-no']) !!}
        </div>
    </div>
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel">
            Client Phone Number
            {!! Form::radio('search-parameter', '3', false,['id'=>'phone-number']) !!}
        </div>
    </div>
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel">
            ID Number
            {!! Form::radio('search-parameter', '4', false,['id'=>'id-number']) !!}
        </div>
    </div>

    <div class="guestDetails_inputDivider1"></div>
    <div class="guestDetails_input">
        <div class="guestDetails_inputLabel">Select Section</div>
        <div id="client-name">
            <div class="guestDetails_input" id="client-name-search">
                <select class="selected-option" name="client-name" id="select-list" style="width: 450px">
                    <option value="">Select Client by Name</option>
                    @isset($clients)
                        @foreach($clients as $client)
                            <option value="{{$client->c_id}}">{!! strtoupper($client->nms) !!}</option>
                        @endforeach
                    @endisset
                </select>

{{--                {!! Form::select('client-name', $clients, null, ['placeholder' => 'Select Client by Name', 'id'=>'select-list']) !!}--}}

            </div>
        </div>

        <div id="client-file-no" style="display: none">
            <div class="guestDetails_input" id="client-name-search">
                <select class="selected-option" name="client-file-no" id="select-file-no" style="width: 450px">
                    <option value="">Select Client by File No</option>
                    @isset($clients)
                        @foreach($clients as $client)
                            @if($client->fl_no != "")
                            <option value="{{$client->c_id}}">{{$client->fl_no}} - {!! strtoupper($client->nms) !!}</option>
                            @endif
                        @endforeach
                    @endisset
                </select>
            </div>
        </div>

        <div id="client-phone-no" style="display: none">
            <div class="guestDetails_input" id="client-phone-search">
                <select class="selected-option" name="client-phone-no" id="select-phone-no" style="width: 450px">
                    <option value="">Select Client by Phone No</option>
                    @isset($clients)
                        @foreach($clients as $client)
                            @if($client->pn != "")
                                <option value="{{$client->c_id}}">{{$client->pn}} - {!! strtoupper($client->nms) !!}</option>
                            @endif
                        @endforeach
                    @endisset
                </select>
            </div>
        </div>

        <div id="client-id-no" style="display: none">
            <div class="guestDetails_input" id="client-id-search">
                <select class="selected-option" name="client-id-no" id="select-id-no" style="width: 450px">
                    <option value="">Select Client by ID No</option>
                    @isset($clients)
                        @foreach($clients as $client)
                            @if($client->id_no != "")
                                <option value="{{$client->c_id}}">{{$client->id_no}} - {!! strtoupper($client->nms) !!}</option>
                            @endif
                        @endforeach
                    @endisset
                </select>
            </div>
        </div>
    </div>
    <div class="guestDetails_inputDivider"></div>
    <p><b class="error">If Client is not in the Database, consider Creating the Client by Clicking on the below button</b></p>
    <button onclick="window.location='/add-client/General'" class="navButtons" type="button" style="background-color: #2c79ab; margin-left: 0;margin-bottom: 0"><i class="fa fa-user-plus" aria-hidden="true"></i> &nbsp;&nbsp;Add New Client</button>
</div>
{!! Form::close() !!}
