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

(-)a/Koha/Item.pm (+12 lines)
Lines 282-287 sub current_holds { Link Here
282
    return Koha::Holds->_new_from_dbic($hold_rs);
282
    return Koha::Holds->_new_from_dbic($hold_rs);
283
}
283
}
284
284
285
=head3 has_waiting_or_transit_hold
286
287
    Returns true if an item has a waiting or transit hold
288
289
=cut
290
291
sub has_waiting_or_transit_hold {
292
    my ( $self ) = @_;
293
    my $rs = $self->_result->reserves;
294
    return Koha::Holds->_new_from_dbic($rs)->waiting_or_transit->count;
295
}
296
285
=head3 type
297
=head3 type
286
298
287
=cut
299
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (+9 lines)
Lines 42-47 Link Here
42
        </ul>
42
        </ul>
43
    </div>
43
    </div>
44
[% END %]
44
[% END %]
45
[% BLOCK item_status %][%# pass Koha::Item into myitem %]
46
    [% IF !myitem # Note: article request may have no item %]
47
    [% ELSIF myitem.onloan %]Checked out
48
    [% ELSIF myitem.has_waiting_or_transit_hold %]On hold
49
    [% ELSE %]Available
50
    [% END %]
51
[% END %]
45
52
46
<body id="circ_article-requests" class="circ">
53
<body id="circ_article-requests" class="circ">
47
    [% INCLUDE 'header.inc' %]
54
    [% INCLUDE 'header.inc' %]
Lines 176-181 Link Here
176
                                            [% END %]
183
                                            [% END %]
177
184
178
                                            [% ar.item.itemcallnumber %]
185
                                            [% ar.item.itemcallnumber %]
186
                                            <p>[% PROCESS 'item_status' myitem = ar.item %]</p>
179
                                        </td>
187
                                        </td>
180
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
188
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
181
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
189
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
Lines 284-289 Link Here
284
                                            [% END %]
292
                                            [% END %]
285
293
286
                                            [% ar.item.itemcallnumber %]
294
                                            [% ar.item.itemcallnumber %]
295
                                            <p>[% PROCESS 'item_status' myitem = ar.item %]</p>
287
                                        </td>
296
                                        </td>
288
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
297
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
289
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
298
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
(-)a/t/db_dependent/Koha/Items.t (-3 / +17 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 9;
22
use Test::More tests => 10;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Circulation;
25
use C4::Circulation;
Lines 34-40 use t::lib::Mocks; Link Here
34
my $schema = Koha::Database->new->schema;
34
my $schema = Koha::Database->new->schema;
35
$schema->storage->txn_begin;
35
$schema->storage->txn_begin;
36
36
37
my $builder     = t::lib::TestBuilder->new;
37
our $builder     = t::lib::TestBuilder->new;
38
my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
38
my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
39
my $library     = $builder->build( { source => 'Branch' } );
39
my $library     = $builder->build( { source => 'Branch' } );
40
my $nb_of_items = Koha::Items->search->count;
40
my $nb_of_items = Koha::Items->search->count;
Lines 164-168 subtest 'can_be_transferred' => sub { Link Here
164
$retrieved_item_1->delete;
164
$retrieved_item_1->delete;
165
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
165
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
166
166
167
subtest 'has_waiting_or_transit_hold' => sub {
168
    plan tests => 3;
169
170
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => { found => 'W' } });
171
    my $itemnumber = $hold->itemnumber;
172
    is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 1,
173
        'Item is waiting' );
174
    $hold->found('T')->store;
175
    is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 1,
176
        'Item has transit hold' );
177
    $hold->delete;
178
    is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 0,
179
        'Item should be available' );
180
};
181
167
$schema->storage->txn_rollback;
182
$schema->storage->txn_rollback;
168
183
169
- 

Return to bug 20469