Bugzilla – Attachment 102123 Details for
Bug 25020
Extending due dates to a specified date should preserve time portion of original due date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25020: Preserve time part when batch extending due dates
Bug-25020-Preserve-time-part-when-batch-extending-.patch (text/plain), 5.22 KB, created by
David Nind
on 2020-03-31 11:26:53 UTC
(
hide
)
Description:
Bug 25020: Preserve time part when batch extending due dates
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-03-31 11:26:53 UTC
Size:
5.22 KB
patch
obsolete
>From 303d8dd60c932db62ce7952b04cfb071c1705d7a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 30 Mar 2020 16:11:51 +0200 >Subject: [PATCH] Bug 25020: Preserve time part when batch extending due dates > >When selecting a new hard due date, we should keep the time part of the >original checkouts. > >Test plan: >1 - Checkout an item specifying a date due >2 - Checkout an item without specifying a date due >3 - Use Tools->Batch extend due date >4 - Select a hard due date >5 - On the confirmation screen you should see that the time part has >been kept >6 - Confirm >7 - Make sure the correct values hava been inserted in DB >8 - Try now using the other option, give a number of days >9 - Repeat 4-7 > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../en/modules/tools/batch_extend_due_dates.tt | 6 +-- > tools/batch_extend_due_dates.pl | 47 ++++++++++++++++++---- > 2 files changed, 40 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt >index 1286337220..e572b2b3d7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt >@@ -134,11 +134,7 @@ > <td>[% checkout.issuedate | $KohaDates %]</td> > <td>[% Branches.GetName( checkout.branchcode ) | html %]</td> > <td> >- [% IF new_hard_due_date %] >- [% new_hard_due_date | $KohaDates %] >- [% ELSE %] >- [% new_due_dates.shift | $KohaDates %] >- [% END %] >+ [% new_due_dates.shift | $KohaDates as_due_date => 1 %] > </td> > </tr> > [% END %] >diff --git a/tools/batch_extend_due_dates.pl b/tools/batch_extend_due_dates.pl >index caec5bd230..572e57bdc9 100755 >--- a/tools/batch_extend_due_dates.pl >+++ b/tools/batch_extend_due_dates.pl >@@ -25,7 +25,7 @@ use CGI; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use Koha::Checkouts; >-use Koha::DateUtils qw( dt_from_string ); >+use Koha::DateUtils qw( dt_from_string output_pref ); > > my $input = new CGI; > my $op = $input->param('op') // q|form|; >@@ -52,6 +52,8 @@ elsif ( $op eq 'list' ) { > my $new_hard_due_date = $input->param('new_hard_due_date'); > my $due_date_days = $input->param('due_date_days'); > >+ $new_hard_due_date &&= dt_from_string($new_hard_due_date); >+ > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > my $search_params; > if (@categorycodes) { >@@ -99,12 +101,17 @@ elsif ( $op eq 'list' ) { > ); > > my @new_due_dates; >- if ( not $new_hard_due_date && $due_date_days ) { >- while ( my $checkout = $checkouts->next ) { >- my $due_date = dt_from_string( $checkout->date_due ); >- push @new_due_dates, $due_date->add( days => $due_date_days ); >- } >+ while ( my $checkout = $checkouts->next ) { >+ push @new_due_dates, >+ output_pref({ dt => calc_new_due_date( >+ { >+ due_date => dt_from_string($checkout->date_due), >+ new_hard_due_date => $new_hard_due_date, >+ add_days => $due_date_days >+ } >+ ), dateformat => 'iso' }); > } >+ > $template->param( > checkouts => $checkouts, > new_hard_due_date => $new_hard_due_date >@@ -126,8 +133,13 @@ elsif ( $op eq 'modify' ) { > my $checkouts = > Koha::Checkouts->search( { issue_id => { -in => \@issue_ids } } ); > while ( my $checkout = $checkouts->next ) { >- my $new_due_date = $new_hard_due_date >- || dt_from_string( $checkout->date_due )->add( days => $due_date_days ); >+ my $new_due_date = calc_new_due_date( >+ { >+ due_date => dt_from_string($checkout->date_due), >+ new_hard_due_date => $new_hard_due_date, >+ add_days => $due_date_days >+ } >+ ); > > # Update checkout's due date > $checkout->date_due($new_due_date)->store; >@@ -142,4 +154,23 @@ elsif ( $op eq 'modify' ) { > ); > } > >+sub calc_new_due_date { >+ my ($params) = @_; >+ my $due_date = $params->{due_date}; >+ my $new_hard_due_date = $params->{new_hard_due_date}; >+ my $add_days = $params->{add_days}; >+ >+ my $new; >+ if ( $new_hard_due_date ) { >+ $new = $new_hard_due_date->clone->set( >+ hour => $due_date->hour, >+ minute => $due_date->minute, >+ second => $due_date->second, >+ ) >+ } else { >+ $new = $due_date->clone->add( days => $add_days ); >+ } >+ return $new; >+} >+ > output_html_with_http_headers $input, $cookie, $template->output; >-- >2.11.0
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 25020
:
102085
|
102123
|
102250
|
102251