From 082a9e685800f1e0ace51995071207f78ee57252 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 16 Oct 2023 09:20:01 +0000 Subject: [PATCH] Bug 35044: Update: Serial subscriptions Test plan, k-t-d: Preparation: Create additional fields for table 'subscription', visit: /cgi-bin/koha/admin/additional-fields.pl?tablename=subscription 2 text fields, one repeatable, one not-repeatable 2 AV fields, one repeatable, one not-repeatable 2 MARC fields, one 'get' and one 'set', both non-repeatable, MARC field 942$c Attempt to create a repeatable MARC field (get or set). Notice you're unable to. 1) Add a new serial subscription, visit: /cgi-bin/koha/serials/subscription-add.pl 2) Set the mandatory "Record" input (e.g. '112'). Click the 'Next' and press 'Ok' on the alert box. 3) Fill in all required fields and press "Test prediction pattern" 4) At the bottom, fill in all additional fields, click the '+New' and 'Clear' links, hit 'Save' 5) Notice the fields are shown, repeated fields are comma separated 6) Click Edit -> Edit Subscription, repeat steps 4 and 5 7) Go back to subscription additional fields, set all fields as searchable 8) Visit serials-home: /cgi-bin/koha/serials/serials-home.pl 9) Click 'Search' 10) Notice the searchable fields now show in their columns, repeated fields separated by comma 11) Perform a search using a repeatable field, verify it all works as expected. -- Subscription Claims -- Preparation: 1) Define a new claim notice, visit: /cgi-bin/koha/tools/letter.pl?op=add_form&module=claimissues 2) Input code, name, click "Email" set a "Message subject" and put something in the message body. Hit 'Save'. 3) Set a serial as late, visit our original subscription: /cgi-bin/koha/serials/serials-collection.pl?subscriptionid=1 4) Click "Edit serials" and status -> "Late". Hit "Save". 5) Link the original subscription to the existing vendor, visit: /cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=1 6) Click "Search for a vendor". Hit "Ok". Hit "Choose". Save the subscription. Claims: 7) Visit claims: /cgi-bin/koha/serials/claims.pl 8) Click "Ok" 9) Verify that searchable additional fields all have their respective column. Repeated fields are shown comma separated. Signed-off-by: Martin Renvoize Signed-off-by: Julian Maurice Signed-off-by: Katrin Fischer --- C4/Serials.pm | 2 + .../prog/en/includes/serials-advsearch.inc | 2 +- .../prog/en/modules/serials/claims.tt | 8 +--- .../prog/en/modules/serials/serials-search.tt | 8 +--- .../en/modules/serials/subscription-add.tt | 1 + serials/claims.pl | 3 ++ serials/subscription-add.pl | 37 +++++++++---------- serials/subscription-detail.pl | 2 +- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 3298b06cd9..0c60da5e3f 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -645,6 +645,8 @@ sub SearchSubscriptions { $subscription->{additional_fields} = { map { $_->field->name => $_->value } $subscription_object->additional_field_values->as_list }; + #FIXME: The above $subscription->{additional_fields} may be redundant. Remove if so. + $subscription->{additional_field_values} = $subscription_object->get_additional_field_values_for_template; } return wantarray ? @{$results} : { results => $results, total => $total_results }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc index 4a685642d4..e25dabb998 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc @@ -58,7 +58,7 @@ [% END %] - [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %] + [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 search_form=1 %] [% IF ( mana ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt index 798644d3c2..8b98eebc7e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt @@ -167,13 +167,7 @@ [% missingissue.claimdate | $KohaDates %] - [% FOR field IN additional_fields_for_subscription %] - [% IF field.authorised_value_category %] - [% AuthorisedValues.GetByCode( field.authorised_value_category, missingissue.additional_fields.${field.name} ) | html %] - [% ELSE %] - [% missingissue.additional_fields.${field.name} | html %] - [% END %] - [% END %] + [% INCLUDE 'additional-fields-display.inc' available=additional_fields_for_subscription values=missingissue.additional_field_values value_only=1 is_table_cell=1 %] [% END # /FOREACH missingissue %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt index 6463a4043e..b7b3cc62ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt @@ -122,13 +122,7 @@ [% END %] - [% FOR field IN additional_fields_for_subscription %] - [% IF field.authorised_value_category %] - [% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) | html %] - [% ELSE %] - [% subscription.additional_fields.${field.name} | html %] - [% END %] - [% END %] + [% INCLUDE 'additional-fields-display.inc' available=additional_fields_for_subscription values=subscription.additional_field_values value_only=1 is_table_cell=1 %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index d69cf8df4f..f169a58274 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -594,6 +594,7 @@ fieldset.rows table { clear: none; margin: 0; } [% Asset.js("js/subscription-add.js") | $raw %] [% Asset.js("js/showpredictionpattern.js") | $raw %] + [% Asset.js("js/additional-fields-entry.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/serials/claims.pl b/serials/claims.pl index 5b5479f749..363541fedf 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -86,6 +86,9 @@ if ($supplierid) { foreach my $issue (@missingissues) { $issue->{cannot_claim} = 1 unless C4::Serials::can_claim_subscription($issue); + + $issue->{additional_field_values} = + Koha::Subscriptions->find( $issue->{subscriptionid} )->get_additional_field_values_for_template; } $template->param( suppliername => $supplier->name ); } diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 13a57ecb91..b9c66eae22 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -132,17 +132,12 @@ $template->param( ); my @additional_fields = Koha::AdditionalFields->search({ tablename => 'subscription' })->as_list; -my %additional_field_values; -if ($subscriptionid) { - my $subscription = Koha::Subscriptions->find($subscriptionid); - foreach my $value ($subscription->additional_field_values->as_list) { - $additional_field_values{$value->field_id} = $value->value; - } -} +my @additional_field_values; +@additional_field_values = Koha::Subscriptions->find($subscriptionid)->get_additional_field_values_for_template if $subscriptionid; $template->param( - additional_fields => \@additional_fields, - additional_field_values => \%additional_field_values, + additional_fields => \@additional_fields, + additional_field_values => @additional_field_values, ); my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; @@ -368,11 +363,13 @@ sub redirect_add_subscription { my $biblio = Koha::Biblios->find($biblionumber); my $subscription_fields = Koha::AdditionalFields->search({ tablename => 'subscription' }); while ( my $field = $subscription_fields->next ) { - my $value = $query->param('additional_field_' . $field->id); - push @additional_fields, { - id => $field->id, - value => $value, - }; + my @field_values = $query->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { + push @additional_fields, { + id => $field->id, + value => $value, + } if $value; + } } Koha::Subscriptions->find($subscriptionid)->set_additional_fields(\@additional_fields); @@ -482,11 +479,13 @@ sub redirect_mod_subscription { my $biblio = Koha::Biblios->find($biblionumber); my $subscription_fields = Koha::AdditionalFields->search({ tablename => 'subscription' }); while ( my $field = $subscription_fields->next ) { - my $value = $query->param('additional_field_' . $field->id); - push @additional_fields, { - id => $field->id, - value => $value, - }; + my @field_values = $query->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { + push @additional_fields, { + id => $field->id, + value => $value, + } if $value; + } } Koha::Subscriptions->find($subscriptionid)->set_additional_fields(\@additional_fields); diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 55c7a65ae4..8140feb8c2 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -125,7 +125,7 @@ my $subscription = Koha::Subscriptions->find( $subscriptionid ); $template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'subscription' } ), - additional_field_values => { map { $_->field->name => $_->value } $subscription->additional_field_values->as_list }, + additional_field_values => $subscription->get_additional_field_values_for_template, ); # FIXME Do we want to hide canceled orders? -- 2.39.5