[Koha-patches] [PATCH 4/4] bug 1532: various code cleanup
Galen Charlton
gmcharlt at gmail.com
Fri Feb 19 04:49:34 CET 2010
* export C4::Reserves::CancelExpiredReserves
* rename misc/cronjobs/cancel_expired_reserves.pl
to misc/cronjobs/holds/cancel_expired_holds.pl
* added cancel_expired_holds.pl to example crontab
* fix staff crash if AllowHoldDateInFuture is on
* expirationdate is now nullable instead of relying
on 0000-00-00
Signed-off-by: Galen Charlton <gmcharlt at gmail.com>
---
C4/Reserves.pm | 18 +++++++-----
misc/cronjobs/cancel_expired_reserves.pl | 39 ---------------------------
misc/cronjobs/crontab.example | 3 ++
misc/cronjobs/holds/cancel_expired_holds.pl | 31 +++++++++++++++++++++
opac/opac-reserve.pl | 6 ++--
reserve/request.pl | 5 ++-
6 files changed, 51 insertions(+), 51 deletions(-)
delete mode 100755 misc/cronjobs/cancel_expired_reserves.pl
create mode 100755 misc/cronjobs/holds/cancel_expired_holds.pl
diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 668117e..fae352c 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -113,6 +113,7 @@ BEGIN {
&CanBookBeReserved
&CanItemBeReserved
&CancelReserve
+ &CancelExpiredReserves
&IsAvailableForItemLevelRequest
@@ -849,13 +850,16 @@ sub CheckReserves {
sub CancelExpiredReserves {
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare( "SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) AND expirationdate != '0000-00-00'" );
- $sth->execute();
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare( "
+ SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() )
+ AND expirationdate IS NOT NULL
+ " );
+ $sth->execute();
- while ( my $res = $sth->fetchrow_hashref() ) {
- CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
- }
+ while ( my $res = $sth->fetchrow_hashref() ) {
+ CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
+ }
}
diff --git a/misc/cronjobs/cancel_expired_reserves.pl b/misc/cronjobs/cancel_expired_reserves.pl
deleted file mode 100755
index 41a810e..0000000
--- a/misc/cronjobs/cancel_expired_reserves.pl
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-
-# This script loops through each overdue item, determines the fine,
-# and updates the total amount of fines due by each user. It relies on
-# the existence of /tmp/fines, which is created by ???
-# Doesnt really rely on it, it relys on being able to write to /tmp/
-# It creates the fines file
-#
-# This script is meant to be run nightly out of cron.
-
-# 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., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-# $Id: sendoverdues.pl,v 1.1.2.1 2007/03/26 22:38:09 tgarip1957 Exp $
-
-BEGIN {
- # find Koha's Perl modules
- # test carefully before changing this
- use FindBin;
- eval { require "$FindBin::Bin/../kohalib.pl" };
-}
-
-use C4::Reserves;
-
-CancelExpiredReserves();
\ No newline at end of file
diff --git a/misc/cronjobs/crontab.example b/misc/cronjobs/crontab.example
index bdb58f7..33845a8 100644
--- a/misc/cronjobs/crontab.example
+++ b/misc/cronjobs/crontab.example
@@ -64,6 +64,9 @@ KOHA_CRON_PATH = /home/liblime/kohaclone/misc/cronjobs
# Hourly holds queue updated
52 * * * * $KOHA_CRON_PATH/holds/build_holds_queue.pl >/dev/null 2>&1
+# Cancel expired holds
+0 1 * * * $KOHA_CRON_PATH/holds/cancel_expired_holds.pl >/dev/null 2>&1
+
# ZEBRA INDEX UPDATES with -z option, incremental index updates throughout the day
# for both authorities and bibs
*/10 * * * * $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null
diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl
new file mode 100755
index 0000000..4b5cf8c
--- /dev/null
+++ b/misc/cronjobs/holds/cancel_expired_holds.pl
@@ -0,0 +1,31 @@
+#!/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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+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;
+
+CancelExpiredReserves();
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 499f9cb..d5d39db 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -294,7 +294,6 @@ $template->param('item-level_itypes' => $itemLevelTypes);
foreach my $biblioNum (@biblionumbers) {
my $record = GetMarcBiblio($biblioNum);
- my $subtitle = C4::Biblio::get_koha_field_from_marc('bibliosubtitle', 'subtitle', $record, '');
# Init the bib item with the choices for branch pickup
my %biblioLoopIter = ( branchChoicesLoop => $CGIbranchloop );
@@ -307,7 +306,7 @@ foreach my $biblioNum (@biblionumbers) {
$biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
$biblioLoopIter{title} = $biblioData->{title};
- $biblioLoopIter{subtitle} = $subtitle;
+ $biblioLoopIter{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($biblioData->{biblionumber}));
$biblioLoopIter{author} = $biblioData->{author};
$biblioLoopIter{rank} = $biblioData->{rank};
$biblioLoopIter{reservecount} = $biblioData->{reservecount};
@@ -489,9 +488,10 @@ if (
) {
$template->param(
reserve_in_future => 1,
- DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
);
}
+$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar() );
+
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/reserve/request.pl b/reserve/request.pl
index 561bb5a..17c83a9 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -509,7 +509,8 @@ foreach my $biblionumber (@biblionumbers) {
$reserve{'hidename'} = 1;
$reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
}
- $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} ) unless ( $res->{'expirationdate'} eq '0000-00-00' );
+ $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} )
+ unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' );
$reserve{'date'} = format_date( $res->{'reservedate'} );
$reserve{'borrowernumber'} = $res->{'borrowernumber'};
$reserve{'biblionumber'} = $res->{'biblionumber'};
@@ -585,7 +586,7 @@ if ($multihold) {
}
if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
- template->param( reserve_in_future => 1 );
+ $template->param( reserve_in_future => 1 );
}
# printout the page
--
1.6.3.3
More information about the Koha-patches
mailing list