@@ -, +, @@ length type" disregards the stored value, also make SLT translateable. --- .../en/includes/serials/showSubscriptionLengthType.inc | 8 ++++++++ .../prog/en/modules/serials/subscription-add.tt | 2 +- .../en/modules/serials/subscription-numberpatterns.tt | 2 +- serials/showpredictionpattern.pl | 8 ++++---- serials/subscription-add.pl | 15 +++++++-------- serials/subscription-numberpatterns.pl | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc @@ -0,0 +1,8 @@ +[%# This template must receive a parameter stl_name, containing the name of the subscription length type, either 'monthlength', 'numberlength' or 'weeklength'.Eg. "\[% INCLUDE showSubscriptionLengthType stl_name=subt.name %\]" %] +[% IF (stl_name) == 'numberlength' %] +issues +[% ELSIF (stl_name) == 'weeklength' %] +weeks +[% ELSIF (stl_name) == 'monthlength' %] +months +[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -658,7 +658,7 @@ $(document).ready(function() { [% ELSE %] [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt @@ -218,7 +218,7 @@ function show_blocking_subs() { --- a/serials/showpredictionpattern.pl +++ a/serials/showpredictionpattern.pl @@ -149,11 +149,11 @@ while( $i < 1000 ) { # Check if we don't have exceed end date if($sublength){ - if($subtype eq "issues" && $i >= $sublength){ + if($subtype eq "numberlength" && $i >= $sublength){ last; - } elsif($subtype eq "weeks" && $date && Delta_Days( split(/-/, $date), Add_Delta_Days( split(/-/, $firstacquidate), 7*$sublength - 1 ) ) < 0) { + } elsif($subtype eq "weeklength" && $date && Delta_Days( split(/-/, $date), Add_Delta_Days( split(/-/, $firstacquidate), 7*$sublength - 1 ) ) < 0) { last; - } elsif($subtype eq "months" && $date && (Delta_Days( split(/-/, $date), Add_Delta_YM( split(/-/, $firstacquidate), 0, $sublength) ) - 1) < 0 ) { + } elsif($subtype eq "monthlength" && $date && (Delta_Days( split(/-/, $date), Add_Delta_YM( split(/-/, $firstacquidate), 0, $sublength) ) - 1) < 0 ) { last; } } @@ -186,7 +186,7 @@ if ( $frequency->{unit} and not $custompattern ) { } if ( ( $date && $enddate && $date ne $enddate ) - or ( $subtype eq 'issues' && $i < $sublength ) ) + or ( $subtype eq 'numberlength' && $i < $sublength ) ) { $template->param( not_consistent_end_date => 1 ); } --- a/serials/subscription-add.pl +++ a/serials/subscription-add.pl @@ -59,7 +59,7 @@ my ($template, $loggedinuser, $cookie) my $sub_on; -my @subscription_types = (qw(issues weeks months)); +my @subscription_types = (qw(numberlength weeklength monthlength)); #These are the same as the koha.subscription-columns my @sub_type_data; my $subs; @@ -92,7 +92,7 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ; $subs->{nextacquidate} = $nextexpected->{planneddate} if($op eq 'modify'); unless($op eq 'modsubscription') { - foreach my $length_unit (qw(numberlength weeklength monthlength)) { + foreach my $length_unit (@subscription_types) { if ($subs->{$length_unit}) { $sub_length=$subs->{$length_unit}; $sub_on=$length_unit; @@ -103,7 +103,6 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { $template->param( %{$subs} ); $template->param( $op => 1, - "subtype_$sub_on" => 1, sublength =>$sub_length, history => ($op eq 'modify'), firstacquiyear => substr($firstissuedate,0,4), @@ -250,9 +249,9 @@ sub _get_sub_length { my ($type, $length) = @_; return ( - $type eq 'issues' ? $length : 0, - $type eq 'weeks' ? $length : 0, - $type eq 'months' ? $length : 0, + $type eq 'numberlength' ? $length : 0, + $type eq 'weeklength' ? $length : 0, + $type eq 'monthlength' ? $length : 0, ); } @@ -323,7 +322,7 @@ sub redirect_add_subscription { my $enddate = format_date_in_iso( $query->param('enddate') ); my $firstacquidate = format_date_in_iso($query->param('firstacquidate')); if(!defined $enddate || $enddate eq '') { - if($subtype eq "issues") { + if($subtype eq "numberlength") { $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength); } else { $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); @@ -390,7 +389,7 @@ sub redirect_mod_subscription { # Guess end date if(!defined $enddate || $enddate eq '') { - if($subtype eq "issues") { + if($subtype eq "numberlength") { $enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); } else { $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); --- a/serials/subscription-numberpatterns.pl +++ a/serials/subscription-numberpatterns.pl @@ -104,7 +104,7 @@ if($op && ($op eq 'new' || $op eq 'modify')) { } my @frequencies = GetSubscriptionFrequencies(); my @subtypes; - push @subtypes, { value => $_ } for (qw/ issues weeks months /); + push @subtypes, { value => $_ } for (qw/ numberlength weeklength monthlength/); my $languages = [ map { { --