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

(-)a/Koha/Items.pm (+13 lines)
Lines 37-42 Koha::Items - Koha Item object set class Link Here
37
37
38
=cut
38
=cut
39
39
40
=head3 filter_by_for_loan
41
42
$items->filter_by_not_for_loan;
43
44
Return the items of the set that are not for loan
45
46
=cut
47
48
sub filter_by_for_loan {
49
    my ($self) = @_;
50
    return $self->search( { notforloan => [ 0, undef ] } );
51
}
52
40
=head3 type
53
=head3 type
41
54
42
=cut
55
=cut
(-)a/catalogue/MARCdetail.pl (-4 lines)
Lines 267-273 my %witness Link Here
267
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
267
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
268
my @item_subfield_codes;
268
my @item_subfield_codes;
269
my @item_loop;
269
my @item_loop;
270
my $norequests = 1;
271
270
272
foreach my $field (@fields) {
271
foreach my $field (@fields) {
273
    next if ( $field->tag() < 10 );
272
    next if ( $field->tag() < 10 );
Lines 295-302 foreach my $field (@fields) { Link Here
295
            $item->{ $subf[$i][0] } .= GetAuthorisedValueDesc( $field->tag(), $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
294
            $item->{ $subf[$i][0] } .= GetAuthorisedValueDesc( $field->tag(), $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
296
        }
295
        }
297
296
298
        $norequests = 0 if  $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.notforloan' and $subf[$i][1] == 0;
299
300
        my $kohafield = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield};
297
        my $kohafield = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield};
301
        $item->{ $subf[$i][0] } = output_pref( { str => $item->{ $subf[$i][0] }, dateonly => 1 } )
298
        $item->{ $subf[$i][0] } = output_pref( { str => $item->{ $subf[$i][0] }, dateonly => 1 } )
302
          if grep { $kohafield eq $_ }
299
          if grep { $kohafield eq $_ }
Lines 330-336 if ($subscriptionscount) { Link Here
330
}
327
}
331
328
332
$template->param (
329
$template->param (
333
    norequests              => $norequests,
334
    item_loop               => \@item_loop,
330
    item_loop               => \@item_loop,
335
    item_header_loop        => \@item_header_loop,
331
    item_header_loop        => \@item_header_loop,
336
    item_subfield_codes     => \@item_subfield_codes,
332
    item_subfield_codes     => \@item_subfield_codes,
(-)a/catalogue/detail.pl (-5 lines)
Lines 270-276 my $collections = Link Here
270
my $copynumbers =
270
my $copynumbers =
271
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
271
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
272
my (@itemloop, @otheritemloop, %itemfields);
272
my (@itemloop, @otheritemloop, %itemfields);
273
my $norequests = 1;
274
273
275
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
274
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
276
if ( $mss->count ) {
275
if ( $mss->count ) {
Lines 306-314 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homeb Link Here
306
foreach my $item (@items) {
305
foreach my $item (@items) {
307
    my $itembranchcode = $item->{$separatebranch};
306
    my $itembranchcode = $item->{$separatebranch};
308
307
309
    # can place holds defaults to yes
310
    $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
311
312
    $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
308
    $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
313
                                               : '';
309
                                               : '';
314
310
Lines 409-415 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { Link Here
409
    }
405
    }
410
}
406
}
411
407
412
$template->param( norequests => $norequests );
413
$template->param(
408
$template->param(
414
    MARCNOTES   => $marcnotesarray,
409
    MARCNOTES   => $marcnotesarray,
415
    itemdata_ccode      => $itemfields{ccode},
410
    itemdata_ccode      => $itemfields{ccode},
(-)a/catalogue/imageviewer.pl (-10 lines)
Lines 47-61 my $biblio = Koha::Biblios->find( $biblionumber ); Link Here
47
my $itemcount = $biblio ? $biblio->items->count : 0;
47
my $itemcount = $biblio ? $biblio->items->count : 0;
48
my @items = GetItemsInfo($biblionumber);
48
my @items = GetItemsInfo($biblionumber);
49
49
50
my $norequests = 1;
51
foreach my $item (@items) {
52
53
    # can place holds defaults to yes
54
    $norequests = 0
55
      unless ( ( $item->{'notforloan_per_itemtype'} > 0 )
56
        || ( $item->{'itemnotforloan'} > 0 ) );
57
}
58
59
if ( $query->cookie("holdfor") ) {
50
if ( $query->cookie("holdfor") ) {
60
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
51
    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
61
    $template->param(
52
    $template->param(
Lines 82-88 if ( C4::Context->preference("LocalCoverImages") ) { Link Here
82
}
73
}
83
$template->{VARS}->{'count'}        = $itemcount;
74
$template->{VARS}->{'count'}        = $itemcount;
84
$template->{VARS}->{'biblionumber'} = $biblionumber;
75
$template->{VARS}->{'biblionumber'} = $biblionumber;
85
$template->{VARS}->{'norequests'}   = $norequests;
86
$template->param(C4::Search::enabled_staff_search_views);
76
$template->param(C4::Search::enabled_staff_search_views);
87
$template->{VARS}->{'biblio'} = $biblio;
77
$template->{VARS}->{'biblio'} = $biblio;
88
78
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +4 lines)
Lines 1-3 Link Here
1
[% USE Context %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
[% INCLUDE 'blocking_errors.inc' %]
2
<div id="toolbar" class="btn-toolbar">
3
<div id="toolbar" class="btn-toolbar">
3
4
Lines 116-122 CAN_user_serials_create_subscription ) %] Link Here
116
    <div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
117
    <div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
117
118
118
[% IF ( CAN_user_reserveforothers ) %]
119
[% IF ( CAN_user_reserveforothers ) %]
119
    [% UNLESS ( norequests ) %]
120
    [%# biblio.items.filter_by_for_loan.count %]
121
    [% SET items = biblio.items %]
122
    [% IF Context.Scalar(Context.Scalar(items, "filter_by_for_loan"), "count") %]
120
        [% IF ( holdfor ) %]
123
        [% IF ( holdfor ) %]
121
            <div class="btn-group">
124
            <div class="btn-group">
122
                <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
125
                <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
(-)a/t/db_dependent/Koha/Items.t (-2 / +14 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Circulation;
25
use C4::Circulation;
Lines 196-201 subtest 'can_be_transferred' => sub { Link Here
196
       'We get the same result also if we pass the from-library parameter.');
196
       'We get the same result also if we pass the from-library parameter.');
197
};
197
};
198
198
199
subtest 'filter_by_for_loan' => sub {
200
    plan tests => 3;
201
202
    my $biblio = $builder->build_sample_biblio;
203
    is( $biblio->items->filter_by_for_loan->count, 0, 'no item yet' );
204
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } );
205
    is( $biblio->items->filter_by_for_loan->count, 0, 'no item for loan' );
206
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } );
207
    is( $biblio->items->filter_by_for_loan->count, 1, '1 item for loan' );
208
209
    $biblio->delete;
210
};
211
199
$retrieved_item_1->delete;
212
$retrieved_item_1->delete;
200
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
213
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
201
214
202
- 

Return to bug 26139