Bug 33059: Fix capitalizatoin of AV sample category descriptions
[koha-ffzg.git] / serials / routing.pl
index af23b6c..2e3122d 100755 (executable)
@@ -25,23 +25,19 @@ printed out
 
 =cut
 
-use strict;
-use warnings;
+use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Koha;
-use C4::Auth;
-use C4::Output;
-use C4::Acquisition;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_and_exit output_html_with_http_headers );
 use C4::Context;
 
-use C4::Members;
-use C4::Serials;
+use C4::Serials qw( GetSubscription delroutingmember addroutingmember getroutinglist GetSerials GetLatestSerials check_routing );
 use Koha::Patrons;
 
 use URI::Escape;
 
-my $query = new CGI;
+my $query = CGI->new;
 my $subscriptionid = $query->param('subscriptionid');
 my $serialseq = $query->param('serialseq');
 my $routingid = $query->param('routingid');
@@ -52,6 +48,20 @@ my $date_selected = $query->param('date_selected');
 $date_selected ||= q{};
 my $dbh = C4::Context->dbh;
 
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => 'serials/routing.tt',
+        query           => $query,
+        type            => 'intranet',
+        flagsrequired   => { serials => 'routing' },
+    }
+);
+
+my $subs = GetSubscription($subscriptionid);
+
+output_and_exit( $query, $cookie, $template, 'unknown_subscription')
+    unless $subs;
+
 if($op eq 'delete'){
     delroutingmember($routingid,$subscriptionid);
 }
@@ -67,7 +77,7 @@ if($op eq 'save'){
 }
 
 my @routinglist = getroutinglist($subscriptionid);
-my $subs = GetSubscription($subscriptionid);
+
 my ($count,@serials) = GetSerials($subscriptionid);
 my $serialdates = GetLatestSerials($subscriptionid,$count);
 
@@ -85,15 +95,6 @@ foreach my $dateseq (@{$serialdates}) {
     push @{$dates}, $d;
 }
 
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => 'serials/routing.tt',
-                               query => $query,
-                               type => 'intranet',
-                               authnotrequired => 0,
-                               flagsrequired => {serials => 'routing'},
-                               debug => 1,
-                               });
-
 my $member_loop = [];
 for my $routing ( @routinglist ) {
     my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed;