Bug 11897: Stockrotation
[koha.git] / Koha / Library.pm
index 7420c6a..7877174 100644 (file)
@@ -21,7 +21,10 @@ use Modern::Perl;
 
 use Carp;
 
+use C4::Context;
+
 use Koha::Database;
+use Koha::StockRotationStages;
 
 use base qw(Koha::Object);
 
@@ -31,7 +34,11 @@ Koha::Library - Koha Library Object class
 
 =head1 API
 
-=head2 Class Methods
+=head2 Class methods
+
+=head3 get_categories
+
+TODO: Ask the author to add a proper description
 
 =cut
 
@@ -41,12 +48,24 @@ sub get_categories {
     return $self->{_result}->categorycodes( $params );
 }
 
+=head3 update_categories
+
+TODO: Ask the author to add a proper description
+
+=cut
+
 sub update_categories {
     my ( $self, $categories ) = @_;
     $self->_result->delete_related( 'branchrelations' );
     $self->add_to_categories( $categories );
 }
 
+=head3 add_to_categories
+
+TODO: Ask the author to add a proper description
+
+=cut
+
 sub add_to_categories {
     my ( $self, $categories ) = @_;
     for my $category ( @$categories ) {
@@ -54,11 +73,54 @@ sub add_to_categories {
     }
 }
 
-=head3 type
+=head3 stockrotationstages
+
+  my $stages = Koha::Library->stockrotationstages;
+
+Returns the stockrotation stages associated with this Library.
+
+=cut
+
+sub stockrotationstages {
+    my ( $self ) = @_;
+    my $rs = $self->_result->stockrotationstages;
+    return Koha::StockRotationStages->_new_from_dbic( $rs );
+}
+
+=head3 get_effective_marcorgcode
+
+    my $marcorgcode = Koha::Libraries->find( $library_id )->get_effective_marcorgcode();
+
+Returns the effective MARC organization code of the library. It falls back to the value
+from the I<MARCOrgCode> syspref if undefined for the library.
+
+=cut
+
+sub get_effective_marcorgcode {
+    my ( $self )  = @_;
+
+    return $self->marcorgcode || C4::Context->preference("MARCOrgCode");
+}
+
+=head3 library_groups
+
+Return the Library groups of this library
+
+=cut
+
+sub library_groups {
+    my ( $self ) = @_;
+    my $rs = $self->_result->library_groups;
+    return Koha::Library::Groups->_new_from_dbic( $rs );
+}
+
+=head2 Internal methods
+
+=head3 _type
 
 =cut
 
-sub type {
+sub _type {
     return 'Branch';
 }