<div class="findAmmoPage">

<div class="findAmmoFilterGrid pt-5">
<div class="row">

<div class="col-lg-12 col-md-8 col-12 listAmmo pl-5" id="listAmmofocus">
<div class="b2bAmmoLoader"></div> 
<h5 id="resultcount">Showing results 1-10 of 20</h5>
<!--<h3 class="not-found p-5">No results not found </h3>-->
<div class="table-responsive">
<table class="table mb-0">
<thead class="thead-dark">
<tr>
<th>Caliber</th>
<th>Grains <span> /Weight</span></th>
<th>Bullet Type</th>
<th>Brand</th>
<th>Price</th>
<th class="sorting" >Grand Total <i class="fa fa-sort pricesorting" data-id="1"></i></th>
<th class="sorting" >Rounds <i class="fa fa-sort roundssorting" data-id="1"></i> </th>

<th>Units Booked</th>
<th>Reserved On</th>
<th>Reservation Valid Till </th>
<th>Status</th>
<th>View</th>
</tr>
</thead>
<tbody class="productList">

</tbody>
</table>
</div>
<!-- <nav aria-label="Page navigation" class=" b2bAmmoPage mt-4 pt-2">
  <ul class="pagination">
    <li class="page-item prev"><a class="page-link" href="#">Previous</a></li>
    <li class="page-item active"><a class="page-link" href="#">1</a></li>
    <li class="page-item"><a class="page-link" href="#">2</a></li>
    <li class="page-item"><a class="page-link" href="#">3</a></li>
    <li class="page-item next"><a class="page-link" href="#">Next</a></li>
  </ul>
</nav> -->
</div> 
</div> 
</div>
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<input type="hidden" name="" id="page_count" value="2" />
<input type="hidden" name="" id="pricesorting_hidden" value="" />
<input type="hidden" name="" id="roundssorting_hidden" value="" />

<input type="hidden" name="" id="pricesorting_id" value="" />
<input type="hidden" name="" id="roundssorting_id" value="" />


