From 9326d96b7ebaff3502e15ec9ba07e03f4b8509da Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 13 Apr 2012 10:11:00 -0400 Subject: [PATCH] Bug 7641 - Followup - Suspend Until not set on by suspend button. Content-Type: text/plain; charset="utf-8" For request.pl, there are two ways to suspend a reserve, either by using the 'suspend' button for an individual reserve, or by using the 'Update hold(s)' button with suspend until dates set. If the 'suspend' button is used, any date in the 'suspend until' field is ignored. This commit fixes this issue. * Add suspend_until date to suspend button link via jquery * Add optional date to ToggleSuspend() * Add KohaDates plugin where necessary Signed-off-by: Nicole C. Engard Signed-off-by: Liz Rea passes tests, tested: * suspend all holds from circ.pl * suspend one hold from circ.pl * suspend all holds from moremember.pl * suspend one hold from moremember.pl --- NOTE: clicking suspend all holds without setting a date will mean the holds must be manually unsuspended. I'm not sure this is intentional? * suspend a specific hold using the in-table button on reserves * suspend a specific hold using the "update hold" button 500 error is gone. --- C4/Reserves.pm | 22 ++++++++++++++----- .../prog/en/modules/circ/circulation.tt | 1 + .../prog/en/modules/members/moremember.tt | 1 + .../prog/en/modules/reserve/request.tt | 5 ++- reserve/request.pl | 5 ++- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index c4b2c66..a64abde 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -36,6 +36,9 @@ use C4::Members qw(); use C4::Letters; use C4::Branch qw( GetBranchDetail ); use C4::Dates qw( format_date_in_iso ); + +use Koha::DateUtils; + use List::MoreUtils qw( firstidx ); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -1517,20 +1520,27 @@ be cleared when it is unsuspended. =cut sub ToggleSuspend { - my ( $borrowernumber, $biblionumber ) = @_; + my ( $borrowernumber, $biblionumber, $suspend_until ) = @_; + + $suspend_until = output_pref( dt_from_string( $suspend_until ), 'iso' ) if ( $suspend_until ); + + my $do_until = ( $suspend_until ) ? '?' : 'NULL'; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( "UPDATE reserves SET suspend = NOT suspend, - suspend_until = CASE WHEN suspend = 0 THEN NULL ELSE suspend_until END + suspend_until = CASE WHEN suspend = 0 THEN NULL ELSE $do_until END WHERE biblionumber = ? AND borrowernumber = ? "); - $sth->execute( - $biblionumber, - $borrowernumber, - ); + + my @params; + push( @params, $suspend_until ) if ( $suspend_until ); + push( @params, $biblionumber ); + push( @params, $borrowernumber ); + + $sth->execute( @params ); $sth->finish; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index e79cef1..b41184e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Circulation [% IF ( borrowernumber ) %] › Checking out to [% INCLUDE 'patron-title.inc' %] [% END %] [% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 27c7a2f..202c9d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Patrons › [% IF ( unknowuser ) %] 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 0d16ce0..effeb7a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] [% UNLESS ( multi_hold ) %] <title>Koha › Circulation › Holds › Place a hold on [% title |html %] @@ -731,11 +732,11 @@ function checkMultiHold() { [% UNLESS ( reserveloo.wait ) %] - + [% IF AutoResumeSuspendedHolds %] - + Show calendar