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

(-)a/C4/Serials.pm (-1 / +18 lines)
Lines 1495-1500 sub NewSubscription { Link Here
1495
    return $subscriptionid;
1495
    return $subscriptionid;
1496
}
1496
}
1497
1497
1498
=head2 _get_sub_length
1499
my ($numberlength, $weeklength, $monthlength) = _get_sub_length( $subtype, $sublength );
1500
1501
this function calculates the subscription length.
1502
1503
=cut
1504
1505
sub _get_sub_length {
1506
    my ($type, $subtype, $length) = @_;
1507
    return
1508
    (
1509
          $subtype eq 'issues' ? $length : 0,
1510
          $subtype eq 'weeks'   ? $length : 0,
1511
          $subtype eq 'months'  ? $length : 0,
1512
    );
1513
}
1514
1515
1498
=head2 ReNewSubscription
1516
=head2 ReNewSubscription
1499
1517
1500
ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note)
1518
ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note)
Lines 1529-1535 sub ReNewSubscription { Link Here
1529
            }
1547
            }
1530
        );
1548
        );
1531
    }
1549
    }
1532
1533
    # renew subscription
1550
    # renew subscription
1534
    $query = qq|
1551
    $query = qq|
1535
        UPDATE subscription
1552
        UPDATE subscription
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-3 / +32 lines)
Lines 32-40 Link Here
32
            </li>
32
            </li>
33
		<li><fieldset>
33
		<li><fieldset>
34
		<legend>Subscription length:</legend>
34
		<legend>Subscription length:</legend>
35
		<ol><li><label for="numberlength">Number of num:</label><input type="text" id="numberlength" name="numberlength" value="[% numberlength %]" /></li>
35
		<select name="subtype" id="subtype">
36
		<li><label for="weeklength">Number of weeks: </label><input type="text" id="weeklength" name="weeklength" value="[% weeklength %]" /></li>
36
        [% FOREACH st IN subtypes %]
37
		<li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% monthlength %]" /></li></ol></fieldset></li>
37
            [% SWITCH st %]
38
                [% CASE 'numberlength'%]
39
                    [% IF st == subtype %]
40
                        <option value="issues" selected="selected">
41
                    [% ELSE %]
42
                        <option value="issues">
43
                    [% END %]
44
                    issues
45
                [% CASE 'weeklength' %]
46
                    [% IF st == subtype %]
47
                        <option value="weeks" selected="selected">
48
                    [% ELSE %]
49
                        <option value="weeks">
50
                    [% END %]
51
                    weeks
52
                [% CASE 'monthlength' %]
53
                    [% IF st == subtype %]
54
                        <option value="months" selected="selected">
55
                    [% ELSE %]
56
                        <option value="months">
57
                    [% END %]
58
                    months
59
                [% CASE %][% st %]
60
            [% END %]
61
            </option>
62
        [% END %]
63
    </select>
64
    <input type="text" name="sublength" id="sublength" value="[% sublength %]" size="3" />(enter amount in numerals)
65
    <input type="hidden" name="issuelengthcount">
66
    </li>
38
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
67
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
39
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
68
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
40
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
69
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
(-)a/serials/subscription-add.pl (-12 / +2 lines)
Lines 248-263 sub get_letter_loop { Link Here
248
    ];
248
    ];
249
}
249
}
250
250
251
sub _get_sub_length {
252
    my ($type, $length) = @_;
253
    return
254
        (
255
            $type eq 'issues' ? $length : 0,
256
            $type eq 'weeks'   ? $length : 0,
257
            $type eq 'months'  ? $length : 0,
258
        );
259
}
260
261
sub _guess_enddate {
251
sub _guess_enddate {
262
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
252
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
263
    my ($year, $month, $day);
253
    my ($year, $month, $day);
Lines 301-307 sub redirect_add_subscription { Link Here
301
    my $subtype = $query->param('subtype');
291
    my $subtype = $query->param('subtype');
302
    my $sublength = $query->param('sublength');
292
    my $sublength = $query->param('sublength');
303
    my ( $numberlength, $weeklength, $monthlength )
293
    my ( $numberlength, $weeklength, $monthlength )
304
        = _get_sub_length( $subtype, $sublength );
294
        = C4::Serials->_get_sub_length( $subtype, $sublength );
305
    my $add1              = $query->param('add1');
295
    my $add1              = $query->param('add1');
306
    my $lastvalue1        = $query->param('lastvalue1');
296
    my $lastvalue1        = $query->param('lastvalue1');
307
    my $innerloop1        = $query->param('innerloop1');
297
    my $innerloop1        = $query->param('innerloop1');
Lines 379-385 sub redirect_mod_subscription { Link Here
379
    my $subtype = $query->param('subtype');
369
    my $subtype = $query->param('subtype');
380
    my $sublength = $query->param('sublength');
370
    my $sublength = $query->param('sublength');
381
    my ($numberlength, $weeklength, $monthlength)
371
    my ($numberlength, $weeklength, $monthlength)
382
        = _get_sub_length( $subtype, $sublength );
372
        = C4::Serials->_get_sub_length( $subtype, $sublength );
383
    my $numberpattern = $query->param('numbering_pattern');
373
    my $numberpattern = $query->param('numbering_pattern');
384
    my $locale = $query->param('locale');
374
    my $locale = $query->param('locale');
385
    my $lastvalue1 = $query->param('lastvalue1');
375
    my $lastvalue1 = $query->param('lastvalue1');
(-)a/serials/subscription-renew.pl (-3 / +7 lines)
Lines 62-67 my $dbh = C4::Context->dbh; Link Here
62
my $mode           = $query->param('mode') || q{};
62
my $mode           = $query->param('mode') || q{};
63
my $op             = $query->param('op') || 'display';
63
my $op             = $query->param('op') || 'display';
64
my $subscriptionid = $query->param('subscriptionid');
64
my $subscriptionid = $query->param('subscriptionid');
65
my $sublength = $query->param('sublength');
66
my $subtype = $query->param('subtype');
67
my ($numberlength, $weeklength, $monthlength) = C4::Serials->_get_sub_length( $subtype, $sublength );
68
65
my $done = 0;    # for after form has been submitted
69
my $done = 0;    # for after form has been submitted
66
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
67
    {
71
    {
Lines 77-84 if ( $op eq "renew" ) { Link Here
77
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
81
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
78
    ReNewSubscription(
82
    ReNewSubscription(
79
        $subscriptionid, $loggedinuser,
83
        $subscriptionid, $loggedinuser,
80
        $startdate, $query->param('numberlength'),
84
        $startdate, $numberlength,
81
        $query->param('weeklength'), $query->param('monthlength'),
85
        $weeklength, $monthlength,
82
        $query->param('note')
86
        $query->param('note')
83
    );
87
    );
84
}
88
}
Lines 93-98 my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 Link Here
93
    or output_pref( { dt => dt_from_string, dateonly => 1 } );
97
    or output_pref( { dt => dt_from_string, dateonly => 1 } );
94
98
95
$template->param(
99
$template->param(
100
    subtypes       => [ qw( numberlength weeklength monthlength ) ],
96
    startdate      => $newstartdate,
101
    startdate      => $newstartdate,
97
    numberlength   => $subscription->{numberlength},
102
    numberlength   => $subscription->{numberlength},
98
    weeklength     => $subscription->{weeklength},
103
    weeklength     => $subscription->{weeklength},
99
- 

Return to bug 7046