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

(-)a/C4/Serials.pm (+35 lines)
Lines 87-92 BEGIN { Link Here
87
      HasItems
87
      HasItems
88
      &GetSubscriptionsFromBorrower
88
      &GetSubscriptionsFromBorrower
89
      &subscriptionCurrentlyOnOrder
89
      &subscriptionCurrentlyOnOrder
90
      &GuessEnddate
90
91
91
    );
92
    );
92
}
93
}
Lines 2715-2720 sub findSerialsByStatus { Link Here
2715
    return @$serials;
2716
    return @$serials;
2716
}
2717
}
2717
2718
2719
=head2 GessEnddate
2720
2721
my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2722
2723
=cut
2724
2725
sub GuessEnddate {
2726
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
2727
    my ($year, $month, $day);
2728
    my $enddate;
2729
    if($numberlength != 0) {
2730
        my $frequency = GetSubscriptionFrequency($frequencyid);
2731
        if($frequency->{'unit'} eq 'day') {
2732
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2733
        } elsif($frequency->{'unit'} eq 'week') {
2734
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2735
        } elsif($frequency->{'unit'} eq 'month') {
2736
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2737
        } elsif($frequency->{'unit'} eq 'year') {
2738
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0);
2739
        }
2740
    } elsif($weeklength != 0) {
2741
        ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7);
2742
    } elsif($monthlength != 0) {
2743
        ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength);
2744
    }
2745
    if(defined $year) {
2746
        $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day);
2747
    } else {
2748
        undef $enddate;
2749
    }
2750
    return $enddate;
2751
}
2752
2718
1;
2753
1;
2719
__END__
2754
__END__
2720
2755
(-)a/Koha/Subscription.pm (+22 lines)
Lines 130-135 sub permanent_irregularities { Link Here
130
    return split(';', $self->permanent_irregularity);
130
    return split(';', $self->permanent_irregularity);
131
}
131
}
132
132
133
=head3 subtype
134
135
Return the length type (issues, weeks, months)
136
137
=cut
138
139
sub subtype {
140
    my ($self) = @_;
141
142
    if ($self->numberlength) {
143
        return 'issues';
144
    }
145
146
    if ($self->weeklength) {
147
        return 'weeks';
148
    }
149
150
    if ($self->monthlength) {
151
        return 'months';
152
    }
153
}
154
133
=head3 type
155
=head3 type
134
156
135
=cut
157
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+1 lines)
Lines 509-514 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
509
        var MSG_PUB_DATE_UNDEFINED = _("First publication date is not defined");
509
        var MSG_PUB_DATE_UNDEFINED = _("First publication date is not defined");
510
        var MSG_NEXT_ISSUE_UNDEFINED = _("Next issue publication date is not defined");
510
        var MSG_NEXT_ISSUE_UNDEFINED = _("Next issue publication date is not defined");
511
    </script>
511
    </script>
512
    [% Asset.js("js/subscription.js") %]
512
    [% Asset.js("js/subscription-add.js") %]
513
    [% Asset.js("js/subscription-add.js") %]
513
    [% Asset.js("js/showpredictionpattern.js") %]
514
    [% Asset.js("js/showpredictionpattern.js") %]
514
[% END %]
515
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (+39 lines)
Lines 1-3 Link Here
1
[% USE Asset %]
1
[% SET footerjs = 1 %]
2
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% IF subscription %]
4
[% IF subscription %]
Lines 26-31 Link Here
26
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
27
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
27
		<input type="hidden" name="op" value="renew" />
28
		<input type="hidden" name="op" value="renew" />
28
		<input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid %]" />
29
		<input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid %]" />
30
        <input type="hidden" id="frequency" value="[% subscription.periodicity %]" />
31
        <input type="hidden" id="acqui_date" value="[% subscription.firstacquidate %]" />
32
        <input type="hidden" id="nextacquidate" value="[% nextacquidate %]" />
33
34
        <input type="hidden" id="to" value="[% enddate %]" />
35
        <input type="hidden" id="subtype" value="[% subtype %]" />
36
        <input type="hidden" id="sublength" value="[% sublength %]" />
37
        <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod %]" />
38
        <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 %]" />
39
        <input type="hidden" id="lastvalue2" value="[% subscription.lastvalue2 %]" />
