Added comments to ILS-DI code
[koha_fer] / opac / opac-user.pl
index 777c659..8247f96 100755 (executable)
@@ -66,14 +66,21 @@ $borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} );
 if ( $borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'} ) {
     $borr->{'flagged'} = 1;
 }
-# $make flagged available everywhere in the template
-my $patron_flagged = $borr->{'flagged'};
+
 if ( $borr->{'amountoutstanding'} > 5 ) {
     $borr->{'amountoverfive'} = 1;
 }
 if ( 5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
     $borr->{'amountoverzero'} = 1;
 }
+
+if ( $borr->{'amountoutstanding'} > C4::Context->preference( 'OPACFineNoRenewals' ) ) {
+    $borr->{'flagged'} = 1;
+    $template->param(
+        renewal_blocked_fines => sprintf( "%.02f", C4::Context->preference( 'OPACFineNoRenewals' ) ),
+    );
+}
+
 if ( $borr->{'amountoutstanding'} < 0 ) {
     $borr->{'amountlessthanzero'} = 1;
     $borr->{'amountoutstanding'} = -1 * ( $borr->{'amountoutstanding'} );
@@ -86,7 +93,7 @@ $bordat[0] = $borr;
 
 $template->param(   BORROWER_INFO  => \@bordat,
                     borrowernumber => $borrowernumber,
-                    patron_flagged => $patron_flagged,
+                    patron_flagged => $borr->{flagged},
                 );
 
 #get issued items ....
@@ -127,8 +134,9 @@ foreach my $issue ( @issue_list ) {
     # check if item is renewable
     my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
     ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
-
-    $issue->{'status'} = $status || C4::Context->preference("OpacRenewalAllowed");
+    $issue->{'status'} = $status && C4::Context->preference("OpacRenewalAllowed");
+    $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
+    $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';
 
     if ( $issue->{'overdue'} ) {
         push @overdues, $issue;
@@ -170,7 +178,7 @@ for my $branch_hash (sort keys %$branches ) {
         selected => $selected
       };
 }
-$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
+$template->param( branchloop => \@branch_loop );
 
 # now the reserved items....
 my @reserves  = GetReservesFromBorrowernumber( $borrowernumber );