- next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in good format.
- if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
- Date_to_Days(split "-",$expirationdate) > Date_to_Days(split "-",$today) ) {
- push @subscriptions_loop,$subscription;
+
+ next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
+
+ next if $subscription->{closed};
+ if ( !C4::Context->preference("IndependentBranches")
+ or C4::Context->IsSuperLibrarian()
+ or ( ref $flags->{serials} and $flags->{serials}->{superserials} )
+ or ( !ref $flags->{serials} and $flags->{serials} == 1 ) )
+ {
+ $subscription->{cannotedit} = 0;
+ }
+ next if $subscription->{cannotedit};
+
+ my $expirationdate_dt = dt_from_string( $expirationdate, 'iso' );
+ my $today_dt = dt_from_string();
+ if ( DateTime->compare( $date, $expirationdate_dt ) == 1
+ && ( $showhistoricexpired || DateTime->compare( $expirationdate_dt, $today_dt ) == 1 )
+ && ( !$branch || ( $subscription->{'branchcode'} eq $branch ) ) ) {
+ push @subscriptions_loop, $subscription;