$(document).ready(function(){
 
  $('.invoice_trashbtn').on('click',function(){
  
    var gettingid=$(this).data('id');

    var confirmation=confirm("Are You Sure !!!");

    if(confirmation==true)
    { 
      deletetemp_invoice(gettingid);
    }


  });   


  $(document).on('click', '.invoice_trashbtnDelete', function () {

    var gettingid=$(this).data('id');

    deleteperm_invoice(gettingid);

  });  

});


 

function  deletetemp_invoice(gettingid)
{
  $.ajaxSetup({

    headers: {

        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    } 

  });
 

  $.ajax({ 
  
    url:url_invoicemovetrash,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

    {
      var success="";

      success=success+
      
      '<p style="text-align:center;"><b>Invoice Moved to Trash Successfully !!!</b></p>';
      
      $('#invoice_success').append(success);
      $('#invoice_success').removeClass("hide");
      
      setTimeout(function(){
        location.reload();
      }, 200);
    }

 });
}

function deleteperm_invoice(gettingid)
{

  $.ajaxSetup({

    headers: {

        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    } 

  });


  $.ajax({ 
  
    url:url_removeinvoiceperm,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

    {
      $("#invoice-trash").modal('hide');

      $('#invoice_trashedlist').empty();

      var success="";

      success=success+
      
      '<p style="text-align:center;"><b>Invoice Deleted Successfully !!!</b></p>';
      
      $('#invoice_success').append(success);
      $('#invoice_success').removeClass("hide");
      
      setTimeout(function(){
        location.reload();
      }, 200);
    }

 });

}