<?php
$title = 'Account';
$customerTypes = Config("params.customer_types");
?>
<?php echo $__env->make('front/common/meta', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->startSection('content'); ?>
<div class="col-lg-8 px-lg-5 shadow py-lg-4 py-3">
    <div class="col-lg-12" id="errors"></div>

    <div class="alert alert-success alert-dismissible account-success" style="display: none" role="alert">
        <p class="mb-0">Account Updated!</p>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true"><i class="feather icon-x-circle"></i></span>
        </button>
    </div>

    <h4 class="font-weight-bold">Customer Type</h4>

    <form method="post" action="<?php echo url("account/update") ?>" id="account" name="account" >
        <span class="bg-gradiat-color py-2 d-inline-block rounded-lg btn-lg text-white px-4"><?php echo e($customerTypes[$model->type] == 'HomeOwner' ? 'Home Owner' : $customerTypes[$model->type]); ?></span>

        <div class="form-row mt-4">
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Title</label>
                <input type="text" name="title" class="form-control bg-light  form-control-lg " placeholder="Mr"  value="<?php echo $model->title ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">First Name</label>
                <input type="text" name="first_name" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->firstName ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Last Name</label>
                <input type="text" name="last_name" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->lastName ?>">
            </div>

            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Telephone Number</label>
                <input type="text" name="phone" class="form-control bg-light  form-control-lg " placeholder="0123456789" value="<?php echo $model->phone ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Email Address</label>
                <input type="hidden" name="old_email" value="<?php echo $model->email ?>">
                <input readonly type="email" name="email" class="form-control bg-light  form-control-lg "   value="<?php echo $model->email ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Address Line 1</label>
                <input type="text" name="address1" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->address->address1 ?>">
            </div>

            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Address Line 2</label>
                <input type="text" name="address2" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->address->address2 ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">City</label>
                <input type="text" name="city" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->address->city ?>">
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Postcode</label>
                <input type="text" name="postcode" class="form-control bg-light  form-control-lg " placeholder="" value="<?php echo $model->address->postcode ?>">
            </div>


            <?php if (isset($model->transaction)) { ?>

                <div class="col-md-4 form-group mb-md-4">
                    <label class="font-weight-bold">Agreement Start Date</label>
                    <input type="text" name="date" class="form-control bg-light form-control-lg " disabled="disabled" placeholder="<?php echo date("d/m/Y", strtotime($model->transaction->startDate)); ?>">
                </div>
                <div class="col-md-4 form-group mb-md-4">
                    <label class="font-weight-bold">How Old Is Your Boiler?</label>
                    <input type="text" name="city" class="form-control bg-light form-control-lg " disabled="disabled" placeholder="<?php echo $model->transaction->boilerAge ?>">
                </div>
                <div class="col-md-4 form-group mb-md-4">
                    <label class="font-weight-bold">Package</label>
                    <input type="text" name="package" class="form-control bg-light form-control-lg " disabled="disabled" placeholder="<?php echo isset($model->transaction->package->title) ? $model->transaction->package->title : "No package found." ?>">
                </div>
            <?php } ?>

            <div class="col-md-12 form-group mb-md-4">
                <h4 class="h3 font-weight-bold d-inline-block pr-5 pb-2 text-primary border-bottom border-primary">Update You Password</h4>
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Current Password</label>
                <input type="text" name="current_password" value="" class="form-control bg-light  form-control-lg">
                <button type="button" class="btn btn-lg show-password"><i class="fas fa-eye"></i></button>
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">New Password</label>
                <input type="password" name="password" value="" class="form-control bg-light  form-control-lg ">
                <button type="button" class="btn btn-lg show-password"><i class="fas fa-eye-slash"></i></button>
            </div>
            <div class="col-md-4 form-group mb-md-4">
                <label class="font-weight-bold">Confirm New Password</label>
                <input type="password" name="password_confirmation" value="" class="form-control bg-light form-control-lg ">
                <button type="button" class="btn btn-lg show-password "><i class="fas fa-eye-slash"></i></button>
            </div>
        </div>
    </form>
    <div class="col-md-4 form-group mb-md-4">
        <button class="btn btn-primary btn-lg bg-success-grandiant border-0 text-uppercase text-white px-4 update-account">Update</button>
    </div>
</div>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('myscript'); ?>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>

    $(document).ready(function () {

        $(document).on("click", ".update-account", function () {

            var type = "POST";
            var dataType = "json";
            var data = $('#account').serialize();

            $('#errors').hide();
            $('.account-success').hide();
            var callBack = function (response) {
                if (response.error === 1) {
                    displayErrors(response, "errors");
                } else
                {
                    $('.account-success').show();

                }
            };

            var errorCallBack = function (response) {
                displayErrors(response, "errors");
            };
            var url = "<?php echo url("account/update") ?>";
            ajaxRequest(url, type, dataType, data, callBack, errorCallBack);

        });



    });


</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('front.layouts.account', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/seolocaj/public_html/homefloltd/resources/views/front/account.blade.php ENDPATH**/ ?>