From 19546f9f71f7a53c1ed39cdf960e5f5728f0c105 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 9 Dec 2019 04:33:42 +0000 Subject: [PATCH] Bug 24194: Add HideReserveExpiration system preference to hide expiration date options for reserves To test: 1) Update database 2) Go to place a hold on any biblio in the staff intranet and confirm you can see the 'Hold expires on date' field. 3) In another tab, go to place a hold on any biblio in the OPAC and confirm you can see the 'Hold not needed after' field as an option. 4) In yet another tab, open the staff intranet and place a reserve for a user. Check it in and set the reserve as waiting. Notice that an expiration date has now been generated for this reserve. 5) Attempt to check out the item you reserved to some other borrower. Revert waiting status. Notice that the expiration date that was generated remains. 6) Go to Administration -> system preferences and set HideReserveExpiration system preference to 'Hide' 7) Refresh the hold request page in the intranet. Confirm the expiration date field disappears. 8) Refresh the hold request page in the OPAC. Confirm the expiration date field disappears. 9) Place another reserve. Check it in and set the reserve as waiting. Notice that no expiration date was generated for this reserve. 10) Attempt to check out the item you reserved to some other borrower. Revert waiting status. The expiration date should remain null. Sponsored-by: Horowhenua Library Trust Signed-off-by: David Nind --- C4/Reserves.pm | 12 ++++++++ Koha/Hold.pm | 34 ++++++++++++---------- ...bug24194-add-HideReserveExpiration-syspref.perl | 7 +++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 6 ++++ .../prog/en/modules/reserve/request.tt | 14 +++++---- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 12 ++++---- 7 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug24194-add-HideReserveExpiration-syspref.perl diff --git a/C4/Reserves.pm b/C4/Reserves.pm index f2bf8bd5d3..baeb1f5c8d 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1974,6 +1974,18 @@ sub RevertWaitingStatus { WHERE reserve_id = ? "; + if ( C4::Context->preference('HideReserveExpiration') ){ + $query = " + UPDATE reserves + SET + priority = 1, + found = NULL, + waitingdate = NULL, + expirationdate = NULL + WHERE + reserve_id = ? + "; + } $sth = $dbh->prepare( $query ); $sth->execute( $reserve->{'reserve_id'} ); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index e2308dbd1f..d52dc9d954 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -171,27 +171,29 @@ sub set_waiting { waitingdate => $today->ymd, }; - my $requested_expiration; - if ($self->expirationdate) { - $requested_expiration = dt_from_string($self->expirationdate); - } + unless ( C4::Context->preference('HideReserveExpiration') ){ + my $requested_expiration; + if ($self->expirationdate) { + $requested_expiration = dt_from_string($self->expirationdate); + } + + my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); + my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); + my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); - my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); - my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); - my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); + my $expirationdate = $today->clone; + $expirationdate->add(days => $max_pickup_delay); - my $expirationdate = $today->clone; - $expirationdate->add(days => $max_pickup_delay); + if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { + $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); + } - if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { - $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); + # If patron's requested expiration date is prior to the + # calculated one, we keep the patron's one. + my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; + $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; } - # If patron's requested expiration date is prior to the - # calculated one, we keep the patron's one. - my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; - $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; - $self->set($values)->store(); return $self; diff --git a/installer/data/mysql/atomicupdate/bug24194-add-HideReserveExpiration-syspref.perl b/installer/data/mysql/atomicupdate/bug24194-add-HideReserveExpiration-syspref.perl new file mode 100644 index 0000000000..514cae0807 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug24194-add-HideReserveExpiration-syspref.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ( "HideReserveExpiration", 0, NULL, "Hide expiration date in reserves module.", "YesNo" ) }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24194 - HideReserveExpiration system preference)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index cfa295e197..5c59f27e3b 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -210,6 +210,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), +('HideReserveExpiration', 0, NULL, 'Hide expiration date in reserves module.', 'YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'), ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch\'s items to emphasize. If PatronBranch, emphasize the logged in user\'s library\'s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha\'s Apache configuration file.','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 6eb5af0660..8139d6a7c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -157,6 +157,12 @@ Circulation: yes: Allow no: "Don't allow" - patrons to submit notes about checked out items. + - + - pref: HideReserveExpiration + choices: + yes: Hide + no: "Don't hide" + - expiration date options for reserves. Checkout Policy: - 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 8c34184557..073adbc469 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -455,12 +455,14 @@ [% END %] -
  • - - - - Clear date -
  • + [% IF !Koha.Preference('HideReserveExpiration') %] +
  • + + + + Clear date +
  • + [% END %] [% UNLESS ( multi_hold ) %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 6932d49f90..93660ce3de 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -267,11 +267,13 @@
  • [% END %] -
  • - - - [% INCLUDE 'date-format.inc' %] -
  • + [% IF !Koha.Preference('HideReserveExpiration') %] +
  • + + + [% INCLUDE 'date-format.inc' %] +
  • + [% END %] [% IF Koha.Preference('AllowHoldItemTypeSelection') %] [% itemtypes = [] %] -- 2.11.0