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 2712-2717 sub findSerialsByStatus { Link Here
2712
    return @$serials;
2713
    return @$serials;
2713
}
2714
}
2714
2715
2716
=head2 GessEnddate
2717
2718
my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2719
2720
=cut
2721
2722
sub GuessEnddate {
2723
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
2724
    my ($year, $month, $day);
2725
    my $enddate;
2726
    if($numberlength != 0) {
2727
        my $frequency = GetSubscriptionFrequency($frequencyid);
2728
        if($frequency->{'unit'} eq 'day') {
2729
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2730
        } elsif($frequency->{'unit'} eq 'week') {
2731
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2732
        } elsif($frequency->{'unit'} eq 'month') {
2733
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
2734
        } elsif($frequency->{'unit'} eq 'year') {
2735
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0);
2736
        }
2737
    } elsif($weeklength != 0) {
2738
        ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7);
2739
    } elsif($monthlength != 0) {
2740
        ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength);
2741
    }
2742
    if(defined $year) {
2743
        $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day);
2744
    } else {
2745
        undef $enddate;
2746
    }
2747
    return $enddate;
2748
}
2749
2715
1;
2750
1;
2716
__END__
2751
__END__
2717
2752
(-)a/Koha/Subscription.pm (+22 lines)
Lines 72-77 sub permanent_irregularities { Link Here
72
    return split(';', $self->permanent_irregularity);
72
    return split(';', $self->permanent_irregularity);
73
}
73
}
74
74
75
=head3 subtype
76
77
Return the length type (issues, weeks, months)
78
79
=cut
80
81
sub subtype {
82
    my ($self) = @_;
83
84
    if ($self->numberlength) {
85
        return 'issues';
86
    }
87
88
    if ($self->weeklength) {
89
        return 'weeks';
90
    }
91
92
    if ($self->monthlength) {
93
        return 'months';
94
    }
95
}
96
75
=head3 type
97
=head3 type
76
98
77
=cut
99
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+1 lines)
Lines 510-515 fieldset.rows li.radio { width: 100%; } /* override staff-global.css */ Link Here
510
        var MSG_PUB_DATE_UNDEFINED = _("First publication date is not defined");
510
        var MSG_PUB_DATE_UNDEFINED = _("First publication date is not defined");
511
        var MSG_NEXT_ISSUE_UNDEFINED = _("Next issue publication date is not defined");
511
        var MSG_NEXT_ISSUE_UNDEFINED = _("Next issue publication date is not defined");
512
    </script>
512
    </script>
513
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/subscription.js"></script>
513
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/subscription-add.js"></script>
514
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/subscription-add.js"></script>
514
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/showpredictionpattern.js"></script>
515
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/showpredictionpattern.js"></script>
515
[% END %]
516
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (+42 lines)
Lines 24-29 Link Here
24
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
24
<form name="f" action="/cgi-bin/koha/serials/subscription-renew.pl" method="post">
25
		<input type="hidden" name="op" value="renew" />
25
		<input type="hidden" name="op" value="renew" />
26
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
26
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
27
        <input type="hidden" id="frequency" value="[% periodicity %]" />
28
        <input type="hidden" id="acqui_date" value="[% firstacquidate %]" />
29
        <input type="hidden" id="nextacquidate" value="[% nextacquidate %]" />
30
31
        <input type="hidden" id="to" value="[% enddate %]" />
32
        <input type="hidden" id="subtype" value="[% subtype %]" />
33
        <input type="hidden" id="sublength" value="[% sublength %]" />
34
        <input type="hidden" id="numberingmethod" value="[% numberingmethod %]" />
35
        <input type="hidden" id="lastvalue1" value="[% lastvalue1 %]" />
36
        <input type="hidden" id="lastvalue2" value="[% lastvalue2 %]" />
37
        <input type="hidden" id="lastvalue3" value="[% lastvalue3 %]" />
38
        <input type="hidden" id="add1" value="[% add1 %]" />
39
        <input type="hidden" id="add2" value="[% add2 %]" />
40
        <input type="hidden" id="add3" value="[% add3 %]" />
41
        <input type="hidden" id="every1" value="[% every1 %]" />
42
        <input type="hidden" id="every2" value="[% every2 %]" />
