From 4bbe74d70cd718612872c7fa79cbe0e9f18b7c56 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 14 Oct 2016 17:40:41 +0200 Subject: [PATCH] Bug 18606: Get rid of GetCollection --- C4/RotatingCollections.pm | 32 ------------------------------ rotating_collections/addItems.pl | 15 ++++++++------ rotating_collections/editCollections.pl | 8 ++++---- rotating_collections/transferCollection.pl | 14 +++++++------ 4 files changed, 21 insertions(+), 48 deletions(-) diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index c142d34..484c044 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -53,7 +53,6 @@ BEGIN { GetItemsInCollection - GetCollection GetCollections AddItemToCollection @@ -240,37 +239,6 @@ sub GetItemsInCollection { return \@results; } -=head2 GetCollection - - ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId ); - -Returns information about a collection - - Input: - $colId: Id of the collection - Output: - $colId, $colTitle, $colDesc, $colBranchcode - -=cut - -sub GetCollection { - my ($colId) = @_; - - my $dbh = C4::Context->dbh; - - my ( $sth, @results ); - $sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); - $sth->execute($colId) or return 0; - - my $row = $sth->fetchrow_hashref; - - return ( - $$row{'colId'}, $$row{'colTitle'}, - $$row{'colDesc'}, $$row{'colBranchcode'} - ); - -} - =head2 AddItemToCollection ( $success, $errorcode, $errormessage ) = AddItemToCollection( $colId, $itemnumber ); diff --git a/rotating_collections/addItems.pl b/rotating_collections/addItems.pl index cd24d50..1a3f358 100755 --- a/rotating_collections/addItems.pl +++ b/rotating_collections/addItems.pl @@ -24,6 +24,8 @@ use C4::Context; use C4::RotatingCollections; use C4::Items; +use Koha::RotatingCollections; + use CGI qw ( -utf8 ); my $query = new CGI; @@ -87,18 +89,19 @@ if ( $query->param('action') eq 'addItem' ) { } } -my ( $colId, $colTitle, $colDescription, $colBranchcode ) = - GetCollection( $query->param('colId') ); +my $colId = $query->param('colId'); +my $collection = Koha::RotatingCollections->find($colId); + my $collectionItems = GetItemsInCollection($colId); if ($collectionItems) { $template->param( collectionItemsLoop => $collectionItems ); } $template->param( - colId => $colId, - colTitle => $colTitle, - colDescription => $colDescription, - colBranchcode => $colBranchcode, + colId => $collection->colId, + colTitle => $collection->colTitle, + colDescription => $collection->colDesc, + colBranchcode => $collection->colBranchcode, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl index 3b0e854..bd4b917 100755 --- a/rotating_collections/editCollections.pl +++ b/rotating_collections/editCollections.pl @@ -77,13 +77,13 @@ if ( $action eq 'create' ) { ## Edit a club or service: grab data, put in form. elsif ( $action eq 'edit' ) { - my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $query->param('colId') ); + my $collection = Koha::RotatingCollections->find($query->param('colId')); $template->param( previousActionEdit => 1, - editColId => $colId, - editColTitle => $colTitle, - editColDescription => $colDesc, + editColId => $collection->{colId}, + editColTitle => $collection->{colTitle}, + editColDescription => $collection->{colDesc}, ); } diff --git a/rotating_collections/transferCollection.pl b/rotating_collections/transferCollection.pl index 49b09b3..8c48ed9 100755 --- a/rotating_collections/transferCollection.pl +++ b/rotating_collections/transferCollection.pl @@ -23,6 +23,8 @@ use C4::Auth; use C4::Context; use C4::RotatingCollections; +use Koha::RotatingCollections; + use CGI qw ( -utf8 ); my $query = new CGI; @@ -60,13 +62,13 @@ if ($toBranch) { } ## Get data about collection -my ( $colTitle, $colDesc, $colBranchcode ); -( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId); +my $collection = Koha::RotatingCollections->find($colId); + $template->param( - colId => $colId, - colTitle => $colTitle, - colDesc => $colDesc, - colBranchcode => $colBranchcode, + colId => $collection->colId, + colTitle => $collection->colTitle, + colDesc => $collection->colDesc, + colBranchcode => $collection->colBranchcode, ); output_html_with_http_headers $query, $cookie, $template->output; -- 2.1.4