</div>
    <!-- /#wrapper -->
    
    <script>
var deleteLinks = document.querySelectorAll('.delete');

for (var i = 0; i < deleteLinks.length; i++) {
deleteLinks[i].addEventListener('click', function(event) {
  event.preventDefault();

  var choice = confirm(this.getAttribute('data-confirm'));

  if (choice) {
    window.location.href = this.getAttribute('href');
  }
});
}
</script>
<script>
function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#upload')
                    .attr('src', e.target.result)
                    .width(300)
                    .height(150);
            };

            reader.readAsDataURL(input.files[0]);
        }
    }
</script>
    
   <script src="js/jquery3.min.js"></script>
    <script src="js/bootstrap.3.min.js"></script>

    
<script src="js/jquery.dataTables1.min.js"></script>
<script src="js/dataTables.bootstrap.min.js"></script>
<script src="js/dataTables.responsive.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
    
    <script src="js/tabby.min.js"></script>
    <script>
		var tabs = new Tabby('[data-tabs]');
	</script>
 <script>
		var tabsx = new Tabby('[data-tabsx]');

	</script>


<script type="text/javascript">
function fetchClientData(d){
    var a = document.getElementById(d);
    if(typeof(a) != 'undefined' || a != null){ 
    a.onclick = function() {
        var n = d.substr(10);
        n1 = "new" +n+n;
        n2 = "old" +n+n;  

        if(typeof(n) != 'undefined' || n != null){   
        $.ajax({
        type: "POST",
        url: "client_price_list_adata.php",
        data:'cl_id='+n,
        success: function(data){
            $("#"+n1).html(data);
            $("#"+n2).hide();

       
        $('#dataTables-bidwiz'+n1).DataTable({
            responsive: true,
           
        
        });


       

       
        $('#dataTables-bidwiz'+n2).DataTable({
            responsive: true,
            "order": [[ 0, "desc" ]],
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });

        }
        });
    }

          return true;
    }   
}
}
</script> 