<script>
$(document).ready(function($){

  findammopost(1);
 // $(".filter-submit-find-ammo").click( function(e) {
   // findammopost(1);
  //});
  //Price Sorting Start****************************
  $(".pricesorting").click( function(e) {


    //Add and remove round sort 

    $(".roundssorting").removeClass('fa-sort-desc');
    $(".roundssorting").removeClass('fa-sort-asc');
    $(".roundssorting").addClass('fa-sort');
    $("#roundssorting_hidden").val('');
    $("#roundssorting_id").val('');
    //
    var id = $('#pricesorting_hidden').val();
    
    $(this).removeClass('fa-sort');
    if(id == ''){
      id = $(this).data('id');
    }
    if(id == 1){
      $("#pricesorting_id").val(1);
      var page_count = $('#page_count').val() - 1;
      findammopost(page_count);
      $("#pricesorting_hidden").val(2);
      
      $(this).removeClass('fa-sort-desc');
      $(this).addClass('fa-sort-asc');
      
    }
    if(id == 2){
      $("#pricesorting_id").val(2);
      var page_count = $('#page_count').val() - 1;
      findammopost(page_count);
      $("#pricesorting_hidden").val(3);
      
      $(this).addClass('fa-sort-desc');
      $(this).removeClass('fa-sort-asc');
      
      
    }


    if(id == 3){
      $("#pricesorting_id").val('');
      var page_count = $('#page_count').val() - 1;
      findammopost(page_count);
      $("#pricesorting_hidden").val('');
      
      $(this).addClass('fa-sort');
      $(this).removeClass('fa-sort-desc');
      
      
    }
  });
  //Price Sorting End****************************

  
  $(".populalDiv").click( function(e) {
      var id = $(this).data('id');
      var name = $(this).data('name');
      $(".populalDiv").removeClass('popularActive');
      $(this).addClass('popularActive');
      if(name == 'caliber'){
        $('#calibar_product_findammo').val(id);
        $('#platform_findammo').val('');
      }
      if(name == 'platform'){
        $('#platform_findammo').val(id);
        $('#calibar_product_findammo').val('');
      }
      
      var page_count = $('#page_count').val() - 1;
      findammopost(page_count);
  });
    //Round Sorting Start****************************
    $(".roundssorting").click( function(e) {


        //Add and remove round sort 

        $(".pricesorting").removeClass('fa-sort-desc');
        $(".pricesorting").removeClass('fa-sort-asc');
        $(".pricesorting").addClass('fa-sort');
        $("#pricesorting_hidden").val('');
        $("#pricesorting_id").val('');
        //
        var id = $('#roundssorting_hidden').val();

        $(this).removeClass('fa-sort');
        if(id == ''){
          id = $(this).data('id');
        }
        if(id == 1){
          $("#roundssorting_id").val(1);
          var page_count = $('#page_count').val() - 1;
          findammopost(page_count);
          $("#roundssorting_hidden").val(2);
          
          $(this).removeClass('fa-sort-desc');
          $(this).addClass('fa-sort-asc');
          
          
        }
        if(id == 2){
          $("#roundssorting_id").val(2);
          var page_count = $('#page_count').val() - 1;
          findammopost(page_count);
          $("#roundssorting_hidden").val(3);
          $(this).addClass('fa-sort-desc');
          $(this).removeClass('fa-sort-asc');
      
        }

        if(id == 3){
          $("#roundssorting_id").val('');
          var page_count = $('#page_count').val() - 1;
          findammopost(page_count);
          $("#roundssorting_hidden").val('');
          $(this).addClass('fa-sort');
          $(this).removeClass('fa-sort-desc');
      
        }
  });
//Round Sorting End****************************
});
function findammopost(page){
//return false;
var findAmmoOrderAjax = 'findAmmoOrderAjax';
var urls = AjaxUrls+'?action='+findAmmoOrderAjax;

var calibar_product_findammo = $('#calibar_product_findammo').val();
var platform_findammo = $('#platform_findammo').val();
var sub_platform_findammo = $('#sub_platform_findammo').val();
var brand_findammo = $('#brand_findammo').val();
var bullet_type_findammo = $('#bullet_type_findammo').val();
var case_condition_findammo = $('.case_condition_findammo:checked').val();

var subsonic_findammo = $('.subsonic_findammo:checked').val();
var test_velocity = $('.test_velocity').val();

var pricesorting_hidden = $('#pricesorting_id').val();

var roundssorting_hidden = $('#roundssorting_id').val();

var formData = new FormData();

formData.append('calibar_product', calibar_product_findammo);
formData.append('platform', platform_findammo);
formData.append('sub_platform', sub_platform_findammo);
formData.append('brand', brand_findammo);
formData.append('bullet_type', bullet_type_findammo);

formData.append('case_condition', case_condition_findammo);
formData.append('subsonic_findammo', subsonic_findammo);
formData.append('test_velocity', test_velocity);
formData.append('page', page);

formData.append('sorting_price', pricesorting_hidden);

formData.append('sorting_routing', roundssorting_hidden);

$("#listAmmofocus").focus();

$.ajax({
type: "POST",
data : formData,
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
url: urls,
success: function(data) {
var obj = $.parseJSON( data );	
console.log(obj.html);
if(obj.status == true){

$('.productList').html(obj.html);
$('#resultcount').html(obj.resultcount);
$(".listAmmo").scrollTop();
}else{
$('.productList').html(obj.html);
$("#resultcount").html('');
}

},
error: function() {
//alert('error handling here');
}
// });
});
return false;
}

jQuery(function($){
	var canBeLoaded = true, // this param allows to initiate the AJAX call only if necessary
	    bottomOffset = 1500; // the distance (in px) from the page bottom when you want to load more posts
 
	$(window).scroll(function(){
		if( $(document).scrollTop() > ( $(document).height() - bottomOffset ) && canBeLoaded == true ){
      var page_count = $('#page_count').val();
      findammopost(page_count)
      page_count = parseInt(page_count) + 1;
      $('#page_count').val(page_count);
		console.log('hi');
		}
	});
});

</script>

<style>
/* .noresultfound{
  text-align: center;
  font-size:large !important;
} 
.popularActive{
  border-color: coral;
    border-style: solid;
} */

</style>
{"id":1709,"date":"2021-09-06T11:22:07","date_gmt":"2021-09-06T11:22:07","guid":{"rendered":"https:\/\/dev-b2bammo.dolphin247.com\/?page_id=1709"},"modified":"2021-12-07T08:10:43","modified_gmt":"2021-12-07T08:10:43","slug":"my-reservations","status":"publish","type":"page","link":"https:\/\/dev-b2bammo.dolphin247.com\/?page_id=1709","title":{"rendered":"Reservation"},"content":{"rendered":"\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1709","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/pages\/1709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1709"}],"version-history":[{"count":4,"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/pages\/1709\/revisions"}],"predecessor-version":[{"id":2403,"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=\/wp\/v2\/pages\/1709\/revisions\/2403"}],"wp:attachment":[{"href":"https:\/\/dev-b2bammo.dolphin247.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}