From 3beea1db0690bd4b4b834758147001967db9b8fa Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 3 Feb 2020 01:31:14 +0000 Subject: [PATCH] Bug 24718: Get reservedate and expirationdate to use datetime Sponsored-by: Waikato Institute of Technology Signed-off-by: David Nind --- C4/Reserves.pm | 26 +++++++++++++++---- .../bug24718_use_datetime_for_reserves.perl | 15 +++++++++++ .../intranet-tmpl/prog/en/includes/holds_table.inc | 18 ++++++++----- .../prog/en/modules/reserve/request.tt | 30 +++++++++++++++++++--- 4 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug24718_use_datetime_for_reserves.perl diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9c040bdc12..ce8e6f1389 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -185,10 +185,26 @@ sub AddReserve { my $found = $params->{found}; my $itemtype = $params->{itemtype}; - $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) - or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); - - $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' }); + if ( C4::Context->preference('HourBasedHolds') ){ + if ( $resdate ){ + $resdate = dt_from_string( $resdate )->set_second( 00 ); + } else { + $resdate = dt_from_string(); + } + if ( $expdate ){ + $expdate = dt_from_string( $expdate )->set_second( 59 ); + } + } else { + # add hour and minute components + if ( $resdate ){ + $resdate = dt_from_string( $resdate )->set({ hour => 00, minute => 00, second => 00 }); + } else { + $resdate = dt_from_string(); + } + if ( $expdate ){ + $expdate = dt_from_string( $expdate )->set({ hour => 23, minute => 59, second => 59 }); + } + } # if we have an item selectionned, and the pickup branch is the same as the holdingbranch # of the document, we force the value $priority and $found . @@ -886,7 +902,7 @@ sub CancelExpiredReserves { my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay'); my $dtf = Koha::Database->new->schema->storage->datetime_parser; - my $params = { expirationdate => { '<', $dtf->format_date($today) } }; + my $params = { expirationdate => { '<', $today } }; $params->{found} = [ { '!=', 'W' }, undef ] unless $expireWaiting; # FIXME To move to Koha::Holds->search_expired (?) diff --git a/installer/data/mysql/atomicupdate/bug24718_use_datetime_for_reserves.perl b/installer/data/mysql/atomicupdate/bug24718_use_datetime_for_reserves.perl new file mode 100644 index 0000000000..f07fd091ed --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug24718_use_datetime_for_reserves.perl @@ -0,0 +1,15 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + if( column_exists( 'reserves', 'reservedate' ) ) { + $dbh->do(q{ALTER TABLE reserves MODIFY column reservedate datetime}); + } + + if( column_exists( 'reserves', 'expirationdate' ) ) { + $dbh->do(q{ALTER TABLE reserves MODIFY column expirationdate datetime}); + } + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24718 - Use datetime for reserves.reservedate and reserves.expirationdate)\n"; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 919ccdd9f8..fbe455fcc7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -106,15 +106,21 @@ [% hold.notes | html %] - + [% IF Koha.Preference('HourBasedHolds') %] [% IF Koha.Preference('AllowHoldDateInFuture') %] - + [% ELSE %] - [% hold.date | $KohaDates %] + [% hold.date | $KohaDates with_hours = 1 | html %] [% END %] - - - + + [% ELSE %] + [% IF Koha.Preference('AllowHoldDateInFuture') %] + + [% ELSE %] + [% hold.date | $KohaDates | html %] + [% END %] + + [% END %] [% IF ( hold.found ) %] [% IF ( hold.atdestination ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index acb9bd9139..f632e92cce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -435,7 +435,11 @@ [% IF ( reserve_in_future ) %]
  • - + [% IF Koha.Preference('HourBasedHolds') %] + + [% ELSE %] + + [% END %] Clear date
  • @@ -443,7 +447,11 @@
  • - + [% IF Koha.Preference('HourBasedHolds') %] + + [% ELSE %] + + [% END %] Clear date
  • @@ -935,6 +943,8 @@ [% INCLUDE 'calendar.inc' %] [% INCLUDE 'columns_settings.inc' %] [% Asset.js("js/circ-patron-search-results.js") | $raw %] + [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %] + [% INCLUDE 'timepicker.inc' %]