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

(-)a/C4/Serials.pm (-65 / +37 lines)
Lines 1301-1337 sub ModNextExpected { Link Here
1301
1301
1302
}
1302
}
1303
1303
1304
=head2 GetSubscriptionIrregularities
1305
1306
=over 4
1307
1308
=item @irreg = &GetSubscriptionIrregularities($subscriptionid);
1309
get the list of irregularities for a subscription
1310
1311
=back
1312
1313
=cut
1314
1315
sub GetSubscriptionIrregularities {
1316
    my $subscriptionid = shift;
1317
1318
    return unless $subscriptionid;
1319
1320
    my $dbh = C4::Context->dbh;
1321
    my $query = qq{
1322
        SELECT irregularity
1323
        FROM subscription
1324
        WHERE subscriptionid = ?
1325
    };
1326
    my $sth = $dbh->prepare($query);
1327
    $sth->execute($subscriptionid);
1328
1329
    my ($result) = $sth->fetchrow_array;
1330
    my @irreg = split /;/, $result;
1331
1332
    return @irreg;
1333
}
1334
1335
=head2 ModSubscription
1304
=head2 ModSubscription
1336
1305
1337
this function modifies a subscription. Put all new values on input args.
1306
this function modifies a subscription. Put all new values on input args.
Lines 1342-1364 returns the number of rows affected Link Here
1342
sub ModSubscription {
1311
sub ModSubscription {
1343
    my (
1312
    my (
1344
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
1313
    $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
1345
    $periodicity, $firstacquidate, $irregularity, $numberpattern, $locale,
1314
    $periodicity, $firstacquidate, $irregularity, $permanent_irregularity,
1346
    $numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1,
1315
    $numberpattern, $locale, $numberlength, $weeklength, $monthlength,
1347
    $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status,
1316
    $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3,
1348
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1317
    $innerloop3, $status, $biblionumber, $callnumber, $notes, $letter,
1349
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1318
    $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1350
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1319
    $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
1351
    $itemtype, $previousitemtype
1320
    $skip_serialseq, $itemtype, $previousitemtype
1352
    ) = @_;
1321
    ) = @_;
1353
1322
1354
    my $dbh   = C4::Context->dbh;
1323
    my $dbh   = C4::Context->dbh;
1355
    my $query = "UPDATE subscription
1324
    my $query = "UPDATE subscription
1356
        SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?,
1325
        SET librarian=?, branchcode=?, aqbooksellerid=?, cost=?, aqbudgetid=?,
1357
            startdate=?, periodicity=?, firstacquidate=?, irregularity=?,
1326
            startdate=?, periodicity=?, firstacquidate=?, irregularity=?,
1358
            numberpattern=?, locale=?, numberlength=?, weeklength=?, monthlength=?,
1327
            permanent_irregularity=?, numberpattern=?, locale=?, numberlength=?,
1359
            lastvalue1=?, innerloop1=?, lastvalue2=?, innerloop2=?,
1328
            weeklength=?, monthlength=?, lastvalue1=?, innerloop1=?,
1360
            lastvalue3=?, innerloop3=?, status=?, biblionumber=?,
1329
            lastvalue2=?, innerloop2=?, lastvalue3=?, innerloop3=?, status=?,
1361
            callnumber=?, notes=?, letter=?, manualhistory=?,
1330
            biblionumber=?, callnumber=?, notes=?, letter=?, manualhistory=?,
1362
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1331
            internalnotes=?, serialsadditems=?, staffdisplaycount=?,
1363
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1332
            opacdisplaycount=?, graceperiod=?, location = ?, enddate=?,
1364
            skip_serialseq=?, itemtype=?, previousitemtype=?
1333
            skip_serialseq=?, itemtype=?, previousitemtype=?
Lines 1366-1382 sub ModSubscription { Link Here
1366
1335
1367
    my $sth = $dbh->prepare($query);
1336
    my $sth = $dbh->prepare($query);
1368
    $sth->execute(
1337
    $sth->execute(
1369
        $auser,           $branchcode,     $aqbooksellerid, $cost,
1338
        $auser,                     $branchcode,        $aqbooksellerid,
1370
        $aqbudgetid,      $startdate,      $periodicity,    $firstacquidate,
1339
        $cost,                      $aqbudgetid,        $startdate,
1371
        $irregularity,    $numberpattern,  $locale,         $numberlength,
1340
        $periodicity,               $firstacquidate,    $irregularity,
1372
        $weeklength,      $monthlength,    $lastvalue1,     $innerloop1,
1341
        $permanent_irregularity,    $numberpattern,     $locale,
1373
        $lastvalue2,      $innerloop2,     $lastvalue3,     $innerloop3,
1342
        $numberlength,              $weeklength,        $monthlength,
1374
        $status,          $biblionumber,   $callnumber,     $notes,
1343
        $lastvalue1,                $innerloop1,        $lastvalue2,
1375
        $letter,          ($manualhistory ? $manualhistory : 0),
1344
        $innerloop2,                $lastvalue3,        $innerloop3,
1376
        $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1345
        $status,                    $biblionumber,      $callnumber,
1377
        $graceperiod,     $location,       $enddate,        $skip_serialseq,
1346
        $notes,                     $letter,            ($manualhistory ? $manualhistory : 0),
1378
        $itemtype,        $previousitemtype,
1347
        $internalnotes,             $serialsadditems,   $staffdisplaycount,
1379
        $subscriptionid
1348
        $opacdisplaycount,          $graceperiod,       $location,
1349
        $enddate,                   $skip_serialseq,    $itemtype,
1350
        $previousitemtype,          $subscriptionid
1380
    );
1351
    );
1381
    my $rows = $sth->rows;
1352
    my $rows = $sth->rows;
1382
1353
Lines 1407-1415 sub NewSubscription { Link Here
1407
    $startdate, $periodicity, $numberlength, $weeklength, $monthlength,
1378
    $startdate, $periodicity, $numberlength, $weeklength, $monthlength,
1408
    $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3,
1379
    $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3,
1409
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1380
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1410
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1381
    $permanent_irregularity, $numberpattern, $locale, $callnumber,
1411
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1382
    $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1412
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1383
    $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1384
    $itemtype, $previousitemtype
1413
    ) = @_;
1385
    ) = @_;
1414
    my $dbh = C4::Context->dbh;
1386
    my $dbh = C4::Context->dbh;
1415
1387
Lines 1420-1430 sub NewSubscription { Link Here
1420
            biblionumber, startdate, periodicity, numberlength, weeklength,
1392
            biblionumber, startdate, periodicity, numberlength, weeklength,
1421
            monthlength, lastvalue1, innerloop1, lastvalue2, innerloop2,
1393
            monthlength, lastvalue1, innerloop1, lastvalue2, innerloop2,
1422
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1394
            lastvalue3, innerloop3, status, notes, letter, firstacquidate,
1423
            irregularity, numberpattern, locale, callnumber,
1395
            irregularity, permanent_irregularity, numberpattern, locale,
1424
            manualhistory, internalnotes, serialsadditems, staffdisplaycount,
1396
            callnumber, manualhistory, internalnotes, serialsadditems,
1425
            opacdisplaycount, graceperiod, location, enddate, skip_serialseq,
1397
            staffdisplaycount, opacdisplaycount, graceperiod, location,
1426
            itemtype, previousitemtype)
1398
            enddate, skip_serialseq, itemtype, previousitemtype)
1427
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1399
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
1428
        |;
1400
        |;
1429
    my $sth = $dbh->prepare($query);
1401
    my $sth = $dbh->prepare($query);
1430
    $sth->execute(
1402
    $sth->execute(
Lines 1432-1441 sub NewSubscription { Link Here
1432
        $startdate, $periodicity, $numberlength, $weeklength,
1404
        $startdate, $periodicity, $numberlength, $weeklength,
1433
        $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
1405
        $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
1434
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1406
        $lastvalue3, $innerloop3, $status, $notes, $letter,
1435
        $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber,
1407
        $firstacquidate, $irregularity, $permanent_irregularity,
1436
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
1408
        $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1437
        $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq,
1409
        $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1438
        $itemtype, $previousitemtype
1410
        $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype
1439
    );
1411
    );
1440
1412
1441
    my $subscriptionid = $dbh->{'mysql_insertid'};
1413
    my $subscriptionid = $dbh->{'mysql_insertid'};
(-)a/Koha/DateUtils.pm (-1 / +30 lines)
Lines 18-30 package Koha::DateUtils; Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
use DateTime;
20
use DateTime;
21
use Date::Calc qw( Day_of_Week );
21
use C4::Context;
22
use C4::Context;
22
use Koha::Exceptions;
23
use Koha::Exceptions;
23
24
24
use base 'Exporter';
25
use base 'Exporter';
25
26
26
our @EXPORT = (
27
our @EXPORT = (
27
    qw( dt_from_string output_pref format_sqldatetime )
28
    qw( dt_from_string output_pref format_sqldatetime issue_number )
28
);
29
);
29
30
30
=head1 DateUtils
31
=head1 DateUtils
Lines 317-320 sub format_sqldatetime { Link Here
317
    return q{};
318
    return q{};
318
}
319
}
319
320
321
=head2 issue_number
322
323
my $week_number = issue_number('2017-01-01', 'week');
324
325
=cut
326
327
sub issue_number {
328
    my ($date, $issue_type) = @_;
329
330
    unless ( ref($date) eq 'DateTime' ) {
331
        Koha::Exceptions::WrongParameter->throw("Date passed to issue_number is not a valid DateTime object" );
332
    }
333
334
    if ($issue_type eq 'day') {
335
        return Day_of_Week(split /-/, $date->ymd);
336
    }
337
338
    if ($issue_type eq 'week') {
339
        return $date->week_number;
340
    }
341
342
    if ($issue_type eq 'month') {
343
        return $date->month;
344
    }
345
346
    return 0;
347
}
348
320
1;
349
1;
(-)a/Koha/Subscription.pm (+24 lines)
Lines 106-111 sub remove_subscriber { Link Here
106
    $subscriber->delete if $subscriber;
106
    $subscriber->delete if $subscriber;
107
}
107
}
108
108
109
=head2 irregularities
110
111
Returns an array containing irregularities
112
113
=cut
114
115
sub irregularities {
116
    my ($self) = @_;
117
118
    return split(';', $self->irregularity);
119
}
120
121
=head2 permanent_irregularities
122
123
Returns an array containing permanent irregularities
124
125
=cut
126
127
sub permanent_irregularities {
128
    my ($self) = @_;
129
130
    return split(';', $self->permanent_irregularity);
131
}
132
109
=head3 type
133
=head3 type
110
134
111
=cut
135
=cut
(-)a/installer/data/mysql/atomicupdate/Bug_17656-add-permanent-irregularities.sql (+1 lines)
Line 0 Link Here
1
ALTER TABLE `subscription` ADD permanent_irregularity text AFTER irregularity;
(-)a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css (+6 lines)
Lines 3319-3321 span.name { Link Here
3319
    margin: auto;
3319
    margin: auto;
3320
    margin-bottom: 2px;
3320
    margin-bottom: 2px;
3321
}
3321
}
3322
3323
.week-columns{
3324
    -moz-column-count: 2; /* Firefox */
3325
    -webkit-column-count: 2; /* Safari and Chrome */
3326
    column-count: 3;
3327
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_daily_choice.inc (+21 lines)
Line 0 Link Here
1
<p><em>
2
    If there is a day (or more) in the week where issues are never
3
    published, you can check corresponding boxes below.
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} ] %]
6
7
[% FOREACH day IN daily_choice %]
8
    [% IF permanent_irreg.grep( day.value ).0 == day.value %]
