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

(-)a/C4/Serials.pm (-2 / +10 lines)
Lines 512-518 subscription expiration date. Link Here
512
=cut
512
=cut
513
513
514
sub SearchSubscriptions {
514
sub SearchSubscriptions {
515
    my ( $args ) = @_;
515
    my ( $args, $params ) = @_;
516
517
    $params //= {};
516
518
517
    my $additional_fields = $args->{additional_fields} // [];
519
    my $additional_fields = $args->{additional_fields} // [];
518
    my $matching_record_ids_for_additional_fields = [];
520
    my $matching_record_ids_for_additional_fields = [];
Lines 617-622 sub SearchSubscriptions { Link Here
617
    $sth->execute(@where_args);
619
    $sth->execute(@where_args);
618
    my $results =  $sth->fetchall_arrayref( {} );
620
    my $results =  $sth->fetchall_arrayref( {} );
619
621
622
    my $total_results = @{$results};
623
624
    if ($params->{results_limit} && $total_results > $params->{results_limit}) {
625
        $results = [splice(@{$results}, 0, $params->{results_limit})];
626
    }
627
620
    for my $subscription ( @$results ) {
628
    for my $subscription ( @$results ) {
621
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
629
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
622
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
630
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
Lines 627-633 sub SearchSubscriptions { Link Here
627
635
628
    }
636
    }
629
637
630
    return @$results;
638
    return wantarray ? @{$results} : { results => $results, total => $total_results };
631
}
639
}
632
640
633
641
(-)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 660-665 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
660
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
660
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
661
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
661
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
662
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
662
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
663
('SerialsSearchResultsLimit', NULL, NULL, 'Serials search results limit', 'integer'),
663
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
664
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
664
('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'),
665
('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'),
665
('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'),
666
('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 240-245 Link Here
240
                        [% END %]
240
                        [% END %]
241
                    [% ELSE %]
241
                    [% ELSE %]
242
                        [% IF ( done_searched ) %]
242
                        [% IF ( done_searched ) %]
243
                            [% IF orig_total > total %]
244
                                <div class="dialog alert">
245
                                    <p>The search originally produced [% orig_total | html %] results and was limited to [% total | html %].</p>
246
                                </div>
247
                            [% END %]
243
                            <h1>Serials subscriptions ([% total | html %] found)</h1>
248
                            <h1>Serials subscriptions ([% total | html %] found)</h1>
244
                        [% ELSE %]
249
                        [% ELSE %]
245
                            <h1>Serials subscriptions search</h1>
250
                            <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