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

(-)a/C4/Serials.pm (-11 / +6 lines)
Lines 419-427 sub PrepareSerialsData { Link Here
419
419
420
    foreach my $subs (@{$lines}) {
420
    foreach my $subs (@{$lines}) {
421
        for my $datefield ( qw(publisheddate planneddate) ) {
421
        for my $datefield ( qw(publisheddate planneddate) ) {
422
            # handle both undef and undef returned as 0000-00-00
422
            # handle 0000-00-00 dates
423
            if (!defined $subs->{$datefield} or $subs->{$datefield}=~m/^00/) {
423
            if (defined $subs->{$datefield} and $subs->{$datefield} =~ m/^00/) {
424
                $subs->{$datefield} = 'XXX';
424
                $subs->{$datefield} = undef;
425
            }
425
            }
426
        }
426
        }
427
        $subs->{ "status" . $subs->{'status'} } = 1;
427
        $subs->{ "status" . $subs->{'status'} } = 1;
Lines 1235-1244 sub ModSerialStatus { Link Here
1235
        DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } );
1235
        DelIssue( { 'serialid' => $serialid, 'subscriptionid' => $subscriptionid, 'serialseq' => $serialseq } );
1236
    } else {
1236
    } else {
1237
1237
1238
        unless ($frequency->{'unit'}) {
1239
            if ( not $planneddate or $planneddate eq '0000-00-00' ) { $planneddate = C4::Dates->new()->output('iso') };
1240
            if ( not $publisheddate or $publisheddate eq '0000-00-00' ) { $publisheddate = C4::Dates->new()->output('iso') };
1241
        }
1242
        my $query = 'UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE  serialid = ?';
1238
        my $query = 'UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE  serialid = ?';
1243
        $sth = $dbh->prepare($query);
1239
        $sth = $dbh->prepare($query);
1244
        $sth->execute( $serialseq, $publisheddate, $planneddate, $status, $notes, $serialid );
1240
        $sth->execute( $serialseq, $publisheddate, $planneddate, $status, $notes, $serialid );
Lines 2532-2544 skipped then the returned date will be 2007-05-10 Link Here
2532
return :
2528
return :
2533
$resultdate - then next date in the sequence (ISO date)
2529
$resultdate - then next date in the sequence (ISO date)
2534
2530
2535
Return $publisheddate if subscription is irregular
2531
Return undef if subscription is irregular
2536
2532
2537
=cut
2533
=cut
2538
2534
2539
sub GetNextDate {
2535
sub GetNextDate {
2540
    my ( $subscription, $publisheddate, $updatecount ) = @_;
2536
    my ( $subscription, $publisheddate, $updatecount ) = @_;
2541
2537
2538
    return unless $subscription and $publisheddate;
2539
2542
    my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
2540
    my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
2543
2541
2544
    if ($freqdata->{'unit'}) {
2542
    if ($freqdata->{'unit'}) {
Lines 2676-2684 sub GetNextDate { Link Here
2676
        }
2674
        }
2677
        return sprintf("%04d-%02d-%02d", $year, $month, $day);
2675
        return sprintf("%04d-%02d-%02d", $year, $month, $day);
2678
    }
2676
    }
2679
    else {
2680
        return $publisheddate;
2681
    }
2682
}
2677
}
2683
2678
2684
=head2 _numeration
2679
=head2 _numeration
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt (-2 / +14 lines)
Lines 244-253 $(document).ready(function() { Link Here
244
                 <td><a href="serials-collection.pl?subscriptionid=[% serial.subscriptionid %]">[% serial.subscriptionid %]</a></td>
244
                 <td><a href="serials-collection.pl?subscriptionid=[% serial.subscriptionid %]">[% serial.subscriptionid %]</a></td>
245
[% END %]
245
[% END %]
246
                <td>
246
                <td>
247
                    <span title="[% serial.publisheddate %]">[% serial.publisheddate | $KohaDates %]</span>
247
                    <span title="[% serial.publisheddate %]">
248
                      [% IF serial.publisheddate %]
249
                        [% serial.publisheddate | $KohaDates %]
250
                      [% ELSE %]
251
                        Unknown
252
                      [% END %]
253
                    </span>
248
                </td>
254
                </td>
249
                <td>
255
                <td>
250
                    <span title="[% serial.planneddate %]">[% serial.planneddate | $KohaDates %]</span>
256
                    <span title="[% serial.planneddate %]">
257
                      [% IF serial.planneddate %]
258
                        [% serial.planneddate | $KohaDates %]
259
                      [% ELSE %]
260
                        Unknown
261
                      [% END %]
262
                    </span>
251
                </td>
263
                </td>
252
                <td>
264
                <td>
253
                    [% serial.serialseq %]
265
                    [% serial.serialseq %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-2 / +10 lines)
Lines 259-268 $(document).ready(function() { Link Here
259
                    [% serialslis.serialseq %]
259
                    [% serialslis.serialseq %]
260
                </td>
260
                </td>
261
                <td>
261
                <td>
262
                    [% serialslis.planneddate %]
262
                    [% IF serialslis.planneddate %]
263
                      [% serialslis.planneddate %]
264
                    [% ELSE %]
265
                      Unknown
266
                    [% END %]
263
                </td>
267
                </td>
264
                <td>
268
                <td>
265
                    [% serialslis.publisheddate %]
269
                    [% IF serialslis.publisheddate %]
270
                      [% serialslis.publisheddate %]
271
                    [% ELSE %]
272
                      Unknown
273
                    [% END %]
266
                </td>
274
                </td>
267
                <td>
275
                <td>
268
                    [% IF ( serialslis.status1 ) %]Expected[% END %]
276
                    [% IF ( serialslis.status1 ) %]Expected[% END %]
(-)a/misc/cronjobs/serialsUpdate.pl (-1 / +3 lines)
Lines 99-106 my $sth = $dbh->prepare( Link Here
99
     FROM serial 
99
     FROM serial 
100
     LEFT JOIN subscription 
100
     LEFT JOIN subscription 
101
       ON (subscription.subscriptionid=serial.subscriptionid) 
101
       ON (subscription.subscriptionid=serial.subscriptionid) 
102
     LEFT JOIN subscription_frequencies
103
       ON (subscription.periodicity = subscription_frequencies.id)
102
     WHERE serial.status = 1 
104
     WHERE serial.status = 1 
103
       AND periodicity <> 32
105
       AND subscription_frequencies.unit IS NOT NULL
104
       AND DATE_ADD(planneddate, INTERVAL CAST(graceperiod AS SIGNED) DAY) < NOW()
106
       AND DATE_ADD(planneddate, INTERVAL CAST(graceperiod AS SIGNED) DAY) < NOW()
105
       AND subscription.closed = 0
107
       AND subscription.closed = 0
106
    }
108
    }
(-)a/serials/showpredictionpattern.pl (-2 / +2 lines)
Lines 119-125 my @predictions_loop; Link Here
119
my ($calculated) = GetSeq(\%subscription, \%pattern);
119
my ($calculated) = GetSeq(\%subscription, \%pattern);
120
push @predictions_loop, {
120
push @predictions_loop, {
121
    number => $calculated,
121
    number => $calculated,
122
    publicationdate => ($frequency->{unit} ? $date : undef),
122
    publicationdate => $date,
123
    issuenumber => $issuenumber,
123
    issuenumber => $issuenumber,
124
    dow => Day_of_Week(split /-/, $date),
124
    dow => Day_of_Week(split /-/, $date),
125
};
125
};
Lines 143-149 while( $i < 1000 ) { Link Here
143
        $date = GetNextDate(\%subscription, $date);
143
        $date = GetNextDate(\%subscription, $date);
144
    }
144
    }
145
    if(defined $date){
145
    if(defined $date){
146
        $line{'publicationdate'} = $date if $frequency->{unit};
146
        $line{'publicationdate'} = $date;
147
        $line{'dow'} = Day_of_Week(split /-/, $date);
147
        $line{'dow'} = Day_of_Week(split /-/, $date);
148
    }
148
    }
149
149
(-)a/t/db_dependent/Serials/GetNextDate.t (-7 / +12 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use C4::Context;
3
use C4::Context;
4
use Test::More tests => 84;
4
use Test::More tests => 86;
5
use Modern::Perl;
5
use Modern::Perl;
6
6
7
my $dbh = C4::Context->dbh;
7
my $dbh = C4::Context->dbh;
Lines 471-477 is($publisheddate, '1974-01-01'); Link Here
471
# TEST CASE 25 - Irregular
471
# TEST CASE 25 - Irregular
472
$id = AddSubscriptionFrequency({
472
$id = AddSubscriptionFrequency({
473
    description => "Irregular",
473
    description => "Irregular",
474
    unit => '',
474
    unit => undef,
475
    issuesperunit => 1,
475
    issuesperunit => 1,
476
    unitsperissue => 1,
476
    unitsperissue => 1,
477
});
477
});
Lines 482-491 $subscription = { Link Here
482
    countissuesperunit => 1,
482
    countissuesperunit => 1,
483
};
483
};
484
$publisheddate = $subscription->{firstacquidate};
484
$publisheddate = $subscription->{firstacquidate};
485
# GetNextDate always return the same date if subscription is irregular
485
# GetNextDate always return undef if subscription is irregular
486
$publisheddate = GetNextDate($subscription, $publisheddate);
486
$publisheddate = GetNextDate($subscription, $publisheddate);
487
is($publisheddate, '1970-01-01');
487
is($publisheddate, undef);
488
$publisheddate = GetNextDate($subscription, $publisheddate);
488
489
is($publisheddate, '1970-01-01');
489
# GetNextDate returns undef if one of two first parameters is undef
490
$publisheddate = GetNextDate($subscription, undef);
491
is($publisheddate, undef);
492
$publisheddate = GetNextDate(undef, $subscription->{firstacquidate});
493
is($publisheddate, undef);
494
$publisheddate = GetNextDate(undef, undef);
495
is($publisheddate, undef);
490
496
491
$dbh->rollback;
497
$dbh->rollback;
492
- 

Return to bug 12003