Bugzilla – Attachment 157009 Details for
Bug 22188
Use publication date as numbering pattern
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22188: Use publication date as numbering pattern
Bug-22188-Use-publication-date-as-numbering-patter.patch (text/plain), 22.86 KB, created by
Aleisha Amohia
on 2023-10-13 01:53:27 UTC
(
hide
)
Description:
Bug 22188: Use publication date as numbering pattern
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-10-13 01:53:27 UTC
Size:
22.86 KB
patch
obsolete
>From faa3f7900f3f09934fadadd95e7d494dd93a097a Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >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 1eae56bc8d1..fcf0aaebe9a 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 19d53a1c330..753212df2a4 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 %] > </option> > [% END %] >+ <option value="0">Use publication date</option> > </select> > <span class="required">Required</span> > </li> >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 e596aba7027..2b49ff75f37 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 @@ > </p> > </div> > [% END %] >+ <div id="subscription_planning"> >+ <div class="row"> >+ <div class="col-sm-12"> >+ <div class="rows"> >+ <ol> >+ <li><span class="label">Beginning date:</span> [% startdate | html %] >+ </li> >+ <li><span class="label">Frequency:</span> >+ [% frequency.description | html %] >+ </li> >+ <li> >+ <span class="label">Manual history: </span> >+ [% IF ( manualhistory ) %] >+ Enabled <a href="/cgi-bin/koha/serials/subscription-history.pl?subscriptionid=[% subscriptionid | uri %]">Edit history</a> >+ [% ELSE %] >+ Disabled >+ [% END %] >+ </li> >+ <li><span class="label">Number pattern:</span> >+ [% IF ( numberpattern ) %] >+ [% numberpattern.label | html %] >+ [% ELSE %] >+ Uses publication date >+ [% END %] >+ </li> >+ [% IF ( numberpattern ) %] >+ <li><table> >+ <tr> >+ <td>Starting with:</td> >+ [% IF (has_X) %] >+ <td align="center">[% lastvalue1 | html %]</td> >+ [% END %] >+ [% IF (has_Y) %] >+ <td align="center">[% lastvalue2 | html %]</td> >+ [% END %] >+ [% IF (has_Z) %] >+ <td align="center">[% lastvalue3 | html %]</td> >+ [% END %] >+ </tr> >+ <tr> >+ <td>Rollover:</td> >+ [% IF (has_X) %] >+ <td align="center">[% numberpattern.whenmorethan1 | html %]</td> >+ [% END %] >+ [% IF (has_Y) %] >+ <td align="center">[% numberpattern.whenmorethan2 | html %]</td> >+ [% END %] >+ [% IF (has_Z) %] >+ <td align="center">[% numberpattern.whenmorethan3 | html %]</td> >+ [% END %] >+ </tr> >+ </table></li> >+ [% END %] >+ [% IF ( irregular_issues ) %] >+ <li><span class="label">Irregularity:</span> [% irregular_issues | html %] issues >+ </li> >+ [% END %] >+ <li><span class="label">First arrival:</span> [% firstacquidate | html %] >+ </li> >+ [% IF ( numberlength ) %]<li><span class="label">Number of issues:</span> [% numberlength | html %]</li>[% END %] >+ [% IF ( weeklength ) %]<li><span class="label">Number of weeks:</span> [% weeklength | html %]</li>[% END %] >+ [% IF ( monthlength ) %]<li><span class="label">Number of months:</span> [% monthlength | html %]</li>[% END %] >+ </ol> >+ </div> >+ </div> >+ </div> >+ </div> >+ <div id="subscription_numbering" style="display:none;"> >+ <h3>Numbering calculation</h3> >+ <p><label>Numbering formula:</label> [% numberingmethod | html %]</p> >+ <table> >+ <tr> >+ <th> </th> >+ <th>X</th> >+ <th>Y</th> >+ <th>Z</th> >+ </tr> >+ <tr> >+ <td>Add</td> >+ <td> >+ [% add1 | html %] >+ </td> >+ <td> >+ [% add2 | html %] >+ </td> >+ <td> >+ [% add3 | html %] >+ </td> >+ </tr> >+ <tr> >+ <td>once every</td> >+ <td>[% every1 | html %]</td> >+ <td>[% every2 | html %]</td> >+ <td>[% every3 | html %]</td> >+ </tr> >+ <tr> >+ <td>When more than</td> >+ <td>[% whenmorethan1 | html %] [% IF ( innerloop1 ) %]<br /> >+ <i>(is [% innerloop1 | html %])</i>[% END %]</td> >+ <td>[% whenmorethan2 | html %] [% IF ( innerloop2 ) %]<br /> >+ <i>(is [% innerloop2 | html %])</i>[% END %]</td> >+ <td>[% whenmorethan3 | html %] [% IF ( innerloop3 ) %]<br /> >+ <i>(is [% innerloop3 | html %])</i>[% END %]</td> >+ </tr> >+ <tr> >+ <td>Set back to</td> >+ <td>[% setto1 | html %]</td> >+ <td>[% setto2 | html %]</td> >+ <td>[% setto3 | html %]</td> >+ </tr> >+ <tr> >+ <td> >+ Inner counter >+ </td> >+ <td>[% innerloop1 | html %]</td> >+ <td>[% innerloop2 | html %]</td> >+ <td>[% innerloop3 | html %]</td> >+ </tr> >+ <tr> >+ <td> >+ Last value >+ </td> >+ <td>[% lastvalue1 | html %]</td> >+ <td>[% lastvalue2 | html %]</td> >+ <td>[% lastvalue3 | html %]</td> >+ </tr> >+ </table> >+ </div> >+ <div id="subscription_issues"> >+ <table> >+ <tr> >+ <th>Issue number</th> >+ <th>Planned date</th> >+ <th>Published date</th> >+ <th>Published date (text)</th> >+ <th>Status</th> >+ </tr> >+ [% FOREACH serialslis IN serialslist %] >+ <tr> >+ <td> >+ [% serialslis.serialseq | html %] >+ </td> >+ <td> >+ [% IF serialslis.planneddate %] >+ [% serialslis.planneddate | html %] >+ [% ELSE %] >+ Unknown >+ [% END %] >+ </td> >+ <td> >+ [% IF serialslis.publisheddate %] >+ [% serialslis.publisheddate | html %] >+ [% ELSE %] >+ Unknown >+ [% END %] >+ </td> >+ <td> >+ [% serialslis.publisheddatetext | html %] >+ </td> >+ <td> >+ [% 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 %] >+ </td> >+ </tr> >+ [% END %] >+ </table> >+ </div> >+ <div id="subscription_summary"> >+ <div class="row"> >+ <div class="col-sm-12"> >+ <div class="rows"> >+ <ol> >+ <li><span class="label">Start date:</span> [% startdate | html %] </li> >+ <li><span class="label">End date:</span> [% enddate | html %]</li> >+ <li><span class="label">History start date:</span> [% histstartdate | html %] </li> >+ <li><span class="label">History end date:</span> [% histenddate | html %]</li> >+ <li><span class="label">Received issues:</span>[% recievedlist | html | html_line_break %]</li> >+ <li><span class="label">Missing issues:</span>[% missinglist | html | html_line_break %]</li> >+ <li><span class="label">Nonpublic note:</span>[% internalnotes | html | html_line_break %]</li> >+ <li><span class="label">Public note:</span>[% notes | html | html_line_break %]</li> >+ <li><span class="label">History staff note:</span>[% librariannote | html | html_line_break %]</li> >+ <li><span class="label">History OPAC note:</span>[% opacnote | html | html_line_break %]</li> >+ </ol> >+ </div> >+ </div> >+ </div> >+ </div> >+ >+ [% IF orders_grouped.size %] >+ <div id="acquisition_details"> >+ <h2>Acquisition details</h2> >+ <table id="orders"> >+ <caption> >+ <span class="actions"> >+ <a href="#" id="hide_received_orders">Hide already received orders</a> >+ | <a href="#" id="show_all_orders">Show all orders</a> >+ | <a href="#" id="expand_all">Expand all</a> >+ | <a href="#" id="collapse_all">Collapse all</a> >+ </span> >+ </caption> > > [% WRAPPER tabs id= "subscription_description" %] > [% WRAPPER tabs_nav %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >index ebf0977d470..f2293aa33c8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -252,6 +252,24 @@ function modifyAdvancedPattern() { > advancedpatternlocked = 0; > } > >+function clearAdvancedPattern() { >+ $("#patternname").prop('readOnly', false).val(''); >+ $("#numberingmethod").prop('readOnly', false).val(''); >+ >+ $("#advancedpredictionpatternt input").each(function() { >+ $(this).prop('readOnly', false).val(''); >+ }); >+ $("#advancedpredictionpatternt select").each(function() { >+ $(this).prop('disabled', false).val(''); >+ }); >+ >+ $("#restoreadvancedpatternbutton").hide(); >+ $("#saveadvancedpatternbutton").hide(); >+ $("#modifyadvancedpatternbutton").hide(); >+ >+ advancedpatternlocked = 1; >+} >+ > function restoreAdvancedPattern() { > $("#patternname").prop('readOnly', true).val(globalnumpatterndata.label); > $("#numberingmethod").prop('readOnly', true).val(globalnumpatterndata.numberingmethod); >@@ -553,6 +571,15 @@ function hidePredcitionPatternTest(){ > $("#page_2 > div").attr("class","col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"); > } > >+function usedatepattern() { >+ $("#more_options").hide(); >+ clearAdvancedPattern(); >+ if ($("#advancedpredictionpattern").is(":visible")){ >+ $("#advancedpredictionpattern").toggle(); >+ $(".toggle_advanced_pattern").toggle(); >+ } >+} >+ > $(document).ready(function() { > if ( mana_enabled == 1 ) { > mana_search(); >@@ -585,7 +612,12 @@ $(document).ready(function() { > }); > $("select#numberpattern").change(function(){ > patternneedtobetested = 1; >- numberpatternload(); >+ console.log($("select#numberpattern").val()); >+ if ($("select#numberpattern").val() == "0"){ >+ usedatepattern(); >+ } else { >+ numberpatternload(); >+ } > }); > $("#subtype").change(function(){ > $("input[name='enddate']").val(''); >@@ -634,7 +666,7 @@ $(document).ready(function() { > if($("#frequency").val() != ""){ > frequencyload(); > } >- if($("#numberpattern").val() != ""){ >+ if($("#numberpattern").val() != "0" && $("#numberpattern").val() != ""){ > numberpatternload(); > } > >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index 2179b830699..9edbbf33200 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -81,6 +81,10 @@ if($op eq 'gennext' && @subscriptionid){ > $newinnerloop1, $newinnerloop2, $newinnerloop3 > ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}); > >+ if (!defined $pattern && !defined $newserialseq){ >+ $newserialseq = $expected->{publisheddate}; >+ } >+ > ## We generate the next publication date > my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1); > my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate; >@@ -151,8 +155,11 @@ if (@subscriptionid){ > $location = $subs->{'location'}; > $callnumber = $subs->{callnumber}; > my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subs->{periodicity}); >- my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern}); > $subs->{frequency} = $frequency; >+ my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subs->{numberpattern}); >+ if (!defined $numberpattern){ >+ $numberpattern->{label} = "Uses publication date"; >+ } > $subs->{numberpattern} = $numberpattern; > $subs->{'hasRouting'} = check_routing($subscriptionid); > push @$subscriptiondescs,$subs; >@@ -171,7 +178,11 @@ if (@subscriptionid){ > my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($s->{periodicity}); > my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($s->{numberpattern}); > $s->{frequency} = $frequency; >- $s->{numberpattern} = $numberpattern; >+ if (!defined $numberpattern){ >+ $numberpattern->{label} = "pubdate"; >+ } else { >+ $s->{numberpattern} = $numberpattern; >+ } > } > my $subscriptioninformation = GetFullSubscriptionsFromBiblionumber($biblionumber); > $subscriptions=PrepareSerialsData($subscriptioninformation); >diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl >index 9fc801102be..d0aae17b586 100755 >--- a/serials/showpredictionpattern.pl >+++ b/serials/showpredictionpattern.pl >@@ -35,6 +35,7 @@ use Date::Calc qw( Add_Delta_Days Add_Delta_YM Day_of_Week Delta_Days ); > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Serials qw( GetSubscription GetFictiveIssueNumber GetSeq GetSubscriptionIrregularities GetNextDate GetNextSeq ); >+use POSIX qw(strftime); > use C4::Serials::Frequency; > use Koha::DateUtils qw( dt_from_string ); > >@@ -119,6 +120,11 @@ if(defined $subscriptionid) { > > my @predictions_loop; > my ($calculated) = GetSeq(\%subscription, \%pattern); >+ >+if ($calculated eq "pubdate"){ >+ $calculated = dt_from_string( $date )->strftime('%Y %B %d'); >+} >+ > push @predictions_loop, { > number => $calculated, > publicationdate => $date, >@@ -166,6 +172,9 @@ while( $i < 1000 ) { > ($calculated, $subscription{'lastvalue1'}, $subscription{'lastvalue2'}, $subscription{'lastvalue3'}, $subscription{'innerloop1'}, $subscription{'innerloop2'}, $subscription{'innerloop3'}) = GetNextSeq(\%subscription, \%pattern, $frequency); > $issuenumber++; > $line{'number'} = $calculated; >+ if ($calculated eq ''){ >+ $line{'number'} = dt_from_string( $date )->strftime('%Y %B %d'); >+ } > $line{'issuenumber'} = $issuenumber; > if(@irreg && $issuenumber == $irreg[0]){ > $line{'not_published'} = 1; >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index f8cbc572f23..ed4aa7b4bfd 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -349,6 +349,11 @@ sub redirect_add_subscription { > $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) > } > } >+ >+ if ($numberpattern == "0"){ # using publication date as numbering pattern >+ $numberpattern = undef; >+ } >+ > my $subscriptionid = NewSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, > $startdate, $periodicity, $numberlength, $weeklength, >@@ -467,6 +472,10 @@ sub redirect_mod_subscription { > $firstissuedate = $nextacquidate if($nextexpected->{isfirstissue}); > } > >+ if ($numberpattern == "0"){ # using publication date as numbering pattern >+ $numberpattern = undef; >+ } >+ > ModSubscription( > $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, > $periodicity, $firstacquidate, join(";",@irregularity), >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22188
:
84314
|
85415
|
85540
|
85541
|
85542
|
86419
|
87433
|
88830
|
91761
|
91762
|
92185
|
92186
|
92345
|
92364
|
94290
|
94291
|
156886
|
156887
|
156888
|
156889
|
156890
|
156891
| 157009 |
157010
|
157011
|
157012
|
157013
|
157014
|
157015
|
157179
|
158638
|
158659