From 2afed5a897839b7c29c284478233fd18ac935481 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Tue, 16 Dec 2014 15:01:54 +0200 Subject: [PATCH] Bug 13471 - When editing a subscription, the "subscription length type" disregards the stored value, also make SLT translateable. This issue causes loss of data when the subscription length type (SLT) is other than issues. TO REPLICATE: We make an subscription with SLT of months = 12. Later make an arbitrary edit to the subscription, and miss out the fact that the SLT selection is set to issues. Save the changes. Serial subscription end date is set to 12 issues since the start date, instead of 12 months which it used to be. This causes a myriad of issues :=) AFTER THIS PATCH: SLT defaults to the value initially saved instead of always being issues. Now the selection can be translated! HOTFIX 1: Added elements to showSubscriptionLengthType.inc so the translation tool can catch them. --- .../serials/showSubscriptionLengthType.inc | 8 ++++++++ .../prog/en/modules/serials/subscription-add.tt | 2 +- serials/subscription-add.pl | 15 +++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials/showSubscriptionLengthType.inc new file mode 100644 index 0000000..a6795cd --- /dev/null +++ b/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 %] \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index e69649c..45f3c98 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -658,7 +658,7 @@ $(document).ready(function() { [% ELSE %] [% END %] diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index b17fc60..22819df 100755 --- a/serials/subscription-add.pl +++ b/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); -- 1.7.9.5