From ccd6a334b7447b446bd150d0420f5ad7544bbb8c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 1 Nov 2018 17:41:37 -0300 Subject: [PATCH] Bug 15774: Use the include file to display the subscription's additional fields We have it, why not to use it? Signed-off-by: Jonathan Druart Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../prog/en/modules/serials/subscription-detail.tt | 13 ++----------- serials/subscription-detail.pl | 11 +++++++++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index e469da671a..0c07bf86fc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -131,23 +131,14 @@ - [% IF additional_fields_for_subscription %] + [% IF available_additional_fields %]

Additional fields:

    - [% FOR field IN additional_fields_for_subscription %] -
  1. - [% field.name | html %]: - [% IF field.authorised_value_category %] - [% AuthorisedValues.GetByCode( field.authorised_value_category, additional_fields.${field.name} ) | html %] - [% ELSE %] - [% additional_fields.${field.name} | html %] - [% END %] -
  2. - [% END %] + [% INCLUDE 'additional-fields-display.inc' available=available_additional_fields values=additional_field_values %]
diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index c023c748e2..b7137bdbc7 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -30,6 +30,7 @@ use Koha::AdditionalFields; use Koha::AuthorisedValues; use Koha::DateUtils; use Koha::Acquisition::Bookseller; +use Koha::Subscriptions; use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/; use Carp; @@ -129,8 +130,14 @@ my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($su my $default_bib_view = get_default_view(); -my $additional_fields = Koha::AdditionalFields->search( { tablename => 'subscription' } ); -$template->param( additional_fields_for_subscription => $additional_fields ); +my $subscription_object = Koha::Subscriptions->find( $subscriptionid ); +$template->param( + available_additional_fields => [ Koha::AdditionalFields->search( { tablename => 'subscription' } ) ], + additional_field_values => { + map { $_->field->name => $_->value } + $subscription_object->additional_field_values->as_list + }, +); # FIXME Do we want to hide canceled orders? my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => [ { -desc => 'timestamp' }, \[ "field(orderstatus, 'ordered', 'partial', 'complete')" ] ] } ); -- 2.39.5