<?php echo $__env->make('messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
$roles = Config::get('params.roles');
$required = '';
//d($roles,1);
//$currency = $currencies[Config::get('params.currency_default')]['symbol'];
?>

<div class="row">
    <div class="col-sm-6">
        <div class="form-group">
            <?php echo Form::label('First Name'); ?>

            <?php echo Form::text('firstName', null, ['class' => 'form-control', $required]); ?>

        </div>
    </div>


    <div class="col-sm-6">
        <div class="form-group">
            <?php echo Form::label('Last Name'); ?>

            <?php echo Form::text('lastName', null, ['class' => 'form-control', $required]); ?>

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

<div class="row">
    <div class="col-sm-6">
        <div class="form-group">
            <?php echo Form::label('Email'); ?>

            <?php echo Form::text('email', null, ['class' => 'form-control', $required]); ?>

        </div>
    </div>

    <div class="col-sm-6">
        <div class="form-group">
            <?php echo Form::label('Phone'); ?>

            <?php echo Form::text('phone', null, ['class' => 'form-control', $required]); ?>

        </div>
    </div>
</div>
<div class="row">
    <div class="col-sm-6">
        <div class="form-group">
            <?php echo Form::label('Password'); ?>

            <?php echo Form::password('password', ['placeholder' => 'Password', 'class' => 'form-control']); ?>

        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <p class="mb-0">Type</p>
            <select name="type" id="type" class="form-control">
                <option value="1" <?php echo e($model->type == 1 ? 'selected' : ''); ?>>Home Owner</option>
                <option value="2"<?php echo e($model->type == 2 ? 'selected' : ''); ?>>Landlord</option>

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


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

            <p class="mb-0">Post Code</p>
            <input type="text" name="postcode_lookup" id="postcode_lookup" class="form-control"
                aria-label="Input group example" aria-describedby="btnGroupAddon"
                value="<?php echo e($model->address->postcode); ?>">
        </div>
    </div>
    <div class="col-md-6 form-group custom-select2" style="" id="div_addresses">
        <label>Select Your Address</label>
        <select id="addresses" name="addresses" class="custom-select"></select>
    </div>




    <div class="col-md-12 form-group">
        
        <div class="row address-manually">
            <div class="col-md-6 form-group">
                <label class="font-weight-bold">Address Line</label>
                <input type="text" name="address" id="address" class="form-control"
                    value="<?php echo e($model->address->address1); ?>">
            </div>
            <div class="col-md-6 form-group">
                <label class="font-weight-bold">Address Line 2</label>
                <input type="text" name="address2" id="address2" class="form-control"
                    value="<?php echo e($model->address->address2); ?>">
            </div>
            <div class="col-md-6 form-group">
                <label class="font-weight-bold">City</label>
                <input type="text" name="city" id="city"
                    class="form-control"value="<?php echo e($model->address->city); ?>">
            </div>
            <div class="col-md-6 form-group">
                <label class="font-weight-bold">Postcode</label>
                <input type="text" name="postcode" id="postcode" value="<?php echo e($model->address->postcode); ?>"
                    class="form-control">
            </div>
        </div>
    </div>

</div>





<div class="row">
    <div class="col-sm-2">
        <div class="d-flex justify-content-start flex-wrap">
            <div class="custom-control custom-switch custom-switch-success mr-2 mb-1">
                <p class="mb-0">Status</p>
                <input type="checkbox" <?php if(isset($model->status) && $model->status == 'Active'): ?> checked <?php endif; ?> class="custom-control-input"
                    name="status" id="status" value="1">
                <label class="custom-control-label" for="status">Status</label>
            </div>
        </div>
    </div>
</div>
<br clear="all" />
<div class="row">
    <div class="col-md-8">
        <button type="submit" class="btn btn-primary mr-1 mb-1 waves-effect waves-light">Save</button>
        <a href="<?php echo e(url('admin/customers')); ?>" class="btn btn-outline-warning mr-1 mb-1 waves-effect waves-light">Cancel</a>
    </div>
</div>
<?php $__env->startSection('myscript'); ?>
    <script>
        $(document).ready(function() {

            $("#div_addresses").hide();
            $(document).on("keyup","#postcode_lookup", function() {

                var optionHtml ="";
                $('#addresses')
                    .find('option')
                    .remove()
                    .end();


                var postcode = $("#postcode_lookup").val();

                if (postcode.length < 5) {
                    return false;
                }

                $("#div_addresses").show();

                var type ="GET";
                var url = '<?php echo e(url('address')); ?>/' + postcode;
                var dataType ="html";

                $.ajax({
                    url: url,
                    type: type,

                    success: function(response) {
                        console.log(response);
                        if (response.success == true) {
                            if (response.addresses.length > 0) {

                                optionHtml =
                                   "<option value='' >Please select your address</option>";

                                $('#addresses').append(optionHtml);
                                $('#postcode').val($('#postcode_lookup').val());

                                jQuery.each(response.addresses, function() {

                                    $('#city').val(this.city);

                                    optionHtml ="<option value='" + this.address +
                                       "' >" + this.address +"</option>";
                                    $('#addresses').append(optionHtml);
                                });
                                optionHtml ="<option value=''> Not on the list? </option>";
                                $('#addresses').append(optionHtml);

                            } else {
                                optionHtml +="<option value=''>Address not found...</option>";
                                $('#addresses').append(optionHtml);
                            }
                        } else {
                            $('#error').append("<div>fff</div>");
                        }



                    },
                    error: function(jqXHR, error, errorThrown) {}
                });
            });

            $('#addresses').on('change', function(e) {

                var optionSelected = $("option:selected", this);
                var valueSelected = this.value;

                //$("#btnAddressManually").fadeOut(200);
                $('.address-manually').fadeIn(200);
                //var completedata = valueSelected.split(",");
                $("#address").val(valueSelected);
                //$("#address2").val(completedata[2]);
                //$("#city").val(completedata[3]);
                // $("#postcode").$("#postcode_lookup").val();
            });


            $('#btnAddressManually').click(function() {
                $('#postcode').val($('#postcode_lookup').val());
                $(".custom-select2").fadeOut(200);
                $(this).fadeOut(200);
                $('.address-manually').fadeIn(200);
                $('#postcode_lookup').val("");
            })
        });
    </script>
<?php $__env->stopSection(); ?>
<?php /**PATH /home/seolocaj/public_html/homefloltd/resources/views/admin/customers/form.blade.php ENDPATH**/ ?>