 @extends('adminlte::page') @section('content')
<?php Fun::lang()?>
<div class="title-add">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li> <a class="ng-binding" href="#"><i class="fa fa-dashboard"></i> Dashboard</a> </li>
            <li><a href="#">Operation</a></li>
            <li><a href="#">Manage Client</a></li>
            <li><a href="#">Client Relationship List</a></li>
            <li><a href="#">Edit</a></li>
        </ul>
    </div>
</div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-page">
                        <div class="pull-left">
                            <h3>Edit Client Relationship</h3>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                @if (count($errors) > 0)
                <div class="alert-message alert-danger">
                    <strong>Whoops!</strong> There were some problems with your input.
                    <ul>
                        @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
                @endif
                <div class="form-wrapper">
                    {!! Form::model($client_re, ['method' => 'PATCH','route' => ['clients-relationship.update', $client_re->id],'enctype'=>'multipart/form-data']) !!}
                    <div class="row">
                        <!-- <div class="form-group col-sm-6 col-xs-12">
                            <label class="required">Relationship</label>
                            {!! Form::text('clientship_is', null, array('placeholder' => 'relationship','class' => 'form-control','required')) !!}
                        </div> -->
                        <div class="form-group col-sm-6 col-xs-12">
                            <label class="required">Client Fullname</label>
                            {!! Form::text('clientship_fullname', null, array('placeholder' => 'Client Fullname','class' => 'form-control','required')) !!}
                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label class="required">Gender</label>
                            <select name="clientship_gender" id="" class="select2 form-control">
                                <option value="<?= $client_re['clientship_gender'] ?>"><?= $client_re['clientship_gender'] ?></option>
                                <option value="Male">Male</option>
                                <option value="Female">Female</option>
                            </select>

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label class="required">Client DOB</label>
                            {!! Form::text('clientship_dob', null, array('placeholder' => 'Client DOB','class' => 'form-control date_picker','required')) !!}

                        </div>

                        <div class="form-group col-sm-6 col-xs-12">

                            <label class="required">Nationality</label>
                            {!! Form::text('clientship_national', null, array('placeholder' => 'Nationality','class' => 'form-control','required')) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Phone</label>
                            {{-- {!! Form::text('clientship_phone1', null, array('placeholder' => 'Phone','class' => 'form-control number-only','required')) !!} --}}
                            <input type="text" class="form-control number-only" name="clientship_phone1" value="{{ $client_re->clientship_phone1 }}" 
                                        data-inputmask="'mask': ['999-999-9999', '+099 99 99 9999[9]-9999']" data-mask placeholder="Phone Number">

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label for="">Phone 2</label>
                            {{-- {!! Form::text('clientship_phone2', null, array('placeholder' => 'Phone 2','class' => 'form-control number-only')) !!} --}}
                            <input type="text" class="form-control number-only" name="clientship_phone2" value="{{ $client_re->clientship_phone2 }}" 
                                        data-inputmask="'mask': ['999-999-9999', '+099 99 99 9999[9]-9999']" data-mask placeholder="Phone Number">

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label class="required">Personal Type</label>
                            {!! Form::select('personal_type', ["1"=>"By ID Card","2"=>"By Passport"],null, array('class' => 'form-control select2','required',"id"=>'personal-type')) !!}

                        </div>
                        <div id="append-personal-type">
                            
                        </div>
                        
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Province </label>
                            {!! Form::select('p_province', $provinces, null, ['class' => 'form-control select2','id'=>'p_province']) !!}
                            <span class="focus-border"></span>

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>District </label>
                            {!! Form::select('p_district', $districts, null, ['class' => 'form-control select2','id'=>'p_district']) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Commune </label>
                            {!! Form::select('p_commune', $communes, null, ['class' => 'form-control select2','id'=>'p_commune']) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Village </label>
                            {!! Form::select('p_village', $villages, null, ['class' => 'form-control select2','id'=>'p_village']) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">
                            <label class="">House</label>
                            {!! Form::text('house', null, array('placeholder' => 'House','class' => 'form-control')) !!}
                        </div>
                        <div class="form-group col-sm-6 col-xs-12">
                            <label class="">Street</label>
                            {!! Form::text('street', null, array('placeholder' => 'Street','class' => 'form-control')) !!}
                        </div>
                        <div class="col-sm-12 col-xs-12">
                            <div class="form-group">
                                <button type="submit" class="button_sm button_primary pull-right"><span class="fa fa-save"></span> Save</button>
                                <button type="button"  onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                        <span class=" fa fa-arrow-circle-left"></span> Back</button>

                            </div>
                        </div>
                </div>

                {!! Form::close() !!}
            </div>
        </div>
    </div>
    </div>
    @endsection @section('js')
    <script type="text/javascript" src="{{asset('assets/controller/location.js')}}"></script>
    <script type="text/javascript">
        function append_personal_type(type){
            var opt=``;
            if(type==1){
                opt = ` <div class="form-group col-sm-6 col-xs-12">

                        <label class="required">ID Card</label>
                        {!! Form::text('clientship_cardid',$client_re->clientship_cardid, array('placeholder' => 'ID Card','class' => 'form-control','required')) !!}

                    </div>
                    <div class="form-group col-sm-6 col-xs-12">

                        <label>ID Card Date</label>
                        {!! Form::text('clientship_datecard', empty($client_re->clientship_datecard)?"":date("d-m-Y",strtotime($client_re->clientship_datecard)), array('placeholder' => 'ID Card Date','class' => 'form-control date_picker')) !!}

                    </div>
                    <div class="form-group col-sm-6 col-xs-12">

                        <label for="">ID Card Date Valid</label>
                        {!! Form::text('clientship_cardvalid', empty($client_re->clientship_cardvalid)?"":date("d-m-Y",strtotime($client_re->clientship_cardvalid)), array('placeholder' => 'ID Card Date Valid','class' => 'form-control date_picker')) !!}

                    </div>`;
            }
            else{
                opt = `<!--Client with Passport-->
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Passport Number</label>
                            {!! Form::text('passport_number', $client_re->passport_number, array('placeholder' => 'Passport Number','class' => 'form-control')) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12">

                            <label>Passport Date Of Issue</label>
                            {!! Form::text('passport_date_issue', empty($client_re->passport_date_issue)?"":date("d-m-Y",strtotime($client_re->passport_date_issue)), array('placeholder' => 'Passport Date Of Issue','class' => 'form-control date_picker','autocomplete'=> 'off')) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12 ">

                            <label for="">Passport Expiry Date</label>
                            {!! Form::text('passport_expiry_date', empty($client_re->passport_expiry_date)?"":date("d-m-Y",strtotime($client_re->passport_expiry_date)), array('placeholder' => 'Passport Expiry Date','class' => 'form-control date_picker','autocomplete'=> 'off')) !!}

                        </div>
                        <div class="form-group col-sm-6 col-xs-12 ">

                            <label>Country Of Passport</label>
                            {!! Form::text('country_of_passport', $client_re->country_of_passport, array('placeholder' => 'Country Of Passport','class' => 'form-control')) !!}

                        </div>

                        <div class="form-group col-sm-6 col-xs-12">
                            <label>Visa Type</label>
                            {!! Form::text('visa_type', $client_re->visa_type, array('placeholder' => 'Visa Type','class' => 'form-control')) !!}
                        </div>
                        <div class="form-group col-sm-6 col-xs-12">
                            <label>Intended Date Of Entry</label>
                            {!! Form::text('intended_date_of_entry',empty($client_re->intended_date_of_entry)?"":date("d-m-Y",strtotime($client_re->intended_date_of_entry)), array('placeholder' => 'Intended Date Of Entry','class' => 'form-control date_picker','autocomplete'=> 'off')) !!}
                        </div>
                        <div class="form-group col-sm-6 col-xs-12">
                            <label>Port Of Entry</label>
                            {!! Form::text('port_of_entry', $client_re->port_of_entry, array('placeholder' => 'Port Of Entry','class' => 'form-control')) !!}
                        </div>
                        <!--Client with Passport-->`;
            }

            $("#append-personal-type").empty();
            $("#append-personal-type").append(opt);
            $(".date_picker").datepicker();
        }
        $(document).ready(function  () {
            append_personal_type($("#personal-type").val());
        });
    $(document).on("change","#personal-type",function(){
        append_personal_type($(this).val());
    });
    </script>
    @endsection