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

(-)a/C4/HoldsQueue.pm (-11 / +28 lines)
Lines 126-138 Returns hold queue for a holding branch. If branch is omitted, then whole queue Link Here
126
126
127
sub GetHoldsQueueItems {
127
sub GetHoldsQueueItems {
128
    my $params = shift;
128
    my $params = shift;
129
    my $dbh   = C4::Context->dbh;
129
    my $dbh    = C4::Context->dbh;
130
130
131
    my $search_params;
131
    my $search_params;
132
    $search_params->{'me.holdingbranch'} = $params->{branchlimit} if $params->{branchlimit};
132
    $search_params->{'me.holdingbranch'} = $params->{branchlimit}    if $params->{branchlimit};
133
    $search_params->{'itype'} = $params->{itemtypeslimit} if $params->{itemtypeslimit};
133
    $search_params->{'itype'}            = $params->{itemtypeslimit} if $params->{itemtypeslimit};
134
    $search_params->{'ccode'} = $params->{ccodeslimit} if $params->{ccodeslimit};
134
    $search_params->{'ccode'}            = $params->{ccodeslimit}    if $params->{ccodeslimit};
135
    $search_params->{'location'} = $params->{locationslimit} if $params->{locationslimit};
135
    $search_params->{'location'}         = $params->{locationslimit} if $params->{locationslimit};
136
    my $rows = $params->{limit} || 20;
137
    my $page = $params->{page}  || 1;
136
138
137
    my $results = Koha::Hold::HoldsQueueItems->search(
139
    my $results = Koha::Hold::HoldsQueueItems->search(
138
        $search_params,
140
        $search_params,
Lines 143-162 sub GetHoldsQueueItems { Link Here
143
            prefetch => [
145
            prefetch => [
144
                'biblio',
146
                'biblio',
145
                'biblioitem',
147
                'biblioitem',
146
                {
148
                { 'item' => { 'item_group_item' => 'item_group' } }
147
                    'item' => {
148
                        'item_group_item' => 'item_group'
149
                    }
150
                }
151
            ],
149
            ],
152
            order_by => [
150
            order_by => [
153
                'ccode',        'location',   'item.cn_sort', 'author',
151
                'ccode',        'location',   'item.cn_sort', 'author',
154
                'biblio.title', 'pickbranch', 'reservedate'
152
                'biblio.title', 'pickbranch', 'reservedate'
155
            ],
153
            ],
154
            rows => $rows,
155
            page => $page
156
        }
156
        }
157
    );
157
    );
158
    my $total_results = Koha::Hold::HoldsQueueItems->search(
159
        $search_params,
160
        {
161
            join => [
162
                'borrower',
163
            ],
164
            prefetch => [
165
                'biblio',
166
                'biblioitem',
167
                { 'item' => { 'item_group_item' => 'item_group' } }
168
            ],
169
            order_by => [
170
                'ccode',        'location',   'item.cn_sort', 'author',
171
                'biblio.title', 'pickbranch', 'reservedate'
172
            ],
173
        }
174
    )->count;
158
175
159
    return $results;
176
    return ( $results, $total_results );
160
}
177
}
161
178
162
=head2 CreateQueue
179
=head2 CreateQueue
(-)a/circ/view_holdsqueue.pl (-5 / +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-70 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
        {
54
        {
53
            branchlimit    => $branchlimit,
55
            branchlimit    => $branchlimit,
54
            itemtypeslimit => $itemtypeslimit,
56
            itemtypeslimit => $itemtypeslimit,
55
            ccodeslimit    => $ccodeslimit,
57
            ccodeslimit    => $ccodeslimit,
56
            locationslimit => $locationslimit
58
            locationslimit => $locationslimit,
59
            limit          => $limit,
60
            page           => $page,
57
        }
61
        }
58
    );
62
    );
59
63
64
    my $pages = int( $total / $limit ) + ( ( $total % $limit ) > 0 ? 1 : 0 );
