From 21c7f786bf6b0d23fba69d9def05e1fe47010287 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 18 Feb 2010 22:42:53 -0500 Subject: [PATCH] bug 1532: various code cleanup * 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 --- C4/Reserves.pm | 16 ++++++++++------ misc/cronjobs/crontab.example | 3 +++ .../cancel_expired_holds.pl} | 16 ++++------------ opac/opac-reserve.pl | 6 +++--- reserve/request.pl | 5 +++-- 5 files changed, 23 insertions(+), 23 deletions(-) rename misc/cronjobs/{cancel_expired_reserves.pl => holds/cancel_expired_holds.pl} (64%) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 668117e2f9..fae352c130 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/crontab.example b/misc/cronjobs/crontab.example index bdb58f70a1..33845a80a2 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/cancel_expired_reserves.pl b/misc/cronjobs/holds/cancel_expired_holds.pl similarity index 64% rename from misc/cronjobs/cancel_expired_reserves.pl rename to misc/cronjobs/holds/cancel_expired_holds.pl index 41a810ecd4..4b5cf8cd48 100755 --- a/misc/cronjobs/cancel_expired_reserves.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -1,14 +1,6 @@ #!/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 +# Copyright 2009-2010 Kyle Hall # # This file is part of Koha. # @@ -25,8 +17,6 @@ # 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 @@ -34,6 +24,8 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +# cancel all expired hold requests + use C4::Reserves; -CancelExpiredReserves(); \ No newline at end of file +CancelExpiredReserves(); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 499f9cb726..d5d39dbe75 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 561bb5a03b..17c83a941f 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 -- 2.39.5