43
        <input type="hidden" id="every3" value="[% every3 %]" />
44
        <input type="hidden" id="innerloop1" value="[% innerloop1 %]" />
45
        <input type="hidden" id="innerloop2" value="[% innerloop2 %]" />
46
        <input type="hidden" id="innerloop3" value="[% innerloop3 %]" />
47
        <input type="hidden" id="setto1" value="[% setto1 %]" />
48
        <input type="hidden" id="setto2" value="[% setto2 %]" />
49
        <input type="hidden" id="setto3" value="[% setto3 %]" />
50
        <input type="hidden" id="numbering1" value="[% numbering1 %]" />
51
        <input type="hidden" id="numbering2" value="[% numbering2 %]" />
52
        <input type="hidden" id="numbering3" value="[% numbering3 %]" />
53
        <input type="hidden" id="whenmorethan1" value="[% whenmorethan1 %]" />
54
        <input type="hidden" id="whenmorethan2" value="[% whenmorethan2 %]" />
55
        <input type="hidden" id="whenmorethan3" value="[% whenmorethan3 %]" />
56
        <input type="hidden" id="locale" value="[% locale %]" />
27
		<fieldset class="rows"><legend>Subscription renewal for [% bibliotitle %]</legend>
57
		<fieldset class="rows"><legend>Subscription renewal for [% bibliotitle %]</legend>
28
        <ol>
58
        <ol>
29
            <li>
59
            <li>
Lines 38-50 Link Here
38
		<li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% monthlength %]" /></li></ol></fieldset></li>
68
		<li><label for="monthlength">Number of months: </label><input type="text" id="monthlength" name="monthlength" value="[% monthlength %]" /></li></ol></fieldset></li>
39
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
69
		<li><label for="note">Note for the librarian that will manage your renewal request: </label>
40
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
70
		<textarea name="note" id="note" rows="5" cols="50"></textarea></li></ol></fieldset>
71
        <li id="displayexample"></li>
41
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
72
		<fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
73
42
</form>
74
</form>
43
</div>
75
</div>
44
[% END %]
76
[% END %]
45
77
46
[% MACRO jsinclude BLOCK %]
78
[% MACRO jsinclude BLOCK %]
47
    [% INCLUDE 'calendar.inc' %]
79
    [% INCLUDE 'calendar.inc' %]
80
    <script type="text/javascript">
81
        var subscriptionid = "[% subscriptionid %]";
82
        var irregularity = "[% irregularity %]";
83
        var more_than_one_serial = "[% more_than_one_serial %]";
84
        $(document).ready(function(){
85
            testPredictionPattern();
86
        });
87
    </script>
88
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/subscription.js"></script>
89
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/showpredictionpattern.js"></script>
48
[% END %]
90
[% END %]
49
91
50
[% INCLUDE 'intranet-bottom.inc' %]
92
[% INCLUDE 'intranet-bottom.inc' %]
(-)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 258-291 sub _get_sub_length { Link Here
258
        );
258
        );
259
}
259
}
260
260
261
sub _guess_enddate {
262
    my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_;
263
    my ($year, $month, $day);
264
    my $enddate;
265
    if($numberlength != 0) {
266
        my $frequency = GetSubscriptionFrequency($frequencyid);
267
        if($frequency->{'unit'} eq 'day') {
268
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
269
        } elsif($frequency->{'unit'} eq 'week') {
270
            ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
271
        } elsif($frequency->{'unit'} eq 'month') {
272
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'});
273
        } elsif($frequency->{'unit'} eq 'year') {
274
            ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0);
275
        }
276
    } elsif($weeklength != 0) {
277
        ($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7);
278
    } elsif($monthlength != 0) {
279
        ($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength);
280
    }
281
    if(defined $year) {
282
        $enddate = sprintf("%04d-%02d-%02d", $year, $month, $day);
283
    } else {
284
        undef $enddate;
285
    }
286
    return $enddate;