60
    $template->param(
65
    $template->param(
61
        branchlimit    => $branchlimit,
66
        branchlimit    => $branchlimit,
62
        itemtypeslimit => $itemtypeslimit,
67
        itemtypeslimit => $itemtypeslimit,
63
        ccodeslimit    => $ccodeslimit,
68
        ccodeslimit    => $ccodeslimit,
64
        locationslimit => $locationslimit,
69
        locationslimit => $locationslimit,
65
        total          => $items->count,
70
        total          => $total,
66
        itemsloop      => $items,
71
        itemsloop      => $items,
67
        run_report     => $run_report,
72
        run_report     => $run_report,
73
        page           => $page,
74
        limit          => $limit,
75
        pagination_bar => pagination_bar(
76
            'view_holdsqueue.pl',
77
            $pages, $page, 'page',
78
            {
79
                branchlimit    => $branchlimit,
80
                itemtypeslimit => $itemtypeslimit,
81
                ccodeslimit    => $ccodeslimit,
82
                locationslimit => $locationslimit,
83
                limit          => $limit,
84
                run_report     => 1,
85
            }
86
        ),
68
    );
87
    );
69
}
88
}
70
89
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (+27 lines)
Lines 68-73 Link Here
68
            [% IF ( ccodeslimit ) %] <span>and collection: [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %]</span>[% END %]
68
            [% IF ( ccodeslimit ) %] <span>and collection: [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %]</span>[% END %]
69
            [% IF ( locationslimit ) %] <span>and shelving location: [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %]</span>[% END %]
69
            [% IF ( locationslimit ) %] <span>and shelving location: [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %]</span>[% END %]
70
        </div>
70
        </div>
71
72
        <form action="view_holdsqueue.pl" method="get" id="limitselect">
73
            <input type="hidden" name="page" value="1"/>
74
            <input type="hidden" name="branchlimit" value="[% branchlimit | html %]"/>
75
            <input type="hidden" name="itemtypeslimit" value="[% itemtypeslimit | html %]"/>
76
            <input type="hidden" name="ccodeslimit" value="[% ccodeslimit | html %]"/>
77
            <input type="hidden" name="locationslimit" value="[% locationslimit | html %]"/>
78
            <input type="hidden" name="run_report" value="1"/>
79
80
            <label for="limit">Rows per page: </label>
81
            <select name="limit" id="limit">
82
                [% limits = [ 10, 20, 50, 100, 200, 300, 400, 500, 1000 ] %]
83
                [% FOREACH l IN limits %]
84
                    [% IF l == limit %]
85
                        <option value="[% l | html %]" selected="selected">[% l | html %]</option>
86
                    [% ELSE %]
87
                        <option value="[% l | html %]">[% l | html %]</option>
88
                    [% END %]
89
                [% END %]
90
            </select>
91
        </form> <!-- /#limitselect -->
92
        <div class="pages">[% pagination_bar | $raw %]</div>
93
71
    [% ELSE %]
94
    [% ELSE %]
72
        <div class="dialog message">No items found.</div>
95
        <div class="dialog message">No items found.</div>
73
    [% END %]
96
    [% END %]
