
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
  /* Styles for tabs */
  .tab {
    display: inline-block;
    padding: 12px 26px;
    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;
  }
  .form-group {
    margin-bottom: 1rem;
    margin-bottom: 30px !important;
}
.form-group input, .form-group select{
    height:42px;
    padding-top:10px 25px !important;
}
.form-group label, .tab{
    font-size:13px !important;
}
.company-save-btn{
    position:fixed;
    bottom:0;left:250px;
    background-color:white;
    border-top:1px solid #ccc;
}
.inner-border{
    border:-2px solid #ddd !important;
}
@media  only screen and (max-width: 768px) {
    .company-save-btn{
    position:fixed;
    bottom:0;left:0px;
    background-color:white;
    border-top:1px solid #ccc;
}
}
</style>

    <main class="main-content px-0">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header m-0 border-0">
                <h3> <?php echo e(__('message.edit')); ?> Vendor</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('account/vendor')); ?>">Vendor</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.edit')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->

            <div class="row py-5">
                <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 border-0">
                        
                        <div class="card-body py-0 border">
                            <form action="<?php echo e(asset('account/add-vendor')); ?>" method="post">
                                <input type="hidden" value="<?php echo e($vendor->id); ?>" name="vendor_id">
                                <div class="row">
                                    <div class="col-md-6 py-3 pt-5">
                                        <?php echo csrf_field(); ?>
                                        <div class="form-group d-flex justify-content-between align-items-center ">
                                            <label for="name" class="col-md-4">Company  <?php echo e(__('message.name')); ?></label>
                                            <div class="col-md-8 px-0">
                                                <input type="text" class="form-control" value="<?php echo e($vendor->name); ?>" name="name" id="name">
                                                <?php if($errors->has('name')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('name')); ?>

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

                                        </div>
                                       
                                       

                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="email" class="col-md-4"><?php echo e(__('message.email')); ?> </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="email" class="form-control" name="email" value="<?php echo e($vendor->email); ?>">
                                                 <?php if($errors->has('email')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('email')); ?>

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

                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="phone" class="col-md-4"><?php echo e(__('message.phone')); ?> </label>
                                            <div class="col-md-8 px-0">
                                                <input type="number" class="form-control " name="mobile" id="phone" value="<?php echo e($vendor->mobile); ?>">

                                                <?php if($errors->has('mobile')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('mobile')); ?>

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

                                        </div>
                                        
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="website" class="col-md-4">GST Treatment </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="gst_treatment" value="<?php echo e($vendor->gst_treatment); ?>">
                                                 <?php if($errors->has('gst_treatment')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('gst_treatment')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="website" class="col-md-4">GSTIN </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="gstin" value="<?php echo e($vendor->gstin); ?>">
                                                 <?php if($errors->has('gstin')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('gstin')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="website" class="col-md-4">PAN </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="pan" value="<?php echo e($vendor->pan); ?>">
                                                 <?php if($errors->has('pan')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('pan')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="website" class="col-md-4">VAT </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="vat" value="<?php echo e($vendor->vat); ?>">
                                                 <?php if($errors->has('vat')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('vat')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="website" class="col-md-4"><?php echo e(__('message.website')); ?> </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="website" class="form-control" name="website" value="<?php echo e($vendor->website); ?>">
                                                 <?php if($errors->has('website')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('website')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="gst" class="col-md-4">Vendor Code </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="vendor_code" value="<?php echo e($vendor->vendor_code); ?>">
                                                 <?php if($errors->has('vendor_code')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('vendor_code')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="form-group  d-flex justify-content-between align-items-center">
                                            <label for="gst" class="col-md-4">Currency </label>
                                            <div class="col-md-8 px-0">
                                                 <input type="text" class="form-control" name="currency" value="<?php echo e($vendor->currency); ?>">
                                                 <?php if($errors->has('currency')): ?>
                                                    <div class="error">
                                                        <?php echo e($errors->first('currency')); ?>

                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                         
                                         
                                                                     
                                           
                                    </div>
                                    <div class="col-md-6 border-left px-0">
                                        
                                        <!-- Tabs -->
                                        <div id="tabs" class="border-bottom">
                                            <div class="tab active" onclick="openTab('tab1')">
                                                <strong> <?php echo e(__('message.address')); ?></strong>
                                            </div>
                                            <div class="tab " onclick="openTab('tab2')">
                                                <strong> <?php echo e(__('message.contact')); ?></strong>
                                            </div>
                                            <div class="tab " onclick="openTab('tab3')">
                                                <strong> <?php echo e(__('message.other')); ?></strong>
                                            </div>
                                        </div>

                                        <!-- Tab content -->
                                        <div class="tab-content active animate__animated animate__fadeIn" id="tab1">
                                           
                                            <h5>Billing Address</h5>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="location_address" class="col-md-4"> <?php echo e(__('message.address')); ?></label>
                                                <div class="col-md-8 px-0">
                                                    <input type="text" class="form-control" name="billing_address" id="address" value="<?php echo e($vendor->billing_address); ?>">
                                                    

                                                    <?php if($errors->has('billing_address')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('billing_address')); ?>

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

                                            </div>

                                            <div class="form-group d-flex">
                                                <label for="location_city" class="col-md-4"><?php echo e(__('message.city')); ?></label>
                                                <div class="col-md-8 px-0">
                                                    <div class="d-flex flex-column p-0" style="position:relative;">
                                                        <input type="search" readonly class="form-control text-capitalize location_city" name="billing_city" id="location_city" placeholder="Select City" value="<?php echo e($vendor->billing_city); ?>">
                                                    
                                                        <div class="main-add-city-box bg-white  border mb-2 d-none" style="width:100%;position:absolute;top:40px;z-index:50">
                                                            <div class="add-search-city-box d-none mb-2 px-2 pt-2"></div>  
                                                            <div class="location_city_search_box d-none px-2 "></div>
                                                        
                                                        </div>
                                                    </div>

                                                    <?php if($errors->has('city')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('city')); ?>

                                                        </div>
                                                    <?php endif; ?>
                                                </div>
                                                
                                            </div>
                                            
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="location_country" class="col-md-4"><?php echo e(__('message.country')); ?></label>
                                                <div class="col-md-8 px-0">
                                                    <select class="form-control select2" name="billing_country" id="location_country" >
                                                            <option selected disabled>--Select--</option>
                                                            <option value="1" <?php echo e($vendor->billing_country == 1 ? 'selected': ''); ?>>India</option>
                                                        
                                                    </select>  
                                                    <?php if($errors->has('country')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('country')); ?>

                                                        </div>
                                                    <?php endif; ?>  
                                                </div>                                       
                                            </div>
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="location_state" class="col-md-4"><?php echo e(__('message.state')); ?></label>
                                                <div class="col-md-8 px-0">
                                                    <select class="form-control select2" name="billing_state" id="location_state">
                                                        
                                                    </select>
                                                    <?php if($errors->has('state')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('state')); ?>

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

                                            </div>

                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="zip" class="col-md-4">ZIP</label>
                                                <div class="col-md-8 px-0">
                                                    <input type="text" class="form-control" name="billing_zip" id="zip" value="<?php echo e($vendor->billing_zip); ?>">
                                                    
                                                    <?php if($errors->has('zip')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('zip')); ?>

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

                                            <div class="shipping_address_box">
                                                <h5>Shipping Address</h5>
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="location_address" class="col-md-4"> <?php echo e(__('message.address')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <input type="text" class="form-control" name="shipping_address" id="shipping_address" value="<?php echo e($vendor->shipping_address); ?>">
                                                        

                                                        <?php if($errors->has('location_address')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('location_address')); ?>

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

                                                </div>

                                                <div class="form-group d-flex">
                                                    <label for="location_city" class="col-md-4"><?php echo e(__('message.city')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <div class="d-flex flex-column p-0" style="position:relative;">
                                                            <input type="search" readonly class="form-control text-capitalize location_city" name="shipping_city" id="shipping_location_city" placeholder="Select City" value="<?php echo e($vendor->shipping_city); ?>" >
                                                        
                                                            <div class="shipping-main-add-city-box bg-white  border mb-2 d-none" style="width:100%;position:absolute;top:40px;z-index:50">
                                                                <div class="shipping-add-search-city-box d-none mb-2 px-2 pt-2"></div>  
                                                                <div class="shipping_location_city_search_box d-none px-2 "></div>
                                                            
                                                            </div>
                                                        </div>

                                                        <?php if($errors->has('city')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('city')); ?>

                                                            </div>
                                                        <?php endif; ?>
                                                    </div>
                                                    
                                                </div>
                                                
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="location_country" class="col-md-4"><?php echo e(__('message.country')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <select class="form-control select2" name="shipping_country" id="shipping_location_country">
                                                                <option selected disabled>--Select--</option>
                                                                <option value="1">India</option>
                                                            
                                                        </select>  
                                                        <?php if($errors->has('country')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('country')); ?>

                                                            </div>
                                                        <?php endif; ?>  
                                                    </div>                                       
                                                </div>
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="location_state" class="col-md-4"><?php echo e(__('message.state')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <select class="form-control select2" name="shipping_state" id="shipping_location_state">
                                                            
                                                        </select>
                                                        <?php if($errors->has('state')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('state')); ?>

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

                                                </div>

                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="zip" class="col-md-4">ZIP</label>
                                                    <div class="col-md-8 px-0">
                                                        <input type="text" class="form-control" name="shipping_zip" id="shipping_zip" value="<?php echo e($vendor->shipping_zip); ?>">
                                                        
                                                        <?php if($errors->has('shipping_zip')): ?>
                                                                <div class="error">
                                                                    <?php echo e($errors->first('shipping_zip')); ?>

                                                                </div>
                                                            <?php endif; ?>
                                                    </div>
                                                
                                                </div>
                                                
                                            </div>
                                            
                                        </div>
                                        <div class="tab-content animate__animated animate__fadeIn" id="tab2">
                                           
                                            
                                            <?php
                                                $contactDetails = json_decode($vendor->contact_details, true) ?? [];
                                                $contactCount = count($contactDetails) > 0 ? count($contactDetails) : 1;
                                                
                                            ?>
                                                
                                            <?php $__currentLoopData = json_decode($vendor->contact_details); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                
                                                <div class="contact-group">
                                                    <strong class="pb-2 mb-1 text-primary border-bottom mr-2">Contact :  </strong>
                                                    
                                                        <button type="button" class="btn btn-outline-danger btn-sm contact-delete-btn" data-toggle="tooltip" title="Delete Contact">
                                                            <i class="fa fa-trash"></i>
                                                        </button>
                                                    
                                                    <div class="form-group d-flex justify-content-between align-items-center">
                                                        <label for="" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.name')); ?></label>
                                                        <div class="col-md-8 px-0">
                                                            <input type="text" class="form-control" name="contact_name[]" id="contact_name" 
                                                                value="<?php echo e($value->name ?? ''); ?>">
                                                            <?php if($errors->has('contact_name')): ?>
                                                                <div class="error">
                                                                    <?php echo e($errors->first('contact_name')); ?>

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

                                                    <div class="form-group d-flex justify-content-between align-items-center">
                                                        <label for="contact_email" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.email')); ?></label>
                                                        <div class="col-md-8 px-0">
                                                            <input type="email" class="form-control" name="contact_email[]" id="contact_email" 
                                                                value="<?php echo e($value->email ?? ''); ?>">
                                                            <?php if($errors->has('contact_email')): ?>
                                                                <div class="error">
                                                                    <?php echo e($errors->first('contact_email')); ?>

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

                                                    <div class="form-group d-flex justify-content-between align-items-center">
                                                        <label for="contact_phone" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.phone')); ?></label>
                                                        <div class="col-md-8 px-0">
                                                            <input type="text" class="form-control" name="contact_phone[]" id="contact_phone" 
                                                                value="<?php echo e($value->phone ?? ''); ?>">
                                                            <?php if($errors->has('contact_phone')): ?>
                                                                <div class="error">
                                                                    <?php echo e($errors->first('contact_phone')); ?>

                                                                </div>
                                                            <?php endif; ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                           

                                            <div class="add-contact-box">

                                            </div>
                                            <div class="d-flex justify-content-end">
                                                <button type="button" class="btn btn-outline-primary btn-sm add-contact-btn ">
                                                    <i class="fa fa-plus"> Add</i>
                                                </button>
                                            </div>

                                           
                                            
                                        </div>
                                        <div class="tab-content animate__animated animate__fadeIn" id="tab3">
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="note" class="col-md-4"> Opening Balance</label>
                                                <div class="col-md-8 px-0">
                                               
                                                    <input type="number" min="0" name="opening_balance" class="form-control" value="<?php echo e($vendor->opening_balance); ?>">

                                                    <?php if($errors->has('opening_balance')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('opening_balance')); ?>

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

                                            </div>
                                            
                                            <div class="form-group d-flex justify-content-between align-items-center">
                                                <label for="note" class="col-md-4"> <?php echo e(__('message.notes')); ?></label>
                                                <div class="col-md-8 px-0">
                                               
                                                    <textarea rows="3" class="border px-2" cols="50" name="note" id="note"><?php echo e($vendor->note); ?></textarea>

                                                    <?php if($errors->has('note')): ?>
                                                        <div class="error">
                                                            <?php echo e($errors->first('note')); ?>

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

                                            </div>
                                            
                                        </div>
                                                                             
                                        
                                    </div>
                                    
                                </div>
                                

                                    <div class="py-5" style="z-index:50;position:absolute" >
                                        <div class="py-3 px-5 w-100 company-save-btn " >
                                            <button type="submit" class="btn btn-success-lux"><i class="fa fa-check"></i>&nbsp <?php echo e(__('message.save')); ?></button>
                                        </div>
                                    </div>
                                 
                                
                            </form>
                        </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({});


            //add contact btn
            var count=2;

            

        
            
                $(".add-contact-btn").click(function(){
                    
                    if(count<6)
                    {
                        var contact_box = `<div>
                                                <strong class="pb-2 mb-1 text-primary border-bottom mr-2">Contact : ${count} </strong><button class="btn btn-outline-danger btn-sm contact-delete-btn" data-toggle="tooltip" title="Delete Contact" ><i class="fa fa-trash"></i></button>
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="contact_name" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.name')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <input type="text"  class="form-control" name="contact_name[]" id="contact_name">
                                                        

                                                        <?php if($errors->has('contact_name')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('contact_name')); ?>

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

                                                </div>


                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="contact_email" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.email')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <input type="email"  class="form-control" name="contact_email[]" id="contact_email">
                                                        

                                                        <?php if($errors->has('contact_email')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('contact_email')); ?>

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

                                                </div>
                                                <div class="form-group d-flex justify-content-between align-items-center">
                                                    <label for="contact_phone" class="col-md-4"><?php echo e(__('message.contact')); ?> <?php echo e(__('message.phone')); ?></label>
                                                    <div class="col-md-8 px-0">
                                                        <input  class="form-control" name="contact_phone[]" id="contact_phone">
                                                        

                                                        <?php if($errors->has('contact_phone')): ?>
                                                            <div class="error">
                                                                <?php echo e($errors->first('contact_phone')); ?>

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

                                                </div>
                                                
                                </div>
                                                        
                        `;

                        if ($(".add-contact-box").append(contact_box))
                        {
                                count++;
                        }
                    
                        $(".contact-delete-btn").click(function(){
                            $(this).parent().remove();
                            count--;
                            });
                        }
                    else
                    {
                        alert("You Can Add 5 Contacts !");
                    }
                });
                    
            
    });
    $(".contact-delete-btn").click(function(){
        $(this).parent().remove();
        count--;
    });
                        
           

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

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

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

            $("#shipping_location_country").on("change",function(){
                var company_id = $(this).val();
                stateFetch(company_id,"shipping_location_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));
                    }
                });
        }

        $("#shipping_location_city").on("click",function(){
            //var search = $(this).val();
            $(".shipping_location_city_search_box").html("");
            if($(".shipping-main-add-city-box").hasClass("d-none"))
            {
                $(".shipping-main-add-city-box").removeClass("d-none");
                $(".shipping-add-search-city-box").removeClass("d-none");

                var typed_city = `
                            <input type="search" class='form-control border px-2 search-city-val' 
                             style='list-style:none;cursor:pointer;'>`;

               
                            
                $(".shipping-add-search-city-box").html(typed_city);
                $(".search-city-val").focus();
                
                $(".search-city-val").on('input',function(){
                    
                    $(".shipping_location_city_search_box").removeClass("d-none");
                
                    var search = $(this).val();
                    $.ajax({
                        type: "post",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        data: {
                            "search": search
                        },
                        url: "<?php echo e(asset('search-city')); ?>",
                        dataType: "html",
                        success: function(result) 
                        {
                            $(".shipping_location_city_search_box").html("");

                        
                                    
                            var allData = JSON.parse(result);
                            if(allData.message=="success")
                            {
                                //$(".location_city_search_box").removeClass('d-none');
                                var data = allData.data;
                                console.log(data);
                                var i;                           
                                        
                                var new_li = `<li class='text-capitalize rounded new_city_add_btn text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer;background:grey'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".shipping_location_city_search_box").append(new_li);
                            
                                for(i=0;i<data.length;i++)
                                {
                                    
                                    var li = `<li class='text-capitalize rounded city_name_li bg-dark text-white p-2 mb-2' city='${data[i].city_name}' style='list-style:none;cursor:pointer;background:grey'>
                                        ${data[i].city_name}</li>`;
                                    $(".shipping_location_city_search_box").append(li);
                                }
                                $(".city_name_li").click(function(){
                                
                                    var city = $(this).attr('city');
                                    console.log(city);
                                    $("#shipping_location_city").val(city);
                                    
                                    $(".shipping_location_city_search_box").addClass('d-none');
                                    $(".shipping-main-add-city-box").addClass("d-none");
                                    $(".shipping-add-search-city-box").addClass("d-none");
                                });
                            }
                            else
                            {
                                console.log("failed");
                                var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".shipping_location_city_search_box").append(new_li);
                            }

                                $(".new_city_add_btn").click(function(){
                                    var city = $(this).attr('addcity');
                                    var loc_city = $("#shipping_location_city").val(city);
                                // alert(loc_city);
                                    //var city_name = $("#b_city_name").val();
                                    addCity(city,"shipping-main-add-city-box","shipping_location_city");
                                
                                });
                        },
                        error:function(xhr,error,status)
                        {
                            console.log(JSON.parse(xhr.responseText));
                            var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".shipping_location_city_search_box").append(new_li);
                        }
                    });
                });
            }  
            
            else
            {
                $(".shipping-main-add-city-box").addClass("d-none"); 
            }
        })
        //location city code
        $("#location_city").on("click",function(){
            //var search = $(this).val();
            $(".location_city_search_box").html("");
            if($(".main-add-city-box").hasClass("d-none"))
            {
                $(".main-add-city-box").removeClass("d-none");
                $(".add-search-city-box").removeClass("d-none");

                var typed_city = `
                            <input type="search" class='form-control border px-2 search-city-val' 
                             style='list-style:none;cursor:pointer;'>`;

               
                            
                $(".add-search-city-box").html(typed_city);
                $(".search-city-val").focus();
                
                $(".search-city-val").on('input',function(){
                    
                    $(".location_city_search_box").removeClass("d-none");
                
                    var search = $(this).val();
                    $.ajax({
                        type: "post",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        data: {
                            "search": search
                        },
                        url: "<?php echo e(asset('search-city')); ?>",
                        dataType: "html",
                        success: function(result) 
                        {
                            $(".location_city_search_box").html("");

                        
                                    
                            var allData = JSON.parse(result);
                            if(allData.message=="success")
                            {
                                //$(".location_city_search_box").removeClass('d-none');
                                var data = allData.data;
                                console.log(data);
                                var i;                           
                                        
                                var new_li = `<li class='text-capitalize rounded new_city_add_btn text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer;background:grey'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".location_city_search_box").append(new_li);
                            
                                for(i=0;i<data.length;i++)
                                {
                                    
                                    var li = `<li class='text-capitalize rounded city_name_li bg-dark text-white p-2 mb-2' city='${data[i].city_name}' style='list-style:none;cursor:pointer;background:grey'>
                                        ${data[i].city_name}</li>`;
                                    $(".location_city_search_box").append(li);
                                }
                                $(".city_name_li").click(function(){
                                
                                    var city = $(this).attr('city');
                                    console.log(city);
                                    $("#location_city").val(city);
                                    
                                    $(".location_city_search_box").addClass('d-none');
                                    $(".main-add-city-box").addClass("d-none");
                                    $(".add-search-city-box").addClass("d-none");
                                });
                            }
                            else
                            {
                                console.log("failed");
                                var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".location_city_search_box").append(new_li);
                            }

                                $(".new_city_add_btn").click(function(){
                                    var city = $(this).attr('addcity');
                                    var loc_city = $("#location_city").val(city);
                                // alert(loc_city);
                                    //var city_name = $("#b_city_name").val();
                                    addCity(city,"main-add-city-box","location_city");
                                
                                });
                        },
                        error:function(xhr,error,status)
                        {
                            console.log(JSON.parse(xhr.responseText));
                            var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                        Add &nbsp"${search}"...</li>`;
                                    $(".location_city_search_box").append(new_li);
                        }
                    });
                });
            }  
            
            else
            {
                $(".main-add-city-box").addClass("d-none"); 
            }
                

        });
        
        
        //city code
        $("#billing_city").on("click",function(){
           
            //var search = $(this).val();
            $(".billing_city_search_box").html("");
            $(".billing-main-add-city-box").removeClass("d-none");
            $(".billing-add-search-city-box").removeClass("d-none");
           
            var typed_city = `
                            <input type="search" class='form-control innder-border border search-city-val' 
                             style='list-style:none;cursor:pointer'>`;
                            
                $(".billing-add-search-city-box").html(typed_city);
                $(".search-city-val").focus();
            $(".search-city-val").on('input',function(){
                
                $(".billing_city_search_box").removeClass("d-none");
               
                var search = $(this).val();
                $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        "search": search
                    },
                    url: "<?php echo e(asset('search-city')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {
                        $(".billing_city_search_box").html("");

                       
                                
                        var allData = JSON.parse(result);
                        if(allData.message=="success")
                        {
                            //$(".location_city_search_box").removeClass('d-none');
                            var data = allData.data;
                            console.log(data);
                            var i;                           
                                    
                            var new_li = `<li class='text-capitalize rounded new_city_add_btn p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer;background:#ddd'>
                                    Add &nbsp"${search}"...</li>`;
                                $(".billing_city_search_box").append(new_li);
                           
                            for(i=0;i<data.length;i++)
                            {
                                
                                var li = `<li class='text-capitalize rounded city_name_li p-2 mb-2' city='${data[i].city_name}' style='list-style:none;cursor:pointer;'>
                                    ${data[i].city_name}</li>`;
                                $(".billing_city_search_box").append(li);
                            }
                            $(".city_name_li").on('mouseover',function(){
                                $(this).css({'background':'#ddd','color':'white'});
                            });
                            $(".city_name_li").on('mouseleave', function(){
                                // Reset background and text color when mouse leaves
                                $(this).css({'background':'','color':''});
                            });
                            $(".city_name_li").click(function(){
                               
                                var city = $(this).attr('city');
                                console.log(city);
                                $("#billing_city").val(city);
                                
                                $(".billing_city_search_box").addClass('d-none');
                                $(".billing-main-add-city-box").addClass("d-none");
                                $(".billing-add-search-city-box").addClass("d-none");
                            });
                        }
                        else
                        {
                            console.log("failed");
                            var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                    Add &nbsp"${search}"...</li>`;
                                $(".billing_city_search_box").append(new_li);
                        }

                            $(".new_city_add_btn").click(function(){
                                var city = $(this).attr('addcity');
                                var loc_city = $("#billing_city").val(city);
                               // alert(loc_city);
                                //var city_name = $("#b_city_name").val();
                                addCity(city,"billing-main-add-city-box","billing_city");
                            
                            });
                    },
                    error:function(xhr,error,status)
                    {
                        console.log(JSON.parse(xhr.responseText));
                        var new_li = `<li class='text-capitalize rounded new_city_add_btn bg-dark text-white p-2 mb-2' addcity="${search}" style='list-style:none;cursor:pointer'>
                                    Add &nbsp"${search}"...</li>`;
                                $(".location_city_search_box").append(new_li);
                    }
                });
            });

            


        });

        
        

        $(".location-add-city-btn").click(function(){
            if($(".location-add-city-box").hasClass("d-none"))
            {
                $(".location-add-city-box").removeClass("d-none");
                $(".location-add-city-box").removeClass("animate__animated animate__fadeOut");
                $(".location-add-city-box").addClass("animate__animated animate__bounceInRight");
                $(".location-add-city-box i").removeClass("fa-plus");
                $(".location-add-city-box i").addClass("fa-minus");
            }
            else
            { 
                
                $(".location-add-city-box").removeClass("animate__animated animate__bounceInRight")    
                $(".location-add-city-box").addClass("animate__animated animate__fadeOut"); 
                $(".location-add-city-box").addClass("d-none");              
                $(".location-add-city-box i").removeClass("fa-minus");
                $(".location-add-city-box i").addClass("fa-plus");
                
            }
            
           
           
        });

        $(".l-city-form-btn").click(function(){
            
            var city_name = $("#l_city_name").val();
            addCity(city_name,"location-add-city-box","location_city");
        });
        

        function addCity(city_name,cityformBox,city_input)
        {
            $.ajax({
                    type: "post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        "city_name": city_name
                    },
                    url: "<?php echo e(asset('add-city')); ?>",
                    dataType: "html",
                    success: function(result) 
                    {
                        console.log(result);
                        var allData = JSON.parse(result);
                        if(allData.message=="success")
                        {
                            $("."+cityformBox).addClass("d-none");
                            $("."+city_input).val(allData.data);
                            
                        }
                        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');
    }

    $(".billing-btn-toggle").click(function(){
        if($(".billing-address-main").hasClass('d-none'))
        {
            $(".billing-address-main").removeClass("d-none");
        }
        else
        {
            $(".billing-address-main").addClass("d-none");
        }
    });



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

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