9
        <input type="checkbox" name="permanent_irregularity"
10
               id="[% day.name %]" data-dow="[% day.value %]"
11
               value="[% day.value %]" class="skip"
12
               checked="checked"
13
        />
14
    [% ELSE %]
15
        <input type="checkbox" name="permanent_irregularity"
16
               id="[% day.name %]" data-dow="[% day.value %]"
17
               value="[% day.value %]" class="skip"
18
        />
19
    [% END %]
20
    <label for="[% day.name %]">[% day.desc %]</label>
21
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_monthly_choice.inc (+21 lines)
Line 0 Link Here
1
<p><em>
2
    If there is a month (or more) in the year where issues are never
3
    published, you can check corresponding boxes below.
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} ] %]
6
7
[% FOREACH month IN monthly_choice %]
8
    [% IF permanent_irreg.grep( month.value ).0 == month.value %]
9
        <input type="checkbox" name="permanent_irregularity"
10
               id="[% month.name %]" data-dow="[% month.value %]"
11
               value="[% month.value %]" class="skip"
12
               checked="checked"
13
        />
14
    [% ELSE %]
15
        <input type="checkbox" name="permanent_irregularity"
16
               id="[% month.name %]" data-dow="[% month.value %]"
17
               value="[% month.value %]" class="skip"
