$("#view,#view_all").on("click",function(){
  
    var report_two=document.getElementById("report_two").value;
    var from_date=document.getElementById("from_date").value;
    var to_date=document.getElementById("to_date").value;
    var item_id=document.getElementById("item_id").value;
    var warehouse_id=document.getElementById("warehouse_id").value;
    var users=document.getElementById("users").value;
    var from_time=document.getElementById("from_time").value;
    var to_time=document.getElementById("to_time").value;
    if(from_date == "")
        {
            toastr["warning"]("Select From Date!");
            document.getElementById("from_date").focus();
            return;
        }
     
     if(to_date == "")
        {
            toastr["warning"]("Select To Date!");
            document.getElementById("to_date").focus();
            return;
        }
    
        if(this.id=="view_all"){
          var view_all='yes';
        }
        else{
          var view_all='no';
        }

        if(report_two == "true"){
          var link="reports/show_item_sales_report2";
        }
        else{
          var link="reports/show_item_sales_report";
        }
           
        $(".box").append('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
        $.post($("#base_url").val()+link,{users:users,item_id:item_id,view_all:view_all,from_date:from_date,to_date:to_date,from_time:from_time,to_time:to_time,store_id:$("#store_id").val(),warehouse_id:warehouse_id},function(result){
          //alert(result);
            setTimeout(function() {
             $("#tbodyid").empty().append(result);     
             $(".overlay").remove();
            }, 0);
           }); 
     
  
});

