//Function to get customer selection element ID
function getCustomerSelectionId() {
    return '#customer_id';
}

//Function to load first customer - enable customer select2
function load_customer_select2() {
    return true;
}

$("#view_report,#view_all").on("click",function(){
	

    var from_date=document.getElementById("from_date").value;
    var to_date=document.getElementById("to_date").value;
    var customer_id=document.getElementById("customer_id").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';
        }
      	   
        $(".box").append('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
        $.post($("#base_url").val()+"reports/show_customer_financial_report",{customer_id:customer_id,view_all:view_all,from_date:from_date,to_date:to_date,store_id:$("#store_id").val()},function(result){
          //alert(result);
            setTimeout(function() {
             $("#sales-report-tbody").empty().append(result);     
             $(".overlay").remove();
            }, 0);
           }); 
     
	
});
