[% IF localimages.count %]
@@ -1301,6 +1355,7 @@ Note that permanent location is a code, and location may be an authval.
[% IF ( Koha.Preference('CatalogConcerns') ) %]
[% INCLUDE 'modals/add_catalog_concern.inc' %]
+ [% INCLUDE 'modals/display_ticket.inc' %]
[% END %]
[% MACRO jsinclude BLOCK %]
@@ -1313,8 +1368,130 @@ Note that permanent location is a code, and location may be an authval.
[% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
+ [% Asset.js("js/modals/display_ticket.js") | $raw %]
[% END %]
+ [% Asset.js("js/modals/display_ticket.js") | $raw %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]
--- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js
+++ a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js
@@ -0,0 +1,94 @@
+$(document).ready(function() {
+ $('#ticketDetailsModal').on('show.bs.modal', function(event) {
+ let modal = $(this);
+ let button = $(event.relatedTarget);
+ let ticket_id = button.data('concern');
+ modal.find('.modal-footer input').val(ticket_id);
+
+ let detail = $('#detail_' + ticket_id).text();
+
+ let display = '
';
+ display += '
';
+ display += '' + detail + '';
+ display += '
';
+ display += '
';
+ display += 'Loading updates . . .';
+ display += '
';
+ display += '
';
+
+ let details = modal.find('#concern-details');
+ details.html(display);
+
+ $.ajax({
+ url: "/api/v1/tickets/" + ticket_id + "/updates",
+ method: "GET",
+ headers: {
+ "x-koha-embed": "user"
+ },
+ }).success(function(data) {
+ let updates_display = $('#concern-updates');
+ let updates = '';
+ data.forEach(function(item, index) {
+ updates += '
';
+ updates += '' + item.message + '';
+ updates += '' + $patron_to_html(item.user, {
+ display_cardnumber: false,
+ url: true
+ }) + ' (' + $datetime(item.date) + ')';
+ updates += '
';
+ });
+ updates_display.html(updates);
+ }).error(function() {
+
+ });
+ });
+
+ $('#ticketDetailsModal').on('click', '#updateTicket', function(e) {
+ let ticket_id = $('#ticket_id').val();
+ let params = {
+ 'public': $('#public').is(":checked"),
+ message: $('#update_message').val(),
+ user_id: logged_in_user_borrowernumber
+ };
+
+ $.ajax({
+ url: "/api/v1/tickets/" + ticket_id + "/updates",
+ method: "POST",
+ data: JSON.stringify(params),
+ ontentType: "application/json; charset=utf-8"
+ }).success(function() {
+ $("#ticketDetailsModal").modal('hide');
+ tickets.DataTable().ajax.reload(function(data) {
+ $("#concern_action_result_dialog").hide();
+ $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
+ });
+ }).error(function() {
+ $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
+ });
+ });
+
+ $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) {
+ let ticket_id = $('#ticket_id').val();
+ let params = {
+ 'public': $('#public').is(":checked"),
+ message: $('#update_message').val(),
+ user_id: logged_in_user_borrowernumber,
+ state: 'resolved'
+ };
+
+ $.ajax({
+ url: "/api/v1/tickets/" + ticket_id + "/updates",
+ method: "POST",
+ data: JSON.stringify(params),
+ ontentType: "application/json; charset=utf-8"
+ }).success(function() {
+ $("#ticketDetailsModal").modal('hide');
+ tickets.DataTable().ajax.reload(function(data) {
+ $("#concern_action_result_dialog").hide();
+ $("#concern_delete_success").html(_("Concern #%s updated successfully.").format(ticket_id)).show();
+ });
+ }).error(function() {
+ $("#concern_update_error").html(_("Error resolving concern #%s. Check the logs.").format(ticket_id)).show();
+ });
+ });
+});
--