Bug 17792: Add opac_editable and opac_display methods
[koha.git] / circ / returns.pl
index b91778a..6e27645 100755 (executable)
@@ -50,11 +50,13 @@ use C4::RotatingCollections;
 use Koha::AuthorisedValues;
 use Koha::DateUtils;
 use Koha::Calendar;
+use Koha::Checkouts;
+use Koha::BiblioFrameworks;
 
 my $query = new CGI;
 
 #getting the template
-my ( $template, $librarian, $cookie ) = get_template_and_user(
+my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
     {
         template_name   => "circ/returns.tt",
         query           => $query,
@@ -323,9 +325,11 @@ if ($barcode) {
         push( @inputloop, \%input );
 
         if ( C4::Context->preference("FineNotifyAtCheckin") ) {
-            my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrower->{'borrowernumber'} );
-            if ($fines && $fines > 0) {
-                $template->param( fines => sprintf("%.2f",$fines) );
+            my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
+            my $balance = $patron->account->balance;
+
+            if ($balance > 0) {
+                $template->param( fines => sprintf("%.2f", $balance) );
                 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
             }
         }
@@ -464,6 +468,7 @@ if ( $messages->{'ResFound'}) {
             borrowernumber => $reserve->{'borrowernumber'},
             itemnumber     => $reserve->{'itemnumber'},
             reservenotes   => $reserve->{'reservenotes'},
+            reserve_id     => $reserve->{reserve_id},
             bormessagepref => $holdmsgpreferences->{'transports'},
         );
     } # else { ; }  # error?
@@ -552,7 +557,7 @@ my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C
 my $count = 0;
 my @riloop;
 my $shelflocations =
-  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
+  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
 foreach ( sort { $a <=> $b } keys %returneditems ) {
     my %ri;
     if ( $count++ < $returned_counter ) {
@@ -578,6 +583,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
             $ri{bortitle}       = $b->{'title'};
             $ri{bornote}        = $b->{'borrowernotes'};
             $ri{borcategorycode}= $b->{'categorycode'};
+            $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
         }
         else {
             $ri{borrowernumber} = $riborrowernumber{$_};
@@ -643,5 +649,8 @@ if ( $itemnumber ) {
     }
 }
 
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
 # actually print the page!
 output_html_with_http_headers $query, $cookie, $template->output;