<script>
   $(document).ready(function() {
        $('#dataTables-bidwiz12333').DataTable({
            responsive: true,           
            "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
          
            "ordering":false,
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
    });

    $(document).ready(function() {
        $('#dataTables-bidwiz-view-invoice').DataTable({
            responsive: true, 
            "paging":true,
            "ordering":false,
            "processing": true,
            "serverSide": true,
            "ajax":{
                url :"view_invoices_response.php?client_id=<?php echo $cl_id; ?>&year=<?php echo $year_selected; ?>&option=<?php echo $option_selected; ?>&value=<?php echo $value_selected; ?>",                                
                type: "post",
            },
            "language": {
                        processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw" style="color:#0b57a4;margin-top:15%"></i><span class="sr-only">Loading..n.</span> '
                        },
            "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        });       
    });
    $(document).ready(function() {
        $('#dataTables-bidwiz-view-bid').DataTable({
            responsive: true, 
            "paging":true,
            "ordering":false,
            "processing": true,
            "serverSide": true,
            "ajax":{
                url :"view_bids_response.php?client_id=<?php echo $cl_id; ?>&year=<?php echo $year_selected; ?>&option=<?php echo $option_selected; ?>&value=<?php echo $value_selected; ?>",                               
                type: "post",
            },
            "language": {
                        processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw" style="color:#0b57a4;margin-top:15%"></i><span class="sr-only">Loading..n.</span> '
                        },
            "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],                      
        });       
    });     
              
   
    </script>

 <?php

$query = "SELECT * FROM client WHERE is_approve = 1 AND client_is_delete IS NULL AND is_list = 1";

$run = mysqli_query($conn, $query);

if(mysqli_num_rows($run)>0){
    echo "<script>";
    $c = 1;
    while($row = mysqli_fetch_array($run)){
    $client_id = $row['client_id'];
    $s = $c + 1;
    $c = 'var c'.$s;

    echo $c . ' = "client_id_'. $client_id .'";';
    

    echo 'fetchClientData(c' .$s. ');';

   }

   
   echo 'var cxx0 = "client_id_0";';
    echo 'fetchClientData(cxx0);';
  
  echo "</script>"; 

}


?> 
<!-- price-->
<script type="text/javascript">
function fetchClientItemData(d){

    var a = document.getElementById(d);
    if(typeof(a) != 'undefined' || a != null){ 
    a.onclick = function() {
/*         var tabsx= new Tabby('[data-tabsx]');       
 */
       /*  tabsx.destroy(); */
        var n = d.substr(11);
        n1 = "nqew" +n+n;
        n2 = "oqld" +n+n;  

        if(typeof(n) != 'undefined' || n != null){   
        $.ajax({
        type: "POST",
        url: "zclient_item_list_adata.php",
        data:'cl_id='+n,
        success: function(data){
            $("#"+n1).html(data);
            $("#"+n2).hide();

       
        $('#dataTables-bidwiz'+n1).DataTable({
            responsive: true,
           
        
        });
         /* do add vars here */

        /* '[data-tabsx]' */
        var qwe = '[data-tabsx'+ n + ']';
		var tabsx= new Tabby(qwe);       

       
        $('#dataTables-bidwiz'+n2).DataTable({
            responsive: true,
            "order": [[ 0, "desc" ]],
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });

        }
        });
    }

          return true;
    }   
}
}
</script> 

 <?php

$query = "SELECT * FROM client WHERE is_approve = 1 AND client_is_delete IS NULL AND is_list = 1";

$run = mysqli_query($conn, $query);

if(mysqli_num_rows($run)>0){
    echo "<script>";
    $c = 1;
    while($row = mysqli_fetch_array($run)){
    $client_id = $row['client_id'];
    $s = $c + 1;
    $c = 'var c'.$s;

    echo $c . ' = "clientq_id_'. $client_id .'";';
    

    echo 'fetchClientItemData(c' .$s. ');';

   }

   
   echo 'var cxx0 = "clientq_id_0";';
    echo 'fetchClientItemData(cxx0);';
  
  echo "</script>"; 

}
?> 

<!-- /  price1 -->


    <script>
    function hideRowUOM() {
       var val3 = document.getElementById("maps_uom");
       if(typeof(val3) != 'undefined' && val3 != null){
        val3 = val3.value;

    }
        if(val3 == ''){
            var elemxxx = document.querySelector('#UOMsetDeleteRow');
if(typeof(elemxxx) != 'undefined' && elemxxx != null){
    elemxxx.style.display = 'block';
    }

        }else{
    var elemxxx = document.querySelector('#UOMsetDeleteRow');
if(typeof(elemxxx) != 'undefined' && elemxxx != null){
    elemxxx.style.display = 'none';
    }

}
 
}

function getUOMvalue() {
  var val1 = document.getElementById("maps_uom");
  val1 = val1.value;    
  var val2 = document.getElementById("maps_id");  
  if(typeof(val2) == 'undefined' || val2 == null){
        val2 = '';
    }else{
        val2 = val2.value;
    }
  $.ajax({
  type: "POST",
  url: "get_uom_value.php",
  data:'maps_uom_id='+val1+'&maps_id='+val2,
  success: function(data){
    $("#displayUOMvalueForm").html(data);
  }
  });

  hideRowUOM();
}
function getUOMvalue3() {
  var val1 = document.getElementById("maps_uom").value;
 
  
  $.ajax({
  type: "POST",
  url: "get_uom_value.php",
  data:'maps_uom_id='+val1+'&maps_id=',
  success: function(data){
    $("#displayUOMvalueForm").html(data);
  }
  });

  hideRowUOM();
}

function getUOMvalue1() {
  var val1 = document.getElementById("maps_uom");
    if(typeof(val1) != 'undefined' && val1 != null){
        val1 = val1.value;  
    }

    var val2 = document.getElementById("maps_id");
    if(typeof(val2) != 'undefined' && val2 != null){
        val2 = val2.value;  
    }
 
  if(typeof(val2) == 'undefined' && val2 == null){
        val2 = '';
    }
  $.ajax({
  type: "POST",
  url: "get_uom_value.php",
  data:'maps_uom_id='+val1+'&maps_id='+val2,
  success: function(data){
    $("#displayUOMvalueForm").html(data);
  }
  });
  
}
getUOMvalue1();
hideRowUOM();
function showChildCat(){
    var elemxxx = document.querySelector('#hiddenCatInput');
elemxxx.style.display = 'block';


}

function showSubmitGroup(){
    var elemxxx1 = document.querySelector('#hiddenSubmitGroup');
elemxxx1.style.display = 'block';


}
<?php 
if(!isset($url_client_id)){
    $url_client_id = 0;
    
}

?>
function getParentItemValue(){
  var val1 = document.getElementById("cat_name_parent");
  val1 = val1.value; 
  if(typeof(val1) != 'undefined' || val2 != null){   
        $.ajax({
        type: "POST",
        url: "get_maps_name_parent.php",
        data:'cat_id='+val1+ '&cl_id=<?php echo $url_client_id; ?>',
        success: function(data){
            $("#maps_group_parent_name").html(data);
        }
        });
    }
  
}
function getChildItemValue(){
  var val1 = document.getElementById("cat_name_child");
  val1 = val1.value; 
  if(typeof(val1) != 'undefined' || val2 != null){   
        $.ajax({
        type: "POST",
        url: "get_maps_name_child.php",
        data:'cat_id='+val1+ '&cl_id=<?php echo $url_client_id; ?>',
        success: function(data){
            $("#maps_group_child_name").html(data);
        }
        });
    }
  
}

function getNewBidPropValue(){
  var val1 = document.getElementById("new_bid_client_name");
  val1 = val1.value; 
  if(typeof(val1) != 'undefined' || val1 != null){ 
    var elemxxxq = document.querySelector('#new_bid_wo');
        
        elemxxxq.style.display = 'none';
      
    var data33 = '';
         $("#new_bid_if_add").html(data33);   
        $.ajax({
        type: "POST",
        url: "get_new_bid_client_prop.php",
        data:'cl_id='+val1,
        success: function(data){
            $("#new_bid_prop_column").html(data);
        }
        });
    }
  
}

function getNewBidWOValue(){
  var val1 = document.getElementById("new_bid_prop_id");
  val1 = val1.value; 
  if(typeof(val1) != 'undefined' || val1 != null){ 
    
      if(val1 == 'new'){
        var data3 = '';
         $("#new_bid_if_set").html(data3);
      var data2 = '<div class = "row">'+
        
        '<div class = "form-group col-lg-6">'+
        '<label for="prop_case_num">Case/Loan Number</label>'+
        '<input type="text" class="form-control" name="prop_case_num" id="prop_case_num" value="<?php $prop_case_num =time().mt_rand (10,99); echo $prop_case_num; ?>" required="required" autofocus>'+
        '</div>'+
        '<div class = "form-group col-lg-6">  '+                           

        '</div>'+
        ' </div>  '+      

      '  <div class = "row">      '+  
      ' <div class = "form-group col-lg-6">'+
      '     <label for="prop_full_add">Address</label> '+         
      '     <textarea rows="4" name="prop_full_add" class = "form-control" id="prop_full_add" placeholder=""  maxlength="5000"></textarea>  '+

         '   </div>   '+
    
         '<div class = "form-group col-lg-6">'+
         '  <div class="row">'+
         '    <div class="form-group col-lg-6">'+
         '          <label for="prop_city">City</label>'+
                    

                        '    <input type="text" class="form-control" name="prop_city" id="prop_city" required="required">   '+ 

                      '  </div>'+
                      '   <div class="form-group col-lg-6">'+
                      '  <label for="prop_county">County</label>'+
                    

                          '  <input type="text" class="form-control" name="prop_county" id="prop_county" required="required">  '+
                        
                          '</div>'+
                       
                    
                          ' </div>'+

                  '  <div class="row">'+

                       ' <div class="form-group col-lg-6">'+
                       '  <label for="prop_state">State</label>'+

                      '  <select class="form-control" name="prop_state"  id="prop_state" required="required">'+
                      ' <option value="" disabled="disabled" selected="selected">Select State</option>'+

	'<option value="AL">Alabama</option>'+
	'<option value="AK">Alaska</option>'+
	'<option value="AZ">Arizona</option>'+
	'<option value="AR">Arkansas</option>'+
	'<option value="CA">California</option>'+
	'<option value="CO">Colorado</option>'+
	'<option value="CT">Connecticut</option>'+
	'<option value="DE">Delaware</option>'+
	'<option value="DC">District of Columbia</option>'+
	'<option value="FL">Florida</option>'+
	'<option value="GA">Georgia</option>'+
	'<option value="HI">Hawaii</option>'+
	'<option value="ID">Idaho</option>'+
	'<option value="IL">Illinois</option>'+
	'<option value="IN">Indiana</option>'+
	'<option value="IA">Iowa</option>'+
	'<option value="KS">Kansas</option>'+
	'<option value="KY">Kentucky</option>'+
	'<option value="LA">Louisiana</option>'+
	'<option value="ME">Maine</option>'+
	'<option value="MD">Maryland</option>'+
	'<option value="MA">Massachusetts</option>'+
	'<option value="MI">Michigan</option>'+
	'<option value="MN">Minnesota</option>'+
	'<option value="MS">Mississippi</option>'+
	'<option value="MO">Missouri</option>'+
	'<option value="MT">Montana</option>'+
	'<option value="NE">Nebraska</option>'+
	'<option value="NV">Nevada</option>'+
	'<option value="NH">New Hampshire</option>'+
	'<option value="NJ">New Jersey</option>'+
	'<option value="NM">New Mexico</option>'+
	'<option value="NY">New York</option>'+
	'<option value="NC">North Carolina</option>'+
	'<option value="ND">North Dakota</option>'+
	'<option value="OH">Ohio</option>'+
	'<option value="OK">Oklahoma</option>'+
	'<option value="OR">Oregon</option>'+
	'<option value="PA">Pennsylvania</option>'+
	'<option value="RI">Rhode Island</option>'+
	'<option value="SC">South Carolina</option>'+
	'<option value="SD">South Dakota</option>'+
	'<option value="TN">Tennessee</option>'+
	'<option value="TX">Texas</option>'+
	'<option value="UT">Utah</option>'+
	'<option value="VT">Vermont</option>'+
	'<option value="VA">Virginia</option>'+
	'<option value="WA">Washington</option>'+
	'<option value="WV">West Virginia</option>'+
	'<option value="WI">Wisconsin</option>'+
	'<option value="WY">Wyoming</option>'+
    '</select>'+
    '</div>'+
    ' <div class="form-group col-lg-6">'+
    '<label for="prop_zip">Zipcode</label>'+
    '   <input type="text" class="form-control" name="prop_zip" id="prop_zip" required="required">  '+                    

                     '   </div>'+

                   ' </div>'+
                
                
                   ' </div>    '+ ' </div>'; 


      $("#new_bid_if_add").html(data2); 
      var elemxxx = document.querySelector('#new_bid_wo');
        
        elemxxx.style.display = 'block';
      }else{
          var data3 = '';
         $("#new_bid_if_add").html(data3);
         var val11 = document.getElementById("new_bid_prop_id");
         val11 = val11.value;
         if(typeof(val11) != 'undefined' || val11 != null){   
       
        var data9 = '<input type = "hidden" name ="prop_id" value="'+val11 +'">';
      
        $("#new_bid_if_set").html(data9);

        var elemxxx = document.querySelector('#new_bid_wo');

        elemxxx.style.display = 'block';
        
    }

      }     


    }
  
}


function addAddress(){
    var data2 = '<div class = "row">'+
        
        '<div class = "form-group col-lg-6">'+
        '<label for="prop_case_num">Case/Loan Number</label>'+
        '<input type="text" class="form-control" name="prop_case_num" id="prop_case_num" value="<?php $prop_case_num =time().mt_rand (10,99); echo $prop_case_num; ?>" required="required" autofocus>'+
        '</div>'+
        '<div class = "form-group col-lg-6">  '+                           

        '</div>'+
        ' </div>  '+      

      '  <div class = "row">      '+  
      ' <div class = "form-group col-lg-6">'+
      '     <label for="prop_full_add">Address</label> '+         
      '     <textarea rows="4" name="prop_full_add" class = "form-control" id="prop_full_add" placeholder=""  maxlength="5000"></textarea>  '+

         '   </div>   '+
    
         '<div class = "form-group col-lg-6">'+
         '  <div class="row">'+
         '    <div class="form-group col-lg-6">'+
         '          <label for="prop_city">City</label>'+
                    

                        '    <input type="text" class="form-control" name="prop_city" id="prop_city" required="required">   '+ 

                      '  </div>'+
                      '   <div class="form-group col-lg-6">'+
                      '  <label for="prop_county">County</label>'+
                    

                          '  <input type="text" class="form-control" name="prop_county" id="prop_county" required="required">  '+
                        
                          '</div>'+
                       
                    
                          ' </div>'+

                  '  <div class="row">'+

                       ' <div class="form-group col-lg-6">'+
                       '  <label for="prop_state">State</label>'+

                      '  <select class="form-control" name="prop_state"  id="prop_state" required="required">'+
                      ' <option value="" disabled="disabled" selected="selected">Select State</option>'+

	'<option value="AL">Alabama</option>'+
	'<option value="AK">Alaska</option>'+
	'<option value="AZ">Arizona</option>'+
	'<option value="AR">Arkansas</option>'+
	'<option value="CA">California</option>'+
	'<option value="CO">Colorado</option>'+
	'<option value="CT">Connecticut</option>'+
	'<option value="DE">Delaware</option>'+
	'<option value="DC">District of Columbia</option>'+
	'<option value="FL">Florida</option>'+
	'<option value="GA">Georgia</option>'+
	'<option value="HI">Hawaii</option>'+
	'<option value="ID">Idaho</option>'+
	'<option value="IL">Illinois</option>'+
	'<option value="IN">Indiana</option>'+
	'<option value="IA">Iowa</option>'+
	'<option value="KS">Kansas</option>'+
	'<option value="KY">Kentucky</option>'+
	'<option value="LA">Louisiana</option>'+
	'<option value="ME">Maine</option>'+
	'<option value="MD">Maryland</option>'+
	'<option value="MA">Massachusetts</option>'+
	'<option value="MI">Michigan</option>'+
	'<option value="MN">Minnesota</option>'+
	'<option value="MS">Mississippi</option>'+
	'<option value="MO">Missouri</option>'+
	'<option value="MT">Montana</option>'+
	'<option value="NE">Nebraska</option>'+
	'<option value="NV">Nevada</option>'+
	'<option value="NH">New Hampshire</option>'+
	'<option value="NJ">New Jersey</option>'+
	'<option value="NM">New Mexico</option>'+
	'<option value="NY">New York</option>'+
	'<option value="NC">North Carolina</option>'+
	'<option value="ND">North Dakota</option>'+
	'<option value="OH">Ohio</option>'+
	'<option value="OK">Oklahoma</option>'+
	'<option value="OR">Oregon</option>'+
	'<option value="PA">Pennsylvania</option>'+
	'<option value="RI">Rhode Island</option>'+
	'<option value="SC">South Carolina</option>'+
	'<option value="SD">South Dakota</option>'+
	'<option value="TN">Tennessee</option>'+
	'<option value="TX">Texas</option>'+
	'<option value="UT">Utah</option>'+
	'<option value="VT">Vermont</option>'+
	'<option value="VA">Virginia</option>'+
	'<option value="WA">Washington</option>'+
	'<option value="WV">West Virginia</option>'+
	'<option value="WI">Wisconsin</option>'+
	'<option value="WY">Wyoming</option>'+
    '</select>'+
    '</div>'+
    ' <div class="form-group col-lg-6">'+
    '<label for="prop_zip">Zipcode</label>'+
    '   <input type="text" class="form-control" name="prop_zip" id="prop_zip" required="required">  '+                    

                     '   </div>'+

                   ' </div>'+
                
                
                   ' </div>    '+ ' </div>'; 


      $("#new_bid_if_add").html(data2); 
}
</script>

    <!-- Bootstrap Core JavaScript -->
 <!--    <script src="js/bootstrap.3.min.js"></script>

    
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="js/dataTables.bootstrap.min.js"></script>
    <script src="js/dataTables.responsive.js"></script>
 <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script> --> 
  
<script>
    $(document).ready(function() {
        $('#dataTables-bidwiz').DataTable({
            responsive: true,
            "order": [[ 0, "desc" ]],
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
    });
    </script>
    <script>

               

  
    </script>
    <script>
    $(document).ready(function() {
        $('#dataTables-bidwizzz').DataTable({
            responsive: true,
            "ordering": false,
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
       
    });
    </script>
   

   <script>
   
   
        $('#dataTables-bidwizzz1').DataTable({
            responsive: true,
            "ordering": false,
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
  
    </script> 


    <script>
    $(document).ready(function() {
        $('#dataTables-bidwiz2').DataTable({
            responsive: true,
           
        
        });
    });
    </script>
    <script>
    $(document).ready(function() {
        $('#dataTables-bidwiz1').DataTable({
            responsive: true,
            
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
    });
    </script>

    <script>
    $(document).ready(function() {
        $('#dataTables-signup').DataTable({
            responsive: true,
            "order": [[ 0, "desc" ]],
            dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
        });
    });
    </script>

<script>  
function cancelSubmitInv(){
    document.getElementById('submit_excel_form').style.display = 'none';
    $("#vendor-alert-success").fadeOut();
    $("#vendor-alert").fadeOut(); 
    $("#invoice_excel_table").fadeOut();
    $("#cancel_excel_inv").fadeIn(); 
}

function finalSubmitInv(){
    document.getElementById('submit_excel_form').style.display = 'none';
    $("#upload_excel_inv").fadeIn(); 
    var excel_inv_file = $("#invoice_file_excel").val();
    $.ajax({
        url: "invoices-import-adata.php?final_upload_excel=" + excel_inv_file,
        type: "POST",
        contentType: false,
        cache: false,
        processData:false,
        success: function(data){
            var data = data.trim();
            var data_response = JSON.parse(data);
            var succ = data_response.succ;             
            var status = data_response.status;            
            if(status == 'yes'){
                $("#invoice_excel_table").fadeOut();
                $("#upload_excel_inv").fadeOut();    
                $("#danger_text1").html(succ).fadeIn();
                $("#vendor-alert-success").fadeIn();
            }
        }          
    });
}

$('#addBidModal').click(function(e)
{
    e.preventDefault();   
    $('#bidModal').modal('show');
});

$(function(){
    $('#fileToUpload_inv').on('change', function (){
        $("#vendor-alert-warning").fadeIn(); 
        $("#cancel_excel_inv").fadeOut(); 

        $("#vendor-alert-success").fadeOut();
        $("#vendor-alert").fadeOut();
        document.getElementById("invoice_excel_table").style.display = "none";
        var data = new FormData();
        //Form data
        var form_data = $('#bid_item_excel').serializeArray();
        $.each(form_data, function (key, input) {
            data.append(input.name, input.value);
        });
        //File data
        var file_data = $('input[name="fileToUpload_inv"]')[0].files;
        for (var i = 0; i < file_data.length; i++) {
            data.append("fileToUpload_inv[]", file_data[i]);
        }
      
        $.ajax({
            url: "invoices-import-adata.php?upload_xl_invoice=",
            type: "POST",
            data:  data,
            contentType: false,
            cache: false,
            processData:false,
            success: function(data){
                document.getElementById('fileToUpload_inv').value = "";
                var data = data.trim();
                var data_response = JSON.parse(data);
                var status = data_response.status;
                if(status == 'Invalid_Excel_Format'){
                    $("#danger_text").html("The excel you uploaded is of incorrect format.").fadeIn();
                    $("#vendor-alert").fadeIn();                   
                }else if(status == 'yes'){
                    var mess = data_response.mess;
                    var err = data_response.err;
                    var succ = data_response.succ;
                    var filename = data_response.file;
                    var bad_rows = data_response.bad_rows;  
                    if(mess == 'err'){
                        $("#danger_text").html(err).fadeIn();
                        $("#vendor-alert").fadeIn(); 
                    }
                    if(filename.length > 3){
                        document.getElementById("invoice_excel_table").style.display = "block";
                        document.getElementById("submit_excel_form").style.display = "block";

                        $('#invoice_file_excel').val(filename);
                        $('#dataTables-bidwiz-excel-invoice').DataTable({
                            responsive: true, 
                            "paging":true,
                            "ordering":false,
                            "processing": true,
                            "serverSide": true,
                            "ajax":{
                                url :"view_excel_invoice_response.php?file=" + filename + "&bad_rows=" + bad_rows,
                                type: "post",
                            },
                            "language": {
                                        processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw" style="color:#0b57a4;margin-top:15%"></i><span class="sr-only">Loading..n.</span> '
                                        },
                            "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
                            "destroy": true
                        }); 
                    }
                }
                $("#vendor-alert-warning").fadeOut();   

            }          
        });

    });
});
$('#bidModal').on('hidden.bs.modal', function () {
 location.reload();
})
</script>


<script>  

$('#addInvoiceModal').click(function(e)
{
    e.preventDefault();   
    $('#invoiceModal').modal({backdrop: 'static', keyboard: false});
    
});

$(function(){
    $('#fileToUpload_bid').on('change', function (){
        $("#vendor-alert-warning").fadeIn(); 
        $("#vendor-alert-success").fadeOut();
        $("#vendor-alert").fadeOut();
        var data = new FormData();
       
        //Form data
        var form_data = $('#bid_item_excel').serializeArray();
        $.each(form_data, function (key, input) {
            data.append(input.name, input.value);
        });
       

        //File data
        var file_data = $('input[name="fileToUpload_bid"]')[0].files;
        for (var i = 0; i < file_data.length; i++) {
            data.append("fileToUpload_bid[]", file_data[i]);
        }
      
        $.ajax({
            url: "bids-import-adata.php?upload_xl_bid=",
            type: "POST",
            data:  data,
            contentType: false,
            cache: false,
            processData:false,
            success: function(data){
                document.getElementById('fileToUpload_bid').value = "";
                var data = data.trim();
                var data_response = JSON.parse(data);
                var status = data_response.status;
                if(status == 'Invalid_Excel_Format'){
                    $("#danger_text").html("The excel you uploaded is of incorrect format.").fadeIn();
                    $("#vendor-alert").fadeIn();                   
                }else if(status == 'yes'){
                    var mess = data_response.mess;
                    var err = data_response.err;
                    var succ = data_response.succ;  
                    if(mess == 'err'){
                        $("#danger_text").html(err).fadeIn();
                        $("#vendor-alert").fadeIn(); 
                    }else if(mess == 'succ'){                         
                        $("#danger_text1").html(succ).fadeIn();
                        $("#vendor-alert-success").fadeIn();   
                    } else if(mess == 'both'){
                        $("#danger_text").html(err).fadeIn();
                        $("#vendor-alert").fadeIn();  
                        $("#danger_text1").html(succ).fadeIn();
                        $("#vendor-alert-success").fadeIn();   
                    }  
                }
                $("#vendor-alert-warning").fadeOut();   

            }          
        });

    });
});
$('#invoiceModal').on('hidden.bs.modal', function () {
 location.reload();
})
</script>

<script src="js/jquery_acomplete.min.js"></script>
<script>
    function set_new_values(){
    var fetch_year = document.getElementById("year-selected").value;
    var fetch_option = document.getElementById("filter-selected").value; 
    if(fetch_option == 'm' || fetch_option == 'q'){
        var fetch_value = document.getElementById("value-selected").value;
    }else{
        var fetch_value = 'none';
    }
    window.location.href = '<?php 
  
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') 
    $link = "https"; 
else
    $link = "http"; 
  
$link .= "://"; 
  
$link .= $_SERVER['HTTP_HOST']; 
  
$link .= $_SERVER['REQUEST_URI']; 
$link = substr($link, 0, strpos($link, "?"));
      
echo $link; 
?>?cl_id=<?php echo $cl_id;?>&year=' + fetch_year + '&option=' + fetch_option + '&value=' + fetch_value; 
}
function select_filter(){
  var opt_filter = document.getElementById("filter-selected").value;
  if(opt_filter == 'm' || opt_filter == 'q'){
    document.getElementById("value-selected").style.display = 'block';
    if(opt_filter == 'm'){
        let dropdown = $('#value-selected');

        dropdown.empty();
        var fetch_year = document.getElementById("year-selected").value;
        var current_year = new Date().getFullYear();

        if(fetch_year == current_year){
            var m_names = ['January', 'February', 'March', 
               'April', 'May', 'June', 'July', 
               'August', 'September', 'October', 'November', 'December'];

            d = new Date();
            var month_digit = d.getMonth();
            for(var k = 0; k <= 11; k++){
                var n = m_names[k];
                dropdown.append('<option value="' + k + '">'+ n +'</option>');
                if(k == month_digit){
                    break;
                }
            }
           
            document.getElementById("value-selected").selectedIndex = month_digit;           
        }else{
            var m_names = ['January', 'February', 'March', 
               'April', 'May', 'June', 'July', 
               'August', 'September', 'October', 'November', 'December'];
            for(var k = 0; k < 12; k++){
                var n = m_names[k];
                dropdown.append('<option value="' + k + '">'+ n +'</option>');
            }
            document.getElementById("value-selected").selectedIndex = 0;
        }
    }
    
     if(opt_filter == 'q'){
        let dropdown = $('#value-selected');

        dropdown.empty();
        var fetch_year = document.getElementById("year-selected").value;
        var current_time = new Date();
        current_year =   current_time.getFullYear();
       
        if(fetch_year == current_year){
            var q_names = ['Quarter 1', 'Quarter 2', 'Quarter 3','Quarter 4'];
            var month_digit = current_time.getMonth();
            month_digit = month_digit +1;
            if(month_digit == 1 || month_digit == 2 || month_digit == 3){
                var current_qtr = 0;
            }else if(month_digit == 4 || month_digit == 5 || month_digit == 6){
                var current_qtr = 1;
            }else if(month_digit == 7 || month_digit == 8 || month_digit == 9){
                var current_qtr = 2;
            }else if(month_digit == 10 || month_digit == 11 || month_digit == 12){
                var current_qtr = 3;
            }
            for(var k = 0; k < 4; k++){
                kk = k + 1;
                var n = q_names[k];
                dropdown.append('<option value="' + kk + '">'+ n +'</option>');
                if(k == current_qtr){
                    break;
                }
            }            
            document.getElementById("value-selected").selectedIndex = current_qtr;           
            
        }else{
            var q_names = ['Quarter 1', 'Quarter 2', 'Quarter 3', 'Quarter 4'];
            for(var k = 0; k < 4; k++){
                kk = k + 1;
                var n = q_names[k];
                dropdown.append('<option value="' + kk + '">'+ n +'</option>');
            }
            document.getElementById("value-selected").selectedIndex = 0;
        }        
    }
  }
if(opt_filter == 'y'){
        document.getElementById("value-selected").style.display = 'none';
    }
    set_new_values();
}

function year_change(){
    var fetch_year = document.getElementById("year-selected").value;
    var current_year = new Date().getFullYear();
    $('#filter-selected').val('y');

    document.getElementById("value-selected").style.display = 'none';
   
    set_new_values();
}
 var countries = [{ value: 'ALL', data: '0' },<?php
                $query_fetch_client = "SELECT * FROM client WHERE client_is_delete IS NULL AND is_approve = 1";
                $run_fetch_client = mysqli_query($conn, $query_fetch_client);
                if(mysqli_num_rows($run_fetch_client)>0){
                    while($row_fetch_client = mysqli_fetch_array($run_fetch_client)){
                        $client_id = $row_fetch_client['client_id'];
                        $client_name = $row_fetch_client['client_name'];
                        $client_alias = $row_fetch_client['client_alias'];
            ?>{ value: '<?php echo $client_alias . ' - ' . $client_name; ?>', data: '<?php echo $client_id;?>' },<?php
            }}
            ?>];

$('#new_bid_client_name1').autocomplete({
    lookup: countries,
    onSelect:function (suggestion){
        var fetch_year = document.getElementById("year-selected").value;
        var fetch_option = document.getElementById("filter-selected").value; 
        if(fetch_option == 'm' || fetch_option == 'q'){
            var fetch_value = document.getElementById("value-selected").value;
        }else{
            var fetch_value = 'none';
        }
        var val1 = suggestion.data;
        window.location.href = '<?php 
  
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') 
    $link = "https"; 
else
    $link = "http"; 
  
$link .= "://"; 
  
$link .= $_SERVER['HTTP_HOST']; 
  
$link .= $_SERVER['REQUEST_URI']; 
$link = substr($link, 0, strpos($link, "?"));
      
echo $link; 
?>?cl_id='+val1 + '&year='+ fetch_year + '&option='+ fetch_option + '&value='+ fetch_value; 

}
});
 </script> 

   
<?php include_once "search_footer.php" ?>