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

(-)a/C4/HoldsQueue.pm (-2 / +20 lines)
Lines 129-135 Returns hold queue for a holding branch. If branch is omitted, then whole queue Link Here
129
=cut
129
=cut
130
130
131
sub GetHoldsQueueItems {
131
sub GetHoldsQueueItems {
132
    my ($branchlimit) = @_;
132
    my ($branchlimit, $limit, $page) = @_;
133
134
    $limit ||= 20;
135
    $page  ||= 1;
136
137
    my $offset = 0 + ( $limit * ( $page - 1 ) );
138
133
    my $dbh   = C4::Context->dbh;
139
    my $dbh   = C4::Context->dbh;
134
140
135
    my @bind_params = ();
141
    my @bind_params = ();
Lines 156-161 sub GetHoldsQueueItems { Link Here
156
        push @bind_params, $branchlimit;
162
        push @bind_params, $branchlimit;
157
    }
163
    }
158
    $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate";
164
    $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate";
165
    $query .= " LIMIT $limit OFFSET $offset";
159
    my $sth = $dbh->prepare($query);
166
    my $sth = $dbh->prepare($query);
160
    $sth->execute(@bind_params);
167
    $sth->execute(@bind_params);
161
    my $items = [];
168
    my $items = [];
Lines 177-183 sub GetHoldsQueueItems { Link Here
177
184
178
        push @$items, $row;
185
        push @$items, $row;
179
    }
186
    }
180
    return $items;
187
188
189
    @bind_params = ();
190
    my $total_query = "SELECT COUNT(*) FROM tmp_holdsqueue";
191
    if ($branchlimit) {
192
        $total_query .=" WHERE tmp_holdsqueue.holdingbranch = ?";
193
        push @bind_params, $branchlimit;
194
    }
195
196
    my ($total_results) = $dbh->selectrow_array( $total_query, undef, @bind_params );
197
198
    return ( $items, $total_results );
181
}
199
}
182
200
183
=head2 CreateQueue
201
=head2 CreateQueue
(-)a/circ/view_holdsqueue.pl (-8 / +26 lines)
Lines 25-31 This script displays items in the tmp_holdsqueue table Link Here
25
use Modern::Perl;
25
use Modern::Perl;
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use C4::Auth qw( get_template_and_user );
27
use C4::Auth qw( get_template_and_user );
28
use C4::Output qw( output_html_with_http_headers );
28
use C4::Output qw( output_html_with_http_headers pagination_bar );
29
use C4::HoldsQueue qw( GetHoldsQueueItems );
29
use C4::HoldsQueue qw( GetHoldsQueueItems );
30
use Koha::BiblioFrameworks;
30
use Koha::BiblioFrameworks;
31
use Koha::ItemTypes;
31
use Koha::ItemTypes;
Lines 43-58 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
43
my $params = $query->Vars;
43
my $params = $query->Vars;
44
my $run_report     = $params->{'run_report'};
44
my $run_report     = $params->{'run_report'};
45
my $branchlimit    = $params->{'branchlimit'};
45
my $branchlimit    = $params->{'branchlimit'};
46
my $itemtypeslimit = $params->{'itemtypeslimit'};
46
my $limit          = $params->{'limit'} || 20;
47
my $page           = $params->{'page'}  || 1;
47
48
48
if ( $run_report ) {
49
if ( $run_report ) {
49
    # XXX GetHoldsQueueItems() does not support $itemtypeslimit!
50
    my ( $items, $total ) = GetHoldsQueueItems( $branchlimit, $limit, $page );
50
    my $items = GetHoldsQueueItems($branchlimit, $itemtypeslimit);
51
52
    my $pages = int( $total / $limit ) + ( ( $total % $limit ) > 0 ? 1 : 0 );
51
    $template->param(
53
    $template->param(
52
        branchlimit     => $branchlimit,
54
        branchlimit    => $branchlimit,
53
        total      => scalar @$items,
55
        total          => $total,
54
        itemsloop  => $items,
56
        itemsloop      => $items,
55
        run_report => $run_report,
57
        run_report     => $run_report,
58
        page           => $page,
59
        limit          => $limit,
60
        pagination_bar => pagination_bar(
61
            'view_holdsqueue.pl',
62
            $pages,
63
            $page,
64
            'page',
65
            {
66
                branchlimit    => $branchlimit,
67
                itemtypeslimit => $itemtypeslimit,
68
                ccodeslimit    => $ccodeslimit,
69
                locationslimit => $locationslimit,
70
                limit          => $limit,
71
                run_report     => 1,
72
            }
73
        ),
56
    );
74
    );
57
}
75
}
58
76
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (+27 lines)
Lines 66-71 Link Here
66
        <div class="results">[% total | html %] items found for
