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

(-)a/C4/Serials.pm (-2 / +2 lines)
Lines 2716-2724 sub findSerialsByStatus { Link Here
2716
    return @$serials;
2716
    return @$serials;
2717
}
2717
}
2718
2718
2719
=head2 GessEnddate
2719
=head2 GuessEnddate
2720
2720
2721
my $enddate = GessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2721
my $enddate = GuessEnddate($startdate_iso $frequencyid, $numberlength, $weeklength, $monthlength);
2722
2722
2723
=cut
2723
=cut
2724
2724
(-)a/Koha/Subscription.pm (-2 / +2 lines)
Lines 130-142 sub permanent_irregularities { Link Here
130
    return split(';', $self->permanent_irregularity);
130
    return split(';', $self->permanent_irregularity);
131
}
131
}
132
132
133
=head3 subtype
133
=head3 lengthtype
134
134
135
Return the length type (issues, weeks, months)
135
Return the length type (issues, weeks, months)
136
136
137
=cut
137
=cut
138
138
139
sub subtype {
139
sub lengthtype {
140
    my ($self) = @_;
140
    my ($self) = @_;
141
141
142
    if ($self->numberlength) {
142
    if ($self->numberlength) {
(-)a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'subscription', 'permanent_irregularity' ) ) {
4
        $dbh->do( "ALTER TABLE `subscription` ADD permanent_irregularity MEDIUMTEXT AFTER irregularity" );
5
    }
6
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug 17656 - Irregularities in serial prediction pattern are planned only for current subscription)\n";
9
}
(-)a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql (-1 lines)
Line 1 Link Here
1
ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2091-2096 CREATE TABLE `subscription` ( -- information related to the subscription Link Here
2091
  `firstacquidate` date default NULL, -- first issue received date
2091
  `firstacquidate` date default NULL, -- first issue received date
2092
  `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually
2092
  `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually
2093
  `irregularity` MEDIUMTEXT, -- any irregularities in the subscription
2093
  `irregularity` MEDIUMTEXT, -- any irregularities in the subscription
2094
  `permanent_irregularity` MEDIUMTEXT,
2094
  skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
2095
  skip_serialseq BOOLEAN NOT NULL DEFAULT 0,
2095
  `letter` varchar(20) default NULL,
2096
  `letter` varchar(20) default NULL,
2096
  `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id
2097
  `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc (-1 / +13 lines)
Lines 4-9 Link Here
4
</em></p>
4
</em></p>
5
[% daily_choice = [ {name => 'monday', desc => 'Monday', value => 1}, {name => 'tuesday', desc => 'Tuesday', value => 2}, {name => 'wednesday', desc => 'Wednesday', value => 3}, {name => 'thursday', desc => 'Thursday', value => 4}, {name => 'friday', desc => 'Friday', value => 5}, {name => 'saturday', desc => 'Saturday', value => 6}, {name => 'sunday', desc => 'Sunday', value => 7} ] %]
5
[% daily_choice = [ {name => 'monday', desc => 'Monday', value => 1}, {name => 'tuesday', desc => 'Tuesday', value => 2}, {name => 'wednesday', desc => 'Wednesday', value => 3}, {name => 'thursday', desc => 'Thursday', value => 4}, {name => 'friday', desc => 'Friday', value => 5}, {name => 'saturday', desc => 'Saturday', value => 6}, {name => 'sunday', desc => 'Sunday', value => 7} ] %]
6
6
7
[% BLOCK days %]
8
    [% SWITCH d %]
9
        [% CASE 'monday' %]Monday
10
        [% CASE 'tuesday' %]Tuesday
11
        [% CASE 'wednesday' %]Wednesday
12
        [% CASE 'thursday' %]Thursday
13
        [% CASE 'friday' %]Friday
14
        [% CASE 'saturday' %]Saturday
15
        [% CASE 'sunday' %]Sunday
16
    [% END %]
17
[% END %]
18
7
[% FOREACH day IN daily_choice %]
19
[% FOREACH day IN daily_choice %]
8
    [% IF permanent_irreg.grep( day.value ).0 == day.value %]
20
    [% IF permanent_irreg.grep( day.value ).0 == day.value %]
9
        <input type="checkbox" name="permanent_irregularity"
21
        <input type="checkbox" name="permanent_irregularity"
Lines 17-21 Link Here
17
               value="[% day.value %]" class="skip"
29
               value="[% day.value %]" class="skip"
18
        />
30
        />
19
    [% END %]
31
    [% END %]
20
    <label for="[% day.name %]">[% day.desc %]</label>
32
    <label for="[% day.name %]">[% PROCESS days d=day.name %]</label>
21
[% END %]
33
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc (-1 / +18 lines)
Lines 4-9 Link Here
4
</em></p>
4
</em></p>
5
[% monthly_choice = [ {name => 'january', desc => 'January', value => 1}, {name => 'february', desc => 'February', value => 2}, {name => 'march', desc => 'March', value => 3}, {name => 'april', desc => 'April', value => 4}, {name => 'may', desc => 'May', value => 5}, {name => 'june', desc => 'June', value => 6}, {name => 'july', desc => 'July', value => 7}, {name => 'august', desc => 'August', value => 8}, {name => 'september', desc => 'September', value => 9}, {name => 'october', desc => 'October', value => 10}, {name => 'november', desc => 'November', value => 11}, {name => 'december', desc => 'December', value =>12} ] %]
5
[% monthly_choice = [ {name => 'january', desc => 'January', value => 1}, {name => 'february', desc => 'February', value => 2}, {name => 'march', desc => 'March', value => 3}, {name => 'april', desc => 'April', value => 4}, {name => 'may', desc => 'May', value => 5}, {name => 'june', desc => 'June', value => 6}, {name => 'july', desc => 'July', value => 7}, {name => 'august', desc => 'August', value => 8}, {name => 'september', desc => 'September', value => 9}, {name => 'october', desc => 'October', value => 10}, {name => 'november', desc => 'November', value => 11}, {name => 'december', desc => 'December', value =>12} ] %]
6
6
7
[% BLOCK months %]
8
    [% SWITCH m %]
9
        [% CASE 'january' %]January
10
        [% CASE 'february' %]February
11
        [% CASE 'march' %]March
12
        [% CASE 'april' %]April
13
        [% CASE 'may' %]May
14
        [% CASE 'june' %]June
15
        [% CASE 'july' %]July
16
        [% CASE 'august' %]August
17
        [% CASE 'september' %]September
18
        [% CASE 'october' %]October
19
        [% CASE 'november' %]November
20
        [% CASE 'december' %]December
21
    [% END %]
22
[% END %]
23
7
[% FOREACH month IN monthly_choice %]
24
[% FOREACH month IN monthly_choice %]
8
    [% IF permanent_irreg.grep( month.value ).0 == month.value %]
25
    [% IF permanent_irreg.grep( month.value ).0 == month.value %]
9
        <input type="checkbox" name="permanent_irregularity"
26
        <input type="checkbox" name="permanent_irregularity"
Lines 17-21 Link Here
17
               value="[% month.value %]" class="skip"
34
               value="[% month.value %]" class="skip"
18
        />
35
        />
19
    [% END %]
36
    [% END %]
20
    <label for="[% month.name %]">[% month.desc %]</label>
37
    <label for="[% month.name %]">[% PROCESS months m=month.name %]</label>
21
[% END %]
38
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-1 / +1 lines)
Lines 32-38 Link Here
32
        <input type="hidden" id="nextacquidate" value="[% nextacquidate %]" />
