ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / opac / opac-serial-issues.pl
index fad6127..b94935f 100755 (executable)
@@ -18,8 +18,7 @@
 # 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;
@@ -29,7 +28,6 @@ use C4::Letters;
 use C4::Output;
 use C4::Context;
 
-
 my $query      = new CGI;
 my $op         = $query->param('op');
 my $dbh        = C4::Context->dbh;
@@ -63,9 +61,9 @@ if ( $selectview eq "full" ) {
     # now, check is there is an alert subscription for one of the subscriptions
     if ($loggedinuser) {
         foreach (@$subscriptions) {
-            if (getalert($loggedinuser,'issue',$_->{subscriptionid})) {
-                $_->{hasalert} = 1;
-            }
+            my $subscription = Koha::Subscriptions->find( $_->{subscriptionid} );
+            my $subscriber = $subscription->subscribers->find( $loggedinuser );
+            $_->{hasalert} = 1 if $subscriber;
         }
     }
 
@@ -73,12 +71,11 @@ if ( $selectview eq "full" ) {
     my $yearmin = $subscriptions->[0]->{year};
     my $yearmax = $subscriptions->[ -1 ]->{year};
 
-
     # replace CR by <br> in librarian note
     # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
 
     $template->param(
-        biblionumber   => $query->param('biblionumber'),
+        biblionumber   => scalar $query->param('biblionumber'),
         years          => $subscriptioninformation,
         yearmin        => $yearmin,
         yearmax        => $yearmax,
@@ -101,21 +98,23 @@ else {
 
     my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
     # now, check is there is an alert subscription for one of the subscriptions
-    if ($loggedinuser){
+    if ($loggedinuser) {
         foreach (@$subscriptions) {
-            my $subscription = getalert($loggedinuser,'issue',$_->{subscriptionid});
-            if (@$subscription[0]) {
-                $_->{hasalert} = 1;
-            }
+            my $subscription = Koha::Subscriptions->find( $_->{subscriptionid} );
+            my $subscriber = $subscription->subscribers->find( $loggedinuser );
+            $_->{hasalert} = 1 if $subscriber;
         }
     }
 
     # replace CR by <br> in librarian note
     # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
 
+    my $title   = $subscriptions->[0]->{bibliotitle};
+
     $template->param(
-        biblionumber      => $query->param('biblionumber'),
+        biblionumber      => scalar $query->param('biblionumber'),
         subscription_LOOP => $subscriptions,
+        bibliotitle        => $title,
     );
 }
 output_html_with_http_headers $query, $cookie, $template->output;