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

(-)a/C4/HoldsQueue.pm (-1 / +29 lines)
Lines 132-137 sub GetHoldsQueueItems { Link Here
132
    my $params = shift;
132
    my $params = shift;
133
    my $dbh   = C4::Context->dbh;
133
    my $dbh   = C4::Context->dbh;
134
134
135
    my $limit = $params->{limit} || 20;
136
    my $page  = $params->{page}  || 1;
137
138
    my $offset = 0 + ( $limit * ( $page - 1 ) );
139
135
    my @bind_params = ();
140
    my @bind_params = ();
136
    my $query = q/SELECT borrowers.surname,
141
    my $query = q/SELECT borrowers.surname,
137
                         borrowers.othernames,
142
                         borrowers.othernames,
Lines 169-174 sub GetHoldsQueueItems { Link Here
169
        push @bind_params, $params->{locationslimit};
174
        push @bind_params, $params->{locationslimit};
170
    }
175
    }
171
    $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate";
176
    $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate";
177
    $query .= " LIMIT $limit OFFSET $offset";
172
    my $sth = $dbh->prepare($query);
178
    my $sth = $dbh->prepare($query);
173
    $sth->execute(@bind_params);
179
    $sth->execute(@bind_params);
174
    my $items = [];
180
    my $items = [];
Lines 190-196 sub GetHoldsQueueItems { Link Here
190
196
191
        push @$items, $row;
197
        push @$items, $row;
192
    }
198
    }
193
    return $items;
199
200
    @bind_params = ();
201
    my $total_query = "SELECT COUNT(*) FROM tmp_holdsqueue JOIN items USING (itemnumber) WHERE 1=1 ";
202
    if ($params->{branchlimit}) {
203
        $total_query .=" AND tmp_holdsqueue.holdingbranch = ?";
204
        push @bind_params, $params->{branchlimit};
205
    }
206
    if( $params->{itemtypeslimit} ) {
207
        $total_query .=" AND items.itype = ? ";
208
        push @bind_params, $params->{itemtypeslimit};
209
    }
210
    if( $params->{ccodeslimit} ) {
211
        $total_query .=" AND items.ccode = ? ";
212
        push @bind_params, $params->{ccodeslimit};
213
    }
214
    if( $params->{locationslimit} ) {
215
        $total_query .=" AND items.location = ? ";
216
        push @bind_params, $params->{locationslimit};
217
    }
218
219
    my ($total_results) = $dbh->selectrow_array( $total_query, undef, @bind_params );
220
221
    return ( $items, $total_results );
194
}
222
}
195
223
196
=head2 CreateQueue
224
=head2 CreateQueue
(-)a/circ/view_holdsqueue.pl (-4 / +24 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 44-58 my $params = $query->Vars; Link Here
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 $itemtypeslimit = $params->{'itemtypeslimit'};
47
my $ccodeslimit = $params->{'ccodeslimit'};
47
my $ccodeslimit    = $params->{'ccodeslimit'};
48
my $locationslimit = $params->{'locationslimit'};
48
my $locationslimit = $params->{'locationslimit'};
49
my $limit          = $params->{'limit'} || 20;
50
my $page           = $params->{'page'}  || 1;
49
51
50
if ( $run_report ) {
52
if ( $run_report ) {
51
    my $items = GetHoldsQueueItems({
53
    my ( $items, $total ) = GetHoldsQueueItems({
52
        branchlimt => $branchlimit,
54
        branchlimt => $branchlimit,
53
        itemtypeslimit => $itemtypeslimit,
55
        itemtypeslimit => $itemtypeslimit,
54
        ccodeslimit => $ccodeslimit,
56
        ccodeslimit => $ccodeslimit,
55
        locationslimit => $locationslimit
57
        locationslimit => $locationslimit,
58
        limit => $limit,
59
        page => $page,
56
    });
60
    });
57
61
58
    $template->param(
62
    $template->param(
Lines 63-68 if ( $run_report ) { Link Here
63
        total      => scalar @$items,
67
        total      => scalar @$items,
64
        itemsloop  => $items,
68
        itemsloop  => $items,
65
        run_report => $run_report,
69
        run_report => $run_report,
70
        page           => $page,
71
        limit          => $limit,
72
        pagination_bar => pagination_bar(
73
            'view_holdsqueue.pl',
74
            $pages,
75
            $page,
76
            'page',
77
            {
78
                branchlimit    => $branchlimit,
79
                itemtypeslimit => $itemtypeslimit,
80
                ccodeslimit    => $ccodeslimit,
81
                locationslimit => $locationslimit,
82
                limit          => $limit,
83
                run_report     => 1,
84
            }
85
        ),
66
    );
86
    );
67
}
87
}
68
88
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (+27 lines)
Lines 69-74 Link Here
69
            [% IF ( ccodeslimit ) %] and collection code:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %])[% END %]
69
            [% IF ( ccodeslimit ) %] and collection code:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %])[% END %]
70
            [% IF ( locationslimit ) %] and shelving location:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %])[% END %]
70
            [% IF ( locationslimit ) %] and shelving location:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %])[% END %]
71
        </div>
71
        </div>
72
73
		<form action="view_holdsqueue.pl" method="get" id="limitselect">
74
			<input type="hidden" name="page" value="[% page | html %]"/>
75
            <input type="hidden" name="branchlimit" value="[% branchlimit | html %]"/>
76
            <input type="hidden" name="itemtypeslimit" value="[% itemtypeslimit | html %]"/>
77
            <input type="hidden" name="ccodeslimit" value="[% ccodeslimit | html %]"/>
78
            <input type="hidden" name="locationslimit" value="[% locationslimit | html %]"/>
79
            <input type="hidden" name="run_report" value="1"/>
80
81
			<label for="limit">Rows per page: </label>
82
			<select name="limit" id="limit">
83
				[% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
84
				[% FOREACH l IN limits %]
85
					[% IF l == limit %]
86
						<option value="[% l | html %]" selected="selected">[% l | html %]</option>
87
					[% ELSE %]
88
						<option value="[% l | html %]">[% l | html %]</option>
89
					[% END %]
90
				[% END %]
91
			</select>
92
		</form> <!-- /#limitselect -->
93
        <div class="pages">[% pagination_bar | $raw %]</div>
94
72
    [% ELSE %]
95
    [% ELSE %]
73
        <div class="dialog message">No items found.</div>
96
        <div class="dialog message">No items found.</div>
74
    [% END %]
97
    [% END %]
Lines 278-283 Link Here
278
        $(document).ready(function() {
301
        $(document).ready(function() {
279
            var holdst;
302
            var holdst;
280
303
304
            $('#limit').change(function() {
305
                $('#limitselect').submit();
306
            });
307
281
            // Setup filters before DataTables initialisation, in case some columns are
308
            // Setup filters before DataTables initialisation, in case some columns are
282
            // hidden by default
309
            // hidden by default
283
            var filterColumnTimeoutId;
310
            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({ branchlmit => $least_cost_branch_code}) || [];
166
my ( $queue, $total ) = C4::HoldsQueue::GetHoldsQueueItems({ branchlmit => $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