<?php $__env->startSection('content'); ?>
  <div class="common-content">
    <div class="page-content">
      <div class="page-heading">
        <div class="headings">
          <h6>Get a quote</h6>
        </div>
      </div>
      <div class="boxings">
      <form  id="getquote" method="POST" action="<?php echo e(url('buyers/addquote')); ?>">
      <?php echo csrf_field(); ?>
        <h6>Quote details</h6>
         <div class="flex-ngrad"><div>
            <div class="custom-control custom-radio">
              <input type="radio" class="custom-control-input" id="customRadio4" name="quote_urgency" checked value="2"> 
              <label class="custom-control-label" for="customRadio4">Normal Priority</label>
            </div>  
          </div>
             
          <div>
            <div class="custom-control custom-radio">
              <input type="radio" class="custom-control-input" id="customRadio3" name="quote_urgency"   value="1">
              <label class="custom-control-label" for="customRadio3">Urgent</label>
            </div>  
          </div>
		  
		  <div>
            <div class="custom-control custom-radio">
              <input type="radio" class="custom-control-input" id="customRadio5" name="quote_urgency"   value="3">
              <label class="custom-control-label" for="customRadio5">Ready stock</label>
            </div>  
          </div>
          
        </div>
          <div class="row">
              <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                <div class="form-inputs app-vend f-adj">
                                    <div class="form-group">
                                      <label class="label">Category<sup>*</sup></label>                                       
                                      <select id="category_id" class="form-control <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?> invoiceselect" name="category_id" value="<?php echo e(old('category_id')); ?>" required autocomplete="category_id" autofocus>
                                        <option value="">Select</option>
                                        <?php $__currentLoopData = $category_lists; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($category->category_id); ?>"><?php echo e($category->category); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                      </select>
                                     
                                    </div>
                                </div>
                              </div>
              
          <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
              <div class="form-inputs app-vend f-adj">
                  <div class="form-group">
                      <label>Product<sup>*</sup></label>
                    <select class="form-control js-example-disabled-results invoiceselect"  id="master_product" name="product_id" required>
                      <option value="">Select</option>
                      
                    </select>
                    </div>
              </div>
            </div>
         
        </div>                                                      
        <div class="row">
          <div class="col-lg-112 col-md-12 col-sm-12 col-xs-12">
            <div class="form-inputs app-vend">
              <div class="form-group">
                <label>Product Information<sup>*</sup></label>
                <textarea class="form-control" rows="5" id="comment" name="product_information"></textarea>
              </div>
            </div>
          </div>
        </div>
          <hr>
        <div class="manufact">
          <h6>
            Manufacturer  
          </h6>
          <div class="cust-check">
            <div class="custom-control custom-checkbox">
              <input type="checkbox" class="custom-control-input allmanufacturer <?php $__errorArgs = ['manufacturer'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="manufacturer" id="manufacturer" value="all"  onchange="valueChanged()" autocomplete="manufacturer"checked autofocus>
              <label class="custom-control-label" for="manufacturer">All</label>
                                <?php $__errorArgs = ['manufacturer'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>
          </div>
        </div>
        
        <div class="row manufacturerlist" style="display:none;" >
          <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>Manufacturer 1</label>
                <select class="form-control selectmanufacturer invoiceselect" id="sel1" name="manufacturer1_id">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div>
          <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>Manufacturer 2</label>
                <select class="form-control selectmanufacturer invoiceselect" id="sel2" name="manufacturer2_id">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div>
          <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>Manufacturer 3</label>
                <select class="form-control selectmanufacturer invoiceselect" id="sel3" name="manufacturer3_id">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div>
        </div>
          <hr>
        <div class="vendorsection">
        <div class="manufact">
          <h6>
            Vendor<sup>*</sup>  
          </h6>
        </div>
        <div class="flex-ngrad row">
          <div class="col-lg-3" >
            <div class="custom-control custom-radio f-rad">
              <input type="radio" class="custom-control-input vendorall <?php $__errorArgs = ['vendor'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="vendor" name="vendor"  value="all" autocomplete="manufacturer" autofocus checked  >
              <label class="custom-control-label" for="vendor">All</label>
              <?php $__errorArgs = ['vendor'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>  
          </div>
          <div class="col-lg-3">
            <div class="custom-control custom-radio">
              <input type="radio" class="custom-control-input approvevendor" id="customRadio1" name="vendor" value="approved">
              <label class="custom-control-label" for="customRadio1">Approved Vendors</label>
            </div>  
          </div>
          <!-- <div>
            <div class="custom-control custom-radio">
              <input type="radio" class="custom-control-input" id="customRadio2" name="vendor" value="none">
              <label class="custom-control-label" for="customRadio2">None</label>
            </div>  
          </div> -->
        </div>
                    <!--<div class="row" id="approved-vendor">
                    <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                    <div class="form-inputs app-vend">
                    <div class="form-group">
                        <label>Approved Vendors</label>
                        <select class="form-control aprovedvendorchanges" id="sel1" name="vendor_id">
                            <option value="">Select</option>
                            <option value="all">All</option>
                            <?php $__currentLoopData = $approvedvendors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vendors): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($vendors->id); ?>"><?php echo e($vendors->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    </div>
                    </div>
                    </div>-->
        </div>
        <div class="locationsection" style="display:block">
        <div class="manufact">
          <h6>
            Location  
          </h6>
        </div>
        <div class="row">
         <!-- <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>Country</label>
                <select class="form-control" id="sel1" name="country">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div> -->


	<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>Country</label>
                <!-- <select class="form-control" id="sel1" name="country">
                  <option value="">Select</option>
                </select> -->
                <select class="form-control <?php $__errorArgs = ['state'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="country" name="country">
                  <option value="">Select</option>
                  <?php $__currentLoopData = $states; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $state): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <option value="<?php echo e($state->id); ?>" <?php if($state->id == '101') {?>selected<?php  }?>><?php echo e($state->name); ?></option>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
              </div>
            </div>
          </div>

         <!-- <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>State</label>
                <select class="form-control" id="sel1" name="state">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div>
        </div>
        </div> -->


	<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
            <div class="form-inputs">
              <div class="form-group">
                <label>State</label>
                <select class="form-control invoiceselect" id="state" name="state">
                  <option value="">Select</option>
                </select>
              </div>
            </div>
          </div>
        </div>
        </div>
          <div class="row">
               <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
              <div class="form-inputs app-vend">
                  <div class="form-group calIcons">
                    <label>Closing Date<sup>*</sup></label>
                    <input id="datepicker-after-date" type="text" class="form-control" data-zdp_readonly_element="false" name="closing_date" required>
                  </div>
              </div>
            </div>
          </div>
          
          <div class="row alert-msg" style="display:none" >
          <div class="col-12">
             
            <div class="green-button">
                 <span style="color:red" class="alert-result"></span>
            </div> 
          </div>
        </div>
        
        
        <div class="row">
          <div class="col-12">
            <div class="green-button">
              <button id="create">GET  A QUOTE</button>
            </div> 
          </div>
        </div>
        </form>
      </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script type="text/javascript">