40
        <input type="hidden" id="lastvalue3" value="[% subscription.lastvalue3 %]" />
41
        <input type="hidden" id="add1" value="[% numberpattern.add1 %]" />
42
        <input type="hidden" id="add2" value="[% numberpattern.add2 %]" />
43
        <input type="hidden" id="add3" value="[% numberpattern.add3 %]" />
44
        <input type="hidden" id="every1" value="[% numberpattern.every1 %]" />
45
        <input type="hidden" id="every2" value="[% numberpattern.every2 %]" />
46
        <input type="hidden" id="every3" value="[% numberpattern.every3 %]" />
47
        <input type="hidden" id="innerloop1" value="[% subscription.innerloop1 %]" />
48
        <input type="hidden" id="innerloop2" value="[% subscription.innerloop2 %]" />
49
        <input type="hidden" id="innerloop3" value="[% subscription.innerloop3 %]" />
50
        <input type="hidden" id="setto1" value="[% numberpattern.setto1 %]" />
51
        <input type="hidden" id="setto2" value="[% numberpattern.setto2 %]" />
52
        <input type="hidden" id="setto3" value="[% numberpattern.setto3 %]" />
53
        <input type="hidden" id="numbering1" value="[% numberpattern.numbering1 %]" />
54
        <input type="hidden" id="numbering2" value="[% numberpattern.numbering2 %]" />
55
        <input type="hidden" id="numbering3" value="[% numberpattern.numbering3 %]" />
56
        <input type="hidden" id="whenmorethan1" value="[% numberpattern.whenmorethan1 %]" />
57
        <input type="hidden" id="whenmorethan2" value="[% numberpattern.whenmorethan2 %]" />
58
        <input type="hidden" id="whenmorethan3" value="[% numberpattern.whenmorethan3 %]" />
59
        <input type="hidden" id="locale" value="[% subscription.locale %]" />
29
		<fieldset class="rows"><legend>Subscription renewal for [% subscription.bibliotitle %]</legend>
60
		<fieldset class="rows"><legend>Subscription renewal for [% subscription.bibliotitle %]</legend>
30
        <ol>
61
        <ol>
31
            <li>
62
            <li>
Lines 40-53 Link Here
40
		<li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% subscription.monthlength %]" /></li></ol></fieldset></li>
71
		<li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% subscription.monthlength %]" /></li></ol></fieldset></li>
41
		<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>
42
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
73
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
74
        <li id="displayexample"></li>
43
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
75
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
76
44
</form>
77
</form>
45
[% END %]
78
[% END %]
46
79
47
[% MACRO jsinclude BLOCK %]
80
[% MACRO jsinclude BLOCK %]
48
    [% INCLUDE 'calendar.inc' %]
81
    [% INCLUDE 'calendar.inc' %]
49
    <script type="text/javascript">
82
    <script type="text/javascript">
83
        var subscriptionid = "[% subscription.subscriptionid %]";
84
        var irregularity = "[% subscription.irregularity %]";
85
        var more_than_one_serial = "[% more_than_one_serial %]";
50
        $(document).ready(function(){
86
        $(document).ready(function(){
87
            testPredictionPattern();
51
            $(".close").on("click", function(e){
88
            $(".close").on("click", function(e){
52
                e.preventDefault();
89
                e.preventDefault();
53
                window.opener.location.reload(false);
90
                window.opener.location.reload(false);
Lines 55-60 Link Here
55
            });
92
            });
56
        });
93
        });
57
    </script>
94
    </script>
95
    [% Asset.js("js/subscription.js") %]
96
    [% Asset.js("js/showpredictionpattern.js") %]
