Bugzilla – Attachment 183943 Details for
Bug 40334
When EDIFACT is enabled, one should be able view the corresponding EDIFACT QUOTE and ORDER messages on the Koha Basket page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40334: Add EDIFACT message display to basket page
Bug-40334-Add-EDIFACT-message-display-to-basket-pa.patch (text/plain), 10.81 KB, created by
Martin Renvoize (ashimema)
on 2025-07-10 13:37:16 UTC
(
hide
)
Description:
Bug 40334: Add EDIFACT message display to basket page
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-10 13:37:16 UTC
Size:
10.81 KB
patch
obsolete
>From f2091c9332a469bdbf0070b3a40144cbc80d102c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 9 Jul 2025 17:06:51 +0100 >Subject: [PATCH] Bug 40334: Add EDIFACT message display to basket page > >This patch extends the EDIFACT message display functionality from the invoice page >to the basket page, providing comprehensive access to EDIFACT messages and error >reporting. > >Features added: >- Toolbar buttons for viewing EDIFACT messages (quote/order) >- Smart button display: single button for one message type, dropdown for multiple >- EDIFACT parsing errors section with inline error display >- Errors grouped by message type with detailed information >- Conditional display: only shows when relevant data exists > >Changes: >- acqui/basket.pl: Added EDIFACT message and error collection logic >- basket.tt: Added toolbar buttons and parsing errors section >- Uses existing modal system for raw message display >--- > acqui/basket.pl | 40 ++++++++ > .../prog/en/modules/acqui/basket.tt | 94 +++++++++++++++++++ > 2 files changed, 134 insertions(+) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 791acd32504..4d4254ce1c4 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -40,6 +40,7 @@ use Koha::Database; > use Koha::EDI qw( create_edi_order ); > use Koha::CsvProfiles; > use Koha::Patrons; >+use Koha::Edifact::Files; > > use Koha::AdditionalFields; > use Koha::Old::Biblios; >@@ -106,6 +107,45 @@ if ($ediaccount) { > $template->param( eans => \@eans ); > } > >+# Check for EDIFACT messages associated with this basket >+my $edifact_enabled = C4::Context->preference('EDIFACT'); >+my @edifact_messages = (); >+my @edifact_errors = (); >+ >+if ( $edifact_enabled && $basketno ) { >+ my $edifact_messages_rs = Koha::Edifact::Files->search( >+ { basketno => $basketno }, >+ { order_by => 'message_type' } >+ ); >+ >+ while ( my $message = $edifact_messages_rs->next ) { >+ push @edifact_messages, { >+ id => $message->id, >+ message_type => $message->message_type, >+ transfer_date => $message->transfer_date, >+ status => $message->status, >+ filename => $message->filename, >+ }; >+ >+ # Get errors for this message >+ my $errors = $message->errors; >+ while ( my $error = $errors->next ) { >+ push @edifact_errors, { >+ message_id => $message->id, >+ message_type => $message->message_type, >+ section => $error->section, >+ details => $error->details, >+ }; >+ } >+ } >+} >+ >+$template->param( >+ edifact_enabled => $edifact_enabled, >+ edifact_messages => \@edifact_messages, >+ edifact_errors => \@edifact_errors, >+); >+ > unless ( CanUserManageBasket( $loggedinuser, $basket, $userflags ) ) { > $template->param( > cannot_manage_basket => 1, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index b35ab760426..5a6678fc45c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -123,6 +123,51 @@ > > [% PROCESS csv_export %] > >+ [% IF edifact_enabled && edifact_messages.size > 0 %] >+ [% SET quote_messages = [] %] >+ [% SET order_messages = [] %] >+ [% FOR message IN edifact_messages %] >+ [% IF message.message_type == 'QUOTE' %] >+ [% quote_messages.push(message) %] >+ [% ELSIF message.message_type == 'ORDERS' %] >+ [% order_messages.push(message) %] >+ [% END %] >+ [% END %] >+ >+ [% IF quote_messages.size > 0 && order_messages.size > 0 %] >+ <!-- Both quote and order messages exist --> >+ <div class="btn-group"> >+ <button class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa fa-file-text"></i> View EDIFACT messages </button> >+ <ul class="dropdown-menu"> >+ [% FOR message IN quote_messages %] >+ <li> >+ <a class="dropdown-item view_edifact_message" href="#" data-message-id="[% message.id | html %]"> >+ <i class="fa fa-quote-left"></i> View quote ([% message.transfer_date | $KohaDates %]) >+ </a> >+ </li> >+ [% END %] >+ [% FOR message IN order_messages %] >+ <li> >+ <a class="dropdown-item view_edifact_message" href="#" data-message-id="[% message.id | html %]"> >+ <i class="fa fa-shopping-cart"></i> View order ([% message.transfer_date | $KohaDates %]) >+ </a> >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ [% ELSIF quote_messages.size > 0 %] >+ <!-- Only quote messages exist --> >+ <div class="btn-group"> >+ <button type="button" class="btn btn-default view_edifact_message" data-message-id="[% quote_messages.0.id | html %]"> <i class="fa fa-quote-left"></i> View EDIFACT quote </button> >+ </div> >+ [% ELSIF order_messages.size > 0 %] >+ <!-- Only order messages exist --> >+ <div class="btn-group"> >+ <button type="button" class="btn btn-default view_edifact_message" data-message-id="[% order_messages.0.id | html %]"> <i class="fa fa-shopping-cart"></i> View EDIFACT order </button> >+ </div> >+ [% END %] >+ [% END %] >+ > [% IF Koha.Preference('EDIFACT') && ediaccount %] > [% UNLESS eans.size %] > <div class="btn-group" title="You must define an EAN in Administration -> Library EANs"> >@@ -315,6 +360,47 @@ > > [% IF ( basketno ) %] > <div id="acqui_basket_summary" class="row"> >+ [% IF edifact_enabled && edifact_errors.size > 0 %] >+ <div class="col-md-12 col-sm-12"> >+ <div class="page-section"> >+ <h2>EDIFACT parsing errors</h2> >+ >+ [% SET errors_by_message = {} %] >+ [% FOR error IN edifact_errors %] >+ [% SET msg_id = error.message_id %] >+ [% IF !errors_by_message.$msg_id %] >+ [% errors_by_message.$msg_id = [] %] >+ [% END %] >+ [% errors_by_message.$msg_id.push(error) %] >+ [% END %] >+ >+ [% FOR message IN edifact_messages %] >+ [% SET msg_id = message.id %] >+ [% IF errors_by_message.$msg_id %] >+ <div class="alert alert-warning"> >+ <h4><i class="fa fa-exclamation-triangle"></i> [% message.message_type | html %] message ([% message.transfer_date | $KohaDates %])</h4> >+ [% IF message.filename %] >+ <p><strong>Filename:</strong> [% message.filename | html %]</p> >+ [% END %] >+ <ul> >+ [% FOR error IN errors_by_message.$msg_id %] >+ <li> >+ <strong>[% error.details | html %]</strong> >+ [% IF error.section %] >+ <br /><pre class="mt-1 mb-0 small text-muted">[% error.section | html %] section</pre> >+ [% END %] >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] >+ [% END %] >+ </div> >+ <!-- /.page-section --> >+ </div> >+ <!-- /.col-md-12 col-sm-12 --> >+ [% END %] >+ > <div class="col-md-6 col-sm-12"> > <div class="page-section rows"> > <h2>General information</h2> >@@ -1111,6 +1197,10 @@ > </div> > <!-- /.modal#dateEditor --> > >+[% IF edifact_enabled && edifact_messages.size > 0 %] >+ [% INCLUDE 'modals/edifact-modal.inc' %] >+[% END %] >+ > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/acquisitions-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] >@@ -1336,6 +1426,10 @@ > [% SET filter = 'baskets_managers' %] > [% PROCESS patron_search_modal columns => columns, modal_title => t("Add user") %] > [% PROCESS patron_search_js columns => columns, actions => ["add"], preview_on_name_click => 1 %] >+ >+ [% IF edifact_enabled && edifact_messages.size > 0 %] >+ [% Asset.js("js/modals/edifact-modal.js") | $raw %] >+ [% END %] > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >-- >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 40334
:
183904
|
183905
|
183943
|
184059
|
184389
|
184390