32
        <input type="hidden" id="nextacquidate" value="[% nextacquidate %]" />
33
33
34
        <input type="hidden" id="to" value="[% enddate %]" />
34
        <input type="hidden" id="to" value="[% enddate %]" />
35
        <input type="hidden" id="subtype" value="[% subtype %]" />
35
        <input type="hidden" id="subtype" value="[% lengthtype %]" />
36
        <input type="hidden" id="sublength" value="[% sublength %]" />
36
        <input type="hidden" id="sublength" value="[% sublength %]" />
37
        <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod %]" />
37
        <input type="hidden" id="numberingmethod" value="[% numberpattern.numberingmethod %]" />
38
        <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 %]" />
38
        <input type="hidden" id="lastvalue1" value="[% subscription.lastvalue1 %]" />
(-)a/serials/subscription-renew.pl (-3 / +2 lines)
Lines 119-125 if ( $op eq "renew" ) { Link Here
119
    }
119
    }
120
120
121
    my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
121
    my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
122
    my $subtype = $subscription_o->subtype;
122
    my $lengthtype = $subscription_o->lengthtype;
123
    my $nextexpected = GetNextExpected($subscriptionid);
123
    my $nextexpected = GetNextExpected($subscriptionid);
124
    my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
124
    my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string,
125
                                 $subscription->{periodicity},
