use Carp;
-use C4::Biblio qw( GetRecordValue GetMarcBiblio GetFrameworkCode );
+use C4::Biblio qw();
use Koha::Database;
+use Koha::DateUtils qw( dt_from_string );
use base qw(Koha::Object);
-use C4::Circulation qw(GetIssuingRule);
use Koha::Items;
use Koha::Biblioitems;
use Koha::ArticleRequests;
use Koha::ArticleRequest::Status;
+use Koha::IssuingRules;
+use Koha::Subscriptions;
=head1 NAME
sub subtitles {
my ( $self ) = @_;
- return map { $_->{subfield} } @{ GetRecordValue( 'subtitle', GetMarcBiblio( $self->id ), $self->frameworkcode ) };
+ return map { $_->{subfield} } @{
+ C4::Biblio::GetRecordValue(
+ 'subtitle',
+ C4::Biblio::GetMarcBiblio({ biblionumber => $self->id }),
+ $self->frameworkcode ) };
}
=head3 can_article_request
my $borrowertype = $borrower->categorycode;
my $itemtype = $self->itemtype();
- my $rules = C4::Circulation::GetIssuingRule( $borrowertype, $itemtype );
+ my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $borrowertype, itemtype => $itemtype });
- return $rules->{article_requests} || q{};
+ return q{} unless $issuing_rule;
+ return $issuing_rule->article_requests || q{}
}
=head3 article_request_type_for_items
=head3 items
-=head3 items
-
my @items = $biblio->items();
my $items = $biblio->items();
sub itemtype {
my ( $self ) = @_;
- return $self->_biblioitem()->itemtype();
+ return $self->biblioitem()->itemtype();
+}
+
+=head3 holds
+
+my $holds = $biblio->holds();
+
+return the current holds placed on this record
+
+=cut
+
+sub holds {
+ my ( $self, $params, $attributes ) = @_;
+ $attributes->{order_by} = 'priority' unless exists $attributes->{order_by};
+ my $hold_rs = $self->_result->reserves->search( $params, $attributes );
+ return Koha::Holds->_new_from_dbic($hold_rs);
+}
+
+=head3 current_holds
+
+my $holds = $biblio->current_holds
+
+Return the holds placed on this bibliographic record.
+It does not include future holds.
+
+=cut
+
+sub current_holds {
+ my ($self) = @_;
+ my $dtf = Koha::Database->new->schema->storage->datetime_parser;
+ return $self->holds(
+ { reservedate => { '<=' => $dtf->format_date(dt_from_string) } } );
}
-=head3 _biblioitem
+=head3 biblioitem
-my $field = $self->_biblioitem()->itemtype
+my $field = $self->biblioitem()->itemtype
Returns the related Koha::Biblioitem object for this Biblio object
return $self->{_biblioitem};
}
+=head3 subscriptions
+
+my $subscriptions = $self->subscriptions
+
+Returns the related Koha::Subscriptions object for this Biblio object
+
+=cut
+
+sub subscriptions {
+ my ($self) = @_;
+
+ $self->{_subscriptions} ||= Koha::Subscriptions->search( { biblionumber => $self->biblionumber } );
+
+ return $self->{_subscriptions};
+}
+
+
=head3 type
=cut