//jshint esversion:6
$(document).on("click",".view-ticket",function(e){
    e.preventDefault();
    var id = $(this).attr("id");
    $.ajax({
        url: "/user/tickets/"+id,
        type: "GET",
        headers:{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
        // cache: false,
        success: function(response){
            // console.log(response);
            $(".ticket-ticket").html(response.ticket.subject);
            $(".ticket-department").html(response.ticket.department);
            if(response.status==='success'){
                $(".request-pending").hide();
                $(".entry").html(response.ticket.reply);
                $(".ticket-author").html(response.name);
                $(".ticket-date").html(response.date);
                $(".ticket-message").html(response.ticket.message);
                // REPLY INFO
                $(".ticket-reply-date").html(response.reply_date);
                $(".ticket-reply").html(response.ticket.reply);

                $(".request-open").show();
                loadModal('view-ticket');
            }
            if(response.status==='warning'){
                $(".request-open").hide();
                $(".request-pending").show();
                loadModal('view-ticket');
            }
       }
    });
});
