From f446b3d03d574e145bbc8f3e241ce2711c935643 Mon Sep 17 00:00:00 2001
From: Kyle M Hall
Date: Thu, 1 Mar 2012 11:57:58 -0500
Subject: [PATCH] Bug 7641: Suspend Reserves
Adds the ability to suspend reserves. The new system preference
AutoResumeSuspendedHolds enables the ability to set a date for
a suspended hold to automatically be resumed.
When a hold is suspended, it will continue to increase in priority
as the holds above it are fulfilled. If the first holds in line
to be filled are suspended, the first non-suspened hold in line
will be used when an item can fulfill a hold that has been placed.
http://bugs.koha-community.org/show_bug.cgi?id=7641
Signed-off-by: Nicole C. Engard
Tested with the preference on and off:
1. placed several holds in the staff client
2. suspended some with a date
3. suspended some without a date
4. triggered hold message by checking in for hold with suspensions
5. the suspended hold was skipped as it should be
6. tested suspending holds in the OPAC w and w/out dates
7. ran the cron to clear suspensions with dates
All the above tests worked as expected. Signing off.
---
C4/Reserves.pm | 137 +++++++++++++++++-
circ/circulation.pl | 5 +
installer/data/mysql/kohastructure.sql | 4 +
installer/data/mysql/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 14 ++
.../admin/preferences/circulation.pref | 6 +
.../prog/en/modules/circ/circulation.tt | 59 +++++++-
.../prog/en/modules/members/moremember.tt | 54 +++++++
.../prog/en/modules/reserve/request.tt | 41 +++++-
.../opac-tmpl/prog/en/modules/opac-user.tt | 57 +++++++-
members/moremember.pl | 6 +-
misc/cronjobs/holds/auto_unsuspend_holds.pl | 34 +++++
opac/opac-modrequest-suspend.pl | 46 ++++++
opac/opac-user.pl | 4 +
reserve/modrequest.pl | 3 +-
reserve/modrequest_suspendall.pl | 58 ++++++++
reserve/request.pl | 9 +-
17 files changed, 524 insertions(+), 14 deletions(-)
create mode 100755 misc/cronjobs/holds/auto_unsuspend_holds.pl
create mode 100755 opac/opac-modrequest-suspend.pl
create mode 100755 reserve/modrequest_suspendall.pl
diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 276658ceed..05a4870f01 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -117,12 +117,16 @@ BEGIN {
&CancelReserve
&CancelExpiredReserves
+ &AutoUnsuspendReserves
+
&IsAvailableForItemLevelRequest
&AlterPriority
&ToggleLowestPriority
&ReserveSlip
+ &ToggleSuspend
+ &SuspendAll
);
@EXPORT_OK = qw( MergeHolds );
}
@@ -264,7 +268,9 @@ sub GetReservesFromBiblionumber {
itemnumber,
reservenotes,
expirationdate,
- lowestPriority
+ lowestPriority,
+ suspend,
+ suspend_until
FROM reserves
WHERE biblionumber = ? ";
unless ( $all_dates ) {
@@ -894,6 +900,24 @@ sub CancelExpiredReserves {
}
+=head2 AutoUnsuspendReserves
+
+ AutoUnsuspendReserves();
+
+Unsuspends all suspended reserves with a suspend_until date from before today.
+
+=cut
+
+sub AutoUnsuspendReserves {
+
+ my $dbh = C4::Context->dbh;
+
+ my $query = "UPDATE reserves SET suspend = 0, suspend_until = NULL WHERE DATE( suspend_until ) < DATE( CURDATE() )";
+ my $sth = $dbh->prepare( $query );
+ $sth->execute();
+
+}
+
=head2 CancelReserve
&CancelReserve($biblionumber, $itemnumber, $borrowernumber);
@@ -1029,7 +1053,7 @@ itemnumber and supplying itemnumber.
sub ModReserve {
#subroutine to update a reserve
- my ( $rank, $biblio, $borrower, $branch , $itemnumber) = @_;
+ my ( $rank, $biblio, $borrower, $branch , $itemnumber, $suspend_until) = @_;
return if $rank eq "W";
return if $rank eq "n";
my $dbh = C4::Context->dbh;
@@ -1062,14 +1086,25 @@ sub ModReserve {
}
elsif ($rank =~ /^\d+/ and $rank > 0) {
- my $query = qq/
- UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL
+ my $query = "
+ UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL
WHERE biblionumber = ?
- AND borrowernumber = ?
- /;
+ AND borrowernumber = ?
+ ";
my $sth = $dbh->prepare($query);
$sth->execute( $rank, $branch,$itemnumber, $biblio, $borrower);
$sth->finish;
+
+ if ( defined( $suspend_until ) ) {
+ if ( $suspend_until ) {
+ $suspend_until = C4::Dates->new( $suspend_until )->output("iso");
+ warn "SUSPEND UNTIL: $suspend_until";
+ $dbh->do("UPDATE reserves SET suspend = 1, suspend_until = ? WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $suspend_until, $biblio, $borrower ) );
+ } else {
+ $dbh->do("UPDATE reserves SET suspend_until = NULL WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $biblio, $borrower ) );
+ }
+ }
+
_FixPriority( $biblio, $borrower, $rank);
}
}
@@ -1472,6 +1507,93 @@ sub ToggleLowestPriority {
_FixPriority( $biblionumber, $borrowernumber, '999999' );
}
+=head2 ToggleSuspend
+
+ ToggleSuspend( $borrowernumber, $biblionumber );
+
+This function sets the suspend field to true if is false, and false if it is true.
+If the reserve is currently suspended with a suspend_until date, that date will
+be cleared when it is unsuspended.
+
+=cut
+
+sub ToggleSuspend {
+ my ( $borrowernumber, $biblionumber ) = @_;
+
+ 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
+ WHERE biblionumber = ?
+ AND borrowernumber = ?
+ ");
+ $sth->execute(
+ $biblionumber,
+ $borrowernumber,
+ );
+ $sth->finish;
+}
+
+=head2 SuspendAll
+
+ SuspendAll(
+ borrowernumber => $borrowernumber,
+ [ biblionumber => $biblionumber, ]
+ [ suspend_until => $suspend_until, ]
+ [ suspend => $suspend ]
+ );
+
+ This function accepts a set of hash keys as its parameters.
+ It requires either borrowernumber or biblionumber, or both.
+
+ suspend_until is wholly optional.
+
+=cut
+
+sub SuspendAll {
+ my %params = @_;
+
+ my $borrowernumber = $params{'borrowernumber'} || undef;
+ my $biblionumber = $params{'biblionumber'} || undef;
+ my $suspend_until = $params{'suspend_until'} || undef;
+ my $suspend = defined( $params{'suspend'} ) ? $params{'suspend'} : 1;
+
+ warn "C4::Reserves::SuspendAll( borrowernumber => $borrowernumber, biblionumber => $biblionumber, suspend_until => $suspend_until, suspend => $suspend )";
+
+ $suspend_until = C4::Dates->new( $suspend_until )->output("iso") if ( defined( $suspend_until ) );
+
+ return unless ( $borrowernumber || $biblionumber );
+
+ my ( $query, $sth, $dbh, @query_params );
+
+ $query = "UPDATE reserves SET suspend = ? ";
+ push( @query_params, $suspend );
+ if ( !$suspend ) {
+ $query .= ", suspend_until = NULL ";
+ } elsif ( $suspend_until ) {
+ $query .= ", suspend_until = ? ";
+ push( @query_params, $suspend_until );
+ }
+ $query .= " WHERE ";
+ if ( $borrowernumber ) {
+ $query .= " borrowernumber = ? ";
+ push( @query_params, $borrowernumber );
+ }
+ $query .= " AND " if ( $borrowernumber && $biblionumber );
+ if ( $biblionumber ) {
+ $query .= " biblionumber = ? ";
+ push( @query_params, $biblionumber );
+ }
+ $query .= " AND found IS NULL ";
+
+ $dbh = C4::Context->dbh;
+ $sth = $dbh->prepare( $query );
+ $sth->execute( @query_params );
+ $sth->finish;
+}
+
+
=head2 _FixPriority
&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank);
@@ -1616,6 +1738,7 @@ sub _Findgroupreserve {
AND item_level_request = 1
AND itemnumber = ?
AND reservedate <= CURRENT_DATE()
+ AND suspend = 0
/;
my $sth = $dbh->prepare($item_level_target_query);
$sth->execute($itemnumber);
@@ -1646,6 +1769,7 @@ sub _Findgroupreserve {
AND item_level_request = 0
AND hold_fill_targets.itemnumber = ?
AND reservedate <= CURRENT_DATE()
+ AND suspend = 0
/;
$sth = $dbh->prepare($title_level_target_query);
$sth->execute($itemnumber);
@@ -1677,6 +1801,7 @@ sub _Findgroupreserve {
OR reserves.constrainttype='a' )
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
AND reserves.reservedate <= CURRENT_DATE()
+ AND suspend = 0
/;
$sth = $dbh->prepare($query);
$sth->execute( $biblio, $bibitem, $itemnumber );
diff --git a/circ/circulation.pl b/circ/circulation.pl
index 082b3d4d0e..469209cf04 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -354,6 +354,8 @@ if ($borrowernumber) {
$getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
$getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
$getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
+ $getreserv{suspend} = $num_res->{'suspend'};
+ $getreserv{suspend_until} = C4::Dates->new( $num_res->{'suspend_until'}, "iso")->output("syspref");
# check if we have a waiting status for reservations
if ( $num_res->{'found'} eq 'W' ) {
$getreserv{color} = 'reserved';
@@ -726,4 +728,7 @@ $template->param(
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
canned_bor_notes_loop => $canned_notes,
);
+
+$template->param( AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
+
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 26689c68fc..fda0bac627 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1459,6 +1459,8 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b
`waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
`expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
`lowestPriority` tinyint(1) NOT NULL,
+ `suspend` BOOLEAN NOT NULL DEFAULT 0,
+ `suspend_until` DATETIME NULL DEFAULT NULL,
KEY `old_reserves_borrowernumber` (`borrowernumber`),
KEY `old_reserves_biblionumber` (`biblionumber`),
KEY `old_reserves_itemnumber` (`itemnumber`),
@@ -1652,6 +1654,8 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
`waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library
`expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date)
`lowestPriority` tinyint(1) NOT NULL,
+ `suspend` BOOLEAN NOT NULL DEFAULT 0,
+ `suspend_until` DATETIME NULL DEFAULT NULL,
KEY priorityfoundidx (priority,found),
KEY `borrowernumber` (`borrowernumber`),
KEY `biblionumber` (`biblionumber`),
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 4a12a17759..e8c22ee83a 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -359,3 +359,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('Babeltheque_url_update', '', 'Url for Babeltheque update (E.G. http://www.babeltheque.com/.../file.csv.bz2)', '', 'Free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SocialNetworks','1','Enable/Disable social networks links in opac detail pages','','YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free');
+INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index d29c8e48d4..ddc288c800 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5095,6 +5095,20 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion($DBversion);
}
+$DBversion = "3.07.00.042";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
+ $dbh->do("ALTER TABLE old_reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
+
+ $dbh->do("ALTER TABLE reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
+ $dbh->do("ALTER TABLE old_reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
+
+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo')");
+
+ print "Upgrade to $DBversion done (Add suspend fields to reserves table, add syspref AutoResumeSuspendedHolds)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
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 59ed56449a..471aa0e433 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
@@ -344,6 +344,12 @@ Circulation:
yes: Transfer
no: "Don't transfer"
- items when cancelling all waiting holds.
+ -
+ - pref: AutoResumeSuspendedHolds
+ choices:
+ yes: Allow
+ no: "Don't allow"
+ - suspended holds to be automatically resumed by a set date.
Fines Policy:
-
- Calculate fines based on days overdue
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 eaa4a8d58c..57c16ee377 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -947,9 +947,10 @@ No patron matched [% message %]
Hold date
Title
Call Number
-
Barcode
+
Barcode
Priority
-
Delete?
+
Delete?
+
[% FOREACH reservloo IN reservloop %]
@@ -976,11 +977,65 @@ No patron matched [% message %]
+
[% IF ( reservloo.suspend ) %]Suspended [% IF ( reservloo.suspend_until ) %] until [% reservloo.suspend_until %][% END %][% END %]
[% END %]
+
+
+
+
+
[% ELSE %]
Patron has nothing on hold.
[% END %]
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 7a62b0015b..b568ec93a3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -606,6 +606,7 @@ function validate1(date) {
Barcode
Priority
Delete?
+
[% FOREACH reservloo IN reservloop %]
@@ -637,12 +638,65 @@ function validate1(date) {
+
[% IF ( reservloo.suspend ) %]Suspended [% IF ( reservloo.suspend_until ) %] until [% reservloo.suspend_until %][% END %][% END %]
[% END %]
+
+
+
+
[% ELSE %]
Patron has nothing on hold.
[% END %]
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 a257e2ef90..3a5c8c3c61 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -597,6 +597,7 @@ function checkMultiHold() {
[% END %]
@@ -653,7 +654,7 @@ function checkMultiHold() {
[% IF ( reserveloo.wait ) %]
[% IF ( reserveloo.atdestination ) %]
- [% IF ( reserveloo.found ) %]
+ [% IF ( reserveloo.found ) %]
Item waiting at [% reserveloo.wbrname %]
[% ELSE %]
Waiting to be pulled
@@ -728,6 +729,44 @@ function checkMultiHold() {
+
+ [% UNLESS ( reserveloo.wait ) %]
+
+
+ [% IF AutoResumeSuspendedHolds %]
+
+
+
+
+ Clear Date
+ [% END %]
+ [% ELSE %]
+
+ [% END %]
+
[% END %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
index 19b7389bf9..b8e98a2069 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
@@ -3,6 +3,7 @@
[% INCLUDE 'doc-head-open.inc' %]
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog › Your library home
[% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
+ Clear Date
+ [% END %]
+
+
+
+
+
[% END %]
diff --git a/members/moremember.pl b/members/moremember.pl
index a83bce97bd..32541c9eda 100755
--- a/members/moremember.pl
+++ b/members/moremember.pl
@@ -320,6 +320,8 @@ if ($borrowernumber) {
$getreserv{biblionumber} = $num_res->{'biblionumber'};
}
$getreserv{waitingposition} = $num_res->{'priority'};
+ $getreserv{suspend} = $num_res->{'suspend'};
+ $getreserv{suspend_until} = C4::Dates->new( $num_res->{'suspend_until'}, "iso")->output("syspref");;
push( @reservloop, \%getreserv );
}
@@ -427,8 +429,8 @@ $template->param(
"dateformat_" . (C4::Context->preference("dateformat") || '') => 1,
samebranch => $samebranch,
quickslip => $quickslip,
- activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
-);
+ activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
+ AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/misc/cronjobs/holds/auto_unsuspend_holds.pl b/misc/cronjobs/holds/auto_unsuspend_holds.pl
new file mode 100755
index 0000000000..268910b56a
--- /dev/null
+++ b/misc/cronjobs/holds/auto_unsuspend_holds.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+# Copyright 2009-2010 Kyle Hall
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+#use strict;
+#use warnings; FIXME - Bug 2505
+
+BEGIN {
+ # find Koha's Perl modules
+ # test carefully before changing this
+ use FindBin;
+ eval { require "$FindBin::Bin/../kohalib.pl" };
+}
+
+# cancel all expired hold requests
+
+use C4::Reserves;
+
+AutoUnsuspendReserves();
diff --git a/opac/opac-modrequest-suspend.pl b/opac/opac-modrequest-suspend.pl
new file mode 100755
index 0000000000..ec152659dd
--- /dev/null
+++ b/opac/opac-modrequest-suspend.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+use warnings;
+
+use CGI;
+use C4::Output;
+use C4::Reserves;
+use C4::Auth;
+my $query = new CGI;
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "opac-account.tmpl",
+ query => $query,
+ type => "opac",
+ authnotrequired => 0,
+ flagsrequired => { borrow => 1 },
+ debug => 1,
+ }
+);
+
+my $suspend = $query->param('suspend');
+my $suspend_until = $query->param('suspend_until') || undef;
+
+SuspendAll(
+ borrowernumber => $borrowernumber,
+ suspend => $suspend,
+ suspend_until => $suspend_until,
+);
+
+print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index b89e862e87..a9a6305d75 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -263,6 +263,7 @@ foreach my $res (@reserves) {
if ($OPACDisplayRequestPriority) {
$res->{'priority'} = '' if $res->{'priority'} eq '0';
}
+ $res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} );
}
# use Data::Dumper;
@@ -360,5 +361,8 @@ $template->param(
dateformat => C4::Context->preference("dateformat"),
);
+$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar() );
+$template->param( AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
+
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl
index eecd86b2f6..03ef064ccc 100755
--- a/reserve/modrequest.pl
+++ b/reserve/modrequest.pl
@@ -46,6 +46,7 @@ my @biblionumber=$query->param('biblionumber');
my @borrower=$query->param('borrowernumber');
my @branch=$query->param('pickup');
my @itemnumber=$query->param('itemnumber');
+my @suspend_until=$query->param('suspend_until');
my $multi_hold = $query->param('multi_hold');
my $biblionumbers = $query->param('biblionumbers');
my $count=@rank;
@@ -66,7 +67,7 @@ if ($CancelBorrowerNumber) {
else {
for (my $i=0;$i<$count;$i++){
undef $itemnumber[$i] unless $itemnumber[$i] ne '';
- ModReserve($rank[$i],$biblionumber[$i],$borrower[$i],$branch[$i],$itemnumber[$i]); #from C4::Reserves
+ ModReserve($rank[$i],$biblionumber[$i],$borrower[$i],$branch[$i],$itemnumber[$i],$suspend_until[$i]); #from C4::Reserves
}
}
my $from=$query->param('from');
diff --git a/reserve/modrequest_suspendall.pl b/reserve/modrequest_suspendall.pl
new file mode 100755
index 0000000000..48d5412734
--- /dev/null
+++ b/reserve/modrequest_suspendall.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+#script to modify reserves/requests
+#written 2/1/00 by chris@katipo.oc.nz
+#last update 27/1/2000 by chris@katipo.co.nz
+
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+use warnings;
+use CGI;
+use C4::Output;
+use C4::Reserves;
+use C4::Auth;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "about.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my $borrowernumber = $query->param('borrowernumber');
+my $suspend = $query->param('suspend');
+my $suspend_until = $query->param('suspend_until');
+
+SuspendAll( borrowernumber => $borrowernumber, suspend_until => $suspend_until, suspend => $suspend );
+
+my $from = $query->param('from');
+$from ||= q{};
+if ( $from eq 'borrower'){
+ print $query->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
+} elsif ( $from eq 'circ'){
+ print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+} else {
+ print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+}
diff --git a/reserve/request.pl b/reserve/request.pl
index b96447f8cc..ff01850d3a 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -110,6 +110,10 @@ if ( $action eq 'move' ) {
my $borrowernumber = $input->param('borrowernumber');
my $biblionumber = $input->param('biblionumber');
ToggleLowestPriority( $borrowernumber, $biblionumber );
+} elsif ( $action eq 'toggleSuspend' ) {
+ my $borrowernumber = $input->param('borrowernumber');
+ my $biblionumber = $input->param('biblionumber');
+ ToggleSuspend( $borrowernumber, $biblionumber );
}
if ($findborrower) {
@@ -568,7 +572,8 @@ foreach my $biblionumber (@biblionumbers) {
$reserve{'lowestPriority'} = $res->{'lowestPriority'};
$reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
$reserve{'optionloop'} = \@optionloop;
-
+ $reserve{'suspend'} = $res->{'suspend'};
+ $reserve{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref");
push( @reserveloop, \%reserve );
}
@@ -627,5 +632,7 @@ if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
$template->param( reserve_in_future => 1 );
}
+$template->param( AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
+
# printout the page
output_html_with_http_headers $input, $cookie, $template->output;
--
2.39.2