|
Line 0
Link Here
|
|
|
1 |
package Koha::Item; |
| 2 |
|
| 3 |
# Copyright ByWater Solutions 2014 |
| 4 |
# |
| 5 |
# This file is part of Koha. |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 8 |
# terms of the GNU General Public License as published by the Free Software |
| 9 |
# Foundation; either version 3 of the License, or (at your option) any later |
| 10 |
# version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License along |
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
|
| 22 |
use Carp; |
| 23 |
|
| 24 |
use Koha::Database; |
| 25 |
use Koha::Biblios; |
| 26 |
use Koha::Deleted::Biblios; |
| 27 |
use Koha::BiblioItems; |
| 28 |
use Koha::Deleted::BiblioItems; |
| 29 |
|
| 30 |
use base qw(Koha::Object); |
| 31 |
|
| 32 |
=head1 NAME |
| 33 |
|
| 34 |
Koha::Item - Koha Item Object class |
| 35 |
|
| 36 |
=head1 API |
| 37 |
|
| 38 |
=head2 Class Methods |
| 39 |
|
| 40 |
=cut |
| 41 |
|
| 42 |
=head3 biblio |
| 43 |
|
| 44 |
my $biblio = $checkout->biblio({ deleted => 1 }); |
| 45 |
|
| 46 |
Returns the related Koha::Biblio for this checkout. |
| 47 |
|
| 48 |
If the parameter delete is passed and true, and the biblionumber |
| 49 |
is not found for current biblios, this method will look for a matching |
| 50 |
deleted biblio. |
| 51 |
|
| 52 |
=cut |
| 53 |
|
| 54 |
sub biblio { |
| 55 |
my ( $self, $params ) = @_; |
| 56 |
|
| 57 |
my $biblio = Koha::Biblios->search( { biblionumber => $self->biblionumber() } )->next(); |
| 58 |
|
| 59 |
$biblio ||= Koha::Deleted::Biblios->search( { biblionumber => $self->biblionumber() } )->next() if ( $params->{deleted} ); |
| 60 |
|
| 61 |
return $biblio || undef; |
| 62 |
} |
| 63 |
|
| 64 |
=head3 biblioitem |
| 65 |
|
| 66 |
my $biblioitem = $checkout->biblio({ deleted => 1 }); |
| 67 |
|
| 68 |
Returns the related Koha::Biblio for this checkout. |
| 69 |
|
| 70 |
If the parameter delete is passed and true, and the biblioitemnumber |
| 71 |
is not found for current biblioitems, this method will look for a matching |
| 72 |
deleted biblioitem. |
| 73 |
|
| 74 |
=cut |
| 75 |
|
| 76 |
sub biblioitem { |
| 77 |
my ( $self, $params ) = @_; |
| 78 |
|
| 79 |
my $biblioitem = Koha::BiblioItems->search( { biblionumber => $self->biblionumber() } )->next(); |
| 80 |
|
| 81 |
$biblioitem ||= Koha::Deleted::BiblioItems->search( { biblionumber => $self->biblionumber() } )->next() if ( $params->{deleted} ); |
| 82 |
|
| 83 |
return $biblioitem || undef; |
| 84 |
} |
| 85 |
|
| 86 |
=head3 type |
| 87 |
|
| 88 |
=cut |
| 89 |
|
| 90 |
sub type { |
| 91 |
return 'Item'; |
| 92 |
} |
| 93 |
|
| 94 |
=head1 AUTHOR |
| 95 |
|
| 96 |
Kyle M Hall <kyle@bywatersolutions.com> |
| 97 |
|
| 98 |
=cut |
| 99 |
|
| 100 |
1; |