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

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

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

  });  

  $(document).on('click', '.quotation_btnDeleteprem', function (e) {
    
    e.preventDefault(e);

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

  });  

});

 


function  deletetemp_quotation(gettingid)
{
  $.ajaxSetup({

    headers: {

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

    } 

  });


  $.ajax({ 
  
    url:url_removequotation,

    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>';
            
            $('#quotation_danger').append(danger);
            $('#quotation_danger').removeClass("hide");
            
            setTimeout(function(){
              location.reload();
            }, 100) 
         }

         else if(result=="Deleted")
         {
            var success="";

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

 });
}

function deleteperm_quotation(gettingid)
{

  $.ajaxSetup({

    headers: {

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

    } 

  });


  $.ajax({ 
  
    url:url_removequotationperm,

    method:"POST",

    data:{gettingid:gettingid},

    success:function(result)

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

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

 });

}