From 005a872869f6bc6131911422f96172729b919e32 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= Date: Fri, 1 Apr 2022 14:13:47 +0000 Subject: [PATCH] Bug 32392: Enable skipping forward issues when receiving serials. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds the ability to skip forward issues when receiving and generating the next issue from both the serial receive page and serial collection page. To test: 1. Apply patch. 2. Set up a subscription for a bib record. 3. Go to Serials -> Search your subscription -> Serial receive 4. Note that below last expected issue there will be checkbox to toggle a field to specify how many issues to skip when recieving and generating the next. 5. On serials-collection page there is also a button 'Skip issues and generate next'. When pressed will open a modal promting how many issues to skip. 6. Generate issues with different values and make sure the correct issue is generated. ​Sponsored-by: Lund University Library Sponsored-by: Bibliotek Mellansjö, Sweden Co-authored-by: Johan Sahlberg Signed-off-by: Marie Hedbom Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- C4/Serials.pm | 15 +++++---- .../includes/modals/serials_skip_issues.inc | 29 +++++++++++++++++ .../en/modules/serials/serials-collection.tt | 5 +++ .../prog/en/modules/serials/serials-edit.tt | 31 +++++++++++++++++++ serials/serials-collection.pl | 8 +++-- serials/serials-edit.pl | 7 ++++- 6 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/serials_skip_issues.inc diff --git a/C4/Serials.pm b/C4/Serials.pm index dccfa6c155..ce1b22f502 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -815,7 +815,7 @@ sub GetPreviousSerialid { my ( $nextseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 - ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate ); + ) = GetNextSeq( $subscription, $pattern, $frequency, $planneddate, $count_forward ); $subscription is a hashref containing all the attributes of the table 'subscription'. @@ -823,18 +823,19 @@ $pattern is a hashref containing all the attributes of the table 'subscription_numberpatterns'. $frequency is a hashref containing all the attributes of the table 'subscription_frequencies' $planneddate is a date string in iso format. +$count_forward is the number of issues to count forward, defaults to 1 if omitted This function get the next issue for the subscription given on input arg =cut sub GetNextSeq { - my ($subscription, $pattern, $frequency, $planneddate) = @_; + my ($subscription, $pattern, $frequency, $planneddate, $count_forward) = @_; return unless ($subscription and $pattern); my ( $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ); - my $count = 1; + my $count = $count_forward ? $count_forward : 1; if ($subscription->{'skip_serialseq'}) { my @irreg = split /;/, $subscription->{'irregularity'}; @@ -1074,7 +1075,7 @@ sub ModSubscriptionHistory { =head2 ModSerialStatus ModSerialStatus($serialid, $serialseq, $planneddate, $publisheddate, - $publisheddatetext, $status, $notes); + $publisheddatetext, $status, $notes, $count_forward); This function modify the serial status. Serial status is a number.(eg 2 is "arrived") Note : if we change from "waited" to something else,then we will have to create a new "waited" entry @@ -1083,10 +1084,12 @@ Note : if we change from "waited" to something else,then we will have to create sub ModSerialStatus { my ($serialid, $serialseq, $planneddate, $publisheddate, $publisheddatetext, - $status, $notes) = @_; + $status, $notes, $count_forward) = @_; return unless ($serialid); + my $count = $count_forward ? $count_forward : 1; + #It is a usual serial # 1st, get previous status : my $dbh = C4::Context->dbh; @@ -1155,7 +1158,7 @@ sub ModSerialStatus { $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ) - = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate ); + = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate, $count ); # next date (calculated from actual date & frequency parameters) my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency, 1); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/serials_skip_issues.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/serials_skip_issues.inc new file mode 100644 index 0000000000..86700511a8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/serials_skip_issues.inc @@ -0,0 +1,29 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index ea9775f66a..d28b403f60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -37,6 +37,8 @@ [% INCLUDE 'modals/serials_multi_receiving.inc' %] + [% INCLUDE 'modals/serials_skip_issues.inc' %] + [% UNLESS ( popup ) %] [% INCLUDE 'serials-toolbar.inc' %] @@ -182,6 +184,9 @@
+
+ +
[% IF ( subscriptions.size == 1 and !serialsadditems ) %] 
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt index b20db8cba4..5b25284910 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt @@ -12,6 +12,26 @@ $('#multi_receiving').on('show', function () { $(this).find(".modal-body").html($(".serials_multi_receiving")[0].outerHTML); }); + + $("form").on("submit", function(){ + let issues = $('input[name="skip_issues"]').val() ? $('input[name="skip_issues"]').val() : ''; + let too_many = _("Choose a value between 0-10 in issues to skip!"); + let no_number = _("Not a number in skip issues!"); + + if ( issues == '' || ( issues.match(/^\d+$/) && issues <= 10 ) ) { + return true; + } + else if ( issues.match(/^\d+$/) && issues > 10 ) { + alert(too_many); + return false; + } else if ( !issues.match(/^\d+$/) ) { + alert(no_number); + return false; + } + else { + return false; + } + }); }); function popup(subscriptionid) { @@ -62,6 +82,14 @@ $(document).ready(function() { } return true; }); + + $("#toggle_skip_issues").on("change", function() { + if (this.checked) { + $("#skip_issues").removeClass("collapse").prop("disabled", false); + } else { + $("#skip_issues").addClass("collapse").prop("disabled", true); + } + }); }); //]]> @@ -327,6 +355,9 @@ $(document).ready(function() { [% END %] [% END %] [% END %] + + Skip issues: + [% FOREACH newserialloo IN newserialloop %] [% UNLESS ( newserialloo.subscriptionexpired ) %] diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 4a6c8ba2f4..a5ca8b7154 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -46,13 +46,15 @@ my ($template, $loggedinuser, $cookie) }); my $biblionumber = $query->param('biblionumber'); my @subscriptionid = $query->multi_param('subscriptionid'); +my $skip_issues = $query->param('skip_issues') || 0; +my $count_forward = int $skip_issues + 1; @subscriptionid= uniq @subscriptionid; @subscriptionid= sort @subscriptionid; my $subscriptiondescs; my $subscriptions; -if($op eq 'gennext' && @subscriptionid){ +if($op eq 'cud-gennext' && @subscriptionid){ my $subscriptionid = $subscriptionid[0]; my $sth = $dbh->prepare(" SELECT publisheddate, publisheddatetext, serialid, serialseq, @@ -69,7 +71,7 @@ if($op eq 'gennext' && @subscriptionid){ my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate}; ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, $planneddate, $issue->{publisheddate}, - $issue->{publisheddatetext}, $status, "" ); + $issue->{publisheddatetext}, $status, "", $count_forward ); } else { require C4::Serials::Numberpattern; my $subscription = GetSubscription($subscriptionid); @@ -79,7 +81,7 @@ if($op eq 'gennext' && @subscriptionid){ my ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 - ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}); + ) = GetNextSeq($subscription, $pattern, $frequency, $expected->{publisheddate}, $count_forward); ## We generate the next publication date my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, $frequency, 1); diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 6acefa5918..ef30c4eae8 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -90,6 +90,10 @@ my @status = $query->multi_param('status'); my @notes = $query->multi_param('notes'); my @subscriptionids = $query->multi_param('subscriptionid'); my $op = $query->param('op'); +my $skip_issues = $query->param('skip_issues') || 0; + +my $count_forward = $skip_issues + 1; + if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) { @subscriptionids = split( /,/, $subscriptionids[0] ); } @@ -241,7 +245,8 @@ if ( $op and $op eq 'cud-serialchangestatus' ) { $pub_date, $publisheddatetexts[$i], $status[$i], - $notes[$i] + $notes[$i], + $count_forward ); } my $makePreviousSerialAvailable = C4::Context->preference('makePreviousSerialAvailable'); -- 2.39.5