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

(-)a/C4/Serials.pm (-8 / +9 lines)
Lines 74-80 BEGIN { Link Here
74
74
75
      &GetNextSeq &GetSeq &NewIssue           &GetSerials
75
      &GetNextSeq &GetSeq &NewIssue           &GetSerials
76
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
76
      &GetLatestSerials   &ModSerialStatus    &GetNextDate       &GetSerials2
77
      &ReNewSubscription  &GetLateOrMissingIssues
77
      &getsublength &ReNewSubscription  &GetLateOrMissingIssues
78
      &GetSerialInformation                   &AddItem2Serial
78
      &GetSerialInformation                   &AddItem2Serial
79
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
79
      &PrepareSerialsData &GetNextExpected    &ModNextExpected
80
      &GetPreviousSerialid
80
      &GetPreviousSerialid
Lines 1483-1502 sub NewSubscription { Link Here
1483
    return $subscriptionid;
1483
    return $subscriptionid;
1484
}
1484
}
1485
1485
1486
=head2 _get_sub_length
1486
=head2 getsublength
1487
my ($numberlength, $weeklength, $monthlength) = _get_sub_length( $subtype, $sublength );
1488
1487
1489
this function calculates the subscription length.
1488
my ($numberlength, $weeklength, $monthlength) = getsublength( $subtype, $sublength );
1489
1490
This function calculates the subscription length.
1490
1491
1491
=cut
1492
=cut
1492
1493
1493
sub _get_sub_length {
1494
sub getsublength {
1494
    my ($type, $subtype, $length) = @_;
1495
    my ($subtype, $length) = @_;
1495
    return
1496
    return
1496
    (
1497
    (
1497
          $subtype eq 'issues' ? $length : 0,
1498
          $subtype eq 'issues' ? $length : 0,
1498
          $subtype eq 'weeks'   ? $length : 0,
1499
          $subtype eq 'weeks'  ? $length : 0,
1499
          $subtype eq 'months'  ? $length : 0,
1500
          $subtype eq 'months' ? $length : 0,
1500
    );
1501
    );
1501
}
1502
}
1502
1503
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-4 / +4 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-67 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 %]
(-)a/serials/subscription-add.pl (-2 / +2 lines)
Lines 320-326 sub redirect_add_subscription { Link Here
320
    my $subtype = $query->param('subtype');
320
    my $subtype = $query->param('subtype');
321
    my $sublength = $query->param('sublength');
321
    my $sublength = $query->param('sublength');
322
    my ( $numberlength, $weeklength, $monthlength )
322
    my ( $numberlength, $weeklength, $monthlength )
323
        = C4::Serials->_get_sub_length( $subtype, $sublength );
323
        = C4::Serials->getsublength( $subtype, $sublength );
324
    my $add1              = $query->param('add1');
324
    my $add1              = $query->param('add1');
325
    my $lastvalue1        = $query->param('lastvalue1');
325
    my $lastvalue1        = $query->param('lastvalue1');
326
    my $innerloop1        = $query->param('innerloop1');
326
    my $innerloop1        = $query->param('innerloop1');
Lines 433-439 sub redirect_mod_subscription { Link Here
433
433
434
    my $subtype = $query->param('subtype');
434
    my $subtype = $query->param('subtype');
435
    my $sublength = $query->param('sublength');
435
    my $sublength = $query->param('sublength');
436
    my ($numberlength, $weeklength, $monthlength) = C4::Serials->get_sub_length( $subtype, $sublength );
436
    my ($numberlength, $weeklength, $monthlength) = C4::Serials->getsublength( $subtype, $sublength );
437
    my $numberpattern = $query->param('numbering_pattern');
437
    my $numberpattern = $query->param('numbering_pattern');
438
    my $locale = $query->param('locale');
438
    my $locale = $query->param('locale');
439
    my $lastvalue1 = $query->param('lastvalue1');
439
    my $lastvalue1 = $query->param('lastvalue1');
(-)a/serials/subscription-renew.pl (-1 / +2 lines)
Lines 64-70 my @subscriptionids = $query->multi_param('subscriptionid'); Link Here
64
my $branchcode     = $query->param('branchcode');
64
my $branchcode     = $query->param('branchcode');
65
my $sublength = $query->param('sublength');
65
my $sublength = $query->param('sublength');
66
my $subtype = $query->param('subtype');
66
my $subtype = $query->param('subtype');
67
my ($numberlength, $weeklength, $monthlength) = C4::Serials->get_sub_length( $subtype, $sublength );
67
my ($numberlength, $weeklength, $monthlength) = C4::Serials->getsublength( $subtype, $sublength );
68
68
69
my $done = 0;    # for after form has been submitted
69
my $done = 0;    # for after form has been submitted
70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 134-139 my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); Link Here
134
$template->param(
134
$template->param(
135
    op => $op,
135
    op => $op,
136
    libraries      => $libraries,
136
    libraries      => $libraries,
137
    subtypes => [ qw( numberlength weeklength monthlength ) ],
137
);
138
);
138
139
139
output_html_with_http_headers $query, $cookie, $template->output;
140
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/Serials/ReNewSubscription.t (-2 / +16 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 93-98 ReNewSubscription( Link Here
93
        monthlength    => 12
94
        monthlength    => 12
94
    }
95
    }
95
);
96
);
97
98
# Calculate the subscription length for the renewal for issues, days and months
99
my ($numberlength, $weeklength, $monthlength) = getsublength('issues', 7);
100
is ( $numberlength, 7, "Sub length is 7 issues");
101
102
($numberlength, $weeklength, $monthlength) = getsublength('weeks', 7);
103
is ( $weeklength, 7, "Sub length is 7 weeks");
104
105
($numberlength, $weeklength, $monthlength) = getsublength('months', 7);
106
is ( $monthlength, 7, "Sub length is 7 months");
107
108
# Renew the subscription and check that enddate has not been set
109
110
ReNewSubscription($subscription->{subscriptionid},'',"2016-01-01",'','',12,'');
96
my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid});
111
my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid});
97
112
98
is ( $history->histenddate(), undef, 'subscription history not empty after renewal');
113
is ( $history->histenddate(), undef, 'subscription history not empty after renewal');
99
- 

Return to bug 7046