18
        />
19
    [% END %]
20
    <label for="[% month.name %]">[% month.desc %]</label>
21
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials/subscription_weekly_choice.inc (+28 lines)
Line 0 Link Here
1
<div class="row select-weeks">
2
    <div class="col-lg-12">
3
        <div class="button-group">
4
            <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
5
                Week(s) not published
6
                <span class="caret"></span>
7
            </button>
8
            <ul class="dropdown-menu week-columns">
9
                [% FOREACH p IN predictions_loop %]
10
                    <li>
11
                        <a href="#" class="small">
12
                            [% IF permanent_irreg.grep( p.dow ).0 == p.dow %]
13
                                <input type="checkbox" name="permanent_irregularity" value="[% p.dow %]" data-dow="[% p.dow %]" class="skip" checked="checked"/>
14
                            [% ELSE %]
15
                                <input type="checkbox" name="permanent_irregularity" value="[% p.dow %]" data-dow="[% p.dow %]" class="skip"/>
16
                            [% END %]
17
                            &nbsp;Week <b>#[% p.dow %]</b> ([% p.publicationdate | $KohaDates %])
18
                        </a>
19
                    </li>
20
                [% END %]
21
            </ul>
22
        </div>
23
    </div>
24
</div>
25
<p>
26
    <em>Choice the week(s) in the year where issues are never
