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

(-)a/Koha/ItemTypes.pm (-39 / +3 lines)
Lines 24-30 use C4::Languages; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::ItemType;
25
use Koha::ItemType;
26
26
27
use base qw(Koha::Objects);
27
use base qw(Koha::Objects Koha::Objects::Limit::Library);
28
28
29
=head1 NAME
29
=head1 NAME
30
30
Lines 32-38 Koha::ItemTypes - Koha ItemType Object set class Link Here
32
32
33
=head1 API
33
=head1 API
34
34
35
=head2 Class Methods
35
=head2 Class methods
36
36
37
=cut
37
=cut
38
38
Lines 62-103 sub search_with_localization { Link Here
62
    }
62
    }
63
}
63
}
64
64
65
=head3 search_with_library_limits
65
=head2 Internal methods
66
67
search itemtypes by library
68
69
my @itemtypes = Koha::ItemTypes->search_with_library_limits({branchcode => branchcode});
70
71
=cut
72
73
sub search_with_library_limits {
74
    my ( $self, $params, $attributes ) = @_;
75
76
    my $branchcode = $params->{branchcode};
77
    delete( $params->{branchcode} );
78
79
    return $self->SUPER::search( $params, $attributes ) unless $branchcode;
80
81
    my $where = {
82
        '-or' => [
83
            'itemtypes_branches.branchcode' => undef,
84
            'itemtypes_branches.branchcode' => $branchcode
85
        ]
86
    };
87
88
    $attributes //= {};
89
    if(exists $attributes->{join}) {
90
        if(ref $attributes->{join} eq 'ARRAY') {
91
            push @{$attributes->{join}}, 'itemtypes_branches';
92
        } else {
93
            $attributes->{join} = [ $attributes->{join}, 'itemtypes_branches' ];
94
        }
95
    } else {
96
        $attributes->{join} = 'itemtypes_branches';
97
    }
98
99
    return $self->SUPER::search( { %$params, %$where, }, $attributes );
100
}
101
66
102
=head3 type
67
=head3 type
103
68
104
- 

Return to bug 15497