-my $weekarrayjs='';
-my $count = 0;
-my ($year, $month, $day) = Today;
-my $firstday = Day_of_Year($year,$month,$day);
-my ($wkno,$yr) = Week_of_Year($year,$month,$day); # week starting monday
-my $weekno = $wkno;
-for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
- $count = $i;
- if($wkno > 52){$year++; $wkno=1;}
- if($count>365){$count=$i-365;}
- my ($y,$m,$d) = Add_Delta_Days($year,1,1, $count - 1);#Date_NthDayOfYear($year,$count);
- # padding Add_Delta_Days;
- my $output = sprintf("%04d-%02d-%02d",$y , $m, $d );
- $weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
- $wkno++;
+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";