27
    published.</em>
28
</p>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt (-19 / +15 lines)
Lines 5-29 Link Here
5
[% END %]
5
[% END %]
6
[% IF (ask_for_irregularities) %]
6
[% IF (ask_for_irregularities) %]
7
    <p><em>Please check issues that are NOT published (irregularities)</em></p>
7
    <p><em>Please check issues that are NOT published (irregularities)</em></p>
8
    [% IF (daily_options) %]
8
    [% IF (show_irregularity_options) %]
9
        <p><em>
9
        <script type="text/javascript">
10
            If there is a day (or more) in the week where issues are never
10
        //<![CDATA[
11
            published, you can check corresponding boxes below.
11
        $(document).ready(function(){
12
        </em></p>
12
            Check_permanent_irregularities();
13
        <input type="checkbox" id="monday" data-dow="1" class="skipday" />
13
        });
14
        <label for="monday">Monday</label>
14
        //]]>
15
        <input type="checkbox" id="tuesday" data-dow="2" class="skipday" />
15
        </script>
16
        <label for="tuesday">Tuesday</label>
16
        [% IF (show_irregularity_options == 'day') %]
17
        <input type="checkbox" id="wednesday" data-dow="3" class="skipday" />
17
            [% INCLUDE 'serials/subscription_daily_choice.inc' %]
18
        <label for="wednesday">Wednesday</label>
18
        [% ELSIF (show_irregularity_options == 'month') %]
19
        <input type="checkbox" id="thursday" data-dow="4" class="skipday" />
19
            [% INCLUDE 'serials/subscription_monthly_choice.inc' %]
20
        <label for="thursday">Thursday</label>
20
        [% ELSIF (show_irregularity_options == 'week') %]
21
        <input type="checkbox" id="friday" data-dow="5" class="skipday" />
21
            [% INCLUDE 'serials/subscription_weekly_choice.inc' %]
22
        <label for="friday">Friday</label>
22
        [% END %]
23
        <input type="checkbox" id="saturday" data-dow="6" class="skipday" />
24
        <label for="saturday">Saturday</label>
25
        <input type="checkbox" id="sunday" data-dow="7" class="skipday" />
26
        <label for="sunday">Sunday</label>
27
    [% END %]
23
    [% END %]
28
[% END %]
24
[% END %]
29
[% IF (predictions_loop) %]
25
[% IF (predictions_loop) %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/showpredictionpattern.js (-1 / +20 lines)
Lines 9-16 function Check_boxes(dow) { Link Here
9
        });
9
        });
10
    }
10
    }