66
        <div class="results">[% total | html %] items found for
67
            [% IF ( branchlimit ) %][% Branches.GetName( branchlimit ) | html %][% ELSE %]All libraries[% END %]
67
            [% IF ( branchlimit ) %][% Branches.GetName( branchlimit ) | html %][% ELSE %]All libraries[% END %]
68
        </div>
68
        </div>
69
70
		<form action="view_holdsqueue.pl" method="get" id="limitselect">
71
			<input type="hidden" name="page" value="[% page | html %]"/>
72
            <input type="hidden" name="branchlimit" value="[% branchlimit | html %]"/>
73
            <input type="hidden" name="itemtypeslimit" value="[% itemtypeslimit | html %]"/>
74
            <input type="hidden" name="ccodeslimit" value="[% ccodeslimit | html %]"/>
75
            <input type="hidden" name="locationslimit" value="[% locationslimit | html %]"/>
76
            <input type="hidden" name="run_report" value="1"/>
77
78
			<label for="limit">Rows per page: </label>
79
			<select name="limit" id="limit">
80
				[% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
81
				[% FOREACH l IN limits %]
82
					[% IF l == limit %]
83
						<option value="[% l | html %]" selected="selected">[% l | html %]</option>
84
					[% ELSE %]
85
						<option value="[% l | html %]">[% l | html %]</option>
86
					[% END %]
87
				[% END %]
88
			</select>
89
		</form> <!-- /#limitselect -->
90
        <div class="pages">[% pagination_bar | $raw %]</div>
91
69
    [% ELSE %]
92
    [% ELSE %]
70
        <div class="dialog message">No items found.</div>
93
        <div class="dialog message">No items found.</div>
71
    [% END %]
94
    [% END %]
Lines 237-242 Link Here
237
        $(document).ready(function() {
260
        $(document).ready(function() {
238
            var holdst;
261
            var holdst;
239
262
263
            $('#limit').change(function() {
264
                $('#limitselect').submit();
265
            });
266
240
            // Setup filters before DataTables initialisation, in case some columns are
267
            // Setup filters before DataTables initialisation, in case some columns are
241
            // hidden by default
268
            // hidden by default
242
            var filterColumnTimeoutId;
269
            var filterColumnTimeoutId;
(-)a/t/db_dependent/HoldsQueue.t (-2 / +1 lines)
Lines 163-169 $dbh->do("DELETE FROM items WHERE holdingbranch = '$borrower_branchcode'"); Link Here
163
# Frst branch from StaticHoldsQueueWeight
163
# Frst branch from StaticHoldsQueueWeight
164
test_queue ('take from lowest cost branch', 0, $borrower_branchcode, $other_branches[0]);
164
test_queue ('take from lowest cost branch', 0, $borrower_branchcode, $other_branches[0]);
165
test_queue ('take from lowest cost branch', 1, $borrower_branchcode, $least_cost_branch_code);
165
test_queue ('take from lowest cost branch', 1, $borrower_branchcode, $least_cost_branch_code);
166
my $queue = C4::HoldsQueue::GetHoldsQueueItems($least_cost_branch_code) || [];
166
my ( $queue, $total ) = C4::HoldsQueue::GetHoldsQueueItems($least_cost_branch_code) || [];
167
my $queue_item = $queue->[0];
167
my $queue_item = $queue->[0];
168
ok( $queue_item
168
ok( $queue_item
169
 && $queue_item->{pickbranch} eq $borrower_branchcode
169
 && $queue_item->{pickbranch} eq $borrower_branchcode
170
- 

Return to bug 28974