Bug 38489: Update EDI accounts UI to use file transport selection

This patch updates the EDI accounts administration interface to use
the new file_transports system instead of direct transport configuration.

Changes:
- Replace transport configuration fields with transport selection dropdown
- Add file_transports data to template for selection options
- Remove password decryption since credentials are now managed by transports
- Simplify form handling to only manage EDI-specific fields
- Add helpful link to file transport administration

Sponsored-by: ByWater Solutions
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2025-09-23 17:25:55 +01:00 committed by Lucas Gass
parent a86cfe61d5
commit e5070c5c0b
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 28 additions and 62 deletions

View File

@ -56,6 +56,13 @@ if ( $op eq 'acct_form' ) {
);
$template->param( vendors => \@vendors );
# Get available file transports for selection
my @file_transports = $schema->resultset('FileTransport')->search(
{},
{ order_by => { -asc => 'name' } }
);
$template->param( file_transports => \@file_transports );
if ( C4::Context->config("enable_plugins") ) {
my @plugins = Koha::Plugins->new()->GetPlugins(
{
@ -71,29 +78,20 @@ if ( $op eq 'acct_form' ) {
if ( $op eq 'cud-save' ) {
# validate & display
my $id = $input->param('id');
my $password = scalar $input->param('password');
$password = $crypt->encrypt_hex($password);
my $id = $input->param('id');
my $fields = {
description => scalar $input->param('description'),
host => scalar $input->param('host'),
username => scalar $input->param('username'),
password => $password,
upload_port => scalar $input->param('upload_port') || $input->param('transport') eq 'FTP' ? 21 : 22,
download_port => scalar $input->param('download_port') || $input->param('transport') eq 'FTP' ? 21 : 22,
vendor_id => scalar $input->param('vendor_id'),
upload_directory => scalar $input->param('upload_directory'),
download_directory => scalar $input->param('download_directory'),
san => scalar $input->param('san'),
standard => scalar $input->param('standard'),
transport => scalar $input->param('transport'),
quotes_enabled => $input->param('quotes_enabled') ? 1 : 0,
invoices_enabled => $input->param('invoices_enabled') ? 1 : 0,
orders_enabled => $input->param('orders_enabled') ? 1 : 0,
responses_enabled => $input->param('responses_enabled') ? 1 : 0,
auto_orders => $input->param('auto_orders') ? 1 : 0,
id_code_qualifier => scalar $input->param('id_code_qualifier'),
plugin => scalar $input->param('plugin'),
description => scalar $input->param('description'),
vendor_id => scalar $input->param('vendor_id'),
file_transport_id => scalar $input->param('file_transport_id') || undef,
san => scalar $input->param('san'),
standard => scalar $input->param('standard'),
quotes_enabled => $input->param('quotes_enabled') ? 1 : 0,
invoices_enabled => $input->param('invoices_enabled') ? 1 : 0,
orders_enabled => $input->param('orders_enabled') ? 1 : 0,
responses_enabled => $input->param('responses_enabled') ? 1 : 0,
auto_orders => $input->param('auto_orders') ? 1 : 0,
id_code_qualifier => scalar $input->param('id_code_qualifier'),
plugin => scalar $input->param('plugin'),
};
if ($id) {
@ -163,7 +161,6 @@ sub show_account {
my $acct_id = $input->param('id');
if ($acct_id) {
my $acct = $schema->resultset('VendorEdiAccount')->find($acct_id);
$acct->password( $crypt->decrypt_hex( $acct->password ) );
if ($acct) {
$template->param( account => $acct );
}

View File

@ -134,49 +134,18 @@
<input type="text" name="description" id="description" size="20" value="[% account.description | html %]" />
</li>
<li>
[% transport_types = [ 'FTP', 'SFTP', 'FILE' ] %]
<label for="transport">Transport: </label>
<select name="transport" title="valid types of transport are FTP and SFTP" id="transport">
[% FOREACH transport_type IN transport_types %]
[% IF transport_type == account.transport %]
<option value="[% transport_type | html %]" selected="selected">[% transport_type | html %]</option>
<label for="file_transport_id">File transport: </label>
<select name="file_transport_id" id="file_transport_id">
<option value="">Select a file transport configuration</option>
[% FOREACH transport IN file_transports %]
[% IF transport.file_transport_id == account.file_transport_id %]
<option value="[% transport.file_transport_id | html %]" selected="selected">[% transport.name | html %] ([% transport.transport | upper | html %] - [% transport.host | html %])</option>
[% ELSE %]
<option value="[% transport_type | html %]">[% transport_type | html %]</option>
<option value="[% transport.file_transport_id | html %]">[% transport.name | html %] ([% transport.transport | upper | html %] - [% transport.host | html %])</option>
[% END %]
[% END %]
</select>
</li>
<li>
<label for="host">Remote host: </label>
<input type="text" name="host" id="host" size="20" maxlength="40" value="[% account.host | html %]" />
</li>
<li>
<label for="username">Username: </label>
<input type="text" name="username" id="username" size="20" maxlength="40" value="[% account.username | html %]" />
</li>
<li>
<label for="password">Password: </label>
<input type="text" name="password" id="password" size="20" maxlength="40" value="[% account.password | html %]" />
</li>
<li>
<label for="upload_port">Upload port: </label>
<input type="text" name="upload_port" id="upload_port" size="20" maxlength="40" value="[% account.upload_port | html %]" />
<div class="hint">The upload port will default to 22 (for SFTP) or 21 (for FTP) if not set.</div>
</li>
<li>
<label for="download_port">Download port: </label>
<input type="text" name="download_port" id="download_port" size="20" maxlength="40" value="[% account.download_port | html %]" />
<div class="hint">The download port will default to 22 (for SFTP) or 21 (for FTP) if not set.</div>
</li>
<li>
<label for="download_directory">Download directory: </label>
<input type="text" name="download_directory" id="download_directory" size="20" value="[% account.download_directory | html %]" />
<div class="hint">The download directory specifies the directory on the ftp site from which quotes and invoices are downloaded.</div>
</li>
<li>
<label for="upload_directory">Upload directory: </label>
<input type="text" name="upload_directory" id="upload_directory" size="20" value="[% account.upload_directory | html %]" />
<div class="hint">The upload directory specifies the directory on the ftp site to which orders are uploaded.</div>
<div class="hint"> Select a file transport configuration for this EDI account. File transports can be managed in <a href="/cgi-bin/koha/admin/file_transports.pl">Administration &rsaquo; File transports</a>. </div>
</li>
<li>
<label for="id_code_qualifier">Qualifier:</label>