
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
        .input_upload{
            width:100px;
            height:35px;
            position:absolute;
            bottom:-34px;
            right:350px;
        }
        .import-content p{
            padding:0;
            margin:0;
            margin-bottom:8px;
            font-size:13px;
        }
        
        .filter-form-box{
            background-color:#FBFAFA;
            padding:10px 24px;
            position:absolute;
            width:450px;
            border:1px solid #ddd;
            border-radius:5px;
            top:69px;
            z-index:20;
        }
        .filter-form-box input{
            height:40px !important;
        }
        .diamond {
            width: 20px; 
            height: 20px; 
            background-color: #FBFAFA; 
            transform: rotate(45deg);
            position: relative; 
            top:-21px;
            left:0px;
            border-top:1px solid #ddd;
            border-left:1px solid #ddd;
        }
        .seach-input:focus{
            outline:none !important;
            border-top:1px solid #ddd !important;
            border-bottom:1px solid #ddd !important;
           
        }
        .seach-input{
            height:40px !important;
            border-top:1px solid #ddd !important;
            border-bottom:1px solid #ddd !important;
            border-left:1px solid #ddd !important;
        }
    </style>
    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3>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 active" aria-current="page"><?php echo e(__('message.list')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->
            <?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="card-header">
                    
                    <div class="row">
                        <div class="col-md-6 py-3">
                            <form action="<?php echo e(asset('visitor-list')); ?>" method="get">                                
                                <div class="company-field-box">
                                    <div>
                                        <div class="input-group">
                                        <div class="input-group-prepend">
                                            <button type="button" class="btn border input-group-text filter-company-btn">
                                                <i class="fa fa-filter fa-lg px-2"></i>
                                            </button>
                                        </div>
                                            
                                        <input placeholder="Date range filter" type="date" name="filter_date" class="form-control" value="<?php echo e($current_date); ?>">
                                            <button class="btn border border-left-0" type="submit" style="margin-left:-5px;">
                                                <i class="fa fa-search fa-lg"></i>
                                            </button>
                                            
                                        </div>
                                        
                                        
                                        <div class="filter-form-box d-none">
                                            <div class="diamond"></div>
                                            <form method="get" action="<?php echo e(asset('visitor-list')); ?>">
                                                <div class="form-group">
                                                    <label>VIN Number</label>
                                                    <input value="<?php echo e(isset($_GET['vin_number']) ? $_GET['vin_number'] : null); ?>" type="text" name="vin_number" class="form-control" >
                                                </div>
                                                <div class="form-group">
                                                    <label>Name</label>
                                                    <input value="<?php echo e(isset($_GET['visitor_name']) ? $_GET['visitor_name'] : null); ?>" type="text" name="name" class="form-control" >
                                                </div>
                                                <div class="form-group">
                                                    <label>Id Number</label>
                                                    <input type="text" value="<?php echo e(isset($_GET['id_number']) ? $_GET['id_number'] : null); ?>" name="id_number" class="form-control" >
                                                </div>
                                                <div class="form-group">
                                                    <label>Mobile</label>
                                                    <input type="text" name="visitor_mobile" value="<?php echo e(isset($_GET['visitor_mobile']) ? $_GET['visitor_mobile'] : null); ?>" class="form-control" >
                                                </div>
                                                
                                                
                                                <div class="row">
                                                    <div class="form-group col-12">
                                                       <button type="submit" class="btn btn-success-lux mr-5 px-4 apply-button">Apply</button>
                                                    
                                                        <a href="<?php echo e(asset('visitor-list')); ?>" class="btn btn-primary-lux px-5 clear-button text-white">Clear</a>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                               
                            </form>
                                    
                        </div>
                        
                        <div class="col-md-6 d-flex justify-content-end py-3">
                                <button data-original-title="Delete Organizations" class="btn btn-danger text-uppercase text-white mr-2 d-none multiple-delete-btn">
                                            <i class="fa fa-trash fa-lg" style="font-size:24px;"></i>
                                </button>
                            <a data-toggle="tooltip" data-original-title="Add New User"
                                    href="<?php echo e(asset('add-visitor')); ?>"
                                    class="btn btn-primary-lux text-uppercase text-white mr-2"><i
                                        class="fa fa-plus pr-2"></i>New
                                    </a>
                            <a data-toggle="tooltip" data-original-title="Export User"
                                    href="<?php echo e(asset('export-visitor')); ?>"
                                    class="btn btn-white-lux text-uppercase mr-2"><i
                                        class="fa fa-download pr-2"></i>
                                        Export
                            </a>

                            <button type="button" class="btn btn-white-lux text-uppercase  mr-2" data-toggle="modal" data-target="#importModal"><i
                                        class="fa fa-upload pr-2"></i>
                                        Import
                            </button>
                                
                            <button type="button" class="btn btn-danger d-none" id="delete-multiple">
                                <i class="fa fa-trash fa-lg"></i>
                            </button>
                        </div>
                        <div class="col-md-3">
                               
                            </div>
                        
                    </div>
                   

                
            </div>

                <div class="card-body">

                    <?php if(isset($visitorentry)): ?>

                    <div class="table-responsive">
                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>
                                        <input type="checkbox" id="checkAll" />
                                    </th>
                                    
                                    <th>VIN</th>
                                    <th>Name</th>
                                    <th>Gender</th>
                                    <th>ID Number</th>
                                    
                                    <th>Organization</th>
                                    <th>City</th>
                                    <th>State</th>
                                    <th>Country</th>
                                    <th>Mobile</th>
                                    <th>Email</th>
                                    <th>Vehicle Type</th>
                                    <th>Vehicle Model/Brand</th>
                                    <th>Vehicle Number</th>
                                    <th>No. Of Visitors</th>
                                    <th>Purpose</th>
                                    <th>Host Name</th>
                                    <th>Designation</th>
                                    <th>Department</th>
                                    <th>Location</th>
                                    <th>Pass Number</th>
                                    <th>Addition Information</th>
                                                                        
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if(!empty($visitorentry)): ?>
                                    <?php $__currentLoopData = $visitorentry; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                            <td>
                                                <input type="checkbox" name="checkbox[]" class="userids" value="<?php echo e($value->id); ?>" />
                                            </td>
                                            
                                            <td>
                                                <?php echo e($value->visitor_id); ?>

                                            </td>
                                            <td class="text-capitalize"><?php echo e($value->visitor_name); ?></td>
                                            <td><?php echo e($value->gender); ?></td>
                                            <td>
                                                <span class="text-capitalize"><?php echo e($value->id_name ? $value->id_name->id_type : ''); ?> :</span> <strong><?php echo e($value->id_number); ?></strong>
                                            </td>
                                                                                        
                                            <td>
                                                
                                                <?php echo e($value->organization); ?>

                                               
                                            </td>
                                        
                                            
                                            <td><?php echo e($value->city); ?></td>
                                            <td><?php echo e($value->state_name ? $value->state_name->state_name : ''); ?></td>
                                            <td><?php echo e($value->country ? $value->country_name->name : ''); ?></td>
                                            <td><?php echo e($value->visitor_mobile); ?></td>
                                            
                                            <td><?php echo e($value->email); ?></td>
                                            <td><?php echo e($value->vehicle ? $value->vehicle->vehicle_type : ''); ?></td>
                                            <td><?php echo e($value->vehicle_model); ?></td>
                                            <td><?php echo e($value->vehicle_number); ?></td>
                                            <td><?php echo e($value->number_of_visitor); ?></td>
                                            <td><?php echo e($value->purpose_of_visit); ?></td>
                                            <td><?php echo e($value->host ? $value->host->name : ''); ?> </td>
                                            <td><?php echo e($value->host ? $value->host->designation : ''); ?></td>
                                            <td><?php echo e($value->host ? $value->host->department : ''); ?></td>
                                            <td><?php echo e($value->host ? $value->host->location_address : ''); ?></td>
                                            <td><?php echo e($value->pre_approved_pass); ?></td>
                                            <td >
                                                <div class="row" style="width:600px !important;">
                                                
                                                    <div class="col-2">
                                                        <label class="font-weight-bold">Fever</label>
                                                        <div>
                                                            <input type="radio" <?php echo e($value->fever == "yes" ? 'checked' : ''); ?>> Y
                                                            <input type="radio" <?php echo e($value->fever == "no" ? 'checked' : ''); ?>> N
                                                        </div>
                                                    </div>
                                                    <div class="col-2">
                                                        <label class="font-weight-bold">Sore Throat</label>
                                                        <div>
                                                            <input type="radio" <?php echo e($value->sore_throat == "yes" ? 'checked' : ''); ?>> Y
                                                            <input type="radio" <?php echo e($value->sore_throat == "no" ? 'checked' : ''); ?>> N
                                                        </div>
                                                    </div>
                                                    <div class="col-2">
                                                        <label class="font-weight-bold">Dry Cough</label>
                                                        <div>
                                                            <input type="radio" <?php echo e($value->dry_cough == "yes" ? 'checked' : ''); ?>> Y
                                                            <input type="radio" <?php echo e($value->dry_cough == "no" ? 'checked' : ''); ?>> N
                                                        </div>
                                                    </div>
                                                    <div class="col-3">
                                                        <label class="font-weight-bold">Running Nose</label>
                                                        <div>
                                                            <input type="radio" <?php echo e($value->running_nose == "yes" ? 'checked' : ''); ?>> Y
                                                            <input type="radio" <?php echo e($value->running_nose == "no" ? 'checked' : ''); ?>> N
                                                        </div>
                                                    </div>
                                                    <div class="col-3">
                                                        <label class="font-weight-bold">Covid Vaccination</label>
                                                        <div>
                                                            <input type="radio" <?php echo e($value->covid_vaccination == "yes" ? 'checked' : ''); ?>> Y
                                                            <input type="radio" <?php echo e($value->covid_vaccination == "no" ? 'checked' : ''); ?>> N
                                                        </div>
                                                    </div>
                                                </div>
                                                
                                            </td>
                                            <td>
                                            <div class="btn-group">
                                                    <?php if(Auth::user()->hasRole('admin') || Auth::user()->can('view-visitor')): ?>
                                                    <a href="<?php echo e(asset('visitor-view/'.$value->id)); ?>" class="btn btn-info text-white">
                                                        <i class="fa fa-eye"></i>
                                                    </a>
                                                    <?php endif; ?>
                                                    <?php if(Auth::user()->hasRole('admin') || Auth::user()->can('edit-visitor')): ?>
                                                    <a href="<?php echo e(asset('edit-visitor/'.$value->id)); ?>" class="btn btn-success text-white">
                                                        <i class="fa fa-edit"></i>
                                                    </a>
                                                    <?php endif; ?>
                                                    <?php if(Auth::user()->hasRole('admin') || Auth::user()->can('delete-visitor')): ?>
                                                    <button class="btn btn-danger text-white visitor-entry-delete-btn" data-toggle="tooltip"
                                                        data-original-title="Delete" userid="<?php echo e($value->id); ?>" >
                                                        <i class="fa fa-trash fa-lg"></i>
                                                    </button>
                                                    <?php endif; ?>
                                                </div>
                                            </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php else: ?>
                                    <h1>No Record Found!!</h1>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                            <div class="col-md-10"></div>
                            <div class="col-md-2">
                                <form class="per_page_form" method="get" action="<?php echo e(asset('visitor-list')); ?>">
                                    <select class="form-control per_page_element" name="per_page" onchange="">
                                        <option value="10" <?php echo e(isset($_GET['per_page']) ? ($_GET['per_page'] == 10 ? 'selected':'') : null); ?>>10 Per page</option>
                                        <option value="15" <?php echo e(isset($_GET['per_page']) ? ($_GET['per_page'] == 15 ? 'selected':'') : null); ?>>15 Per page</option>
                                        <option value="20" <?php echo e(isset($_GET['per_page']) ? ($_GET['per_page'] == 20 ? 'selected':'') : null); ?>>20 Per page</option>
                                        <option value="25" <?php echo e(isset($_GET['per_page']) ? ($_GET['per_page'] == 25 ? 'selected':'') : null); ?>>25 Per page</option>
                                    </select>
                                </form>
                            </div>
                            
                        </div>                                 


                    <?php endif; ?>
                </div>
            </div>
        </div>


        <!-- The Modal -->
        <div class="modal" id="importModal">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">

            <!-- Modal Header -->
            <div class="modal-header bg-success  rounded-0">
                <h4 class="modal-title">Import Visitors</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <!-- Modal body -->
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-3 py-5">
                        <i class="fa fa-warning text-warning" style="font-size:50px"></i>
                    </div>
                    <div class="col-md-9 import-content">
                        <p>Import Visitors(.xls, .xlsx)</p>
                        <p><strong>Follow these steps:</strong></p>
                        <p>1. Download the Excel template to your computer by clicking the <strong>Download</strong> button.</p>
                        <p>2. Integrate your data into the template file, minding the column names.</p>
                        <p>3. Click the <strong>Import</strong> button.</p>
                        <p><strong>IMPORTANT</strong></p>
                        <p>- If you do not have data for a particular column, leave it empty and do not move or delete the column.</p>
                        
                    </div>
                </div>
            

                                
            </div>

            <!-- Modal footer -->
            <div class="modal-footer position-relative">
                <form  class="import-visitor-form" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="">
                    <div class="">
                        <div class="" style="position:relative">
                            <input type="file" accept="" name="excel_file" class="input_upload input_file_upload" style="z-index:5;opacity:0;cusor:pointer;">
                            <button type="submit" class="btn btn-success text-uppercase input_upload input_upload_btn text-white mr-2">
                            <i class="fa fa-upload pr-2"></i>
                                    Import
                            </button>
                        </div>
                    </div>
                    <div class="">
                        <div class="d-flex justify-content-center">
                            <a href="<?php echo e(asset('public/visitorEntry.xlsx')); ?>" class="btn btn-info" download>Download Sample &nbsp<i class="fa fa-download"></i></a>
                        </div>
                        
                    </div>
                </div>    
                    
                    
                </form>
            </div>

            </div>
        </div>
        </div>
    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::dataTable -->
    <script src="<?php echo e(asset('public/admin/js/examples/datatable.js')); ?>"></script>
    <!-- end::dataTable -->
    <script>
        $(document).ready(function() {

            $(".per_page_element").on("change",function(){
                $(".per_page_form").submit();
            });

            $("#checkAll").click(function() {
                $('.userids:checkbox').not(this).prop('checked', this.checked);
                var length = $('.userids[type="checkbox"]:checked').length;
                if($(".multiple-delete-btn").hasClass('d-none'))
                {
                    $(".multiple-delete-btn").removeClass("d-none");
                    $(".multiple-delete-btn").html('<span class="pt-1">Delete ('+length+")</span>");
                }
                else
                {
                    $(".multiple-delete-btn").addClass("d-none");
                }
                
            });

            //delete 
            $(".visitor-entry-delete-btn").click(function(){
                var id = $(this).attr("userid");

                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });

                        $.ajax({
                            type: "post",
                            data: {
                                "id": id
                            },
                            url: "<?php echo e(asset('visitor-entry-delete')); ?>",
                            dataType: "html",
                            success: function(result) {
                                if(result=="success")
                                {
                                    swal("success!", "Successfully deleted!", "success");
                                    window.location.reload();
                                }
                                else
                                {
                                    swal("error!", "failed !", "failed");
                                    window.location.reload();
                                }
                            }
                        });
                        
                    }
                });

            });
            // Delete Multiple
            $(".multiple-delete-btn").click(function() {
                var URL = "<?php echo e(asset('delete-multiple-visitor')); ?>";
                var user_ids = [];
                $('.userids:checkbox:checked').each(function() {
                    user_ids.push($(this).val());
                });
            
                swal({
                    title: 'Are you sure?',
                    text: 'Once deleted, you will not be recover!',
                    icon: 'warning',
                    dangerMode: true,
                    buttons: ["Cancel", "Yes!"],
                }).then(function(value) {
                    if (value) {
                        $.ajaxSetup({
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            }
                        });

                        $.ajax({
                            type: "post",
                            data: {
                                "ids": user_ids
                            },
                            url: URL,
                            dataType: "html",
                            success: function(result) {
                                console.log(result);
                            }
                        });
                        swal("success!", "Successfully deleted!", "success");
                        window.location.reload();
                    }
                });

            });

            $(".input_file_upload").on("change",function(){
                $(".import-visitor-form").submit();
            });

            $(".import-visitor-form").on("submit", function(event) {
                    // Prevent the default form submission
                    event.preventDefault();                    
                    
                    $.ajax({
                        type: "POST",
                        url: "<?php echo e(asset('import-visitor')); ?>",
                        headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },                       
                        data: new FormData(this), 
                        processData: false,
                        contentType: false,
                        cache:false,
                        beforeSend:function()
                        {
                            $(".import-content").html("<h5>Please wait uploading...</h5>");
                        },
                        success: function(response) 
                        {
                            if(response.message=="success")
                            {
                                var div = `<div class='text-success text-center' style='font-size:50px'>
                                <i class='fa fa-check-circle' ></i>
                                <p  style='font-size:20px'>Visitor Import Successfully !</p>
                            </div>`;
                                $(".import-content").html(div);
                                setTimeout(function(){
                                    window.location.reload();
                                },3000);
                                
                            }
                            else
                            {
                                //console.log(error);
                                var div = `<div class='text-danger text-center' style='font-size:50px'>
                                <i class='fa fa-times-circle' ></i>
                                <p  style='font-size:20px'>Please check the datasheet !</p>
                            </div>`;
                                $(".import-content").html(div);
                            }
                        },
                        error: function(xhr, status, error) 
                        {
                            //console.log(error);
                            var div = `<div class='text-danger text-center' style='font-size:50px'>
                            <i class='fa fa-times-circle' ></i>
                            <p  style='font-size:20px'>Please check the datasheet !</p>
                        </div>`;
                            $(".import-content").html(div);
                        }
                    });
            });


           
        $(".apply-button").click(function(){
            $(".filter-form-box").addClass("d-none");
        });
        

        //filter company code
        $(".filter-company-btn").click(function(){
           
            if($(".filter-form-box").hasClass("d-none"))
            {
                $(".filter-form-box").removeClass("d-none");
            }
            else
            {
                $(".filter-form-box").addClass("d-none");
            }
        });

        //city code
        /*$("#cityInput").click(function() {
            $("#cityDropdown").removeClass("d-none");
        });

        $("#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 = [];
        fetchCity();
        // fetch city
        function fetchCity()
        {
            $.ajax({
                type: "get",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "<?php echo e(asset('fetch-city')); ?>",
                dataType: "html",
                success: function(result) 
                {   
                    var allData = JSON.parse(result);
                    if(allData.message=="success")
                    {
                        var data = allData.data
                        console.log(data);
                        var i; 
                        for(i=0;i<data.length;i++)
                        {
                            cities.push(data[i].city_name);
                        }
                        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;
                            cityItem.addEventListener("click", function() {
                                document.getElementById("cityInput").value = city;
                                document.getElementById("cityDropdown").style.display = "none";
                            });
                            cityList.appendChild(cityItem);
                        });
                    }
                },
                error:function(xhr,status,error)
                {
                    console.log(error);
                }
            });
        }*/
    });
    </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/visitor/visitor-list.blade.php ENDPATH**/ ?>