View | Details | Raw Unified | Return to bug 7046
Collapse All | Expand All

(-)a/C4/Serials.pm (-8 / +9 lines)
Lines 73-79 BEGIN { Link Here
73
73
74
      &GetNextSeq &GetSeq &NewIssue           &GetSerials
74
      &GetNextSeq &GetSeq &NewIssue           &GetSerials
75
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
75
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
76
      &ReNewSubscription  &GetLateOrMissingIssues
76
      &getsublength &ReNewSubscription  &GetLateOrMissingIssues
77
      &GetSerialInformation                   &AddItem2Serial
77
      &GetSerialInformation                   &AddItem2Serial
78
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
78
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
79
      &GetPreviousSerialid
79
      &GetPreviousSerialid
Lines 1453-1472 sub NewSubscription { Link Here
1453
    return $subscriptionid;
1453
    return $subscriptionid;
1454
}
1454
}
1455
1455
1456
=head2 _get_sub_length
1456
=head2 getsublength
1457
my ($numberlength, $weeklength, $monthlength) = _get_sub_length( $subtype, $sublength );
1458
1457
1459
this function calculates the subscription length.
1458
my ($numberlength, $weeklength, $monthlength) = getsublength( $subtype, $sublength );
1459
1460
This function calculates the subscription length.
1460
1461
1461
=cut
1462
=cut
1462
1463
1463
sub _get_sub_length {
1464
sub getsublength {
1464
    my ($type, $subtype, $length) = @_;
1465
    my ($subtype, $length) = @_;
1465
    return
1466
    return
1466
    (
1467
    (
1467
          $subtype eq 'issues' ? $length : 0,
1468
          $subtype eq 'issues' ? $length : 0,
1468
          $subtype eq 'weeks'   ? $length : 0,
1469
          $subtype eq 'weeks'  ? $length : 0,
1469
          $subtype eq 'months'  ? $length : 0,
1470
          $subtype eq 'months' ? $length : 0,
1470
    );
1471
    );
1471
}
1472
}
1472
1473
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-5 / +5 lines)
Lines 35-43 Link Here
35
                <input type="text" size="10" id="startdate" name="startdate" value="[% startdate | html %]" class="datepicker"/>
35
                <input type="text" size="10" id="startdate" name="startdate" value="[% startdate | html %]" class="datepicker"/>
36
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
36
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
37
            </li>
37
            </li>
38
		<li><fieldset>
38
    <li><fieldset>
39
		<legend>Subscription length:</legend>
39
    <legend>Subscription length:</legend>
40
		<select name="subtype" id="subtype">
40
    <select name="subtype" id="subtype">
41
        [% FOREACH st IN subtypes %]
41
        [% FOREACH st IN subtypes %]
42
            [% SWITCH st %]
42
            [% SWITCH st %]
43
                [% CASE 'numberlength'%]
43
                [% CASE 'numberlength'%]
Lines 61-72 Link Here
61
                        <option value="months">
61
                        <option value="months">
62
                    [% END %]
62
                    [% END %]
63
                    months
63
                    months
64
                [% CASE %][% st %]
64
                [% CASE %][% st | html %]
65
            [% END %]
65
            [% END %]
66
            </option>
66
            </option>
67
        [% END %]
67
        [% END %]
68
    </select>
68
    </select>
69
    <input type="text" name="sublength" id="sublength" value="[% sublength %]" size="3" />(enter amount in numerals)
69
    <input type="text" name="sublength" id="sublength" value="[% sublength | html %]" size="3" />(enter amount in numerals)
70
    <input type="hidden" name="issuelengthcount">
70
    <input type="hidden" name="issuelengthcount">
71
    </li>
71
    </li>
