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 <martin.renvoize@ptfs-europe.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2023-10-16 09:20:01 +00:00 committed by Katrin Fischer
parent e3787c157f
commit 082a9e6858
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
8 changed files with 28 additions and 35 deletions

View file

@ -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 };

View file

@ -58,7 +58,7 @@
</li>
[% 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 %]
</ol>
<input type="hidden" name="searched" value="1" />
[% IF ( mana ) %]

View file

@ -167,13 +167,7 @@
<td data-order="[% missingissue.claimdate | html %]">
[% missingissue.claimdate | $KohaDates %]
</td>
[% FOR field IN additional_fields_for_subscription %]
[% IF field.authorised_value_category %]
<td>[% AuthorisedValues.GetByCode( field.authorised_value_category, missingissue.additional_fields.${field.name} ) | html %]</td>
[% ELSE %]
<td>[% missingissue.additional_fields.${field.name} | html %]</td>
[% END %]
[% END %]
[% INCLUDE 'additional-fields-display.inc' available=additional_fields_for_subscription values=missingissue.additional_field_values value_only=1 is_table_cell=1 %]
</tr>
[% END # /FOREACH missingissue %]
</tbody>

View file

@ -122,13 +122,7 @@
</td>
[% END %]
[% FOR field IN additional_fields_for_subscription %]
[% IF field.authorised_value_category %]
<td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) | html %]</td>
[% ELSE %]
<td>[% subscription.additional_fields.${field.name} | html %]</td>
[% END %]
[% END %]
[% INCLUDE 'additional-fields-display.inc' available=additional_fields_for_subscription values=subscription.additional_field_values value_only=1 is_table_cell=1 %]
<td>
<div class="btn-group dropup">

View file

@ -594,6 +594,7 @@ fieldset.rows table { clear: none; margin: 0; }
</script>
[% 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' %]

View file

@ -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 );
}

View file

@ -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);

View file

@ -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?