View | Details | Raw Unified | Return to bug 31846
Collapse All | Expand All

(-)a/C4/Serials.pm (-2 / +10 lines)
Lines 517-523 subscription expiration date. Link Here
517
=cut
517
=cut
518
518
519
sub SearchSubscriptions {
519
sub SearchSubscriptions {
520
    my ( $args ) = @_;
520
    my ( $args, $params ) = @_;
521
522
    $params //= {};
521
523
522
    my $additional_fields = $args->{additional_fields} // [];
524
    my $additional_fields = $args->{additional_fields} // [];
523
    my $matching_record_ids_for_additional_fields = [];
525
    my $matching_record_ids_for_additional_fields = [];
Lines 624-629 sub SearchSubscriptions { Link Here
624
    $sth->execute(@where_args);
626
    $sth->execute(@where_args);
625
    my $results =  $sth->fetchall_arrayref( {} );
627
    my $results =  $sth->fetchall_arrayref( {} );
626
628
629
    my $total_results = @{$results};
630
631
    if ($params->{results_limit} && $total_results > $params->{results_limit}) {
632
        $results = [splice(@{$results}, 0, $params->{results_limit})];
633
    }
634
627
    for my $subscription ( @$results ) {
635
    for my $subscription ( @$results ) {
628
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
636
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
629
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
637
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
Lines 634-640 sub SearchSubscriptions { Link Here
634
642
635
    }
643
    }
636
644
637
    return @$results;
645
    return wantarray ? @{$results} : { results => $results, total => $total_results };
638
}
646
}
639
647
640
648
(-)a/installer/data/mysql/atomicupdate/bug-31846-serials-search-results-limit.pl (+17 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "31846",
5
    description => "Add SerialsSearchResultsLimit syspref",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
10
        $dbh->do(q{
11
            INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
12
            VALUES ('SerialsSearchResultsLimit', NULL, NULL, 'Serials search results limit', 'integer')
13
        });
14
        # Print useful stuff here
15
        say $out "SerialsSearchResultsLimit syspref added";
16
    },
17
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 667-672 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
667
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
667
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
668
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
668
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
669
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
669
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
670
('SerialsSearchResultsLimit', NULL, NULL, 'Serials search results limit', 'integer'),
670
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
671
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
671
('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'),
672
('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'),
672
('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'),
673
('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref (+5 lines)
Lines 63-65 Serials: Link Here
63
            1: Do
63
            1: Do
64
            0: Don't
64
            0: Don't
65
        - prefill the notes from the last 'Arrived' serial when generating the next 'Expected' issue.
65
        - prefill the notes from the last 'Arrived' serial when generating the next 'Expected' issue.
66
    -
67
        - Show only the
68
        - pref: SerialsSearchResultsLimit
69
          class: integer
70
        - first serials when performing an advanced serials search.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (+5 lines)
Lines 231-236 Link Here
231
                        [% END %]
231
                        [% END %]
232
                    [% ELSE %]
232
                    [% ELSE %]
233
                        [% IF ( done_searched ) %]
233
                        [% IF ( done_searched ) %]
234
                            [% IF orig_total > total %]
235
                                <div class="dialog alert">
236
                                    <p>The search originally produced [% orig_total | html %] results and was limited to [% total | html %].</p>
237
                                </div>
238
                            [% END %]
234
                            <h1>Serials subscriptions ([% total | html %] found)</h1>
239
                            <h1>Serials subscriptions ([% total | html %] found)</h1>
235
                        [% ELSE %]
240
                        [% ELSE %]
236
                            <h1>Serials subscriptions search</h1>
241
                            <h1>Serials subscriptions search</h1>
(-)a/serials/serials-search.pl (-17 / +23 lines)
Lines 55-60 my $searched = $query->param('searched') || 0; Link Here
55
my $mana      = $query->param('mana') || 0;
55
my $mana      = $query->param('mana') || 0;
56
my @subscriptionids = $query->multi_param('subscriptionid');
56
my @subscriptionids = $query->multi_param('subscriptionid');
57
my $op            = $query->param('op');
57
my $op            = $query->param('op');
58
my $orig_total;
58
59
59
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
60
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
60
    {
61
    {
Lines 90-96 for my $field ( @additional_fields ) { Link Here
90
91
91
my @subscriptions;
92
my @subscriptions;
92
my $mana_statuscode;
93
my $mana_statuscode;
93
if ($searched){
94
if ($searched) {
94
    if ($mana) {
95
    if ($mana) {
95
        my $result = Koha::SharedContent::search_entities("subscription",{
96
        my $result = Koha::SharedContent::search_entities("subscription",{
96
            title        => $title,
97
            title        => $title,
Lines 102-121 if ($searched){ Link Here
102
        @subscriptions = @{ $result->{data} };
103
        @subscriptions = @{ $result->{data} };
103
    }
104
    }
104
    else {
105
    else {
105
        @subscriptions = SearchSubscriptions(
106
        my $subscriptions = SearchSubscriptions(
106
        {
107
            {
107
            biblionumber => $biblionumber,
108
                biblionumber => $biblionumber,
108
            title        => $title,
109
                title        => $title,
109
            issn         => $ISSN,
110
                issn         => $ISSN,
110
            ean          => $EAN,
111
                ean          => $EAN,
111
            callnumber   => $callnumber,
112
                callnumber   => $callnumber,
112
            publisher    => $publisher,
113
                publisher    => $publisher,
113
            bookseller   => $bookseller,
114
                bookseller   => $bookseller,
114
            branch       => $branch,
115
                branch       => $branch,
115
            additional_fields => \@additional_field_filters,
116
                additional_fields => \@additional_field_filters,
116
            location     => $location,
117
                location     => $location,
117
            expiration_date => $expiration_date,
118
                expiration_date => $expiration_date,
118
        });
119
            },
120
            { results_limit => C4::Context->preference('SerialsSearchResultsLimit') }
121
        );
122
        @subscriptions = @{$subscriptions->{results}};
123
        $orig_total = $subscriptions->{total};
124
119
    }
125
    }
120
}
126
}
121
127
Lines 142-149 if ($mana) { Link Here
142
        search_only => 1
148
        search_only => 1
143
    );
149
    );
144
}
150
}
145
else
151
else {
146
{
147
    # to toggle between create or edit routing list options
152
    # to toggle between create or edit routing list options
148
    if ($routing) {
153
    if ($routing) {
149
        for my $subscription ( @subscriptions) {
154
        for my $subscription ( @subscriptions) {
Lines 178-183 else Link Here
178
        openedsubscriptions => \@openedsubscriptions,
183
        openedsubscriptions => \@openedsubscriptions,
179
        closedsubscriptions => \@closedsubscriptions,
184
        closedsubscriptions => \@closedsubscriptions,
180
        total         => @openedsubscriptions + @closedsubscriptions,
185
        total         => @openedsubscriptions + @closedsubscriptions,
186
        orig_total    => $orig_total,
181
        title_filter  => $title,
187
        title_filter  => $title,
182
        ISSN_filter   => $ISSN,
188
        ISSN_filter   => $ISSN,
183
        EAN_filter    => $EAN,
189
        EAN_filter    => $EAN,
(-)a/t/db_dependent/Serials.t (-9 / +94 lines)
Lines 16-22 use Koha::DateUtils qw( dt_from_string output_pref ); Link Here
16
use Koha::Acquisition::Booksellers;
16
use Koha::Acquisition::Booksellers;
17
use t::lib::Mocks;
17
use t::lib::Mocks;
18
use t::lib::TestBuilder;
18
use t::lib::TestBuilder;
19
use Test::More tests => 52;
19
use Test::More tests => 54;
20
20
21
BEGIN {
21
BEGIN {
22
    use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
22
    use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
Lines 26-31 my $schema = Koha::Database->new->schema; Link Here
26
$schema->storage->txn_begin;
26
$schema->storage->txn_begin;
27
my $dbh = C4::Context->dbh;
27
my $dbh = C4::Context->dbh;
28
28
29
$dbh->do('DELETE FROM subscription');
30
29
my $builder = t::lib::TestBuilder->new();
31
my $builder = t::lib::TestBuilder->new();
30
32
31
# This could/should be used for all untested methods
33
# This could/should be used for all untested methods
Lines 76-89 my $notes = "a\nnote\non\nseveral\nlines"; Link Here
76
my $internalnotes = 'intnotes';
78
my $internalnotes = 'intnotes';
77
my $ccode = 'FIC';
79
my $ccode = 'FIC';
78
my $subscriptionid = NewSubscription(
80
my $subscriptionid = NewSubscription(
79
    undef,      "",     undef, undef, $budget_id, $biblionumber,
81
    undef,
80
    '2013-01-01', $frequency_id, undef, undef,  undef,
82
    "",
81
    undef,      undef,  undef, undef, undef, undef,
83
    undef,
82
    1,          $notes, ,undef, '2013-01-01', undef, $pattern_id,
84
    undef,
83
    undef,       undef,  0,    $internalnotes,  0,
85
    $budget_id,
84
    undef, undef, 0,          undef,         '2013-12-31', 0,
86
    $biblionumber,
85
    undef, undef, undef, $ccode
87
    '2013-01-01',
88
    $frequency_id,
89
    undef,
90
    undef,
91
    undef,
92
    undef,
93
    undef,
94
    undef,
95
    undef,
96
    undef,
97
    undef,
98
    1,
99
    $notes,
100
    undef,
101
    '2013-01-01',
102
    undef,
103
    $pattern_id,
104
    undef,
105
    undef,
106
    0,
107
    $internalnotes,
108
    0,
109
    undef,
110
    undef,
111
    0,
112
    undef,
113
    '2013-12-31', 0,
114
    undef,
115
    undef,
116
    undef,
117
    $ccode
118
);
86
119
120
NewSubscription(
121
    undef,
122
    "",
123
    undef,
124
    undef,
125
    $budget_id,
126
    $biblionumber,
127
    '2013-01-02',
128
    $frequency_id,
129
    undef,
130
    undef,
131
    undef,
132
    undef,
133
    undef,
134
    undef,
135
    undef,
136
    undef,
137
    undef,
138
    1,
139
    $notes,
140
    undef,
141
    '2013-01-02',
142
    undef,
143
    $pattern_id,
144
    undef,
145
    undef,
146
    0,
147
    $internalnotes,
148
    0,
149
    undef,
150
    undef,
151
    0,
152
    undef,
153
    '2013-12-31',
154
    0,
155
    undef,
156
    undef,
157
    undef,
158
    $ccode
87
);
159
);
88
160
89
my $subscriptioninformation = GetSubscription( $subscriptionid );
161
my $subscriptioninformation = GetSubscription( $subscriptionid );
Lines 108-113 isa_ok( \@subscriptions, 'ARRAY' ); Link Here
108
@subscriptions = SearchSubscriptions({ biblionumber => $subscriptioninformation->{bibnum}, orderby => 'title' });
180
@subscriptions = SearchSubscriptions({ biblionumber => $subscriptioninformation->{bibnum}, orderby => 'title' });
109
isa_ok( \@subscriptions, 'ARRAY' );
181
isa_ok( \@subscriptions, 'ARRAY' );
110
182
183
@subscriptions = SearchSubscriptions({});
184
is(
185
    @subscriptions,
186
    2,
187
    'SearchSubscriptions returned the expected number of subscriptions when results_limit is not set'
188
);
189
190
@subscriptions = SearchSubscriptions({}, { results_limit => 1 });
191
is(
192
    @subscriptions,
193
    1,
194
    'SearchSubscriptions returned only one subscription when results_limit is set to "1"'
195
);
196
111
my $frequency = GetSubscriptionFrequency($subscriptioninformation->{periodicity});
197
my $frequency = GetSubscriptionFrequency($subscriptioninformation->{periodicity});
112
my $old_frequency;
198
my $old_frequency;
113
if (not $frequency->{unit}) {
199
if (not $frequency->{unit}) {
114
- 

Return to bug 31846