Bugzilla – Attachment 183941 Details for
Bug 40333
When EDIFACT is enabled, one should be able view the corresponding EDIFACT INVOICE message on the Koha Invoice page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40333: Add EDIFACT message view to invoice display page
Bug-40333-Add-EDIFACT-message-view-to-invoice-disp.patch (text/plain), 15.26 KB, created by
Martin Renvoize (ashimema)
on 2025-07-10 13:34:58 UTC
(
hide
)
Description:
Bug 40333: Add EDIFACT message view to invoice display page
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-10 13:34:58 UTC
Size:
15.26 KB
patch
obsolete
>From 8972eb515c3cf6929624794f0f3ec10133126f85 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 10 Jul 2025 14:22:08 +0100 >Subject: [PATCH] Bug 40333: Add EDIFACT message view to invoice display page > >This enhancement adds an EDIFACT message section to the invoice display page. >If there's a linked EDI Message for this invice, we display the basic >details along with any parsing errors that may have been recorded and we >add a button to trigger the display of the raw message in a modal. > >Changes include: >- Display EDIFACT message information on invoice page when available >- Show message type, transfer date, status, and filename >- Add "View EDIFACT message" button that opens modal with raw message >- Display EDIFACT processing errors directly on invoice page >- Create reusable modal components for EDIFACT message display > >The implementation checks if the EDIFACT system is enabled and if the >invoice has an associated message_id before displaying the EDIFACT >section. Processing errors are highlighted in a warning box with >clear formatting. >--- > acqui/invoice.pl | 29 ++++++++ > .../prog/en/includes/modals/edifact-modal.inc | 38 ++++++++++ > .../prog/en/modules/acqui/edifactmsgs.tt | 74 +------------------ > .../prog/en/modules/acqui/invoice.tt | 35 +++++++++ > .../prog/js/modals/edifact-modal.js | 70 ++++++++++++++++++ > 5 files changed, 175 insertions(+), 71 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/edifact-modal.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/modals/edifact-modal.js > >diff --git a/acqui/invoice.pl b/acqui/invoice.pl >index d38a83d217b..e61d5cc30f8 100755 >--- a/acqui/invoice.pl >+++ b/acqui/invoice.pl >@@ -44,6 +44,7 @@ use Koha::DateUtils qw( output_pref ); > use Koha::Misc::Files; > use Koha::Acquisition::Invoice::Adjustments; > use Koha::Acquisition::Invoices; >+use Koha::Edifact::Files; > > my $input = CGI->new; > my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( >@@ -317,6 +318,34 @@ $template->param( > additional_field_values => $invoice->get_additional_field_values_for_template, > ); > >+# Check for EDIFACT message information >+my $edifact_message; >+my $edifact_errors = []; >+my $edifact_enabled = C4::Context->preference('EDIFACT'); >+ >+if ( $edifact_enabled && $details->{'message_id'} ) { >+ $edifact_message = Koha::Edifact::Files->find( $details->{'message_id'} ); >+ >+ if ($edifact_message) { >+ >+ # Get any processing errors for this message using the relation accessor >+ my $errors = $edifact_message->errors; >+ >+ while ( my $error = $errors->next ) { >+ push @$edifact_errors, { >+ section => $error->section, >+ details => $error->details, >+ }; >+ } >+ } >+} >+ >+$template->param( >+ edifact_enabled => $edifact_enabled, >+ edifact_message => $edifact_message, >+ edifact_errors => $edifact_errors, >+); >+ > $template->param( > invoiceid => $details->{'invoiceid'}, > invoicenumber => $details->{'invoicenumber'}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/edifact-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/edifact-modal.inc >new file mode 100644 >index 00000000000..7886d4990c3 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/edifact-modal.inc >@@ -0,0 +1,38 @@ >+[%# EDIFACT message modal include %] >+[%# This modal can be used on any page that needs to display EDIFACT messages %] >+ >+<!-- Modal to display EDIFACT messages --> >+<div class="modal" id="EDI_modal" tabindex="-1" role="dialog" aria-labelledby="EDI_modal_label" aria-hidden="true"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h1 class="modal-title" id="EDI_modal_label">EDIFACT message</h1> >+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >+ </div> >+ <div class="modal-body"> >+ <div id="edi_loading"><img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading</div> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn btn-default" data-bs-dismiss="modal">Close</button> >+ </div> >+ </div> >+ </div> >+</div> >+ >+<!-- Modal to display EDIFACT errors --> >+<div class="modal" id="EDI_errors_modal" tabindex="-1" role="dialog" aria-labelledby="EDI_errors_modal_label" aria-hidden="true"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h1 class="modal-title" id="EDI_errors_modal_label">EDIFACT processing errors for <span id="EDI_errors_filename"></span></h1> >+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >+ </div> >+ <div class="modal-body"> >+ <div id="edi_errors_loading"><img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading</div> >+ </div> >+ <div class="modal-footer"> >+ <button class="btn btn-default" data-bs-dismiss="modal">Close</button> >+ </div> >+ </div> >+ </div> >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >index 1c8d8a56a17..3e8bc28d4a5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >@@ -37,44 +37,13 @@ > </div> > <!-- /#acqui_edifactmsgs --> > >- <!-- Modal to display EDIFACT messages --> >- <div class="modal" id="EDI_modal" tabindex="-1" role="dialog" aria-labelledby="EDI_modal_label" aria-hidden="true"> >- <div class="modal-dialog modal-lg"> >- <div class="modal-content"> >- <div class="modal-header"> >- <h1 class="modal-title" id="EDI_modal_label">EDIFACT message</h1> >- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >- </div> >- <div class="modal-body"> </div> >- <div class="modal-footer"> >- <button class="btn btn-default" data-bs-dismiss="modal">Close</button> >- </div> >- </div> >- </div> >- </div> >- >- <!-- Modal to display EDIFACT errors --> >- <div class="modal" id="EDI_errors_modal" tabindex="-1" role="dialog" aria-labelledby="EDI_errors_modal_label" aria-hidden="true"> >- <div class="modal-dialog modal-lg"> >- <div class="modal-content"> >- <div class="modal-header"> >- <h1 class="modal-title" id="EDI_errors_modal_label">EDIFACT processing errors for <span id="EDI_errors_filename"></span></h1> >- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >- </div> >- <div class="modal-body"> >- <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div> >- </div> >- <div class="modal-footer"> >- <button class="btn btn-default" data-bs-dismiss="modal">Close</button> >- </div> >- </div> >- </div> >- </div> >+ [% INCLUDE 'modals/edifact-modal.inc' %] > [% END %] > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/acquisitions-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] >+ [% Asset.js("js/modals/edifact-modal.js") | $raw %] > <script> > $(document).ready(function() { > let edi_msgs_table_url = '/api/v1/acquisitions/edifiles?'; >@@ -189,43 +158,6 @@ > ] > }, 0, 0); > >- var EDIModal = $("#EDI_modal"); >- var EDIModalBody = $("#EDI_modal .modal-body"); >- >- $("body").on("click", ".view_message", function(e){ >- e.preventDefault(); >- var page = $(this).attr("href"); >- EDIModalBody.load(page + " #edimsg"); >- EDIModal.modal("show"); >- }); >- EDIModal.on("click",".btn-close",function(e){ >- e.preventDefault(); >- EDIModal.modal("hide"); >- }); >- EDIModal.on("hidden.bs.modal", function(){ >- EDIModalBody.html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>"); >- }); >- >- const errorsModal = document.getElementById('EDI_errors_modal') >- if (errorsModal) { >- errorsModal.addEventListener('show.bs.modal', event => { >- // Link that triggered the modal >- const link = event.relatedTarget >- >- // Extract info from data-bs-* attributes >- const filename = link.getAttribute('data-bs-filename') >- const errors = link.getAttribute('data-bs-errors') >- >- // Update the modal's title. >- const modalTitleSpan = errorsModal.querySelector('.modal-title #EDI_errors_filename') >- modalTitleSpan.textContent = filename; >- >- // Update the modal's content. >- const modalBody = errorsModal.querySelector('.modal-body') >- modalBody.innerHTML = errors; >- }) >- } >- > $("body").on("click", ".delete_msg" ,function(){ > return confirm(_("Are you sure you want to delete this message?")); > }); >@@ -233,4 +165,4 @@ > </script> > [% END %] > >-[% INCLUDE 'intranet-bottom.inc' %] >+[% INCLUDE 'intranet-bottom.inc' %] >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >index 91ef1acade2..766faccdeba 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >@@ -57,6 +57,37 @@ > > <p>Vendor: <a href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | uri %]">[% suppliername | html %]</a></p> > >+ [% IF edifact_enabled && edifact_message %] >+ <div class="page-section"> >+ <h3>EDIFACT Message</h3> >+ <p> >+ <strong>Message type:</strong> [% edifact_message.message_type | html %] <strong>Transfer date:</strong> [% edifact_message.transfer_date | $KohaDates %] <strong>Status:</strong> [% edifact_message.status | html %] >+ [% IF edifact_message.filename %] >+ <strong>Filename:</strong> [% edifact_message.filename | html %] >+ [% END %] >+ </p> >+ <p> >+ <a href="#" class="btn btn-default btn-sm view_edifact_message" data-message-id="[% edifact_message.id | html %]"> <i class="fa fa-search"></i> View EDIFACT message </a> >+ </p> >+ >+ [% IF edifact_errors.size > 0 %] >+ <div class="alert alert-warning"> >+ <h4><i class="fa fa-exclamation-triangle"></i> EDIFACT Processing Errors</h4> >+ <ul> >+ [% FOREACH error IN edifact_errors %] >+ <li> >+ <strong>[% error.details | html %]</strong> >+ [% IF error.section %] >+ <br /><pre class="mt-1 mb-0 small text-muted">[% error.section | html %]</pre> >+ [% END %] >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] >+ </div> >+ [% END %] >+ > <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated"> > [% INCLUDE 'csrf-token.inc' %] > <fieldset class="rows"> >@@ -524,6 +555,8 @@ > </div> > <!-- /#updateFund.modal --> > >+[% INCLUDE 'modals/edifact-modal.inc' %] >+ > <div style="display:none;"> > <select id="all_fund_dropdown"> > <option value="">No fund</option> >@@ -545,6 +578,7 @@ > [% Asset.js("js/additional-fields-entry.js") | $raw %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'datatables.inc' %] >+ [% Asset.js("js/modals/edifact-modal.js") | $raw %] > <script> > function updateColumnsVisibility(visible) { > if ( visible ) { >@@ -678,6 +712,7 @@ > $('.ab_inactive').remove(); > } > }); >+ > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/edifact-modal.js b/koha-tmpl/intranet-tmpl/prog/js/modals/edifact-modal.js >new file mode 100644 >index 00000000000..1e4c22a73e6 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/edifact-modal.js >@@ -0,0 +1,70 @@ >+// EDIFACT modal JavaScript functionality >+// This script handles the EDIFACT message modal interactions >+// Include this after the edifact-modal.inc template >+ >+/* global __ interface theme */ >+$(document).ready(function () { >+ // Initialize modal elements >+ var EDIModal = $("#EDI_modal"); >+ var EDIModalBody = $("#EDI_modal .modal-body"); >+ var EDIErrorsModal = $("#EDI_errors_modal"); >+ >+ // Handle view EDIFACT message button clicks >+ $("body").on("click", ".view_edifact_message", function (e) { >+ e.preventDefault(); >+ var message_id = $(this).data("message-id"); >+ var page = >+ "/cgi-bin/koha/acqui/edimsg.pl?id=" + >+ encodeURIComponent(message_id); >+ EDIModalBody.load(page + " #edimsg"); >+ EDIModal.modal("show"); >+ }); >+ >+ // Handle view_message button clicks (for compatibility with existing code) >+ $("body").on("click", ".view_message", function (e) { >+ e.preventDefault(); >+ var page = $(this).attr("href"); >+ EDIModalBody.load(page + " #edimsg"); >+ EDIModal.modal("show"); >+ }); >+ >+ // Handle modal close button >+ EDIModal.on("click", ".btn-close", function (e) { >+ e.preventDefault(); >+ EDIModal.modal("hide"); >+ }); >+ >+ // Reset modal content when hidden >+ EDIModal.on("hidden.bs.modal", function () { >+ EDIModalBody.html( >+ "<div id='edi_loading'><img style='display:inline-block' src='" + >+ interface + >+ "/" + >+ theme + >+ "/img/spinner-small.gif' alt='' /> Loading</div>" >+ ); >+ }); >+ >+ // Handle EDIFACT errors modal >+ const errorsModal = document.getElementById("EDI_errors_modal"); >+ if (errorsModal) { >+ errorsModal.addEventListener("show.bs.modal", function (event) { >+ // Link that triggered the modal >+ const link = event.relatedTarget; >+ >+ // Extract info from data-bs-* attributes >+ const filename = link.getAttribute("data-bs-filename"); >+ const errors = link.getAttribute("data-bs-errors"); >+ >+ // Update the modal's title >+ const modalTitleSpan = errorsModal.querySelector( >+ ".modal-title #EDI_errors_filename" >+ ); >+ modalTitleSpan.textContent = filename; >+ >+ // Update the modal's content >+ const modalBody = errorsModal.querySelector(".modal-body"); >+ modalBody.innerHTML = errors; >+ }); >+ } >+}); >-- >2.50.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40333
:
183902
|
183903
|
183941
|
183942
|
184385
|
184386
|
184387