$( document ).ready(function() {
  var countryid = '101';
      var APP_URL = <?php echo json_encode(url('/getstates1')); ?> ;
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+countryid,
            data: { countryid: countryid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) { 
              $("#state").html(resultData);
            }
            });
});

    function valueChanged()
    {
        if($('.allmanufacturer').is(":checked")){
          $(".manufacturerlist").hide();
          $(".selectmanufacturer").val('');
          $('.vendorsection').show();
          
        }else{ 
          $(".manufacturerlist").show();    
        }
    }

    $(function() {
      
        $('.selectmanufacturer').change(function(){

          if($('.selectmanufacturer').val() != ''){
            $('.vendorsection').hide();           
          }else if($('.selectmanufacturer').val() == ''){
            $('.vendorsection').show();
          }
        });    

    });

    $(function() {
      
      $('.vendorall').change(function(){
        if($('.vendorall').is(":checked")) 
        $('.locationsection').show();
        else
        $('.locationsection').hide();
      });

      $('.approvevendor').change(function(){
        if($('.approvevendor').is(":checked")) 
        $('.locationsection').hide();
        else
        $('.locationsection').show();
      });    

  });

  $(function() {
      
      $('.aprovedvendorchanges').change(function(){
        if($('.aprovedvendorchanges').val() == 'all') 
        $('.locationsection').show();
        else
        $('.locationsection').hide()
      });
      
  });
  
   

$('#country').on('change', function() {
      var countryid = this.value;
      var APP_URL = <?php echo json_encode(url('/getstates1')); ?> ;
      
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+countryid,
            data: { countryid: countryid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) { 
              $("#state").html(resultData);
            }
            });
            
    });
    
     $('#category_id').on('change', function() {
      var catid = this.value;
      var APP_URL = <?php echo json_encode(url('/getproducts')); ?> ;
      $(".pageloader").show();
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+catid,
            data: { catid: catid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) { 
             $("#master_product").html(resultData);
             $(".pageloader").hide();
            }
            });
            
    });
    
