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

(-)a/Koha/Item.pm (+12 lines)
Lines 235-240 sub current_holds { Link Here
235
    return Koha::Holds->_new_from_dbic($hold_rs);
235
    return Koha::Holds->_new_from_dbic($hold_rs);
236
}
236
}
237
237
238
=head3 is_waiting_or_transit
239
240
    Returns true if an item has a waiting or transit hold
241
242
=cut
243
244
sub is_waiting_or_transit {
245
    my ( $self ) = @_;
246
    return 1 if Koha::Holds->search({ itemnumber => $self->itemnumber, found => ['W', 'T'] })->count > 0;
247
    return q{};
248
}
249
238
=head3 type
250
=head3 type
239
251
240
=cut
252
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (+8 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.onloan %]Checked out
47
    [% ELSIF myitem.is_waiting_or_transit %]On hold
48
    [% ELSE %]Available
49
    [% END %]
50
[% END %]
45
51
46
<body id="circ_article-requests" class="circ">
52
<body id="circ_article-requests" class="circ">
47
    [% INCLUDE 'header.inc' %]
53
    [% INCLUDE 'header.inc' %]
Lines 176-181 Link Here
176
                                            [% END %]
182
                                            [% END %]
177
183
178
                                            [% ar.item.itemcallnumber %]
184
                                            [% ar.item.itemcallnumber %]
185
                                            <p>[% PROCESS 'item_status' myitem = ar.item %]</p>
179
                                        </td>
186
                                        </td>
180
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
187
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
181
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
188
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
Lines 284-289 Link Here
284
                                            [% END %]
291
                                            [% END %]
285
292
286
                                            [% ar.item.itemcallnumber %]
293
                                            [% ar.item.itemcallnumber %]
294
                                            <p>[% PROCESS 'item_status' myitem = ar.item %]</p>
287
                                        </td>
295
                                        </td>
288
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
296
                                        <td class="ar-copynumber">[% ar.item.copynumber %]</td>
289
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
297
                                        <td class="ar-enumchron">[% ar.item.enumchron %]</td>
(-)a/t/db_dependent/Koha/Items.t (-3 / +16 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 8;
22
use Test::More tests => 9;
23
23
24
use C4::Circulation;
24
use C4::Circulation;
25
use Koha::Item;
25
use Koha::Item;
Lines 31-37 use t::lib::TestBuilder; Link Here
31
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
32
$schema->storage->txn_begin;
32
$schema->storage->txn_begin;
33
33
34
my $builder     = t::lib::TestBuilder->new;
34
our $builder     = t::lib::TestBuilder->new;
35
my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
35
my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
36
my $library     = $builder->build( { source => 'Branch' } );
36
my $library     = $builder->build( { source => 'Branch' } );
37
my $nb_of_items = Koha::Items->search->count;
37
my $nb_of_items = Koha::Items->search->count;
Lines 121-125 subtest 'checkout' => sub { Link Here
121
$retrieved_item_1->delete;
121
$retrieved_item_1->delete;
122
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
122
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
123
123
124
subtest 'is_waiting_or_transit' => sub {
125
    plan tests => 3;
126
127
    my $hold = $builder->build_object({ class => 'Koha::Holds', value => { found => 'W' } });
128
    is( Koha::Items->find($hold->itemnumber)->is_waiting_or_transit, 1,
129
        'Item is waiting' );
130
    $hold->found('T')->store;
131
    is( Koha::Items->find($hold->itemnumber)->is_waiting_or_transit, 1,
132
        'Item has transit hold' );
133
    $hold->found(undef)->store;
134
    is( Koha::Items->find($hold->itemnumber)->is_waiting_or_transit, q{},
135
        'Item should be available' );
136
};
137
124
$schema->storage->txn_rollback;
138
$schema->storage->txn_rollback;
125
139
126
- 

Return to bug 20469