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

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

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


  });   


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

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

    deleteperm_pi(gettingid);

  });  

});




function  deletetemp_pi(gettingid)
{
  $.ajaxSetup({

    headers: {

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

    } 

  });
 

  $.ajax({ 
  
    url:url_pimovetrash,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

    {
      var success="";

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

 });
}

function deleteperm_pi(gettingid)  
{

  $.ajaxSetup({

    headers: {

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

    } 

  });


  $.ajax({ 
  
    url:url_removepiperm,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

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

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

      var success="";

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

 });

}