From 9dfcce182f9b6d6d03fdf1ac329c956a9b871cca Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 10 Dec 2024 14:42:39 +0000 Subject: [PATCH] Bug 38663: Add AdditionalFields to Library Test plan, k-t-d: 1) Add a new additional field to 'branches': /cgi-bin/koha/admin/additional-fields.pl?tablename=branches 2) Click 'New field'. Add a name. Click Save. 3) Repeat step 2 but repeatable. Repeat again for 2 more of AV category (one repeatable, one not repeatable) 4) Edit a library: /cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=CPL 5) Input various values in the different additional fields. Click 'Submit' 6) Visit the detail page of the library and verify the additional fields data is displayed correctly: /cgi-bin/koha/admin/branches.pl?op=view&branchcode=CPL --- Koha/Library.pm | 2 +- admin/branches.pl | 20 +++++++++++++++++++ .../prog/en/modules/admin/branches.tt | 8 ++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Koha/Library.pm b/Koha/Library.pm index 8056c702920..e970495a362 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -29,7 +29,7 @@ use Koha::StockRotationStages; use Koha::SMTP::Servers; use Koha::Library::Hours; -use base qw(Koha::Object); +use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object); my $cache = Koha::Caches->get_instance(); diff --git a/admin/branches.pl b/admin/branches.pl index b6d705cd185..65e50a5efbc 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -28,6 +28,7 @@ use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Koha; +use Koha::AdditionalFields; use Koha::Database; use Koha::Patrons; use Koha::Items; @@ -49,6 +50,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +if ($branchcode) { + my @additional_fields = Koha::AdditionalFields->search( { tablename => 'branches' } )->as_list; + my @additional_field_values; + @additional_field_values = Koha::Libraries->find($branchcode)->get_additional_field_values_for_template; + + $template->param( + additional_fields => \@additional_fields, + additional_field_values => @additional_field_values, + ); +} + if ( $op eq 'add_form' ) { $template->param( library => Koha::Libraries->find($branchcode), @@ -146,6 +158,10 @@ if ( $op eq 'add_form' ) { $index++; } + my @additional_fields = + Koha::Libraries->find($branchcode)->prepare_cgi_additional_field_values( $input, 'branches' ); + Koha::Libraries->find($branchcode)->set_additional_fields( \@additional_fields ); + push @messages, { type => 'message', code => 'success_on_update' }; } ); @@ -208,6 +224,10 @@ if ( $op eq 'add_form' ) { $index++; } + my @additional_fields = + Koha::Libraries->find($branchcode)->prepare_cgi_additional_field_values( $input, 'branches' ); + Koha::Libraries->find($branchcode)->set_additional_fields( \@additional_fields ); + push @messages, { type => 'message', code => 'success_on_insert' }; } ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index cdf73a5b864..d4d6e400ec0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -368,6 +368,7 @@ + [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values wrap_fieldset=1 %]
Cancel @@ -602,6 +603,12 @@ + [% IF additional_fields && additional_field_values %] +
+

Additional fields

+ [% INCLUDE 'additional-fields-display.inc' available=additional_fields values=additional_field_values %] +
+ [% END %] [% IF OpacLibraryInfo %]
@@ -626,6 +633,7 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("js/admin-menu.js") | $raw %] + [% Asset.js("js/additional-fields-entry.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] -- 2.39.5