$(document).ready(function(){
 
  $(document).on('click', '.deleteid', function () {

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

    var conformation=confirm("Are Sure !!!");

    if(conformation==true)
    {
      deletetemp(gettingid);
    } 

  });  

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

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

      console.log(gettingid);
      deleteperm(gettingid);


  });  

});




function  deletetemp(gettingid)
{
  $.ajaxSetup({

    headers: {

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

  });


  $.ajax({ 
  
    url:url_removecompany,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

    {
         if(result=="not_deleteable")
         {
            var danger="";

            danger=danger+
            
            '<p style="text-align:center;"><b>You are not allowed to delete</b></p>';
            
            $('#company_danger').append(danger);
            $('#company_danger').removeClass("hide");
            
            setTimeout(function(){
              location.reload();
            }, 100) 
         }

         else if(result=="Deleted")
         {
            

            var success="";

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

 });
}

function deleteperm(gettingid)
{

  $.ajaxSetup({

    headers: {

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

    } 

  });


  $.ajax({ 
  
    url:url_url_removecompanyperm,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

    {
      $("#company_trashed").modal('hide');
      
      var success="";

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

 });

}