</script>
<script>
var $disabledResults = $(".js-example-disabled-results");
$disabledResults.select2();
</script>
<script>
$("#create").click(function(){
   // alert("bbbb");
	$("#getquote").validate({
        rules: {
            
			"category_id": {
                required: true
               
            },
            "product_id": {
                required: true
               
            },
            "product_information": {
                required: true
               
            },
            "closing_date": {
                required: true
               
            },
            "vendor": {
                required: true
               
            },
            
        },
        submitHandler: function(form, e) {
             $(".pageloader").show();
            $(".pageloader").delay(5000).fadeOut("slow");
		   form.submit();
        }
    });
});
$(function(){
    $('#getquote').on('submit', function(event){
        event.preventDefault();
       
    });
});

 $(function() {
     
     $('.allmanufacturer').change(function(){
          $(".alert-result").html('');
          $('.alert-msg').hide();
        if($('.allmanufacturer').is(":checked")) {
            if($('.vendorall').is(":checked")) {
            var product_id =  $('#master_product').val();
            var APP_URL = <?php echo json_encode(url('/getproductvendors')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id,
                data: { product_id: product_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 
                  var msg='';
                    if(resultData > 0){
                      

                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }


                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
            }else if($('.approvevendor').is(":checked")) {
                var product_id =  $('#master_product').val();
            var APP_URL = <?php echo json_encode(url('/getproductapprovedvendors')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id,
                data: { product_id: product_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 
                    if(resultData > 0){

                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }
                       
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        var msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
        }else{
            var product_id =  $('#master_product').val();
            var APP_URL = <?php echo json_encode(url('/getproductvendors')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id,
                data: { product_id: product_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 

                  var msg='';
                    if(resultData > 0){

                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }
                        
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        var msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
        }
        }else{
             $(".alert-result").html('');
            $('.alert-msg').hide();
        }
      });
     
     
      
      $('.vendorall').change(function(){
          $(".alert-result").html('');
          $('.alert-msg').hide();
        if($('.vendorall').is(":checked")) {
            var product_id =  $('#master_product').val();
            var APP_URL = <?php echo json_encode(url('/getproductvendors')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id,
                data: { product_id: product_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 
                  var msg='';
                    if(resultData > 0){
                     
                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }
                         
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
        }else{
             $(".alert-result").html('');
            $('.alert-msg').hide();
        }
      });

      $('.approvevendor').change(function(){
           $(".alert-result").html('');
          $('.alert-msg').hide();
        if($('.approvevendor').is(":checked")) {
                var product_id =  $('#master_product').val();
            var APP_URL = <?php echo json_encode(url('/getproductapprovedvendors')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id,
                data: { product_id: product_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 
                  var msg='';
                    if(resultData > 0){
                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }

                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
        }else{
         $(".alert-result").html('');
            $('.alert-msg').hide();
        }
      });    

  });
  
   $('#master_product').on('change', function() {
            //$(".vendorall").val('');
            //$(".approvevendor").val('');
            //$('input[type=radio][name="vendor"]').prop('checked', false);
            $(".alert-result").html('');
            $('.alert-msg').hide();
    });
    
    $('#master_product').on('change', function() {
            var prdid = this.value;
            var APP_URL = <?php echo json_encode(url('/getproductsmanufacturer')); ?> ;
            var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+prdid,
            data: { prdid: prdid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) { 
                console.log(resultData);
              $("#sel1").html(resultData);
              $("#sel2").html(resultData);
              $("#sel3").html(resultData);
            }
            });
    });

</script>

<script>
    $('#state').change(function(){
           $(".alert-result").html('');
          $('.alert-msg').hide();
                var product_id =  $('#master_product').val();
                var state_id  = $('#state').val();
            var APP_URL = <?php echo json_encode(url('/getproductvendorslocation')); ?> ;
            var saveData = $.ajax({
                type: 'GET',
                url: APP_URL+'/'+product_id+'/'+state_id,
                data: { product_id: product_id,state_id: state_id, _token: '<?php echo e(csrf_token()); ?>' },
                dataType: "text",
                success: function(resultData) { 

                     var msg='';
                    if(resultData > 0){

                      if(resultData==1){
                        msg = resultData+' vendor selling this product';
                      }
                      else{
                        msg = resultData+' vendors selling this product';
                      }


                       
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }else{
                        var msg = 'No vendor selling this product';
                        $(".alert-result").html(msg);
                        $('.alert-msg').show();
                    }
                }
            });
      
      });   
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/buyers/get_quote.blade.php ENDPATH**/ ?>