
<?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;
}
    </style>

    <main class="main-content">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3><?php echo e(__('message.add')); ?> Location</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('location-list')); ?>">Location</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.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="card-body">
                        
                            <div class="bg-white ">
                                   
                                <div class="row">
                                    <div class="col-md-6" style="border-right: 1px solid #e5e5e5;">
                                              
                                            <div class="card-body overflow-hidden">
                                                
                                                <form action="<?php echo e(asset('edit-location')); ?>" method="post">
                                                    <?php echo csrf_field(); ?>
                                                    <input type="hidden" name="location_id" value="<?php echo e($location->id); ?>">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="name">Location Type</label>
                                                        <select type="text" class="form-control" id="location_type" name="location_type">
                                                            <option selected disabled>--SELECT--</option>
                                                            <?php $__currentLoopData = $location_type; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option class="text-capitalize"  <?php echo e($location->id == $loc->id ? 'selected' : ''); ?> value="<?php echo e($loc->id); ?>"><?php echo e($loc->location_name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                                                            
                                                        </select>
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center justify-content-end">
                                                        <button  class="btn border location_add_btn" type="button"><i class="fa fa-plus fa-lg"></i>&nbsp Location Type</button>
                                                       
                                                    </div>
                                                    <div class="form-group d-none location-type-box">
                                                        <div class="row">
                                                            <div class="col-3"></div>
                                                            <div class="col-9 pl-1">
                                                                <input type="text" placeholder="Add Location Type" name="location_name" class="form-control mb-1" id="location_name">
                                                                <button type="button" class="btn btn-primary float-right submit-location-btn">Add</button>
                                                            </div>
                                                        </div>
                                                        
                                                    </div>
                                                    
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="city">City/Town/Dist</label>
                                                        <input type="text"  value="<?php echo e($location->city ? $location->city : ''); ?>" class="form-control" name="city" id="city" >
                                                        
                                                    </div>
                        
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="pincode">Pincode</label>
                                                        <input type="text"  value="<?php echo e($location->pincode ? $location->pincode : ''); ?>" name="pincode" class="form-control" id="pincode">
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="gender">Contact Person</label>
                                                        <input type="text"  value="<?php echo e($location->contact_person ? $location->contact_person : ''); ?>" name="contact_person" class="form-control" id="contact_person">
                                                       
                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="contact_phone">Contact Phone</label>
                                                        <input type="text"  value="<?php echo e($location->contact_phone ? $location->contact_phone : ''); ?>" name="contact_phone" class="form-control" id="contact_phone">
                                                       
                                                    </div>
                                                    
                                                    
                                                
                                               
                                            </div>
                                    </div>
                                    <div class="col-md-6">
                                            <div class="card-body">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="address">Address</label>
                                                        <textarea  rows="5" class="w-100 rounded" style="border:1px solid #ddd" name="address" >
                                                         <?php echo e($location->address ? $location->address : ''); ?>

                                                    </textarea>

                                                    </div>
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="country">Country</label>
                                                        <select class="form-control" name="country_id" 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($location->country_id == $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" id="state">
                                                            
                                                        </select>

                                                    </div>

                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="designation">Designation</label>
                                                        <input type="text"   value="<?php echo e($location->designation ? $location->designation : ''); ?>" class="form-control" name="designation" id="designation">

                                                    </div>

                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="contact_email">Contact Email</label>
                                                        <input type="email"  value="<?php echo e($location->contact_email ? $location->contact_email : ''); ?>" class="form-control" name="contact_email" >

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

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

        $("#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 >--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));
                    }
                });
        }

        //location type button
        $(".location_add_btn").click(function(){
            if($(".location-type-box").hasClass("d-none"))
            {
                $(".location-type-box").removeClass("d-none");
                $(".location-type-box").removeClass("animate__animated animate__fadeOut");
                $(".location-type-box").addClass("animate__animated animate__fadeIn");
            }
            else
            {
                setTimeout(function(){
                    $(".location-type-box").removeClass("animate__animated animate__fadeIn");
                    $(".location-type-box").addClass("d-none");
                },1000);
               
                
                $(".location-type-box").addClass("animate__animated animate__fadeOut");
                
            }
        });

        //submit location 
        $(".submit-location-btn").click(function(){
            
            $("#location_name").attr("required");
            var loc_name = $("#location_name").val();
            if(loc_name == "")
            {
                $("#location_name").focus();
            }
            else
            {
                $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        "loc_name": loc_name
                    },
                    url: "<?php echo e(asset('add-location-type')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {
                        console.log(result);
                        
                        var allData = JSON.parse(result);
                        if(allData.message=="success")
                        {
                            setTimeout(function(){
                                $(".location-type-box").removeClass("animate__animated animate__fadeIn");
                                $(".location-type-box").addClass("d-none");
                                location.reload();
                            },1000);
                        }
                        else
                        {
                            console.log("failed");
                        }
                    },
                    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/location/edit-location.blade.php ENDPATH**/ ?>