From 194e1422347c5bb33eba017e073ba689572d082c Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 27 Nov 2017 15:31:35 +1300 Subject: [PATCH] Bug 7046 - Implemented dropdown sub length element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch applies and functions as expected in line with test plan. Signed-off-by: Dilan Johnpullé --- C4/Serials.pm | 19 +++++++++++- .../prog/en/modules/serials/subscription-renew.tt | 35 ++++++++++++++++++++-- serials/subscription-add.pl | 14 ++------- serials/subscription-renew.pl | 9 ++++-- 4 files changed, 59 insertions(+), 18 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 45bae8c..0035f6d 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1495,6 +1495,24 @@ sub NewSubscription { return $subscriptionid; } +=head2 _get_sub_length +my ($numberlength, $weeklength, $monthlength) = _get_sub_length( $subtype, $sublength ); + +this function calculates the subscription length. + +=cut + +sub _get_sub_length { + my ($type, $subtype, $length) = @_; + return + ( + $subtype eq 'issues' ? $length : 0, + $subtype eq 'weeks' ? $length : 0, + $subtype eq 'months' ? $length : 0, + ); +} + + =head2 ReNewSubscription ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) @@ -1529,7 +1547,6 @@ sub ReNewSubscription { } ); } - # renew subscription $query = qq| UPDATE subscription diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt index e7eb83d..96db6af 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt @@ -32,9 +32,38 @@
  • Subscription length: -
    1. -
    2. -
  • + + (enter amount in numerals) + +
  • diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 16d397b..50bc702 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -248,16 +248,6 @@ sub get_letter_loop { ]; } -sub _get_sub_length { - my ($type, $length) = @_; - return - ( - $type eq 'issues' ? $length : 0, - $type eq 'weeks' ? $length : 0, - $type eq 'months' ? $length : 0, - ); -} - sub _guess_enddate { my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; my ($year, $month, $day); @@ -301,7 +291,7 @@ sub redirect_add_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); my ( $numberlength, $weeklength, $monthlength ) - = _get_sub_length( $subtype, $sublength ); + = C4::Serials->_get_sub_length( $subtype, $sublength ); my $add1 = $query->param('add1'); my $lastvalue1 = $query->param('lastvalue1'); my $innerloop1 = $query->param('innerloop1'); @@ -379,7 +369,7 @@ sub redirect_mod_subscription { my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); my ($numberlength, $weeklength, $monthlength) - = _get_sub_length( $subtype, $sublength ); + = C4::Serials->_get_sub_length( $subtype, $sublength ); my $numberpattern = $query->param('numbering_pattern'); my $locale = $query->param('locale'); my $lastvalue1 = $query->param('lastvalue1'); diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index bbbc8e5..24efe00 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -62,6 +62,10 @@ my $dbh = C4::Context->dbh; my $mode = $query->param('mode') || q{}; my $op = $query->param('op') || 'display'; my $subscriptionid = $query->param('subscriptionid'); +my $sublength = $query->param('sublength'); +my $subtype = $query->param('subtype'); +my ($numberlength, $weeklength, $monthlength) = C4::Serials->_get_sub_length( $subtype, $sublength ); + my $done = 0; # for after form has been submitted my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -77,8 +81,8 @@ if ( $op eq "renew" ) { my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); ReNewSubscription( $subscriptionid, $loggedinuser, - $startdate, $query->param('numberlength'), - $query->param('weeklength'), $query->param('monthlength'), + $startdate, $numberlength, + $weeklength, $monthlength, $query->param('note') ); } @@ -93,6 +97,7 @@ my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 or output_pref( { dt => dt_from_string, dateonly => 1 } ); $template->param( + subtypes => [ qw( numberlength weeklength monthlength ) ], startdate => $newstartdate, numberlength => $subscription->{numberlength}, weeklength => $subscription->{weeklength}, -- 2.1.4