From 0ec4f4dfebfb82dff307d7a939c8d7800a719c56 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 15 May 2017 11:42:43 +0000 Subject: [PATCH] Bug 18606: Get rid of GetItemsInCollection --- C4/RotatingCollections.pm | 51 ---------------------- Koha/RotatingCollection.pm | 19 ++++++++ .../en/includes/rotating-collections-toolbar.inc | 8 ++-- .../en/modules/rotating_collections/addItems.tt | 24 +++++----- rotating_collections/addItems.pl | 10 +---- 5 files changed, 36 insertions(+), 76 deletions(-) diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index 66a64c4..dafc1dc 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -48,8 +48,6 @@ BEGIN { require Exporter; @ISA = qw( Exporter ); @EXPORT = qw( - GetItemsInCollection - AddItemToCollection RemoveItemFromCollection TransferCollection @@ -58,55 +56,6 @@ BEGIN { ); } -=head2 GetItemsInCollection - - ( $results, $success, $errorcode, $errormessage ) = GetItemsInCollection( $colId ); - - Returns information about the items in the given collection - - Input: - $colId: The id of the collection - - Output: - $results: Reference to an array of associated arrays - $success: 1 if all database operations were successful, 0 otherwise - $errorCode: Code for reason of failure, good for translating errors in templates - $errorMessage: English description of error - -=cut - -sub GetItemsInCollection { - my ($colId) = @_; - - ## Parameter check - if ( !$colId ) { - return ( 0, 0, 1, "NO_ID" ); - } - - my $dbh = C4::Context->dbh; - - my $sth = $dbh->prepare( - "SELECT - biblio.title, - biblio.biblionumber, - items.itemcallnumber, - items.barcode - FROM collections, collections_tracking, items, biblio - WHERE collections.colId = collections_tracking.colId - AND collections_tracking.itemnumber = items.itemnumber - AND items.biblionumber = biblio.biblionumber - AND collections.colId = ? ORDER BY biblio.title" - ); - $sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() ); - - my @results; - while ( my $row = $sth->fetchrow_hashref ) { - push( @results, $row ); - } - - return \@results; -} - =head2 AddItemToCollection ( $success, $errorcode, $errormessage ) = AddItemToCollection( $colId, $itemnumber ); diff --git a/Koha/RotatingCollection.pm b/Koha/RotatingCollection.pm index c8857b2..ba90192 100644 --- a/Koha/RotatingCollection.pm +++ b/Koha/RotatingCollection.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Items; use base qw(Koha::Object); @@ -35,6 +36,24 @@ Koha::RotatingCollection - Koha Rotating collection Object class =cut +=head3 items + +=cut + +sub items { + my ( $self ) = @_; + my $items = Koha::Items->search( + { + 'collections_trackings.colId' => $self->colId + }, + { + join => [ 'collections_trackings' ] + } + ); + + return $items; +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc index 9dd3e7a..938ec9b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc @@ -17,15 +17,15 @@ New collection - [% IF ( colId ) %] + [% IF ( collection.colId ) %]
- Transfer + Transfer
- Edit + Edit
- Delete + Delete
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt index 43d4a8b..1cfc944 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt @@ -1,5 +1,5 @@ [% INCLUDE 'doc-head-open.inc' %] -Koha › Tools › Rotating collections › Collection [% colTitle %] ’ Add or remove items +Koha › Tools › Rotating collections › Collection [% collection.colTitle %] ’ Add or remove items [% INCLUDE 'doc-head-close.inc' %]