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

(-)a/Koha/Hold.pm (-15 / +13 lines)
Lines 298-308 Returns the related Koha::Item object for this Hold Link Here
298
=cut
298
=cut
299
299
300
sub item {
300
sub item {
301
    my ($self) = @_;
301
    my $self = shift;
302
302
    my $item_rs = $self->_result->item;
303
    $self->{_item} ||= Koha::Items->find( $self->itemnumber() );
303
    return unless $item_rs;
304
304
    return Koha::Item->_new_from_dbic($item_rs);
305
    return $self->{_item};
306
}
305
}
307
306
308
=head3 branch
307
=head3 branch
Lines 311-322 Returns the related Koha::Library object for this Hold Link Here
311
310
312
=cut
311
=cut
313
312
313
# FIXME Should be renamed with ->library
314
sub branch {
314
sub branch {
315
    my ($self) = @_;
315
    my $self = shift;
316
316
    my $branch_rs = $self->_result->branchcode;
317
    $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() );
317
    return unless $branch_rs;
318
318
    return Koha::Library->_new_from_dbic($branch_rs);
319
    return $self->{_branch};
320
}
319
}
321
320
322
=head3 borrower
321
=head3 borrower
Lines 327-337 Returns the related Koha::Patron object for this Hold Link Here
327
326
328
# FIXME Should be renamed with ->patron
327
# FIXME Should be renamed with ->patron
329
sub borrower {
328
sub borrower {
330
    my ($self) = @_;
329
    my $self = shift;
331
330
    my $patron_rs = $self->_result->borrowernumber;
332
    $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
331
    return unless $patron_rs;
333
332
    return Koha::Patron->_new_from_dbic($patron_rs);
334
    return $self->{_borrower};
335
}
333
}
336
334
337
=head3 is_suspended
335
=head3 is_suspended
(-)a/Koha/Item.pm (-10 / +8 lines)
Lines 301-311 sub effective_itemtype { Link Here
301
=cut
301
=cut
302
302
303
sub home_branch {
303
sub home_branch {
304
    my ($self) = @_;
304
    my $self = shift;
305
305
    my $home_branch_rs = $self->_result->homebranch;
306
    $self->{_home_branch} ||= Koha::Libraries->find( $self->homebranch() );
306
    return unless $home_branch_rs;
307
307
    return Koha::Library->_new_from_dbic($home_branch_rs);
308
    return $self->{_home_branch};
309
}
308
}
310
309
311
=head3 holding_branch
310
=head3 holding_branch
Lines 313-323 sub home_branch { Link Here
313
=cut
312
=cut
314
313
315
sub holding_branch {
314
sub holding_branch {
316
    my ($self) = @_;
315
    my $self = shift;
317
316
    my $holding_branch_rs = $self->_result->holdingbranch;
318
    $self->{_holding_branch} ||= Koha::Libraries->find( $self->holdingbranch() );
317
    return unless $holding_branch_rs;
319
318
    return Koha::Library->_new_from_dbic($holding_branch_rs);
320
    return $self->{_holding_branch};
321
}
319
}
322
320
323
=head3 biblio
321
=head3 biblio
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-1 / +1 lines)
Lines 128-134 Link Here
128
                    [% END %]
128
                    [% END %]
129
                [% ELSE %]
129
                [% ELSE %]
130
                    [% IF Koha.Preference('IndependentBranches') && Branches.all().size == 1 %]
130
                    [% IF Koha.Preference('IndependentBranches') && Branches.all().size == 1 %]
131
                        [% Branches.GetName(hold.branchcode) | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" />
131
                        [% hold.branch.branchname | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" />
132
                    [% ELSE %]
132
                    [% ELSE %]
133
                        <select name="pickup">
133
                        <select name="pickup">
134
                            [% PROCESS options_for_libraries libraries => Branches.pickup_locations( { search_params => { item => hold.itemnumber, biblio => hold.biblionumber, patron => hold.patron }, selected => hold.branchcode }) %]
134
                            [% PROCESS options_for_libraries libraries => Branches.pickup_locations( { search_params => { item => hold.itemnumber, biblio => hold.biblionumber, patron => hold.patron }, selected => hold.branchcode }) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc (-3 / +3 lines)
Lines 37-44 Link Here
37
                        [% reserveloo.borrower.first_valid_email_address | html %]</a></span>
37
                        [% reserveloo.borrower.first_valid_email_address | html %]</a></span>
38
                    [% END %]
38
                    [% END %]
39
                </td>
39
                </td>
40
                <td>[% Branches.GetName( reserveloo.item.homebranch ) | html %]</td>
40
                <td>[% reserveloo.item.home_branch.branchname | html %]</td>
41
                <td>[% Branches.GetName( reserveloo.item.holdingbranch ) | html %]</td>
41
                <td>[% reserveloo.item.holding_branch.branchname | html %]</td>
42
                <td>[% AuthorisedValues.GetByCode('LOC', reserveloo.item.location) | html %]</td>
42
                <td>[% AuthorisedValues.GetByCode('LOC', reserveloo.item.location) | html %]</td>
43
                <td>[% reserveloo.item.itemcallnumber | html %]</td>
43
                <td>[% reserveloo.item.itemcallnumber | html %]</td>
44
                <td>[% reserveloo.item.copynumber | html %]</td>
44
                <td>[% reserveloo.item.copynumber | html %]</td>
Lines 51-57 Link Here
51
                        <input type="hidden" name="tbr" value="[% reserveloo.item.homebranch | html %]" />
51
                        <input type="hidden" name="tbr" value="[% reserveloo.item.homebranch | html %]" />
52
                        <input type="hidden" name="tab" value="[% tab | html %]">
52
                        <input type="hidden" name="tab" value="[% tab | html %]">
53
                        [% IF ( reserveloo.item.homebranch != reserveloo.item.holdingbranch ) %]
53
                        [% IF ( reserveloo.item.homebranch != reserveloo.item.holdingbranch ) %]
54
                            <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold and return to: [% Branches.GetName( reserveloo.item.homebranch ) | html %]</button>
54
                            <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold and return to: [% reserveloo.item.home_branch.branchname | html %]</button>
55
                        [% ELSE %]
55
                        [% ELSE %]
56
                            <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold</button>
56
                            <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold</button>
57
                        [% END %]
57
                        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-3 / +3 lines)
Lines 112-123 Link Here
112
                                                until [% HOLD.expirationdate | $KohaDates %]
112
                                                until [% HOLD.expirationdate | $KohaDates %]
113
                                            [% END %]
113
                                            [% END %]
114
                                        [% END %]
114
                                        [% END %]
115
                                        <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" />
115
                                        <input type="hidden" name="pickup" value="[% HOLD.branch.branchcode | html %]" />
116
                                    [% ELSE %]
116
                                    [% ELSE %]
117
                                        Item waiting to be pulled from <strong> [% Branches.GetName( HOLD.branchcode ) | html %]</strong>
117
                                        Item waiting to be pulled from <strong> [% HOLD.branch.branchname | html %]</strong>
118
                                    [% END %]
118
                                    [% END %]
119
                                [% ELSE %]
119
                                [% ELSE %]
120
                                    Item in transit to <strong> [% Branches.GetName( HOLD.branchcode ) | html %]</strong> <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" />
120
                                    Item in transit to <strong> [% HOLD.branch.branchname | html %]</strong> <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" />
121
                                [% END %]
121
                                [% END %]
122
                            [% ELSE %]
122
                            [% ELSE %]
123
                                [% IF ( HOLD.is_in_transit ) %]
123
                                [% IF ( HOLD.is_in_transit ) %]
(-)a/t/db_dependent/Koha/Holds.t (-2 / +13 lines)
Lines 35-41 $schema->storage->txn_begin; Link Here
35
my $builder = t::lib::TestBuilder->new;
35
my $builder = t::lib::TestBuilder->new;
36
36
37
subtest 'DB constraints' => sub {
37
subtest 'DB constraints' => sub {
38
    plan tests => 1;
38
    plan tests => 2;
39
39
40
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
40
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
41
    my $item = $builder->build_sample_item;
41
    my $item = $builder->build_sample_item;
Lines 55-61 subtest 'DB constraints' => sub { Link Here
55
        eval { $hold->priority(undef)->store }
55
        eval { $hold->priority(undef)->store }
56
    }
56
    }
57
    qr{.*DBD::mysql::st execute failed: Column 'priority' cannot be null.*},
57
    qr{.*DBD::mysql::st execute failed: Column 'priority' cannot be null.*},
58
      'DBD should have raised an error about priority that cannot be null';
58
        'DBD should have raised an error about priority that cannot be null';
59
60
    subtest 'Related objects' => sub {
61
        plan tests => 3;
62
        my $item = $hold->item;
63
        is(ref($item), 'Koha::Item', 'Returns a Koha::Item resultset' );
64
        my $patron = $hold->borrower;
65
        is(ref($patron), 'Koha::Patron', 'Returns a Koha::Patron resultset' );
66
        my $library = $hold->branch;
67
        is(ref($library), 'Koha::Library', 'Returns a Koha::Branch resultset' );
68
    };
69
59
};
70
};
60
71
61
subtest 'cancel' => sub {
72
subtest 'cancel' => sub {
(-)a/t/db_dependent/Koha/Item/RelatedObjects.t (-1 / +55 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2020 BULAC
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 2;
23
24
use C4::Biblio;
25
use C4::Circulation;
26
27
use Koha::Items;
28
use Koha::Database;
29
use Koha::Old::Items;
30
31
use List::MoreUtils qw(all);
32
33
use t::lib::TestBuilder;
34
use t::lib::Mocks;
35
36
my $schema  = Koha::Database->new->schema;
37
my $builder = t::lib::TestBuilder->new;
38
39
40
$schema->storage->txn_begin;
41
my $library     = $builder->build( { source => 'Branch' } );
42
my  $nb_of_items = Koha::Items->search->count;
43
my $biblio      = $builder->build_sample_biblio();
44
my $new_item   = $builder->build_sample_item({
45
    biblionumber => $biblio->biblionumber,
46
    homebranch       => $library->{branchcode},
47
    holdingbranch    => $library->{branchcode},
48
                                               });
49
my $home_branch = $new_item->home_branch;
50
is(ref($home_branch), 'Koha::Library', 'Returns a Koha::Library resultset' );
51
my $holding_branch = $new_item->holding_branch;
52
is(ref($holding_branch), 'Koha::Library', 'Returns a Koha::Library resultset' );
53
$schema->storage->txn_rollback;
54
55

Return to bug 25951