Lines 638-660
sub SearchSubscriptions {
Link Here
|
638 |
if ( $params->{results_limit} && $total_results > $params->{results_limit} ) { |
638 |
if ( $params->{results_limit} && $total_results > $params->{results_limit} ) { |
639 |
$results = [ splice( @{$results}, 0, $params->{results_limit} ) ]; |
639 |
$results = [ splice( @{$results}, 0, $params->{results_limit} ) ]; |
640 |
} |
640 |
} |
641 |
my %additional_fields_by_id = map { $_->id => $_->name } Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; |
641 |
my @additional_field_ids = map { $_->id } Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; |
642 |
if (%additional_fields_by_id) { |
642 |
if (@additional_field_ids) { |
643 |
my %subscriptions_by_id = map { $_->{subscriptionid } => $_ } @{$results}; |
643 |
my %subscriptions_by_id = map { $_->{subscriptionid } => $_ } @{$results}; |
644 |
my $field_values_rs = Koha::AdditionalFieldValues->search( |
644 |
my $field_values_rs = Koha::AdditionalFieldValues->search( |
645 |
{ |
645 |
{ |
646 |
field_id => { -in => [ keys %additional_fields_by_id ] }, |
646 |
field_id => { -in => \@additional_field_ids }, |
647 |
record_id => { -in => [ keys %subscriptions_by_id ] } |
647 |
record_id => { -in => [ keys %subscriptions_by_id ] } |
648 |
} |
648 |
} |
649 |
); |
649 |
); |
650 |
while (my $field_value = $field_values_rs->next) { |
650 |
while (my $field_value = $field_values_rs->next) { |
651 |
my $field_name = $additional_fields_by_id{$field_value->field_id}; |
651 |
$subscriptions_by_id{$field_value->record_id}->{additional_field_values}->{$field_value->field_id} = $field_value->value; |
652 |
$subscriptions_by_id{$field_value->record_id}->{additional_fields}->{$field_name} = $field_value->value; |
|
|
653 |
} |
652 |
} |
654 |
} |
653 |
} |
655 |
else { |
654 |
else { |
656 |
for my $subscription ( @{$results} ) { |
655 |
for my $subscription ( @{$results} ) { |
657 |
$subscription->{additional_fields} = {}; |
656 |
$subscription->{additional_field_values} = {}; |
658 |
} |
657 |
} |
659 |
} |
658 |
} |
660 |
|
659 |
|
661 |
- |
|
|