+$$subs{enddate} ||= GetExpirationDate($subscriptionid);
+
+if ($op eq 'del') {
+ if ($$subs{'cannotedit'}){
+ carp "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
+ print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
+ exit;
+ }
+
+ # Asking for confirmation if the subscription has not strictly expired yet or if it has linked issues
+ my $strictlyexpired = HasSubscriptionStrictlyExpired($subscriptionid);
+ my $linkedissues = CountIssues($subscriptionid);
+ my $countitems = HasItems($subscriptionid);
+ if ($strictlyexpired == 0 || $linkedissues > 0 || $countitems>0) {
+ $template->param(NEEDSCONFIRMATION => 1);
+ if ($strictlyexpired == 0) { $template->param("NOTEXPIRED" => 1); }
+ if ($linkedissues > 0) { $template->param("LINKEDISSUES" => 1); }
+ if ($countitems > 0) { $template->param("LINKEDITEMS" => 1); }
+ } else {
+ $issueconfirmed = "1";
+ }
+ # If it's ok to delete the subscription, we do so
+ if ($issueconfirmed eq "1") {
+ &DelSubscription($subscriptionid);
+ print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=serials-home.pl\"></html>";
+ exit;
+ }
+}
+my $hasRouting = check_routing($subscriptionid);
+