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

(-)a/C4/HoldsQueue.pm (-45 / +35 lines)
Lines 25-31 use warnings; Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Circulation qw( GetBranchItemRule );
26
use C4::Circulation qw( GetBranchItemRule );
27
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
28
use Koha::HoldsQueueItems;
28
use Koha::Hold::HoldsQueueItems;
29
use Koha::Items;
29
use Koha::Items;
30
use Koha::Libraries;
30
use Koha::Libraries;
31
use Koha::Patrons;
31
use Koha::Patrons;
Lines 126-177 sub GetHoldsQueueItems { Link Here
126
    my $params = shift;
126
    my $params = shift;
127
    my $dbh   = C4::Context->dbh;
127
    my $dbh   = C4::Context->dbh;
128
128
129
    my @bind_params = ();
129
    my $search_params;
130
    my $query = q/SELECT tmp_holdsqueue.*, biblio.author, items.ccode, items.itype, biblioitems.itemtype, items.location,
130
    $search_params->{'me.holdingbranch'} = $params->{branchlimit} if $params->{branchlimit};
131
                         items.enumchron, items.cn_sort, biblioitems.publishercode,
131
    $search_params->{'itype'} = $params->{itemtypeslimit} if $params->{itemtypeslimit};
132
                         biblio.copyrightdate, biblio.subtitle, biblio.medium,
132
    $search_params->{'ccode'} = $params->{ccodeslimit} if $params->{ccodeslimit};
133
                         biblio.part_number, biblio.part_name,
133
    $search_params->{'location'} = $params->{locationslimit} if $params->{locationslimit};
134
                         biblioitems.publicationyear, biblioitems.pages, biblioitems.size,
134
135
                         biblioitems.isbn, biblioitems.editionstatement, items.copynumber,
135
    my $results = Koha::Hold::HoldsQueueItems->search(
136
                         item_groups.item_group_id, item_groups.description AS item_group_description
136
        $search_params,
137
                  FROM tmp_holdsqueue
137
        {
138
                       JOIN biblio      USING (biblionumber)
138
            join => [
139
                  LEFT JOIN biblioitems USING (biblionumber)
139
                'borrower',
140
                  LEFT JOIN items       USING (  itemnumber)
140
                'biblio',
141
                  LEFT JOIN item_group_items ON ( items.itemnumber =  item_group_items.item_id )
141
                'biblioitem',
142
                  LEFT JOIN item_groups ON ( item_group_items.item_group_id = item_groups.item_group_id )
142
                {
143
                  WHERE 1=1
143
                    'item' => {
144
                /;
144
                        'item_group_item' => 'item_group'
145
    if ($params->{branchlimit}) {
145
                    }
146
        $query .="AND tmp_holdsqueue.holdingbranch = ? ";
146
                },
147
        push @bind_params, $params->{branchlimit};
147
            ],
148
    }
148
            prefetch => [
149
    if( $params->{itemtypeslimit} ) {
149
                'biblio',
150
        $query .=" AND items.itype = ? ";
150
                'biblioitem',
151
        push @bind_params, $params->{itemtypeslimit};
151
                {
152
    }
152
                    'item' => {
153
    if( $params->{ccodeslimit} ) {
153
                        'item_group_item' => 'item_group'
154
        $query .=" AND items.ccode = ? ";
154
                    }
155
        push @bind_params, $params->{ccodeslimit};
155
                }
156
    }
156
            ],
157
    if( $params->{locationslimit} ) {
157
            order_by => [
158
        $query .=" AND items.location = ? ";
158
                'ccode',        'location',   'item.cn_sort', 'author',
159
        push @bind_params, $params->{locationslimit};
159
                'biblio.title', 'pickbranch', 'reservedate'
160
    }
160
            ],
161
    $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate";
162
    my $sth = $dbh->prepare($query);
163
    $sth->execute(@bind_params);
164
    my $items = [];
165
    while ( my $row = $sth->fetchrow_hashref ){
166
        # return the bib-level or item-level itype per syspref
167
        if (!C4::Context->preference('item-level_itypes')) {
168
            $row->{itype} = $row->{itemtype};
169
        }
161
        }
170
        delete $row->{itemtype};
162
    );
171
163
172
        push @$items, $row;
164
    return $results;
173
    }
174
    return $items;
175
}
165
}
176
166
177
=head2 CreateQueue
167
=head2 CreateQueue
(-)a/Koha/Hold/HoldsQueueItem.pm (+39 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Koha::Database;
20
use Koha::Database;
21
21
22
use Koha::Items;
23
use Koha::Biblios;
24
use Koha::Patrons;
25
22
use base qw(Koha::Object);
26
use base qw(Koha::Object);
23
27
24
=head1 NAME
28
=head1 NAME
Lines 27-32 Koha::Hold::HoldsQueueItem - Koha hold cancellation request Object class Link Here
27
31
28
=head1 API
32
=head1 API
29
33
34
=head2 Class methods
35
36
=head3 patron
37
38
=cut
39
40
sub patron {
41
    my ( $self ) = @_;
42
    my $rs = $self->_result->borrowernumber;
43
    return unless $rs;
44
    return Koha::Patron->_new_from_dbic( $rs );
45
}
46
47
=head3 biblio
48
49
=cut
50
51
sub biblio {
52
    my ( $self ) = @_;
53
    my $rs = $self->_result->biblionumber;
54
    return unless $rs;
55
    return Koha::Biblio->_new_from_dbic( $rs );
56
}
57
58
=head3 item
59
60
=cut
61
62
sub item {
63
    my ( $self ) = @_;
64
    my $rs = $self->_result->itemnumber;
65
    return unless $rs;
66
    return Koha::Item->_new_from_dbic( $rs );
67
}
68
30
=head2 Internal methods
69
=head2 Internal methods
31
70
32
=head3 _type
71
=head3 _type
(-)a/Koha/Schema/Result/IdentityProvider.pm (-6 / +4 lines)
Lines 58-64 Protocol provider speaks Link Here
58
=head2 config
58
=head2 config
59
59
60
  data_type: 'longtext'
60
  data_type: 'longtext'
61
  default_value: ''{}''
62
  is_nullable: 0
61
  is_nullable: 0
63
62
64
Configuration of the provider in JSON format
63
Configuration of the provider in JSON format
Lines 66-72 Configuration of the provider in JSON format Link Here
66
=head2 mapping
65
=head2 mapping
67
66
68
  data_type: 'longtext'
67
  data_type: 'longtext'
69
  default_value: ''{}''
70
  is_nullable: 0
68
  is_nullable: 0
71
69
72
Configuration to map provider data to Koha user
70
Configuration to map provider data to Koha user
Lines 103-111 __PACKAGE__->add_columns( Link Here
103
    is_nullable => 0,
101
    is_nullable => 0,
104
  },
102
  },
105
  "config",
103
  "config",
106
  { data_type => "longtext", default_value => "'{}'", is_nullable => 0 },
104
  { data_type => "longtext", is_nullable => 0 },
107
  "mapping",
105
  "mapping",
108
  { data_type => "longtext", default_value => "'{}'", is_nullable => 0 },
106
  { data_type => "longtext", is_nullable => 0 },
109
  "matchpoint",
107
  "matchpoint",
110
  {
108
  {
111
    data_type => "enum",
109
    data_type => "enum",
Lines 160-167 __PACKAGE__->has_many( Link Here
160
);
158
);
161
159
162
160
163
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-20 15:27:55
161
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-09 18:14:13
164
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jmqAwH7/6QvawJ73/0rkQg
162
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SN9hP/G6qcHqdmjEiCWRqg
165
163
166
__PACKAGE__->has_many(
164
__PACKAGE__->has_many(
167
  "domains",
165
  "domains",
(-)a/Koha/Schema/Result/TmpHoldsqueue.pm (+48 lines)
Lines 224-229 __PACKAGE__->add_columns( Link Here
224
    '+item_level_request' => { is_boolean => 1 }
224
    '+item_level_request' => { is_boolean => 1 }
225
);
225
);
226
226
227
__PACKAGE__->belongs_to(
228
  "borrower",
229
  "Koha::Schema::Result::Borrower",
230
  { borrowernumber => "borrowernumber" },
231
  {
232
    is_deferrable => 1,
233
    join_type     => "LEFT",
234
    on_delete     => "CASCADE",
235
    on_update     => "CASCADE",
236
  },
237
);
238
239
__PACKAGE__->belongs_to(
240
  "item",
241
  "Koha::Schema::Result::Item",
242
  { itemnumber => "itemnumber" },
243
  {
244
    is_deferrable => 1,
245
    join_type     => "LEFT",
246
    on_delete     => "CASCADE",
247
    on_update     => "CASCADE",
248
  },
249
);
250
251
__PACKAGE__->belongs_to(
252
  "biblio",
253
  "Koha::Schema::Result::Biblio",
254
  { biblionumber => "biblionumber" },
255
  {
256
    is_deferrable => 1,
257
    join_type     => "LEFT",
258
    on_delete     => "CASCADE",
259
    on_update     => "CASCADE",
260
  },
261
);
262
263
__PACKAGE__->belongs_to(
264
  "biblioitem",
265
  "Koha::Schema::Result::Biblioitem",
266
  { biblionumber => "biblionumber" },
267
  {
268
    is_deferrable => 1,
269
    join_type     => "LEFT",
270
    on_delete     => "CASCADE",
271
    on_update     => "CASCADE",
272
  },
273
);
274
227
sub koha_object_class {
275
sub koha_object_class {
228
    'Koha::HoldsQueueItem';
276
    'Koha::HoldsQueueItem';
229
}
277
}
(-)a/circ/view_holdsqueue.pl (-17 / +17 lines)
Lines 47-70 my $itemtypeslimit = $params->{'itemtypeslimit'}; Link Here
47
my $ccodeslimit = $params->{'ccodeslimit'};
47
my $ccodeslimit = $params->{'ccodeslimit'};
48
my $locationslimit = $params->{'locationslimit'};
48
my $locationslimit = $params->{'locationslimit'};
49
49
50
if ( $run_report ) {
50
if ($run_report) {
51
    my $items = GetHoldsQueueItems({
51
    my $items = GetHoldsQueueItems(
52
        branchlimit => $branchlimit,
52
        {
53
        itemtypeslimit => $itemtypeslimit,
53
            branchlimit    => $branchlimit,
54
        ccodeslimit => $ccodeslimit,
54
            itemtypeslimit => $itemtypeslimit,
55
        locationslimit => $locationslimit
55
            ccodeslimit    => $ccodeslimit,
56
    });
56
            locationslimit => $locationslimit
57
    for my $item ( @$items ) {
57
        }
58
        $item->{patron} = Koha::Patrons->find( $item->{borrowernumber} );
58
    );
59
    }
59
60
    $template->param(
60
    $template->param(
61
        branchlimit     => $branchlimit,
61
        branchlimit    => $branchlimit,
62
        itemtypeslimit     => $itemtypeslimit,
62
        itemtypeslimit => $itemtypeslimit,
63
        ccodeslimit     => $ccodeslimit,
63
        ccodeslimit    => $ccodeslimit,
64
        locationslimit     => $locationslimit,
64
        locationslimit => $locationslimit,
65
        total      => scalar @$items,
65
        total          => $items->count,
66
        itemsloop  => $items,
66
        itemsloop      => $items,
67
        run_report => $run_report,
67
        run_report     => $run_report,
68
    );
68
    );
69
}
69
}
70
70
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-17 / +17 lines)
Lines 166-205 Link Here
166
                    <tr>
166
                    <tr>
167
                        <td class="hq-title">
167
                        <td class="hq-title">
168
                            <p>
168
                            <p>
169
                                [% INCLUDE 'biblio-title.inc' biblio=itemsloo link = 1 %]
169
                                [% INCLUDE 'biblio-title.inc' biblio=itemsloo.biblio link = 1 %]
170
                            </p>
170
                            </p>
171
                            <p>
171
                            <p>
172
                                <div class="hq-biblionumber content_hidden">[% itemsloo.biblionumber | html %]</div>
172
                                <div class="hq-biblionumber content_hidden">[% itemsloo.biblionumber | html %]</div>
173
                                <div class="hq-author">[% itemsloo.author | html %]</div>
173
                                <div class="hq-author">[% itemsloo.biblio.author | html %]</div>
174
                                [% IF ( itemsloo.editionstatement ) %]<div class="hq-editionstatement">[% itemsloo.editionstatement | html %]</div>[% END %]
174
                                [% IF ( itemsloo.biblio.biblioitem.editionstatement ) %]<div class="hq-editionstatement">[% itemsloo.biblio.biblioitem.editionstatement | html %]</div>[% END %]
175
                                <div class="hq-pubdata">
175
                                <div class="hq-pubdata">
176
                                    [% IF ( itemsloo.publishercode ) %][% itemsloo.publishercode | html %][% END %]
176
                                    [% IF ( itemsloo.biblio.biblioitem.publishercode ) %][% itemsloo.biblio.biblioitem.publishercode | html %][% END %]
177
177
178
                                    [% IF ( itemsloo.publicationyear ) %]
178
                                    [% IF ( itemsloo.biblio.biblioitem.publicationyear ) %]
179
                                        , [% itemsloo.publicationyear | html %]
179
                                        , [% itemsloo.biblio.biblioitem.publicationyear | html %]
180
                                    [% ELSIF ( itemsloo.copyrightdate ) %]
180
                                    [% ELSIF ( itemsloo.biblio.copyrightdate ) %]
181
                                        , [% itemsloo.copyrightdate | html %]
181
                                        , [% itemsloo.biblio.copyrightdate | html %]
182
                                    [% END %]
182
                                    [% END %]
183
183
184
                                    [% IF ( itemsloo.pages ) %]: [% itemsloo.pages | html %] [% END %]
184
                                    [% IF ( itemsloo.biblio.biblioitem.pages ) %]: [% itemsloo.biblio.biblioitem.pages | html %] [% END %]
185
185
186
                                    [% IF ( itemsloo.item('size') ) %][% itemsloo.item('size') | html %][% END %]
186
                                    [% IF ( itemsloo.item('size') ) %][% itemsloo.item('size') | html %][% END %]
187
187
188
                                    [% IF ( itemsloo.isbn ) %]<span>ISBN: [% itemsloo.isbn | html %]</span>[% END %]
188
                                    [% IF ( itemsloo.biblio.biblioitem.isbn ) %]<span>ISBN: [% itemsloo.biblio.biblioitem.isbn | html %]</span>[% END %]
189
                                </div>
189
                                </div>
190
                            </p>
190
                            </p>
191
                        </td>
191
                        </td>
192
                        <td class="hq-holdingbranch">[% Branches.GetName( itemsloo.holdingbranch ) | html %]</td>
192
                        <td class="hq-holdingbranch">[% Branches.GetName( itemsloo.holdingbranch ) | html %]</td>
193
                        <td class="hq-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => itemsloo.ccode ) | html %]</td>
193
                        <td class="hq-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => itemsloo.item.ccode ) | html %]</td>
194
                        <td class="hq-itemtype">[% ItemTypes.GetDescription( itemsloo.itype ) | html %]</td>
194
                        <td class="hq-itemtype">[% ItemTypes.GetDescription( itemsloo.item.effective_itemtype ) | html %]</td>
195
                        <td class="hq-callnumber">[% IF ( itemsloo.location ) %]<em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => itemsloo.location ) | html %]</em> [% END %][% itemsloo.itemcallnumber | html %]</td>
