1 $(document).ready(function() {
2 $('#ticketDetailsModal').on('show.bs.modal', function(event) {
4 let button = $(event.relatedTarget);
5 let ticket_id = button.data('concern');
6 let resolved = button.data('resolved');
7 modal.find('.modal-footer input').val(ticket_id);
10 $('#resolveTicket').hide();
12 $('#resolveTicket').show();
15 let detail = $('#detail_' + ticket_id).text();
17 // Display ticket details
18 let display = '<div class="list-group">';
19 display += '<div class="list-group-item">';
20 display += '<span class="wrapfix">' + detail + '</span>';
22 display += '<div id="concern-updates" class="list-group-item">';
23 display += '<span>' + __("Loading updates . . .") + '</span>';
27 let details = modal.find('#concern-details');
28 details.html(display);
30 // Load any existing updates
32 url: "/api/v1/tickets/" + ticket_id + "/updates",
35 "x-koha-embed": "user"
37 }).success(function(data) {
38 let updates_display = $('#concern-updates');
40 data.forEach(function(item, index) {
42 updates += '<div class="list-group-item list-group-item-success">';
43 updates += '<span class="pull-right">' + __("Public") + '</span>';
46 updates += '<div class="list-group-item list-group-item-warning">';
47 updates += '<span class="pull-right">' + __("Private") + '</span>';
49 updates += '<span class="wrapfix">' + item.message + '</span>';
50 updates += '<span class="clearfix">' + $patron_to_html(item.user, {
51 display_cardnumber: false,
53 }) + ' (' + $datetime(item.date) + ')</span>';
56 updates_display.html(updates);
61 // Clear any previously entered update message
62 $('#update_message').val('');
63 $('#public').prop( "checked", false );
66 $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
67 let ticket_id = $('#ticket_id').val();
69 'public': $('#public').is(":checked"),
70 message: $('#update_message').val(),
71 user_id: logged_in_user_borrowernumber
74 $('#comment-spinner').show();
77 url: "/api/v1/tickets/" + ticket_id + "/updates",
79 data: JSON.stringify(params),
80 ontentType: "application/json; charset=utf-8"
81 }).success(function() {
82 $('#comment-spinner').hide();
83 $('#ticketDetailsModal').modal('hide');
84 $('#table_concerns').DataTable().ajax.reload(function(data) {
85 $("#concern_action_result_dialog").hide();
86 $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
89 $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
93 $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
94 let ticket_id = $('#ticket_id').val();
96 'public': $('#public').is(":checked"),
97 message: $('#update_message').val(),
98 user_id: logged_in_user_borrowernumber,
102 $('#resolve-spinner').show();
105 url: "/api/v1/tickets/" + ticket_id + "/updates",
107 data: JSON.stringify(params),
108 ontentType: "application/json; charset=utf-8"
109 }).success(function() {
110 $('#resolve-spinner').hide();
111 $("#ticketDetailsModal").modal('hide');
112 $('#table_concerns').DataTable().ajax.reload(function(data) {
113 $("#concern_action_result_dialog").hide();
114 $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show();
116 }).error(function() {
117 $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();