Bug 14272: (follow-up) Show single display of 'all' news
[koha_ffzg] / catalogue / imageviewer.pl
index aa73e9d..009b82e 100755 (executable)
@@ -17,8 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
 use C4::Auth;
@@ -30,6 +29,7 @@ use C4::Search;
 use C4::Acquisition qw(GetOrdersByBiblionumber);
 
 use Koha::Biblios;
+use Koha::Patrons;
 
 my $query = new CGI;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@@ -45,8 +45,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
 my $imagenumber = $query->param('imagenumber');
 my $biblio = Koha::Biblios->find( $biblionumber );
-my $itemcount = $biblio->items->count;;
-
+my $itemcount = $biblio ? $biblio->items->count : 0;
 my @items = GetItemsInfo($biblionumber);
 
 my $norequests = 1;
@@ -59,13 +58,12 @@ foreach my $item (@items) {
 }
 
 if ( $query->cookie("holdfor") ) {
-    my $holdfor_patron =
-      GetMember( 'borrowernumber' => $query->cookie("holdfor") );
+    my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
     $template->param(
         holdfor            => $query->cookie("holdfor"),
-        holdfor_surname    => $holdfor_patron->{'surname'},
-        holdfor_firstname  => $holdfor_patron->{'firstname'},
-        holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
+        holdfor_surname    => $holdfor_patron->surname,
+        holdfor_firstname  => $holdfor_patron->firstname,
+        holdfor_cardnumber => $holdfor_patron->cardnumber,
     );
 }
 
@@ -109,8 +107,7 @@ $template->param (countorders => $count_orders_using_biblio);
 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
 $template->param (countdeletedorders => $count_deletedorders_using_biblio);
 
-$biblio = Koha::Biblios->find( $biblionumber );
-my $holds = $biblio->holds;
-$template->param( holdcount => $holds->count );
+my $hold_count = $biblio ? $biblio->holds->count : 0;
+$template->param( holdcount => $hold_count );
 
 output_html_with_http_headers $query, $cookie, $template->output;