Koha/misc/cronjobs/cart_to_shelf.pl
Colin Campbell e40e11ab0c bug 3481: Allow Item Temporary Locations for Processing and Shelving.
Allows temporary locations corresponding to 'in processing' and 'shelving'
so that newly-created items, and newly-returned items do not show
immediately as a available. Three new system preferences govern the usage
of these features.

NewItemsDefaultLocation. If system pref NewItemsDefaultLocation is set to a location code,
 all newly catalogued items will be set to the location set in this preference.
 Location code must be a valid LOC authorized value type.

InProcessingToShelvingCart. if the system pref InProcessingToShelvingCart is turned on,
any items run through returns.pl with a location code for 'PROC', will be modified to
have a new location code of 'CART'.

ReturnToShelvingCart.  If the syspref ReturnToShelvingCart is turned on,
all items returned other than confirmed holds will have a new location code of 'CART'.
Any item issued is automatically taken of the shelving cart.

Adds a cron script shelf_to_cart.pl which should be run hourly.
Updates all items with a location of CART to the item's permanent location.

The original location code is stored in the new items column 'permanent_location'.

Original Author: PTFS Contractor <dbavousett@ptfs.com>

This work co-sponsored by
  Middletown Township Public Library, Middletown, NJ USA  and
  East Brunswick Public Library, East Brunswick, NJ USA

Signed-off-by: Colin Campbell <colin.campbell@ptfs-europe.com>
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2009-08-23 11:54:46 -04:00

69 lines
2.1 KiB
Perl
Executable file

#!/usr/bin/perl
#-----------------------------------
# Copyright 2009 PTFS Inc.
#
# 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
#-----------------------------------
=head1 NAME
cart_to_shelf.pl cron script to set items with location of CART to original shelving location after X hours.
Execute without options for help.
=cut
use strict;
use warnings;
BEGIN {
# find Koha's Perl modules
# test carefully before changing this
use FindBin;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
use C4::Context;
use Getopt::Long;
my $hours = 0;
GetOptions( 'h|hours=s' => \$hours, );
my $usage = << 'ENDUSAGE';
longoverdue.pl : This cron script will set any item of the location CART ( Shelving Cart ) to it's original shelving location
after the given numer of hours has passed.
This script takes the following parameters :
--hours | -h The number of hours that need to pass before the location is updated.
examples :
$PERL5LIB/misc/cronjobs/cart_to_shelf.pl --hours 24
Would make any item that has a location of CART for more than 24 hours change to it's original shelving location.
ENDUSAGE
unless ($hours) {
print $usage;
die "ERROR: No --hours (-h) option defined";
}
my $query =
"UPDATE items SET location = permanent_location WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?";
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare($query);
$sth->execute($hours);