287
}
288
289
sub redirect_add_subscription {
261
sub redirect_add_subscription {
290
    my $auser          = $query->param('user');
262
    my $auser          = $query->param('user');
291
    my $branchcode     = $query->param('branchcode');
263
    my $branchcode     = $query->param('branchcode');
Lines 331-339 sub redirect_add_subscription { Link Here
331
303
332
    if(!defined $enddate || $enddate eq '') {
304
    if(!defined $enddate || $enddate eq '') {
333
        if($subtype eq "issues") {
305
        if($subtype eq "issues") {
334
            $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
306
            $enddate = GuessEnddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
335
        } else {
307
        } else {
336
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
308
            $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
337
        }
309
        }
338
    }
310
    }
339
311
Lines 408-416 sub redirect_mod_subscription { Link Here
408
    # Guess end date
380
    # Guess end date
409
    if(!defined $enddate || $enddate eq '') {
381
    if(!defined $enddate || $enddate eq '') {
410
        if($subtype eq "issues") {
382
        if($subtype eq "issues") {
411
            $enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
383
            $enddate = GuessEnddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
412
        } else {
384
        } else {
413
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
385
            $enddate = GuessEnddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
414
        }
386
        }
415
    }
387
    }
416
388
(-)a/serials/subscription-renew.pl (-8 / +72 lines)
Lines 54-59 use C4::Context; Link Here
54
use C4::Auth;
54
use C4::Auth;
55
use C4::Output;
55
use C4::Output;
56
use C4::Serials;
56
use C4::Serials;
57
use C4::Serials::Frequency;
58
use C4::Serials::Numberpattern;
59
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM);
57
use Koha::DateUtils;
60
use Koha::DateUtils;
58
61
59
my $query = new CGI;
62
my $query = new CGI;
Lines 74-79 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
74
    }
77
    }
75
);
78
);
76
if ( $op eq "renew" ) {
79
if ( $op eq "renew" ) {
80
    my @permanent_irregularities = $query->param('permanent_irregularity');
81
    my @irregularities = $query->param('irregularity');
77
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
82
    my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
78
    ReNewSubscription(
83
    ReNewSubscription(
79
        $subscriptionid, $loggedinuser,
84
        $subscriptionid, $loggedinuser,
Lines 81-86 if ( $op eq "renew" ) { Link Here
81
        $query->param('weeklength'), $query->param('monthlength'),
86
        $query->param('weeklength'), $query->param('monthlength'),
82
        $query->param('note')
87
        $query->param('note')
83
    );
88
    );
89
90
    my $subscription = Koha::Subscriptions->find($subscriptionid);
91
    $subscription->permanent_irregularity(join(';', @permanent_irregularities));
92
    $subscription->irregularity(join(';', @irregularities));
93
    $subscription->store;
84
}
94
}
85
95
86
my $subscription = GetSubscription($subscriptionid);
96
my $subscription = GetSubscription($subscriptionid);
Lines 92-106 if ($subscription->{'cannotedit'}){ Link Here
92
my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
102
my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
93
    or output_pref( { dt => dt_from_string, dateonly => 1 } );
103
    or output_pref( { dt => dt_from_string, dateonly => 1 } );
94
104
105
my ($serials_number) = GetSerials($subscriptionid);
106
if ($serials_number > 1) {
107
    $template->param(more_than_one_serial => 1);
108
}
109
110
my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
111
my $subtype = $subscription_o->subtype;
112
my $nextexpected = GetNextExpected($subscriptionid);
113
my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
114
                             $subscription->{periodicity},
115
                             $subscription->{numberlength},
116
                             $subscription->{weeklength},
117
                             $subscription->{monthlength});
118
119
my $sub_length;
120
foreach my $length_unit (qw(numberlength weeklength monthlength)) {
121
    if ($subscription->{$length_unit}) {
122
        $sub_length=$subscription->{$length_unit};
123
        last;
124
    }
125
}
126
127
my $numberpattern = GetSubscriptionNumberpattern($subscription->{numberpattern});
128
95
$template->param(
129
$template->param(
96
    startdate      => $newstartdate,
130
    startdate       => $newstartdate,
97
    numberlength   => $subscription->{numberlength},
131
    numberlength    => $subscription->{numberlength},
98
    weeklength     => $subscription->{weeklength},
132
    weeklength      => $subscription->{weeklength},
99
    monthlength    => $subscription->{monthlength},
133
    monthlength     => $subscription->{monthlength},
100
    subscriptionid => $subscriptionid,
134
    subscriptionid  => $subscriptionid,
101
    bibliotitle    => $subscription->{bibliotitle},
135
    irregularity    => $subscription->{irregularity},
102
    $op            => 1,
136
    periodicity     => $subscription->{periodicity},
103
    popup          => ($mode eq 'popup'),
137
    firstacquidate  => $subscription->{firstacquidate},
138
    nextacquidate   => $nextexpected->{planneddate},
139
    enddate         => $enddate,
140
    subtype         => $subtype,
141
    sublength       => $sub_length,
142
    numberingmethod => $numberpattern->{numberingmethod},
143
    lastvalue1      => $subscription->{lastvalue1},
144
    lastvalue2      => $subscription->{lastvalue2},
145
    lastvalue3      => $subscription->{lastvalue3},
146
    add1            => $numberpattern->{add1},
147
    add2            => $numberpattern->{add2},
148
    add3            => $numberpattern->{add3},
149
    every1          => $numberpattern->{every1},
150
    every2          => $numberpattern->{every2},
151
    every3          => $numberpattern->{every3},
152
    innerloop1      => $subscription->{innerloop1},
153
    innerloop2      => $subscription->{innerloop2},
154
    innerloop3      => $subscription->{innerloop3},
155
    setto1          => $numberpattern->{setto1},
156
    setto2          => $numberpattern->{setto2},
157
    setto3          => $numberpattern->{setto3},
158
    numbering1      => $numberpattern->{numbering1},
159
    numbering2      => $numberpattern->{numbering2},
160
    numbering3      => $numberpattern->{numbering3},
161
    whenmorethan1   => $numberpattern->{whenmorethan1},
162
    whenmorethan2   => $numberpattern->{whenmorethan2},
163
    whenmorethan3   => $numberpattern->{whenmorethan3},
164
    locale          => $subscription->{locale},
165
    bibliotitle     => $subscription->{bibliotitle},
166
    $op             => 1,
167
    popup           => ($mode eq 'popup'),
104
);
168
);
105
169
106
# Print the page
170
# Print the page
(-)a/t/db_dependent/Koha/Subscription.t (-2 / +41 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 2;
23
use t::lib::TestBuilder;
23
24
24
use Koha::Subscription;
25
use Koha::Subscription;
25
use Koha::Biblio;
26
use Koha::Biblio;
Lines 27-32 use Koha::Biblio; Link Here
27
my $schema = Koha::Database->new->schema;
28
my $schema = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
29
$schema->storage->txn_begin;
29
30
31
my $builder = t::lib::TestBuilder->new();
32
30
subtest 'Koha::Subscription::biblio' => sub {
33
subtest 'Koha::Subscription::biblio' => sub {
31
    plan tests => 1;
34
    plan tests => 1;
32
35
Lines 39-44 subtest 'Koha::Subscription::biblio' => sub { Link Here
39
    is($b->biblionumber, $biblio->biblionumber, 'Koha::Subscription::biblio returns the correct biblio');
42
    is($b->biblionumber, $biblio->biblionumber, 'Koha::Subscription::biblio returns the correct biblio');
40
};
43
};
41
44
45
subtest 'Koha::Subscription::subtype' => sub {
46
    plan tests => 3;
47
48
    my $subs = $builder->build({
49
        source => 'Subscription',
50
        value => {
51
            numberlength => 7,
52
            weeklength => 0,
53
            monthlength => 0,
54
        }
55
    });
56
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
57
    is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type');
58
59
    my $subs2 = $builder->build({
60
        source => 'Subscription',
61
        value => {
62
            numberlength => 0,
63
            weeklength => 52,
64
            monthlength => 0,
65
        }
66
    });
67
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
68
    is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type');
69
70
    my $subs3 = $builder->build({
71
        source => 'Subscription',
72
        value => {
73
            numberlength => 0,
74
            weeklength => 0,
75
            monthlength => 12,
76
        }
77
    });
78
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
79
    is($subscription3->subtype, 'months', 'Subscription with monthlength has months type');
80
};
81
42
$schema->storage->txn_rollback;
82
$schema->storage->txn_rollback;
43
83
44
1;
84
1;
45
- 

Return to bug 17656