Bug 26265: (QA follow-up) Remove g option from regex, add few dirs
[koha-equinox.git] / opac / opac-serial-issues.pl
index 6a55a1d..cf095c1 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;
@@ -35,8 +34,6 @@ my $dbh        = C4::Context->dbh;
 my $selectview = $query->param('selectview');
 $selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
 
-my $sth;
-
 # my $id;
 my ( $template, $loggedinuser, $cookie );
 my $biblionumber = $query->param('biblionumber');
@@ -62,13 +59,9 @@ if ( $selectview eq "full" ) {
     # now, check is there is an alert subscription for one of the subscriptions
     if ($loggedinuser) {
         foreach (@$subscriptions) {
-            my $sub = getalert($loggedinuser,'issue_ser',$_->{subscriptionid});
-            if (!defined $sub) {
-                $sub = getalert($loggedinuser,'issue_det',$_->{subscriptionid});
-            }
-            if ($sub) {
-                $_->{hasalert} = 1;
-            }
+            my $subscription = Koha::Subscriptions->find( $_->{subscriptionid} );
+            my $subscriber = $subscription->subscribers->find( $loggedinuser );
+            $_->{hasalert} = 1 if $subscriber;
         }
     }
 
@@ -76,9 +69,6 @@ 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   => scalar $query->param('biblionumber'),
         years          => $subscriptioninformation,
@@ -103,21 +93,14 @@ 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_ser',$_->{subscriptionid});
-            if (!defined $subscription) {
-                $subscription = getalert($loggedinuser,'issue_det',$_->{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(