Bug 30237: Replace AutoEmailOpacUser with AutoEmailNewUser
[koha-ffzg.git] / opac / opac-user.pl
index e610cab..5bc84c5 100755 (executable)
@@ -46,6 +46,7 @@ use Koha::Patron::Messages;
 use Koha::Patron::Discharge;
 use Koha::Patrons;
 use Koha::Ratings;
+use Koha::Recalls;
 use Koha::Token;
 
 use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
@@ -306,6 +307,16 @@ if ( $pending_checkouts->count ) { # Useless test
                     $issue->{biblionumber} ? $my_summary_html =~ s/{BIBLIONUMBER}/$issue->{biblionumber}/g : $my_summary_html =~ s/{BIBLIONUMBER}//g;
                     $issue->{MySummaryHTML} = $my_summary_html;
                 }
+
+        if ( C4::Context->preference('UseRecalls') ) {
+            my $maybe_recalls = Koha::Recalls->search({ biblionumber => $issue->{biblionumber}, itemnumber => [ undef, $issue->{itemnumber} ], old => 0 });
+            while( my $recall = $maybe_recalls->next ) {
+                if ( $recall->checkout and $recall->checkout->issue_id == $issue->{issue_id} ) {
+                    $issue->{recall} = 1;
+                    last;
+                }
+            }
+        }
     }
 }
 my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
@@ -333,6 +344,11 @@ $template->param(
     showpriority   => $show_priority,
 );
 
+if ( C4::Context->preference('UseRecalls') ) {
+    my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber, old => 0 } );
+    $template->param( RECALLS => $recalls );
+}
+
 if (C4::Context->preference('BakerTaylorEnabled')) {
     $template->param(
         BakerTaylorEnabled  => 1,
@@ -370,7 +386,7 @@ if (   C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor'
 {
     my @relatives;
     # Filter out guarantees that don't want guarantor to see checkouts
-    foreach my $gr ( $patron->guarantee_relationships() ) {
+    foreach my $gr ( $patron->guarantee_relationships->as_list ) {
         my $g = $gr->guarantee;
         push( @relatives, $g ) if $g->privacy_guarantor_checkouts;
     }
@@ -382,7 +398,7 @@ if (   C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor')
 {
     my @relatives_with_fines;
     # Filter out guarantees that don't want guarantor to see checkouts
-    foreach my $gr ( $patron->guarantee_relationships() ) {
+    foreach my $gr ( $patron->guarantee_relationships->as_list ) {
         my $g = $gr->guarantee;
         push( @relatives_with_fines, $g ) if $g->privacy_guarantor_fines;
     }