From df06ce7e9b9ff81bb5528b40395aedaffda892af Mon Sep 17 00:00:00 2001
From: Aleisha Amohia
Date: Thu, 13 Dec 2018 03:12:30 +0000
Subject: [PATCH] Bug 22188: Use publication date as numbering pattern
Brimbank were trying to make a numbering pattern that displays the
publication date, but numbering patterns are calculated mathematically,
and dates are not always consistent and don't work that way. I've
written a feature that hardcodes an option to use the publication date
instead of a numbering pattern, in a 'Y M D' format.
To test:
1) Go to Serials
2) Click New subscription
3) Fill in the necessary details for the first page and click Next
4) Fill in the necessary details for the second page. Under numbering
pattern, select Number.
5) Notice the advanced pattern table shows. Put some random data in
these fields
6) Change numbering pattern to Use publication date. Confirm that
selecting this option hides the advanced pattern table and clears its fields.
7) Click Test prediction pattern and confirm the prediction pattern shows as expected
8) Save subscription
9) You should now be on the subscription detail page for your new
subscription. Go to the Planning tab and confirm that it says 'uses
publication date' under Number pattern and that there is now table
saying 'Starting with' and 'Rollover'
10) Go to the Issues tab and confirm the first serial is there with the
correct issue number (publication date).
11) Click the Receive button
12) Confirm the publication date shows under the Numbered column, in the
Issue text field and click Save
13) Click the Generate next button and confirm the alert box
14) Confirm the publication date shows under 'Number'
15) Find/make a subscription that uses a normal numbering pattern
16) Edit this subscription to now use the publication date as numbering
pattern
17) Upon saving, confirm that previously received serials keep their old
issue numbers
18) Click Receive and Generate next again and confirm that the next
serial now has the publication date
19) Confirm that making a subscription with a normal numbering pattern
works as expected. Upon saving, the table should show under the Planning
tab with 'Starting with' and 'Rollover' and all other fields should be
filled correctly.
Sponsored-by: Brimbank Libraries Australia
---
C4/Serials.pm | 29 ++-
.../en/modules/serials/subscription-add.tt | 1 +
.../en/modules/serials/subscription-detail.tt | 215 ++++++++++++++++++
.../intranet-tmpl/prog/js/subscription-add.js | 36 ++-
serials/serials-collection.pl | 15 +-
serials/showpredictionpattern.pl | 9 +
serials/subscription-add.pl | 9 +
7 files changed, 308 insertions(+), 6 deletions(-)
diff --git a/C4/Serials.pm b/C4/Serials.pm
index 1eae56bc8d..fcf0aaebe9 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -840,8 +840,13 @@ sub GetNextSeq {
}
}
- my $numberingmethod = $pattern->{numberingmethod};
my $calculated = "";
+ my $numberingmethod = "";
+ if ($pattern eq "pubdate"){
+ $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' );
+ } else {
+ $numberingmethod = $pattern->{numberingmethod};
+ }
if ($numberingmethod) {
$calculated = $numberingmethod;
my $locale = $subscription->{locale};
@@ -922,6 +927,10 @@ the sequence in string format
sub GetSeq {
my ($subscription, $pattern) = @_;
+ if ($pattern->{numberingmethod} eq ''){
+ return "pubdate";
+ }
+
return unless ($subscription and $pattern);
my $locale = $subscription->{locale};
@@ -1126,6 +1135,19 @@ sub ModSerialStatus {
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
+ my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1);
+ my ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
+ $newinnerloop1, $newinnerloop2, $newinnerloop3 );
+
+ if (!defined $pattern){
+ $pattern = "pubdate";
+ ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
+ $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $nextpublisheddate );
+ } else {
+ ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
+ $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate );
+ }
+
# next issue number
my (
$newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3,
@@ -1134,7 +1156,6 @@ sub ModSerialStatus {
= GetNextSeq( $subscription, $pattern, $frequency, $publisheddate );
# next date (calculated from actual date & frequency parameters)
- my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1);
my $nextpubdate = $nextpublisheddate;
$query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=?
WHERE subscriptionid = ?";
@@ -1454,6 +1475,10 @@ sub NewSubscription {
# calculate issue number
my $serialseq = GetSeq($subscription, $pattern) || q{};
+ if ($serialseq eq "pubdate"){
+ $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d');
+ }
+
Koha::Serial->new(
{
serialseq => $serialseq,
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
index 19d53a1c33..753212df2a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
@@ -370,6 +370,7 @@ fieldset.rows table { clear: none; margin: 0; }
[% numberpattern.label | html %]
[% END %]
+
Required
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
index e596aba702..2b49ff75f3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
@@ -82,6 +82,221 @@
[% END %]
+
+
+
+
+
+
Beginning date: [% startdate | html %]
+
+
Frequency:
+ [% frequency.description | html %]
+
+
+ Manual history:
+ [% IF ( manualhistory ) %]
+ Enabled Edit history
+ [% ELSE %]
+ Disabled
+ [% END %]
+
+
Number pattern:
+ [% IF ( numberpattern ) %]
+ [% numberpattern.label | html %]
+ [% ELSE %]
+ Uses publication date
+ [% END %]
+
+ [% IF ( numberpattern ) %]
+
+
+
Starting with:
+ [% IF (has_X) %]
+
[% lastvalue1 | html %]
+ [% END %]
+ [% IF (has_Y) %]
+
[% lastvalue2 | html %]
+ [% END %]
+ [% IF (has_Z) %]
+
[% lastvalue3 | html %]
+ [% END %]
+
+
+
Rollover:
+ [% IF (has_X) %]
+
[% numberpattern.whenmorethan1 | html %]
+ [% END %]
+ [% IF (has_Y) %]
+
[% numberpattern.whenmorethan2 | html %]
+ [% END %]
+ [% IF (has_Z) %]
+
[% numberpattern.whenmorethan3 | html %]
+ [% END %]
+
+
+ [% END %]
+ [% IF ( irregular_issues ) %]
+
Irregularity: [% irregular_issues | html %] issues
+
+ [% END %]
+
First arrival: [% firstacquidate | html %]
+
+ [% IF ( numberlength ) %]
Number of issues: [% numberlength | html %]
[% END %]
+ [% IF ( weeklength ) %]
Number of weeks: [% weeklength | html %]
[% END %]
+ [% IF ( monthlength ) %]
Number of months: [% monthlength | html %]
[% END %]
+
+
+
+
+
+
+
Numbering calculation
+
[% numberingmethod | html %]
+
+
+
+
X
+
Y
+
Z
+
+
+
Add
+
+ [% add1 | html %]
+
+
+ [% add2 | html %]
+
+
+ [% add3 | html %]
+
+
+
+
once every
+
[% every1 | html %]
+
[% every2 | html %]
+
[% every3 | html %]
+
+
+
When more than
+
[% whenmorethan1 | html %] [% IF ( innerloop1 ) %]
+ (is [% innerloop1 | html %])[% END %]
+
[% whenmorethan2 | html %] [% IF ( innerloop2 ) %]
+ (is [% innerloop2 | html %])[% END %]
+
[% whenmorethan3 | html %] [% IF ( innerloop3 ) %]
+ (is [% innerloop3 | html %])[% END %]
+
+
+
Set back to
+
[% setto1 | html %]
+
[% setto2 | html %]
+
[% setto3 | html %]
+
+
+
+ Inner counter
+
+
[% innerloop1 | html %]
+
[% innerloop2 | html %]
+
[% innerloop3 | html %]
+
+
+
+ Last value
+
+
[% lastvalue1 | html %]
+
[% lastvalue2 | html %]
+
[% lastvalue3 | html %]
+
+
+
+
+
+
+
Issue number
+
Planned date
+
Published date
+
Published date (text)
+
Status
+
+ [% FOREACH serialslis IN serialslist %]
+
+
+ [% serialslis.serialseq | html %]
+
+
+ [% IF serialslis.planneddate %]
+ [% serialslis.planneddate | html %]
+ [% ELSE %]
+ Unknown
+ [% END %]
+
+
+ [% IF serialslis.publisheddate %]
+ [% serialslis.publisheddate | html %]
+ [% ELSE %]
+ Unknown
+ [% END %]
+
+
+ [% serialslis.publisheddatetext | html %]
+
+
+ [% IF ( serialslis.status1 ) %]Expected[% END %]
+ [% IF ( serialslis.status2 ) %]Arrived[% END %]
+ [% IF ( serialslis.status3 ) %]Late[% END %]
+ [% IF ( serialslis.status4 ) %]Missing[% END %]
+ [% IF ( serialslis.status41 ) %]Missing (never received)[% END %]
+ [% IF ( serialslis.status42 ) %]Missing (sold out)[% END %]
+ [% IF ( serialslis.status43 ) %]Missing (damaged)[% END %]
+ [% IF ( serialslis.status44 ) %]Missing (lost)[% END %]
+ [% IF ( serialslis.status5 ) %]Not issued[% END %]
+ [% IF ( serialslis.status6 ) %]Delete[% END %]
+ [% IF ( serialslis.status7 ) %]
+ Claimed
+ [% IF ( serialslis.claimdate ) %]
+ [% serialslis.claimdate | html %]
+ [% END %]
+ [% END %]
+ [% IF ( serialslis.status8 ) %]Stopped[% END %]
+
+
+ [% END %]
+
+
+
+
+
+
+
+
Start date: [% startdate | html %]
+
End date: [% enddate | html %]
+
History start date: [% histstartdate | html %]
+
History end date: [% histenddate | html %]
+
Received issues:[% recievedlist | html | html_line_break %]
+
Missing issues:[% missinglist | html | html_line_break %]
+
Nonpublic note:[% internalnotes | html | html_line_break %]
+
Public note:[% notes | html | html_line_break %]
+
History staff note:[% librariannote | html | html_line_break %]
+
History OPAC note:[% opacnote | html | html_line_break %]