
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
        textarea{
    min-height: 70px !important;
    border:1px solid #ddd;
}

.form-control, .swal-modal input.swal-content__input{
    height: 43px !important;
}


input{
    border: 1px solid #c6d9e0 !important;
}

.search-btn {
    position: relative;
    right: 31px;
    top: 1px;
    color: #bdbdbd;
}

label {
    display: block;
    font-size: 13px;
    line-height: 1.3846153846em;
    color: #526069;
    margin-bottom: 0.7692307692em;
    user-select: none;
    cursor: pointer;
    font-weight: 500;
    width: 10.7692307692em;
}

.search-card{
    width:100%;
    border:none;
}
    </style>
    <main class="main-content">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3>Edit Usher</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>">Dashboard</a></li>
                        <li class="breadcrumb-item" aria-current="page"><a href="<?php echo e(asset('usher-list')); ?>">Ushers</a></li>
                        <li class="breadcrumb-item active" aria-current="page">Add</li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->

            <div class="row">
                <div class="col-md-12">

                    <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
                    <div class="card">
                        <div class="row">
                            <div class="col-md-6" style="border-right: 1px solid #e5e5e5;">
                                    <div class="card-body">
                                            
                                        <form method="post" action="<?php echo e(asset('edit-usher')); ?>">
                                            <?php echo csrf_field(); ?>
                                            <input type="hidden" name="u_id" value="<?php echo e($usher->id); ?>">
                                            <div class="form-group">
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="vin_number" class="col-3">VIN Number</label>
                                                    <select class="form-control col-9" id="vin_number" name="vin_number">
                                                        <option selected disabled>--SELECT-- </option>
                                                            <?php $__currentLoopData = $vin_number; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($vin->id); ?>"  <?php echo e($usher->vin_number == $vin->id ? 'selected' : ''); ?>><?php echo e($vin->id); ?></option>
                                                            
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            
                                                    </select>
                                                </div>
                                            
                                            </div>
                                            
                                            <div class="form-group d-flex align-items-center">
                                                <label for="name" class="col-3">Name</label>
                                                <input type="text" value="<?php echo e($usher->name); ?>" class="form-control col-9" id="name" name="name">
                                            </div>
                
                                            <div class="form-group d-flex align-items-center">
                                                <label for="usher_type" class="col-3">Usher Type</label>
                                                <select  class="form-control col-9" id="usher_type" name="usher_type">
                                                    <option value="gatekeeper" <?php echo e($usher->usher_type == "gatekeeper" ? 'selected' : ''); ?>>Gatekeeper </option>
                                                    <option value="receptionist" <?php echo e($usher->usher_type == "receptionist" ? 'selected' : ''); ?>>Receptionist</option>
                                                    
                                                </select>
                                                
                                            </div>
                
                                            <div class="form-group d-flex align-items-center">
                                                <label for="mobile" class="col-3">Mobile</label>
                                                <input type="text"  value="<?php echo e($usher->mobile); ?>" class="form-control col-9" id="mobile" name="mobile">
                                            </div>
                
                                            <div class="form-group d-flex align-items-center">
                                                <label for="email" class="col-3">Email</label>
                                                <input type="email"  value="<?php echo e($usher->email); ?>" class="form-control col-9" id="email" name="email">
                                            </div>
                                            
                                            <div class="form-group d-flex align-items-center">
                                                <label for="company_location_id" class="col-3">location</label>
                                                <select name="company_location_id"   class="form-control col-9" id="location">
                                                    <option disabled selected>--SELECT--</option>
                                                    <?php $__currentLoopData = $location; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($loc->id); ?>" <?php echo e($loc->id == $usher->company_location_id ? 'selected' : ''); ?> ><?php echo e($loc->location_name); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                                                                                            
                                            </div>
                                        
                                       
                                    </div>
                            </div>
                            <div class="col-md-6">
                                    <div class="card-body">
                                        
                                            <div class="form-group">
                                                <div class="form-group">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="address" class="col-3">Usher Address</label>
                                                        <textarea class="col-9"  id="address" name="usher_address" rows="3" style="height:40px !important;">
                                                            <?php echo e($usher->usher_address); ?>

                                                        </textarea>
                                                    </div>
                                                </div>
                                            
                                            </div>
                                            <div class="form-group d-flex align-items-center">
                                                <label for="company_name" class="col-3">Default Admin Name</label>
                                                <input type="text"  value="<?php echo e($usher->company_name); ?>" class="form-control col-9" name="company_name" id="company_name" >
                                            </div>
                
                                            <div class="form-group d-flex align-items-center">
                                                <label for="location_address" class="col-3">Location Address</label>
                                                <textarea class="col-9"  name="location_address" id="location_address" rows="3" style="height:40px !important;">
                                                    <?php echo e($usher->address); ?>

                                                </textarea>
                                            </div>
                
                                            
                                            <div class="form-group d-flex align-items-center">
                                                <label for="usher_id" class="col-3">Usher ID</label>
                                                <input type="text"  value="<?php echo e($usher->usher_id); ?>" class="form-control col-9" id="usher_id" name="usher_id">

                                            </div>

                                            
                
                                            <div class="row bg-white py-4 w-100"  style="position:fixed;bottom:0;left:266px">
                                                <div class="col-12 py-2 px-4">
                                                    <button  class="btn btn-primary-lux text-white mx-4" type="submit" >
                                                    <i class="fa fa-check fa-lg"></i>&nbsp <?php echo e(__('message.save')); ?>

                                                    </button>
                                                    <button class="btn btn-white-lux " type="button" >Cancel</button>
                                                </div>
                                            </div>
                                        
                                        </form>
                                    </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        
        </div>
    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::select2 -->
    <link rel="stylesheet" href="<?php echo e(asset('public/admin/vendors/select2/css/select2.min.css')); ?>" type="text/css">
    <script src="<?php echo e(asset('public/admin/vendors/select2/js/select2.min.js')); ?>"></script>
    <!-- end::select2 -->
    <script>
       
        $(document).ready(function() {
            $('#js-example-basic-roles').select2({});

            $("#search-company").on('input',function(){
                    var search = $(this).val(); 
                    if(search=="")
                    {
                        $("#search-result-box").css({"display":"none"});
                    }               
                    var URL = "<?php echo e(asset('search-company')); ?>";
                    $.ajaxSetup({
                                headers: {
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                }
                            });

                    $.ajax({
                        type: "post",
                        url: URL,
                        data:{
                            "search":search
                        },
                        dataType: "html",
                        success: function(result) 
                        {
                            //console.log(result);
                            $("#search-result-box").css({"display":"block"});
                            var company = JSON.parse(result);
                            var data = company.company;
                            var i;
                            var fullUrl = "http://localhost/visitor_management/public";
                            
                            for(i=0;i<data.length;i++)
                            {
                                var url = fullUrl+data[i].company_pic;
                                var divBox = `
                                <div >
                                    <li class="d-flex align-items-center m-0 p-0 organization-list" orgname="${data[i].company_name}" orgid="${data[i].id}" style="cursor:pointer;">
                                        <img src="${url}" width="25" height="25" >
                                        &nbsp<p class="py-1 m-0">${data[i].company_name}</p>
                                    </li>
                                </div>
                            `;
                                $("#search-result-box").html(divBox);
                            }
                            $(".organization-list").click(function(){
                                
                                var id = $(this).attr("orgid");
                                var name = $(this).attr("orgname");
                                $("#id_company").val(id);
                                $("#search-company").val(name);
                                $("#search-result-box").css({"display":"none"});
                            });
                                

                            
                            
                            
                        }
                    });

            });

            //add company box
            $(".add-company-btn").click(function(){
                $(".search-company-box").addClass("d-none");
                $(".company-add-box").removeClass("d-none");
                $(".company-add-box").addClass("fadeIn");
            });

            //vin number
            $("#vin_number").on("change",function(){
                var search = $(this).val();
                
                if (isNaN(search)) 
                {
                    alert("Please input a number.");
                    $(this).val("");
                }
                else
                {
                    $.ajax({
                        type: "post",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        data: {
                            "search": search
                        },
                        url: "<?php echo e(asset('search-by-vin')); ?>",
                        dataType: "html",
                        success: function(result) 
                        {
                            
                            var allData = JSON.parse(result);
                            if(allData.message=="success")
                            {
                                var user = allData.data;
                                console.log(user);
                                $("#name").val(user.name);
                                $("#mobile").val(user.mobile);
                                $("#email").val(user.email);
                                $("#address").val(user.address);
                                $("#company_name").val(user.company ? user.company.company_name : '');
                                $("#organization_id").val(user.organization_id);
                            }
                            
                        },
                        error:function(xhr,error,status)
                        {
                            console.log(JSON.parse(xhr.responseText));
                        }
                    });
                }
            });

            //location add code
            $("#location").on("change",function(){
                var loc = $(this).val();
                $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        "id": loc
                    },
                    url: "<?php echo e(asset('location-search')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {
                        
                        var allData = JSON.parse(result);
                        if(allData.message=="success")
                        {
                            var user = allData.data;
                            //console.log(user);
                            $("#location_address").val(user.address);
                            
                        }
                        
                    },
                    error:function(xhr,error,status)
                    {
                        console.log(JSON.parse(xhr.responseText));
                    }
                });
            });
        });


    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/admin.visitorkrypt.com/resources/views/usher/edit-usher.blade.php ENDPATH**/ ?>