From 1c8891424c3a8105545098a9c2a3e33d05a0e605 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 1 Oct 2025 06:37:58 +0100 Subject: [PATCH] Bug 38489: (follow-up) Update EDI accounts list display This patch updates the EDI accounts management page to display the new file transport system instead of the old inline transport configuration fields. Changes: - Replaced multiple transport-related columns (Transport, Remote host, Username, Password, Upload/Download ports and directories) with a single "File transport" column - The file transport column displays the transport name with its connection test status in brackets - Status indicators match the file_transports page: * "Tests passing" (green with checkmark icon) for successful tests * "Errors detected" (red with x icon) for failed tests * "Never used" (italic) for untested transports - Updated the Perl controller to decode the JSON status field from the file_transports table and pass it to the template - Uses get_inflated_columns to convert DBIx::Class results to plain hashrefs for template consumption The display now correctly reflects the architectural change where transport configuration is managed separately in the file_transports table rather than duplicated in each EDI account. Note: At a future date we should replace the raw DBIx::Class methods with Koha::Object based classes. I propose Koha::EDI::Account(s). --- admin/edi_accounts.pl | 21 ++++++++--- .../prog/en/modules/admin/edi_accounts.tt | 35 ++++++++++--------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/admin/edi_accounts.pl b/admin/edi_accounts.pl index 4aa11517614..ffbf6e9b04e 100755 --- a/admin/edi_accounts.pl +++ b/admin/edi_accounts.pl @@ -20,6 +20,7 @@ use Modern::Perl; use CGI; +use JSON qw( decode_json ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); @@ -111,12 +112,24 @@ if ( $op eq 'acct_form' ) { # we do a default display after deletes and saves # as well as when that's all you want $template->param( display => 1 ); - my @ediaccounts = $schema->resultset('VendorEdiAccount')->search( + my $ediaccounts = $schema->resultset('VendorEdiAccount')->search( {}, - { - join => 'vendor', - } + { prefetch => [ 'vendor', 'file_transport' ] } ); + + # Decode file_transport status for each account + my @ediaccounts; + while ( my $ediaccount = $ediaccounts->next ) { + my $unblessed = { $ediaccount->get_inflated_columns }; + $unblessed->{vendor} = { $ediaccount->vendor->get_inflated_columns }; + if ( $ediaccount->file_transport ) { + $unblessed->{file_transport} = { $ediaccount->file_transport->get_inflated_columns }; + $unblessed->{file_transport}->{status} = + $ediaccount->file_transport->status ? decode_json( $ediaccount->file_transport->status ) : undef; + } + push @ediaccounts, $unblessed; + } + $template->param( ediaccounts => \@ediaccounts ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt index 25129642753..4879e2bc4c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt @@ -269,14 +269,7 @@ ID Vendor Description - Transport - Remote host - Username - Password - Upload port - Download port - Download directory - Upload directory + File transport Qualifier SAN Standard @@ -294,14 +287,24 @@ [% account.id | html %] [% account.vendor.name | html %] [% account.description | html %] - [% account.transport | html %] - [% account.host | html %] - [% account.username | html %] - [% IF account.password %]*****[% END %] - [% account.upload_port | html %] - [% account.download_port | html %] - [% account.download_directory | html %] - [% account.upload_directory | html %] + + [% IF account.file_transport %] + [% account.file_transport.name | html %] + [% IF account.file_transport.status %] + [% IF account.file_transport.status.status == "ok" %] + ( Tests passing) + [% ELSIF account.file_transport.status.status == "errors" %] + ( Errors detected) + [% ELSE %] + (Never used) + [% END %] + [% ELSE %] + (Never used) + [% END %] + [% ELSE %] + No transport configured + [% END %] + [% FOREACH qualifier IN code_qualifiers %] [% IF qualifier.code == account.id_code_qualifier %] -- 2.51.0