195
                        <td class="hq-callnumber">[% IF ( itemsloo.item.location ) %]<em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => itemsloo.item.location ) | html %]</em> [% END %][% itemsloo.item.itemcallnumber | html %]</td>
196
                        <td class="hq-copynumber">[% itemsloo.copynumber | html %]</td>
196
                        <td class="hq-copynumber">[% itemsloo.item.copynumber | html %]</td>
197
                        <td class="hq-enumchron">[% itemsloo.enumchron | html %]</td>
197
                        <td class="hq-enumchron">[% itemsloo.item.enumchron | html %]</td>
198
                        <td class="hq-barcode">
198
                        <td class="hq-barcode">
199
                            [% IF ( itemsloo.item_level_request ) %]
199
                            [% IF ( itemsloo.item_level_request ) %]
200
                                <em>Only item:</em> <strong>[% itemsloo.barcode | html %]</strong>
200
                                <em>Only item:</em> <strong>[% itemsloo.barcode | html %]</strong>
201
                            [% ELSIF itemsloo.item_group_id %]
201
                            [% ELSIF itemsloo.item.item_group %]
202
                                <strong>[% itemsloo.barcode | html %]</strong> <em>or any item from item group <strong>[% itemsloo.item_group_description | html %]</strong></em>
202
                                <strong>[% itemsloo.barcode | html %]</strong> <em>or any item from item group <strong>[% itemsloo.item.item_group.description | html %]</strong></em>
