Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 90 lines (66 sloc) 2.936 kb
#!/usr/bin/perl
# Copyright 2009 Liblime
#
# 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
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 C4::Callslip qw/get_requests mod_status/;
use C4::Debug;
use C4::Schema;
use Getopt::Long;
my $verbose = 0;
my $want_help = 0;
my $confirm = 0;
GetOptions(
'verbose|v' => \$verbose,
'help|h' => \$want_help,
'confirm|c' => \$confirm,
);
my $usage = << 'USAGE';
manage_callslips.pl -- update request statuses based on expiry preferences.
callslip and doc_del requests may expire as follows:
(1) a request with status in ( requested, in_process, in_transit, in_process ) passes the not_needed_after date.
( once it's on_hold, we ignore not_needed_after ).
(2) a request with status in ( on_hold ) passes the keep_on_hold_time
in this first implementation of call slips, the keep_on_hold_time is statically defined as a constant
number of days from the fill date in C4::Callslip; the spec does not say how to determine it.
This script has the following parameters :
-c | --confirm : Actually modify the Koha db. No action is taken if this is not supplied.
-h | --help : this message
-v | --verbose : be verbose. Set to > 1 for debugging output.
USAGE
$want_help and die $usage;
our $schema = C4::Schema->connect();
use DBIx::Class::ResultClass::HashRefInflator ;
use DBIx::Class::Storage;
my $expired = { on_hold => 0 , not_needed => 0 };
for my $rq_hold (get_requests( undef, { limit => 'hold_expired' })){
$confirm and C4::Callslip::mod_status($rq_hold->{'callslip_id'},'expired');
$expired->{'on_hold'}++;
}
for my $rq_not_needed (get_requests( undef, { limit => 'not_needed' })){
$confirm and C4::Callslip::mod_status($rq_not_needed->{'callslip_id'},'expired');
$expired->{'not_needed'}++;
}
$verbose and warn sprintf("Expiry results:\n\tExpired %d on_hold requests.\n\tExpired %d not_needed_after requests.\n",$expired->{'on_hold'},$expired->{'not_needed'});
$verbose and ! $confirm and warn "No changes made to database; use --confirm to actually modify the requests";
Jump to Line
Something went wrong with that request. Please try again.