58
[% END %]
97
[% END %]
59
98
60
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
99
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js (-1 lines)
Lines 21-27 function Check_permanent_irregularities() { Link Here
21
    // So check them according to permanent irregularity
21
    // So check them according to permanent irregularity
22
    if (nothing_checked) {
22
    if (nothing_checked) {
23
        $(".skip").each(function() {
23
        $(".skip").each(function() {
24
            console.log('iciiiiiiiiiiiiii');
25
            if ($(this).is(':checked')) {
24
            if ($(this).is(':checked')) {
26
                Check_boxes( $(this).data("dow"));
25
                Check_boxes( $(this).data("dow"));
27
            }
26
            }
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-69 lines)
Lines 225-299 function restoreAdvancedPattern() { Link Here
225
    advancedpatternlocked = 1;
225
    advancedpatternlocked = 1;
226
}
226
}
227
227
228
function testPredictionPattern() {
229
    var frequencyid = $("#frequency").val();
230
    var acquidate;
231
    var error = 0;
232
    var error_msg = "";
233
    if(frequencyid == undefined || frequencyid == ""){
234
        error_msg += _("- Frequency is not defined") + "\n";
235
        error ++;
236
    }
237
    acquidate = $("#acqui_date").val();
238
    if(acquidate == undefined || acquidate == ""){
239
        error_msg += _("- First publication date is not defined") + "\n";
240
        error ++;
241
    }
242
    if( more_than_one_serial !== "" ){
243
        var nextacquidate = $("#nextacquidate").val();
244
        if(nextacquidate == undefined || nextacquidate == ""){
245
            error_msg += _("- Next issue publication date is not defined") + "\n";
246
            error ++;
247
        }
248
    }
249
250
    if(error){
251
        alert(_("Cannot test prediction pattern for the following reason(s): %s").format(error_msg));
252
        return false;
253
    }
254
255
    var custompattern = 0;
256
    if(advancedpatternlocked == 0) {
257
        custompattern = 1;
258
    }
259
260
    var ajaxData = {
261
        'custompattern': custompattern,
262
        'firstacquidate': acquidate
263
    };
264
265
    if( subscriptionid !== "" ){
266
        ajaxData.subscriptionid = subscriptionid;
267
    }
268
    if( more_than_one_serial !== "" ){
269
        ajaxData.nextacquidate = nextacquidate;
270
    }
271
272
273
    var ajaxParams = [
274
        'to', 'subtype', 'sublength', 'frequency', 'numberingmethod',
275
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
276
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
277
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
278
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
279
    ];
280
    for(i in ajaxParams) {
281
        var param = ajaxParams[i];
282
        var value = $("#"+param).val();
283
        if(value.length > 0)
284
            ajaxData[param] = value;
285
    }
286
287
    $.ajax({
288
        url:"/cgi-bin/koha/serials/showpredictionpattern.pl",
289
        data: ajaxData,
290
        success: function(data) {
291
            $("#displayexample").html(data);
292
            patternneedtobetested = 0;
293
        }
294
    });
295
}
296
297
function saveAdvancedPattern() {
228
function saveAdvancedPattern() {
298
    if ($("#patternname").val().length == 0) {
229
    if ($("#patternname").val().length == 0) {
299
        alert(_("Please enter a name for this pattern"));
230
        alert(_("Please enter a name for this pattern"));
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription.js (+71 lines)
Line 0 Link Here
1
2
var advancedpatternlocked;
3
4
function testPredictionPattern() {
5
    var frequencyid = $("#frequency").val();
6
    var acquidate;
7
    var error = 0;
8
    var error_msg = "";
9
    if(frequencyid == undefined || frequencyid == ""){
10
        error_msg += _("- Frequency is not defined") + "\n";
11
        error ++;
12
    }
13
    acquidate = $("#acqui_date").val();
14
    if(acquidate == undefined || acquidate == ""){
15
        error_msg += _("- First publication date is not defined") + "\n";
16
        error ++;
17
    }
18
    if( more_than_one_serial !== "" ){
19
        var nextacquidate = $("#nextacquidate").val();
20
        if(nextacquidate == undefined || nextacquidate == ""){
21
            error_msg += _("- Next issue publication date is not defined") + "\n";
22
            error ++;
23
        }
24
    }
25
26
    if(error){
27
        alert(_("Cannot test prediction pattern for the following reason(s): %s").format(error_msg));
28
        return false;
29
    }
30
31
    var custompattern = 0;
32
    if(advancedpatternlocked == 0) {
33
        custompattern = 1;
34
    }
35
36
    var ajaxData = {
37
        'custompattern': custompattern,
38
        'firstacquidate': acquidate
39
    };
40
41
    if( subscriptionid !== "" ){
42
        ajaxData.subscriptionid = subscriptionid;
43
    }
44
    if( more_than_one_serial !== "" ){
45
        ajaxData.nextacquidate = nextacquidate;
46
    }
47
48
49
    var ajaxParams = [
50
        'to', 'subtype', 'sublength', 'frequency', 'numberingmethod',
51
        'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
52
        'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
53
        'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
54
        'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
55
    ];
56
    for(i in ajaxParams) {
57
        var param = ajaxParams[i];
58
        var value = $("#"+param).val();
59
        if(value.length > 0)
60
            ajaxData[param] = value;
61
    }
62
63
    $.ajax({
64
        url:"/cgi-bin/koha/serials/showpredictionpattern.pl",
65
        data: ajaxData,
66
        success: function(data) {
67
            $("#displayexample").html(data);
68
            patternneedtobetested = 0;
69
        }
70
    });
71
}
(-)a/serials/subscription-add.pl (-32 / +4 lines)
Lines 257-290 sub _get_sub_length { Link Here
257
        );
257
        );
258
}
258
}
259
259
260
sub _guess_enddate {
261
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
262
    my ($year, $month, $day);
263
    my $enddate;
264
    if($numberlength != 0) {
265
        my $frequency = GetSubscriptionFrequency($frequencyid);
266
        if($frequency->{'unit'} eq 'day') {
267
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
268
        } elsif($frequency->{'unit'} eq 'week') {
269
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
270
        } elsif($frequency->{'unit'} eq 'month') {
271
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
272
        } elsif($frequency->{'unit'} eq 'year') {
273
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0);
274
        }
275
    } elsif($weeklength != 0) {
276
        ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7);
277
    } elsif($monthlength != 0) {
278
        ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength);
279
    }
280
    if(defined $year) {
281
        $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day);
282
    } else {
283
        undef $enddate;
284
    }
285
    return $enddate;
286
}
287
288
sub redirect_add_subscription {
260
sub redirect_add_subscription {
289
    my $auser          = $query->param('user');
261
    my $auser          = $query->param('user');
290
    my $branchcode     = $query->param('branchcode');
262
    my $branchcode     = $query->param('branchcode');
Lines 330-338 sub redirect_add_subscription { Link Here
330
302
331
    if(!defined $enddate || $enddate eq '') {
303
    if(!defined $enddate || $enddate eq '') {
332
        if($subtype eq "issues") {
304
        if($subtype eq "issues") {
333
            $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
305
            $enddate = GuessEnddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
334
        } else {
306
        } else {
335
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
307
            $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
336
        }
308
        }
337
    }
309
    }
338
310
Lines 407-415 sub redirect_mod_subscription { Link Here
407
    # Guess end date
379
    # Guess end date
408
    if(!defined $enddate || $enddate eq '') {
380
    if(!defined $enddate || $enddate eq '') {
409
        if($subtype eq "issues") {
381
        if($subtype eq "issues") {
410
            $enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
382
            $enddate = GuessEnddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
411
        } else {
383
        } else {
412
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
384
            $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
413
        }
385
        }
414
    }
386
    }
415
387
(-)a/serials/subscription-renew.pl (-2 / +44 lines)
Lines 53-58 use C4::Context; Link Here
53
use C4::Auth;
53
use C4::Auth;
54
use C4::Output;
54
use C4::Output;
55
use C4::Serials;
55
use C4::Serials;
56
use C4::Serials::Frequency;
57
use C4::Serials::Numberpattern;
58
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM);
56
use Koha::DateUtils;
59
use Koha::DateUtils;
57
60
58
my $query = new CGI;
61
my $query = new CGI;
Lines 75-80 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
75
if ( $op eq "renew" ) {
78
if ( $op eq "renew" ) {
76
    # Do not use this script with op=renew and @subscriptionids > 1!
79
    # Do not use this script with op=renew and @subscriptionids > 1!
77
    my $subscriptionid = $subscriptionids[0];
80
    my $subscriptionid = $subscriptionids[0];
81
    my @permanent_irregularities = $query->param('permanent_irregularity');
82
    my @irregularities = $query->param('irregularity');
78
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
83
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
79
    ReNewSubscription(
84
    ReNewSubscription(
80
        $subscriptionid, $loggedinuser,
85
        $subscriptionid, $loggedinuser,
Lines 82-87 if ( $op eq "renew" ) { Link Here
82
        scalar $query->param('weeklength'), scalar $query->param('monthlength'),
87
        scalar $query->param('weeklength'), scalar $query->param('monthlength'),
83
        scalar $query->param('note')
88
        scalar $query->param('note')
84
    );
89
    );
90
91
    my $subscription = Koha::Subscriptions->find($subscriptionid);
92
    $subscription->permanent_irregularity(join(';', @permanent_irregularities));
93
    $subscription->irregularity(join(';', @irregularities));
94
    $subscription->store;
85
} elsif ( $op eq 'multi_renew' ) {
95
} elsif ( $op eq 'multi_renew' ) {
86
    for my $subscriptionid ( @subscriptionids ) {
96
    for my $subscriptionid ( @subscriptionids ) {
87
        my $subscription = GetSubscription( $subscriptionid );
97
        my $subscription = GetSubscription( $subscriptionid );
Lines 103-116 if ( $op eq "renew" ) { Link Here
103
    my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
113
    my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
104
        or output_pref( { dt => dt_from_string, dateonly => 1 } );
114
        or output_pref( { dt => dt_from_string, dateonly => 1 } );
105
115
116
    my ($serials_number) = GetSerials($subscriptionid);
117
    if ($serials_number > 1) {
118
        $template->param(more_than_one_serial => 1);
119
    }
120
121
    my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
122
    my $subtype = $subscription_o->subtype;
123
    my $nextexpected = GetNextExpected($subscriptionid);
124
    my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
125
                                 $subscription->{periodicity},
126
                                 $subscription->{numberlength},
127
                                 $subscription->{weeklength},
128
                                 $subscription->{monthlength});
129
130
    my $sub_length;
131
    foreach my $length_unit (qw(numberlength weeklength monthlength)) {
132
        if ($subscription->{$length_unit}) {
133
            $sub_length=$subscription->{$length_unit};
134
            last;
135
        }
136
    }
137
138
    my $numberpattern = GetSubscriptionNumberpattern($subscription->{numberpattern});
139
106
    $template->param(
140
    $template->param(
107
        startdate      => $newstartdate,
141
        startdate       => $newstartdate,
108
        subscription   => $subscription,
142
        subscription    => $subscription,
143
        numberpattern   => $numberpattern,
144
        startdate       => $newstartdate,
145
        nextacquidate   => $nextexpected->{planneddate},
146
        enddate         => $enddate,
147
        subtype         => $subtype,
148
        sublength       => $sub_length,
109
    );
149
    );
110
}
150
}
111
151
112
$template->param(
152
$template->param(
113
    op => $op,
153
    op => $op,
154
    #$op             => 1,
155
    popup           => ($mode eq 'popup'),
114
);
156
);
115
157
116
output_html_with_http_headers $query, $cookie, $template->output;
158
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/t/db_dependent/Koha/Subscription.t (-2 / +40 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use Test::More tests => 2;
24
use t::lib::TestBuilder;
23
25
24
use Koha::Subscriptions;
26
use Koha::Subscriptions;
25
use Koha::Biblio;
27
use Koha::Biblio;
Lines 88-93 subtest 'Koha::Subscription->vendor' => sub { Link Here
88
    is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' );
90
    is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' );
89
};
91
};
90
92
93
subtest 'Koha::Subscription::subtype' => sub {
94
    plan tests => 3;
95
96
    my $subs = $builder->build({
97
        source => 'Subscription',
98
        value => {
99
            numberlength => 7,
100
            weeklength => 0,
101
            monthlength => 0,
102
        }
103
    });
104
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
105
    is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type');
106
107
    my $subs2 = $builder->build({
108
        source => 'Subscription',
109
        value => {
110
            numberlength => 0,
111
            weeklength => 52,
112
            monthlength => 0,
113
        }
114
    });
115
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
116
    is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type');
117
118
    my $subs3 = $builder->build({
119
        source => 'Subscription',
120
        value => {
121
            numberlength => 0,
122
            weeklength => 0,
123
            monthlength => 12,
124
        }
125
    });
126
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
127
    is($subscription3->subtype, 'months', 'Subscription with monthlength has months type');
128
};
129
91
$schema->storage->txn_rollback;
130
$schema->storage->txn_rollback;
92
131
93
1;
132
1;
94
- 

Return to bug 17656