Bug 23774: Server-side confirmation for hold pickup location in OPAC
[srvgit] / rotating_collections / addItems.pl
index cd24d50..4c79328 100755 (executable)
@@ -24,6 +24,8 @@ use C4::Context;
 use C4::RotatingCollections;
 use C4::Items;
 
+use Koha::Items;
+
 use CGI qw ( -utf8 );
 
 my $query = new CGI;
@@ -39,12 +41,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-if ( $query->param('action') eq 'addItem' ) {
+if ( defined $query->param('action') and
+     $query->param('action') eq 'addItem' ) {
     ## Add the given item to the collection
     my $colId      = $query->param('colId');
     my $barcode    = $query->param('barcode');
     my $removeItem = $query->param('removeItem');
-    my $itemnumber = GetItemnumberFromBarcode($barcode);
+    my $item       = Koha::Items->find({barcode => $barcode});
+    my $itemnumber = $item ? $item->itemnumber : undef;
 
     my ( $success, $errorCode, $errorMessage );
 
@@ -88,7 +92,7 @@ if ( $query->param('action') eq 'addItem' ) {
 }
 
 my ( $colId, $colTitle, $colDescription, $colBranchcode ) =
-  GetCollection( $query->param('colId') );
+  GetCollection( scalar $query->param('colId') );
 my $collectionItems = GetItemsInCollection($colId);
 if ($collectionItems) {
     $template->param( collectionItemsLoop => $collectionItems );