From 429be6878cc533879b065d84de1b5822881009e1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 16 Apr 2018 18:56:06 -0300 Subject: [PATCH] Bug 18327: Add the ability to set the received date to today on multi receiving serials When receiving several issues for a subscription (Serials > Serial collection > Multi receiving), the reception date is always identical to the publication date. In some use cases we would like to set this "date received" value to today. Note: "date received" refers to the DB column serial.planneddate To make this possible this patch replaces the JS prompt with a modal dialog asking for 1. the number of issues to receive 2. if the received date must be set to today Ergonomic note: bootstrap styled buttons are used, but they do not display correctly We may need to improve that (later) Test plan: - Receive 1 or more serials using the "Multi receiving" buttons Note that this button appears twice, on the "serial collection information" and the "serial edition" pages - Try with and without the new checkbox ticked and confirm the behaviour is correct (i.e. date received is set to today or set to the publish date) - Make sure "Edit serials" and "Generate next" buttons still work as before --- .../prog/en/modules/serials/serials-collection.tt | 51 ++++++++++++++++++---- serials/serials-collection.pl | 9 +++- 2 files changed, 50 insertions(+), 10 deletions(-) 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 c00c7beb13..7f26f8b867 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 @@ -21,6 +21,38 @@
+ + + [% UNLESS ( popup ) %] [% INCLUDE 'serials-toolbar.inc' %] @@ -112,10 +144,12 @@
[% IF ( CAN_user_serials_receive_serials ) %]

-   +

[% UNLESS subscription.closed %] - - [% IF ( subscriptions.size == 1 and !serialsadditems ) %] [% END %] +
+ [% IF ( subscriptions.size == 1 and !serialsadditems ) %]  + + [% END %] [% END %]

[% END %] @@ -273,12 +307,9 @@ [% Asset.js("js/serials-toolbar.js") %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] + diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index ed102c2a22..a4fd91d906 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -28,12 +28,15 @@ use C4::Letters; use C4::Output; use C4::Context; +use Koha::DateUtils qw( dt_from_string ); + use List::MoreUtils qw/uniq/; my $query = new CGI; my $op = $query->param('op') || q{}; my $nbissues=$query->param('nbissues'); +my $date_received_today = $query->param('date_received_today') || 0; my $dbh = C4::Context->dbh; my ($template, $loggedinuser, $cookie) @@ -66,8 +69,9 @@ if($op eq 'gennext' && @subscriptionid){ $sth->execute($subscriptionid); # modify actual expected issue, to generate the next if ( my $issue = $sth->fetchrow_hashref ) { + my $planneddate = $date_received_today ? dt_from_string : $issue->{planneddate}; ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, - $issue->{planneddate}, $issue->{publisheddate}, + $planneddate, $issue->{publisheddate}, $issue->{publisheddatetext}, $status, "" ); } else { require C4::Serials::Numberpattern; @@ -81,9 +85,10 @@ if($op eq 'gennext' && @subscriptionid){ ## We generate the next publication date my $nextpublisheddate = GetNextDate($subscription, $expected->{publisheddate}, 1); + my $planneddate = $date_received_today ? dt_from_string : $nextpublisheddate; ## Creating the new issue NewIssue( $newserialseq, $subscriptionid, $subscription->{'biblionumber'}, - 1, $nextpublisheddate, $nextpublisheddate ); + 1, $planneddate, $nextpublisheddate ); ## Updating the subscription seq status my $squery = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? -- 2.11.0