Bug 11897: Stockrotation
[koha.git] / Koha / Library.pm
index 9e6d616..7877174 100644 (file)
@@ -24,6 +24,7 @@ use Carp;
 use C4::Context;
 
 use Koha::Database;
+use Koha::StockRotationStages;
 
 use base qw(Koha::Object);
 
@@ -41,6 +42,51 @@ TODO: Ask the author to add a proper description
 
 =cut
 
+sub get_categories {
+    my ( $self, $params ) = @_;
+    # TODO This should return Koha::LibraryCategories
+    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 ) {
+        $self->_result->add_to_categorycodes( $category->_result );
+    }
+}
+
+=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();