72
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
72
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
(-)a/serials/subscription-add.pl (-2 / +2 lines)
Lines 293-299 sub redirect_add_subscription { Link Here
293
    my $subtype = $query->param('subtype');
293
    my $subtype = $query->param('subtype');
294
    my $sublength = $query->param('sublength');
294
    my $sublength = $query->param('sublength');
295
    my ( $numberlength, $weeklength, $monthlength )
295
    my ( $numberlength, $weeklength, $monthlength )
296
        = C4::Serials->_get_sub_length( $subtype, $sublength );
296
        = C4::Serials->getsublength( $subtype, $sublength );
297
    my $add1              = $query->param('add1');
297
    my $add1              = $query->param('add1');
298
    my $lastvalue1        = $query->param('lastvalue1');
298
    my $lastvalue1        = $query->param('lastvalue1');
299
    my $innerloop1        = $query->param('innerloop1');
299
    my $innerloop1        = $query->param('innerloop1');
Lines 371-377 sub redirect_mod_subscription { Link Here
371
    my $subtype = $query->param('subtype');
371
    my $subtype = $query->param('subtype');
372
    my $sublength = $query->param('sublength');
372
    my $sublength = $query->param('sublength');
373
    my ($numberlength, $weeklength, $monthlength)
373
    my ($numberlength, $weeklength, $monthlength)
374
        = C4::Serials->_get_sub_length( $subtype, $sublength );
374
        = C4::Serials->getsublength( $subtype, $sublength );
375
    my $numberpattern = $query->param('numbering_pattern');
375
    my $numberpattern = $query->param('numbering_pattern');
376
    my $locale = $query->param('locale');
376
    my $locale = $query->param('locale');
377
    my $lastvalue1 = $query->param('lastvalue1');
377
    my $lastvalue1 = $query->param('lastvalue1');
(-)a/serials/subscription-renew.pl (-1 / +2 lines)
Lines 63-69 my $op = $query->param('op') || 'display'; Link Here
63
my @subscriptionids = $query->multi_param('subscriptionid');
63
my @subscriptionids = $query->multi_param('subscriptionid');
64
my $sublength = $query->param('sublength');
64
my $sublength = $query->param('sublength');
65
my $subtype = $query->param('subtype');
65
my $subtype = $query->param('subtype');
66
my ($numberlength, $weeklength, $monthlength) = C4::Serials->_get_sub_length( $subtype, $sublength );
66
my ($numberlength, $weeklength, $monthlength) = C4::Serials::getsublength( $subtype, $sublength );
67
67
68
my $done = 0;    # for after form has been submitted
68
my $done = 0;    # for after form has been submitted
69
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 119-124 if ( $op eq "renew" ) { Link Here
119
119
120
$template->param(
120
$template->param(
121
    op => $op,
121
    op => $op,
122
    subtypes => [ qw( numberlength weeklength monthlength ) ],
122
);
123
);
123
124
124
output_html_with_http_headers $query, $cookie, $template->output;
125
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/Serials/ReNewSubscription.t (-2 / +13 lines)
Lines 3-8 Link Here
3
# This script includes tests for ReNewSubscription
3
# This script includes tests for ReNewSubscription
4
4
5
# Copyright 2015 BibLibre, Paul Poulain
5
# Copyright 2015 BibLibre, Paul Poulain
6
# Copyright 2018 Catalyst IT, Alex Buckley
6
#
7
#
7
# This file is part of Koha.
8
# This file is part of Koha.
8
#
9
#
Lines 21-27 Link Here
21
22
22
use Modern::Perl;
23
use Modern::Perl;
23
24
24
use Test::More tests => 1;
25
use Test::More tests => 4;
25
use Test::MockModule;
26
use Test::MockModule;
26
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
27
use t::lib::Mocks;
28
use t::lib::Mocks;
Lines 83-89 my $subscriptionhistory = $builder->build({ Link Here
83
84
84
# Actual testing starts here!
85
# Actual testing starts here!
85
86
87
# Calculate the subscription length for the renewal for issues, days and months
88
my ($numberlength, $weeklength, $monthlength) = getsublength('issues', 7);
89
is ( $numberlength, 7, "Sub length is 7 issues");
90
91
($numberlength, $weeklength, $monthlength) = getsublength('weeks', 7);
92
is ( $weeklength, 7, "Sub length is 7 weeks");
93
94
($numberlength, $weeklength, $monthlength) = getsublength('months', 7);
95
is ( $monthlength, 7, "Sub length is 7 months");
96
86
# Renew the subscription and check that enddate has not been set
97
# Renew the subscription and check that enddate has not been set
98
87
ReNewSubscription($subscription->{subscriptionid},'',"2016-01-01",'','',12,'');
99
ReNewSubscription($subscription->{subscriptionid},'',"2016-01-01",'','',12,'');
88
my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid});
100
my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid});
89
101
90
- 

Return to bug 7046