Bug 32392: Enable skipping forward issues when receiving serials.
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 <johan.sahlberg@tidaholm.se> Signed-off-by: Marie Hedbom <marie.hedbom@musikverket.se> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
3f31f327cc
commit
005a872869
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<div id="skip_issues" class="modal" tabindex="-1" role="dialog" aria-labelledby="skip_issues_label" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form action="/cgi-bin/koha/serials/serials-collection.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<div class="modal-body">
|
||||
<fieldset class="rows">
|
||||
<legend>Skip issues and generate next</legend>
|
||||
<ol>
|
||||
<li>
|
||||
<label for="nbissues" class="required">How many issues do you want to skip?</label>
|
||||
<input type="text" pattern="^\d+$" size="10" id="skip_issues" name="skip_issues" required="required" />
|
||||
</li>
|
||||
</ol>
|
||||
<input type="hidden" name="op" value="cud-gennext" />
|
||||
|
||||
[%# subscriptionidlist is used from serials-collection, subscriptionid is used from serils-edit %]
|
||||
<input type="hidden" name="subscriptionid" value="[% subscriptionidlist || subscriptionid | html %]" />
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
|
||||
<input type="submit" class="btn btn-default approve" value="OK" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -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 @@
|
|||
<div class="btn-group">
|
||||
<input type="button" value="Generate next" data-subscriptionid="[% subscriptionidlist | html %]" class="btn btn-default btn-sm generatenext" />
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<input type="button" value="Skip issues and generate next" data-subscriptionid="[% subscriptionidlist | html %]" href="#skip_issues" class="btn btn-default btn-sm" data-toggle="modal" />
|
||||
</div>
|
||||
[% IF ( subscriptions.size == 1 and !serialsadditems ) %]
|
||||
<div class="btn-group"><input type="button" value="Multi receiving" href="#multi_receiving" class="btn btn-default btn-sm" data-toggle="modal"></div>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
|
|
@ -327,6 +355,9 @@ $(document).ready(function() {
|
|||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
<tr>
|
||||
<td colspan="6">Skip issues:<input type="checkbox" id="toggle_skip_issues"> <input id="skip_issues" type="text" pattern="^\d+$" name="skip_issues" class="collapse" value="1" disabled required="required"/></td>
|
||||
</tr>
|
||||
[% FOREACH newserialloo IN newserialloop %]
|
||||
[% UNLESS ( newserialloo.subscriptionexpired ) %]
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue