
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
        textarea{
    min-height: 30px !important;
}

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

.btn.btn-add, .btn.btn-add-payment {
    padding-left: 2.8571428571em;
    background-repeat: no-repeat;
    background-position: 1.4285714286em center;
}




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;
}
.tab {
    display: inline-block;
    padding: 16px 12px;
    cursor: pointer;
    
    background-color: #E6EAED;
    margin-right: -4px; /* Remove spacing between tabs */
  }

  /* Style for highlighted tab */
  .tab.active {
    background-color: white;
  }

  /* Content area style */
  .tab-content {
    
    padding: 20px;
    border-radius: 0 0 5px 5px;
    display: none; /* Hide all content areas by default */
  }

  /* Show active content area */
  .tab-content.active {
    display: block;
  }
    </style>

    <main class="main-content">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3>Edit Visitor</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item" aria-current="page"><a href="<?php echo e(asset('visitor-list')); ?>">Visitors</a></li>
                        <li class="breadcrumb-item active" aria-current="page">Edit</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; ?>
                    <?php if($errors->any()): ?>
                        <div class="alert alert-danger">
                            <ul>
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>
                    
                    <div class="card">
                    
                        <div class="card-body">
                        
                            <div class="bg-white ">
                                   
                                <div class="row pb-5">
                                    <div class="col-md-6" style="border-right: 1px solid #e5e5e5;">
                                              
                                            <div class="card-body">
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="name">VIN</label>
                                                    <select type="text" disabled class="form-control" id="vin_number" name="vin_number">
                                                        <option selected disabled>--SELECT--</option>
                                                        <?php $__currentLoopData = $user_vin; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($vin->id); ?>" <?php echo e($visitor->visitor_id==$vin->id ? 'selected' : ''); ?>><?php echo e($vin->id); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div> 
                                                <form action="<?php echo e(asset('edit-visitor-entry')); ?>" method="post">
                                                    <?php echo csrf_field(); ?>
                                                    <input type="hidden" name="visitor_id" value="<?php echo e($visitor->id); ?>">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="name">Name</label>
                                                        <input type="text" class="form-control" id="name" name="visitor_name" value="<?php echo e($visitor->visitor_name); ?>">
                                                       
                                                    </div>
                                                   
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="visitor_mobile">Mobile</label>
                                                        <input type="text" class="form-control" name="visitor_mobile" id="mobile" value="<?php echo e($visitor->visitor_mobile); ?>">
                                                        
                                                    </div>
                        
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="visitor_email">Email</label>
                                                        <input type="email" name="visitor_email" class="form-control" id="visitor_email" value="<?php echo e($visitor->visitor_email); ?>">
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="designation">Designation</label>
                                                        <input type="text" name="designation" class="form-control" id="" value="<?php echo e($visitor->designation); ?>">
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="gender">Gender</label>
                                                        <select name="gender" class="form-control">
                                                            <option value="male" <?php echo e($visitor->gender == "male" ? 'selected' : ''); ?> >Male</option>
                                                            <option value="female" <?php echo e($visitor->gender == "female" ? 'selected' : ''); ?>>Female</option>
                                                            <option value="other" <?php echo e($visitor->gender == "other" ? 'selected' : ''); ?>>other</option>
                                                        </select>
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="id_type">Id Type</label>
                                                        <select name="id_type" class="form-control">
                                                            <option selected disabled>--SELECT--</option>
                                                            <?php $__currentLoopData = $identity; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($id->id); ?>" <?php echo e($visitor->id_type == $id->id ? 'selected' : ''); ?>><?php echo e($id->id_type); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            
                                                        </select>
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="id_number">Id Number</label>
                                                        <input type="text" name="id_number" class="form-control" value="<?php echo e($visitor->id_number); ?>">
                                                        
                                                    </div>
                                                    
                                                    <div class="form-group d-flex align-items-center">
                                                        <label  for="organization">Organization</label>
                                                        <input type="text" class="form-control" name="organization" id="organization" value="<?php echo e($visitor->organization); ?>">
                                                           
                                                    </div>
                                                    
                                                
                                               
                                            </div>
                                    </div>
                                    <div class="col-md-6">
                                        <!-- Tabs -->
                                        <div id="tabs">
                                            <div class="tab active" onclick="openTab('tab1')">Address</div>
                                            <div class="tab" onclick="openTab('tab2')">Vehicle Information</div>
                                            <div class="tab" onclick="openTab('tab3')">Others</div>
                                            <div class="tab" onclick="openTab('tab4')">Additional Information</div>
                                        </div>

                                        <!-- Tab content -->
                                        <div class="tab-content active" id="tab1">
                                            <h5>Address</h5>
                                            <div class="card-body">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="address">Address</label>
                                                        <textarea class="form-control" name="address" ><?php echo e($visitor->address); ?></textarea>

                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="country">Country</label>
                                                        <select class="form-control" name="country" id="location_country">
                                                            <option selected >--SELECT--</option>
                                                            <?php $__currentLoopData = $country; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cnt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($cnt->id); ?>" <?php echo e($visitor->country == $cnt->id ? 'selected': ''); ?>><?php echo e($cnt->name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>

                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="state">State</label>
                                                        <select class="form-control" name="state" id="state">

                                                        </select>

                                                    </div>

                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="city">City</label>
                                                        <input type="text" class="form-control" name="city" value="<?php echo e($visitor->city); ?>" >

                                                    </div>

                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="pincode">Pincode</label>
                                                        <input type="number" class="form-control" name="pincode" value="<?php echo e($visitor->pincode); ?>">

                                                    </div>
                                                    
                                                    
                                                    
                                            </div>
                                        </div>
                                        <div class="tab-content" id="tab2">
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="youtube">Vehicle Type</label>
                                                <select class="form-control w-75" name="vehicle_type" id="vehicle_type">
                                                    <option selected disabled>--SELECT--</option>
                                                    <?php $__currentLoopData = $vehicle; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vh): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($vh->id); ?>" <?php echo e($visitor->vehicle_type == $vh->id ? 'selected' : ''); ?>><?php echo e($vh->vehicle_type); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="facebook">Vehicle Brand/Model</label>
                                                <input type="text" class="form-control w-75" name="vehicle_model" id="facebook" value="<?php echo e($visitor->vehicle_model); ?>">
                                                        
                                                    
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="instagram">Vehicle Number</label>
                                                <input type="text" class="form-control w-75" name="vehicle_number" id="" value="<?php echo e($visitor->vehicle_number); ?>">
                                                        
                                                   
                                            </div>
                                            
                                        </div>
                                        <div class="tab-content" id="tab3">
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>No. Of Visitors</label>
                                                <input type="number" name="number_of_visitor" class="form-control" value="<?php echo e($visitor->number_of_visitor); ?>">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center" >
                                                <label>Purpose</label>
                                                <input type="text" name="purpose_of_visit" class="form-control" value="<?php echo e($visitor->purpose_of_visit); ?>">
                                            </div>
                                            <div class="">
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label>Host Name</label>
                                                    <input type="hidden" name="host_id" id="host_id_input">
                                                    <input type="text" id="cityInput" value="<?php echo e(isset($_GET['city']) ? $_GET['city'] : null); ?>" class="form-control text-capitalize city"   placeholder="Enter Host Name">
                                                </div>
                                                <div class="row px-2 pr-3">
                                                    <div class="col-3"></div>
                                                    <div id="cityDropdown" class="dropdown-content d-none p-2 border rounded  col-9 px-4">
                                                    
                                                        <input type="text" id="searchInput" class="form-control" placeholder="Search...">
                                                        <div id="cityList" style="overflow-y:scroll;height:200px;">
                                                            <!-- City options will be populated here -->
                                                        </div>
                                                    </div>

                                                </div>
                                                
                                                
                                                        
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Host Designation</label>
                                                <input type="text"  class="form-control" id="host_designation">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Host Department</label>
                                                <input type="text" name="host_department"  class="form-control" id="host_department">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Location</label>
                                                <input type="text"  class="form-control" id="host_location">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Gate No</label>
                                                <input type="text" name="gate" class="form-control" value="<?php echo e($visitor->gate); ?>">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Pass Number</label>
                                                <input type="text" name="pre_approved_pass" class="form-control" value="<?php echo e($visitor->pre_approved_pass); ?>">
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Assigned By</label>
                                                <input type="text" name="assigned_by" class="form-control" value="<?php echo e($visitor->assigned_by); ?>">
                                            </div>
                                            <div class="row">
                                                <div class="form-group col-12 d-flex ">
                                                    <label>Time In</label>
                                                    <input type="datetime-local" name="check_in_time" class="form-control" value="<?php echo e($visitor->check_in_time); ?>">
                                                </div>
                                                <div class="form-group col-12 d-flex ">
                                                    <label>Time Out</label>
                                                    <input type="datetime-local" name="check_out_time" class="form-control" value="<?php echo e($visitor->check_out_time); ?>">
                                                </div>
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label>Notes</label>
                                                <textarea name="remarks" class="w-100" rows="3" style="border:1px solid #ddd"><?php echo e($visitor->remarks); ?></textarea>
                                            </div>
                                        </div>
                                        <div class="tab-content" id="tab4">
                                            <div class="row">
                                                <div class="col-4">
                                                    <label>FEVER</label>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" name="fever" aria-label="Checkbox for following text input" value="yes" <?php echo e($visitor->fever=="yes" ? "checked" : ''); ?>>
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">Yes</span>
                                                    </div>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" name="fever" aria-label="Checkbox for following text input" value="no" <?php echo e($visitor->fever=="no" ? "checked" : ''); ?>>
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">No</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-4">
                                                    <label>SORE THROAT</label>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->sore_throat=="yes" ? "checked" : ''); ?> name="sore_throat" aria-label="Checkbox for following text input" value="yes">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">Yes</span>
                                                    </div>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->sore_throat=="no" ? "checked" : ''); ?> name="sore_throat" aria-label="Checkbox for following text input" value="no">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">No</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-4">
                                                    <label>DRY COUGH</label>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->dry_cough=="yes" ? "checked" : ''); ?> name="dry_cough" aria-label="Checkbox for following text input" value="yes">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">Yes</span>
                                                    </div>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->dry_cough=="no" ? "checked" : ''); ?> name="dry_cough" aria-label="Checkbox for following text input" value="no">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">No</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-4">
                                                    <label>RUNNING NOSE</label>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->running_nose=="yes" ? "checked" : ''); ?> name="running_nose" aria-label="Checkbox for following text input" value="yes">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">Yes</span>
                                                    </div>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->running_nose=="no" ? "checked" : ''); ?> name="running_nose" aria-label="Checkbox for following text input" value="no">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">No</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-4">
                                                    <label>COVIN VACCINATION</label>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->covid_vaccination=="yes" ? "checked" : ''); ?> name="covid_vaccination" aria-label="Checkbox for following text input" value="yes">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">Yes</span>
                                                    </div>
                                                </div>
                                                <div class="col-4">
                                                    <div class="input-group mb-3">
                                                        <div class="input-group-prepend">
                                                            <div class="input-group-text bg-white">
                                                                <input type="radio" <?php echo e($visitor->covid_vaccination=="no" ? "checked" : ''); ?> name="covid_vaccination" aria-label="Checkbox for following text input" value="no">
                                                            </div>
                                                        </div>
                                                        &nbsp <span class="py-1">No</span>
                                                    </div>
                                                </div>
                                            </div>

                                        </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>

                     
        </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");
            });

            //add vehicle btn
            $(".add-vehicle-btn").click(function(){
                if($(".add-vehicle-box").hasClass("d-none"))
                {
                    $(".add-vehicle-box").removeClass("d-none");
                    $(".add-vehicle-box").addClass("animate__animated animate__slideInDown");
                }
                else
                {
                    
                    $(".add-vehicle-box").addClass("d-none");
                }
            });

            //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));
                        }
                    });
                }
            });

            //open tab
            function openTab(tabId) {
                // Get all tabs and hide them
                var tabs = document.querySelectorAll('.tab-content');
                tabs.forEach(function(tab) {
                tab.classList.remove('active');
                });

                // Remove active class from all tabs
                var tabButtons = document.querySelectorAll('.tab');
                tabButtons.forEach(function(button) {
                button.classList.remove('active');
                });

                // Show the clicked tab and add active class
                document.getElementById(tabId).classList.add('active');
                document.querySelector('[onclick="openTab(\'' + tabId + '\')"]').classList.add('active');
            }

            //city code
            $("#cityInput").click(function() {
                $("#cityDropdown").removeClass("d-none");
                document.getElementById("cityDropdown").style.display = "block";
            });

            //host search code
            $("#searchInput").on("keyup", function() 
            {
                var input, filter, ul, li, a, i, txtValue;
                input = document.getElementById('searchInput');
                filter = input.value.toUpperCase();
                ul = document.getElementById("cityList");
                li = ul.getElementsByTagName('div');
            


                for (i = 0; i < li.length; i++) {
                    txtValue = li[i].textContent || li[i].innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                    li[i].style.display = "";
                    } else {
                    li[i].style.display = "none";
                    }
                }
            });

            var cities = [];
            fetchHost();
            console.log(cities);
            // fetch city
            function fetchHost()
            {
                $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    url: "<?php echo e(asset('fetch-host')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {   
                        var allData = JSON.parse(result);
                        console.log(allData);
                        if(allData.message=="success")
                        {
                            var data = allData.data
                            
                            var i; 
                            for(i=0;i<data.length;i++)
                            {
                                cities.push({"name":data[i].name,"host_id":data[i].id,"designation":data[i].designation,"department":data[i].department,"location":data[i].location_address});
                                
                            }
                            var cityList = document.getElementById("cityList");
                            cities.forEach(function(city) {
                                var cityItem = document.createElement("div");
                                cityItem.className = "city-item text-capitalize";
                                cityItem.style.cursor = "pointer";
                                cityItem.style.padding = "5px";
                                cityItem.textContent = city.name;
                               console.log(city);
                                cityItem.addEventListener("click", function() {
                                    document.getElementById("cityInput").value = city.name ? city.name : '';
                                    document.getElementById("host_id_input").value= city.host_id;
                                    document.getElementById("host_designation").value= city.designation ? city.designation : '';
                                    document.getElementById("host_department").value= city.department ? city.department : '';
                                    document.getElementById("host_location").value= city.location_address ? city.location_address : '';
                                    document.getElementById("cityDropdown").style.display = "none";
                                });
                                cityList.appendChild(cityItem);
                            });
                        }
                    },
                    error:function(xhr,status,error)
                    {
                        console.log(error);
                    }
                });
            }
        });

        $("#location_country").on("change",function(){
            var company_id = $(this).val();
            stateFetch(company_id,"state");                
        });

        function stateFetch(company_id,appendState)
        {
            $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        "id": company_id
                    },
                    url: "<?php echo e(asset('fetch-state')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {
                        $("#"+appendState).html("");
                        var allData = JSON.parse(result);
                        if(allData.message=="success")
                        {
                            var data = allData.data;
                            var i;
                            var dOption = "<option selected disabled>--SELECT--</option>";
                            $("#"+appendState).append(dOption);
                            for(i=0;i<data.length;i++)
                            {
                                var option = `<option value="${data[i].id}">
                                                ${data[i].state_name}
                                                </option>
                                `;
                                $("#"+appendState).append(option);
                            }
                        }
                        else
                        {
                            console.log("failed");
                        }
                    },
                    error:function(xhr,error,status)
                    {
                        console.log(JSON.parse(xhr.responseText));
                    }
                });
        }
        function openTab(tabId) {
        // Get all tabs and hide them
        var tabs = document.querySelectorAll('.tab-content');
        tabs.forEach(function(tab) {
        tab.classList.remove('active');
        });

        // Remove active class from all tabs
        var tabButtons = document.querySelectorAll('.tab');
        tabButtons.forEach(function(button) {
        button.classList.remove('active');
        });

        // Show the clicked tab and add active class
        document.getElementById(tabId).classList.add('active');
        document.querySelector('[onclick="openTab(\'' + tabId + '\')"]').classList.add('active');
    }

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

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\adminvisitor\resources\views/visitor/edit-visitor.blade.php ENDPATH**/ ?>