125
                                 $subscription->{periodicity},
Lines 144-157 if ( $op eq "renew" ) { Link Here
144
        startdate       => $newstartdate,
144
        startdate       => $newstartdate,
145
        nextacquidate   => $nextexpected->{planneddate},
145
        nextacquidate   => $nextexpected->{planneddate},
146
        enddate         => $enddate,
146
        enddate         => $enddate,
147
        subtype         => $subtype,
147
        lengthtype      => $lengthtype,
148
        sublength       => $sub_length,
148
        sublength       => $sub_length,
149
    );
149
    );
150
}
150
}
151
151
152
$template->param(
152
$template->param(
153
    op => $op,
153
    op => $op,
154
    #$op             => 1,
155
    popup           => ($mode eq 'popup'),
154
    popup           => ($mode eq 'popup'),
156
);
155
);
157
156
(-)a/t/Koha/DateUtils.t (-2 / +3 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 9;
20
use Test::More tests => 10;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
BEGIN {
23
BEGIN {
Lines 27-32 BEGIN { Link Here
27
my $dt = DateTime->new(year => 2017, month => 1, day => 1);
27
my $dt = DateTime->new(year => 2017, month => 1, day => 1);
28
28
29
eval { issue_number('2017', 'day'); };
29
eval { issue_number('2017', 'day'); };
30
is(ref($@), 'Koha::Exceptions::WrongParameter');
30
is($@, 'Date passed to issue_number is not a valid DateTime object');
31
is($@, 'Date passed to issue_number is not a valid DateTime object');
31
32
32
is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week');
33
is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week');
Lines 41-46 is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week'); Link Here
41
42
42
is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year');
43
is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year');
43
44
44
is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year');
45
is(issue_number($dt, 'month'), 9, '2022-09-17 is the ninth month of the year');
45
46
46
is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type');
47
is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type');
(-)a/t/db_dependent/Koha/Subscription.t (-5 / +4 lines)
Lines 90-96 subtest 'Koha::Subscription->vendor' => sub { Link Here
90
    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' );
91
};
91
};
92
92
93
subtest 'Koha::Subscription::subtype' => sub {
93
subtest 'Koha::Subscription::lengthtype' => sub {
94
    plan tests => 3;
94
    plan tests => 3;
95
95
96
    my $subs = $builder->build({
96
    my $subs = $builder->build({
Lines 102-108 subtest 'Koha::Subscription::subtype' => sub { Link Here
102
        }
102
        }
103
    });
103
    });
104
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
104
    my $subscription = Koha::Subscriptions->find($subs->{subscriptionid});
105
    is($subscription->subtype, 'issues', 'Subscription with numberlength has issues type');
105
    is($subscription->lengthtype, 'issues', 'Subscription with numberlength has issues type');
106
106
107
    my $subs2 = $builder->build({
107
    my $subs2 = $builder->build({
108
        source => 'Subscription',
108
        source => 'Subscription',
Lines 113-119 subtest 'Koha::Subscription::subtype' => sub { Link Here
113
        }
113
        }
114
    });
114
    });
115
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
115
    my $subscription2 = Koha::Subscriptions->find($subs2->{subscriptionid});
116
    is($subscription2->subtype, 'weeks', 'Subscription with weeklength has weeks type');
116
    is($subscription2->lengthtype, 'weeks', 'Subscription with weeklength has weeks type');
117
117
118
    my $subs3 = $builder->build({
118
    my $subs3 = $builder->build({
119
        source => 'Subscription',
119
        source => 'Subscription',
Lines 124-130 subtest 'Koha::Subscription::subtype' => sub { Link Here
124
        }
124
        }
125
    });
125
    });
126
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
126
    my $subscription3 = Koha::Subscriptions->find($subs3->{subscriptionid});
127
    is($subscription3->subtype, 'months', 'Subscription with monthlength has months type');
127
    is($subscription3->lengthtype, 'months', 'Subscription with monthlength has months type');
128
};
128
};
129
129
130
$schema->storage->txn_rollback;
130
$schema->storage->txn_rollback;
131
- 

Return to bug 17656