11
}
11
}
12
function Check_permanent_irregularities() {
13
    nothing_checked = 1;
14
    $("input[name='irregularity']").each(function() {
15
        if ($(this).is(':checked')) {
16
            nothing_checked = 0;
17
        }
18
    });
19
20
    // No day/month/week are checked, could be after a renewal.
21
    // So check them according to permanent irregularity
22
    if (nothing_checked) {
23
        $(".skip").each(function() {
24
            console.log('iciiiiiiiiiiiiii');
25
            if ($(this).is(':checked')) {
26
                Check_boxes( $(this).data("dow"));
27
            }
28
        });
29
    }
30
}
12
$(document).ready(function(){
31
$(document).ready(function(){
13
    $("#displayexample").on("change",".skipday",function(){
32
    $("#displayexample").on("change",".skip",function(){
14
        Check_boxes( $(this).data("dow"));
33
        Check_boxes( $(this).data("dow"));
15
    });
34
    });
16
});
35
});
(-)a/serials/showpredictionpattern.pl (-5 / +10 lines)
Lines 112-126 if(defined $subscriptionid) { Link Here
112
112
113
my @predictions_loop;
113
my @predictions_loop;
114
my ($calculated) = GetSeq(\%subscription, \%pattern);
114
my ($calculated) = GetSeq(\%subscription, \%pattern);
115
my $dow = issue_number( dt_from_string($date), $frequency->{unit} );
115
push @predictions_loop, {
116
push @predictions_loop, {
116
    number => $calculated,
117
    number => $calculated,
117
    publicationdate => $date,
118
    publicationdate => $date,
118
    issuenumber => $issuenumber,
119
    issuenumber => $issuenumber,
119
    dow => Day_of_Week(split /-/, $date),
120
    dow => $dow,
120
};
121
};
121
my @irreg = ();
122
my @irreg = ();
123
my @permanent_irreg = ();
122
if(defined $subscriptionid) {
124
if(defined $subscriptionid) {
123
    @irreg = C4::Serials::GetSubscriptionIrregularities($subscriptionid);
125
    my $subscription_o = Koha::Subscriptions->find($subscriptionid);
126
    @irreg = $subscription_o->irregularities;
127
    @permanent_irreg = $subscription_o->permanent_irregularities;
124
    while(@irreg && $issuenumber > $irreg[0]) {
128
    while(@irreg && $issuenumber > $irreg[0]) {
125
        shift @irreg;
129
        shift @irreg;
126
    }
130
    }
Lines 139-145 while( $i < 1000 ) { Link Here
139
    }
143
    }
140
    if(defined $date){
144
    if(defined $date){
141
        $line{'publicationdate'} = $date;
145
        $line{'publicationdate'} = $date;
142
        $line{'dow'} = Day_of_Week(split /-/, $date);
146
        $line{dow} = issue_number( dt_from_string($date), $frequency->{unit} );
143
    }
147
    }
144
148
145
    # Check if we don't have exceed end date
149
    # Check if we don't have exceed end date
Lines 175-182 $template->param( Link Here
175
179
176
if ( $frequency->{unit} and not $custompattern ) {
180
if ( $frequency->{unit} and not $custompattern ) {
177
    $template->param( ask_for_irregularities => 1 );
181
    $template->param( ask_for_irregularities => 1 );
178
    if ( $frequency->{unit} eq 'day' and $frequency->{unitsperissue} == 1 ) {
182
    if ( $frequency->{unit} =~ /^(day|month|week)$/ and $frequency->{unitsperissue} == 1 ) {
179
        $template->param( daily_options => 1 );
183
        $template->param( show_irregularity_options => $frequency->{unit} );
184
        $template->param( permanent_irreg => \@permanent_irreg );
180
    }
185
    }
181
}
186
}
182
187
(-)a/serials/subscription-add.pl (-3 / +6 lines)
Lines 293-298 sub redirect_add_subscription { Link Here
293
    my $aqbudgetid     = $query->param('aqbudgetid');
293
    my $aqbudgetid     = $query->param('aqbudgetid');
294
    my $periodicity    = $query->param('frequency');
294
    my $periodicity    = $query->param('frequency');
295
    my @irregularity   = $query->multi_param('irregularity');
295
    my @irregularity   = $query->multi_param('irregularity');
296
    my @permanent_irregularity = $query->multi_param('permanent_irregularity');
296
    my $numberpattern  = $query->param('numbering_pattern');
297
    my $numberpattern  = $query->param('numbering_pattern');
297
    my $locale         = $query->param('locale');
298
    my $locale         = $query->param('locale');
298
    my $graceperiod    = $query->param('graceperiod') || 0;
299
    my $graceperiod    = $query->param('graceperiod') || 0;
Lines 340-347 sub redirect_add_subscription { Link Here
340
        $startdate, $periodicity, $numberlength, $weeklength,
341
        $startdate, $periodicity, $numberlength, $weeklength,
341
        $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
342
        $monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2,
342
        $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate,
343
        $lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate,
343
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
344
        join(";",@irregularity), join(';', @permanent_irregularity), $numberpattern, $locale,
344
        $manualhistory, $internalnotes, $serialsadditems,
345
        $callnumber, $manualhistory, $internalnotes, $serialsadditems,
345
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
346
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
346
        $skip_serialseq, $itemtype, $previousitemtype
347
        $skip_serialseq, $itemtype, $previousitemtype
347
    );
348
    );
Lines 356-361 sub redirect_add_subscription { Link Here
356
sub redirect_mod_subscription {
357
sub redirect_mod_subscription {
357
    my $subscriptionid = $query->param('subscriptionid');
358
    my $subscriptionid = $query->param('subscriptionid');
358
    my @irregularity = $query->multi_param('irregularity');
359
    my @irregularity = $query->multi_param('irregularity');
360
    my @permanent_irregularity = $query->multi_param('permanent_irregularity');
359
    my $auser = $query->param('user');
361
    my $auser = $query->param('user');
360
    my $librarian => scalar $query->param('librarian'),
362
    my $librarian => scalar $query->param('librarian'),
361
    my $branchcode = $query->param('branchcode');
363
    my $branchcode = $query->param('branchcode');
Lines 422-428 sub redirect_mod_subscription { Link Here
422
    ModSubscription(
424
    ModSubscription(
423
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
425
        $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate,
424
        $periodicity, $firstacquidate, join(";",@irregularity),
426
        $periodicity, $firstacquidate, join(";",@irregularity),
425
        $numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1,
427
        join(';', @permanent_irregularity), $numberpattern, $locale,
428
        $numberlength, $weeklength, $monthlength, $lastvalue1,
426
        $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3,
429
        $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3,
427
        $status, $biblionumber, $callnumber, $notes, $letter,
430
        $status, $biblionumber, $callnumber, $notes, $letter,
428
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
431
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
(-)a/t/Koha/DateUtils.t (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 9;
21
use Test::Warn;
22
23
BEGIN {
24
    use_ok('Koha::DateUtils');
25
}
26
27
my $dt = DateTime->new(year => 2017, month => 1, day => 1);
28
29
eval { issue_number('2017', 'day'); };
30
is($@, 'Date passed to issue_number is not a valid DateTime object');
31
32
is(issue_number($dt, 'day'), 7, '2017-01-01 is the seventh day of week');
33
34
is(issue_number($dt, 'week'), 52, '2017-01-01 is the week #52 of the year');
35
36
is(issue_number($dt, 'month'), 1, '2017-01-01 is the first month of the year');
37
38
$dt = DateTime->new(year => 2022, month => 9, day => 17);
39
40
is(issue_number($dt, 'day'), 6, '2022-09-17 is the sixth day of week');
41
42
is(issue_number($dt, 'week'), 37, '2022-09-17 is the week #37 of the year');
43
44
is(issue_number($dt, 'month'), 9, '2017-09-17 is the ninth month of the year');
45
46
is(issue_number($dt, 'foo'), 0, 'issue_number return 0 for others issue type');
(-)a/t/db_dependent/Serials/SubscriptionIrregularity.t (-1 / +35 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use t::lib::TestBuilder;
6
use Test::More tests => 6;
7
8
use Koha::Database;
9
10
use_ok('Koha::Subscription');
11
12
my $schema = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
14
15
my $builder = t::lib::TestBuilder->new();
16
17
my $subscription = $builder->build({
18
    source => 'Subscription',
19
    value  => {
20
        irregularity => '2;4;7',
21
        permanent_irregularity => '1;2'
22
    },
23
});
24
25
my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid});
26
my @irreg = $subscription_o->irregularities;
27
is($irreg[0], 2, 'First element of irregularities is 2');
28
is($irreg[1], 4, 'Second element of irregularities is 4');
29
is($irreg[2], 7, 'Third element of irregularities is 7');
30
31
my @permanent_irreg = $subscription_o->permanent_irregularities;
32
is($permanent_irreg[0], 1, 'First element of permanent_irregularities is 1');
33
is($permanent_irreg[1], 2, 'Second element of permanent_irregularities is 2');
34
35
$schema->storage->txn_rollback;

Return to bug 17656