Lines 310-315 Link Here
310
        $(document).ready(function() {
333
        $(document).ready(function() {
311
            var holdst;
334
            var holdst;
312
335
336
            $('#limit').change(function() {
337
                $('#limitselect').submit();
338
            });
339
313
            // Setup filters before DataTables initialisation, in case some columns are
340
            // Setup filters before DataTables initialisation, in case some columns are
314
            // hidden by default
341
            // hidden by default
315
            var filterColumnTimeoutId;
342
            var filterColumnTimeoutId;
(-)a/t/db_dependent/HoldsQueue.t (-14 / +23 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({ branchlimit => $least_cost_branch_code}) || [];
166
my ( $queue, undef ) = C4::HoldsQueue::GetHoldsQueueItems( { branchlimit => $least_cost_branch_code } );
167
my $queue_item = $queue->next;
167
my $queue_item = $queue->next;
168
ok( $queue_item
168
ok( $queue_item
169
 && $queue_item->pickbranch eq $borrower_branchcode
169
 && $queue_item->pickbranch eq $borrower_branchcode
Lines 1889-1895 subtest 'Remove holds on check-in match' => sub { Link Here
1889
};
1889
};
1890
1890
1891
subtest "GetHoldsQueueItems" => sub {
1891
subtest "GetHoldsQueueItems" => sub {
1892
    plan tests => 4;
1892
    plan tests => 8;
1893
1893
1894
    $schema->storage->txn_begin;
1894
    $schema->storage->txn_begin;
1895
1895
Lines 1943-1969 subtest "GetHoldsQueueItems" => sub { Link Here
1943
        ($itemnumber_3,$biblionumber_3,'','','',42,'','')
1943
        ($itemnumber_3,$biblionumber_3,'','','',42,'','')
1944
     " );
1944
     " );
1945
1945
1946
    my $queue_items = GetHoldsQueueItems();
1946
    my ( $queue_items, $queue_count ) = GetHoldsQueueItems();
1947
    is( $queue_items->count, $count + 3, 'Three items added to queue' );
1947
    is( $queue_items->count, $count + 3, 'Three items added to queue' );
1948
    is( $queue_count,        $count + 3, 'Correct count of items in queue' );
1948
1949
1949
    $queue_items = GetHoldsQueueItems( { itemtypeslimit => $item_1->itype } );
1950
    ( $queue_items, $queue_count ) = GetHoldsQueueItems( { itemtypeslimit => $item_1->itype } );
1950
    is( $queue_items->count,
1951
    is(
1951
        3, 'Three items of same itemtype found when itemtypeslimit passed' );
1952
        $queue_items->count,
1953
        3, 'Three items of same itemtype found when itemtypeslimit passed'
1954
    );
1955
    is( $queue_count, $count + 3, 'Correct count of items in queue' );
1952
1956
1953
    $queue_items = GetHoldsQueueItems(
1957
    ( $queue_items, $queue_count ) =
1954
        { itemtypeslimit => $item_1->itype, ccodeslimit => $item_2->ccode } );
1958
        GetHoldsQueueItems( { itemtypeslimit => $item_1->itype, ccodeslimit => $item_2->ccode } );
1955
    is( $queue_items->count,
1959
    is(
1956
        2, 'Two items of same collection found when ccodeslimit passed' );
1960
        $queue_items->count,
1961
        2, 'Two items of same collection found when ccodeslimit passed'
1962
    );
1963
    is( $queue_count, $count + 2, 'Correct count of items in queue' );
1957
1964
1958
    $queue_items = GetHoldsQueueItems(
1965
    ( $queue_items, $queue_count ) = GetHoldsQueueItems(
1959
        {
1966
        {
1960
            itemtypeslimit => $item_1->itype,
1967
            itemtypeslimit => $item_1->itype,
1961
            ccodeslimit    => $item_2->ccode,
1968
            ccodeslimit    => $item_2->ccode,
1962
            locationslimit => $item_3->location
1969
            locationslimit => $item_3->location
1963
        }
1970
        }
1964
    );
1971
    );
1965
    is( scalar $queue_items->count,
1972
    is(
1966
        1, 'One item of shleving location found when locationslimit passed' );
1973
        scalar $queue_items->count,
1974
        1, 'One item of shelving location found when locationslimit passed'
1975
    );
1976
    is( $queue_count, $count + 1, 'Correct count of items in queue' );
1967
1977
1968
    $schema->storage->txn_rollback;
1978
    $schema->storage->txn_rollback;
1969
};
1979
};
1970
- 

Return to bug 28974