203
                            [% ELSE %]
203
                            [% ELSE %]
204
                                <strong>[% itemsloo.barcode | html %]</strong> <em>or any available</em>
204
                                <strong>[% itemsloo.barcode | html %]</strong> <em>or any available</em>
205
                            [% END %]
205
                            [% END %]
(-)a/t/db_dependent/HoldsQueue.t (-12 / +11 lines)
Lines 163-175 $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 = C4::HoldsQueue::GetHoldsQueueItems({ branchlimit => $least_cost_branch_code}) || [];
167
my $queue_item = $queue->[0];
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
170
 && $queue_item->{holdingbranch} eq $least_cost_branch_code, "GetHoldsQueueItems" )
170
 && $queue_item->item->holdingbranch eq $least_cost_branch_code, "GetHoldsQueueItems" )
171
  or diag( "Expected item for pick $borrower_branchcode, hold $least_cost_branch_code, got ".Dumper($queue_item) );
171
  or diag( "Expected item for pick $borrower_branchcode, hold $least_cost_branch_code, got ".Dumper($queue_item->unblessed) );
172
ok( exists($queue_item->{itype}), 'item type included in queued items list (bug 5825)' );
172
ok( $queue_item->item->effective_itemtype, 'item type included in queued items list (bug 5825)' );
173
173
174
ok(
174
ok(
175
    C4::HoldsQueue::least_cost_branch( 'B', [ 'A', 'B', 'C' ] ) eq 'B',
175
    C4::HoldsQueue::least_cost_branch( 'B', [ 'A', 'B', 'C' ] ) eq 'B',
Lines 1944-1968 subtest "GetHoldsQueueItems" => sub { Link Here
1944
     " );
1944
     " );
1945
1945
1946
    my $queue_items = GetHoldsQueueItems();
1946
    my $queue_items = GetHoldsQueueItems();
1947
    is( scalar @$queue_items, $count + 3, 'Three items added to queue' );
1947
    is( $queue_items->count, $count + 3, 'Three items added to queue' );
1948
1948
1949
    $queue_items = GetHoldsQueueItems( { itemtypeslimit => $item_1->itype } );
1949
    $queue_items = GetHoldsQueueItems( { itemtypeslimit => $item_1->itype } );
1950
    is( scalar @$queue_items,
1950
    is( $queue_items->count,
1951
        3, 'Three items of same itemtype found when itemtypeslimit passed' );
1951
        3, 'Three items of same itemtype found when itemtypeslimit passed' );
1952
1952
1953
    $queue_items = GetHoldsQueueItems(
1953
    $queue_items = GetHoldsQueueItems(
1954
        { itemtypeslimit => $item_1->itype, ccodeslimit => $item_2->ccode } );
1954
        { itemtypeslimit => $item_1->itype, ccodeslimit => $item_2->ccode } );
1955
    is( scalar @$queue_items,
1955
    is( $queue_items->count,
1956
        2, 'Two items of same collection found when ccodeslimit passed' );
1956
        2, 'Two items of same collection found when ccodeslimit passed' );
1957
1957
1958
    @$queue_items = GetHoldsQueueItems(
1958
    $queue_items = GetHoldsQueueItems(
1959
        {
1959
        {
1960
            itemtypeslimit => $item_1->itype,
1960
            itemtypeslimit => $item_1->itype,
1961
            ccodeslimit    => $item_2->ccode,
1961
            ccodeslimit    => $item_2->ccode,
1962
            locationslimit => $item_3->location
1962
            locationslimit => $item_3->location
1963
        }
1963
        }
1964
    );
1964
    );
1965
    is( scalar @$queue_items,
1965
    is( scalar $queue_items->count,
1966
        1, 'One item of shleving location found when locationslimit passed' );
1966
        1, 'One item of shleving location found when locationslimit passed' );
1967
1967
1968
    $schema->storage->txn_rollback;
1968
    $schema->storage->txn_rollback;
1969
- 

Return to bug 28966