Bug 20305: Remove warnings from tools scripts
[koha.git] / tools / viewlog.pl
index 9af64d5..e9e9f42 100755 (executable)
@@ -70,28 +70,24 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 if ( $src eq 'circ' ) {
 
     # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
-    use C4::Members;
     use C4::Members::Attributes qw(GetBorrowerAttributes);
     my $borrowernumber = $object;
     my $patron = Koha::Patrons->find( $borrowernumber );
-    $template->param( picture => 1 ) if $patron->image;
-    my $data = $patron->unblessed;
-
+    unless ( $patron ) {
+        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+        exit;
+    }
     if ( C4::Context->preference('ExtendedPatronAttributes') ) {
-        my $attributes = GetBorrowerAttributes( $data->{'borrowernumber'} );
+        my $attributes = GetBorrowerAttributes( $borrowernumber );
         $template->param(
             ExtendedPatronAttributes => 1,
             extendedattributes       => $attributes
         );
     }
 
-    $template->param(%$data);
-
     $template->param(
-        menu           => 1,
-        borrowernumber => $borrowernumber,
-        categoryname   => $patron->category->description,
-        RoutingSerials => C4::Context->preference('RoutingSerials'),
+        patron      => $patron,
+        circulation => 1,
     );
 }
 
@@ -116,10 +112,6 @@ if ($do_it) {
         $result->{'biblionumber'}      = q{};
         $result->{'biblioitemnumber'}  = q{};
         $result->{'barcode'}           = q{};
-        $result->{'userfirstname'}     = q{};
-        $result->{'usersurname'}       = q{};
-        $result->{'borrowerfirstname'} = q{};
-        $result->{'borrowersurname'}   = q{};
 
         if ( substr( $result->{'info'}, 0, 4 ) eq 'item' || $result->{module} eq "CIRCULATION" ) {
 
@@ -138,8 +130,7 @@ if ($do_it) {
         if ( $result->{'user'} ) {
             my $patron = Koha::Patrons->find( $result->{'user'} );
             if ($patron) {
-                $result->{'userfirstname'} = $patron->firstname;
-                $result->{'usersurname'}   = $patron->surname;
+                $result->{librarian} = $patron;
             }
         }
 
@@ -148,8 +139,7 @@ if ($do_it) {
             if ( $result->{'object'} ) {
                 my $patron = Koha::Patrons->find( $result->{'object'} );
                 if ($patron) {
-                    $result->{'borrowerfirstname'} = $patron->firstname;
-                    $result->{'borrowersurname'}   = $patron->surname;
+                    $result->{patron} = $patron;
                 }
             }
         }