Bugzilla – Attachment 13114 Details for
Bug 8985
Add script to batch modify issuing rule hard due dates.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8985 - Add script to batch modify issuing rule hard due dates.
Bug-8985---Add-script-to-batch-modify-issuing-rule.patch (text/plain), 5.24 KB, created by
Kyle M Hall
on 2012-10-30 12:54:18 UTC
(
hide
)
Description:
Bug 8985 - Add script to batch modify issuing rule hard due dates.
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2012-10-30 12:54:18 UTC
Size:
5.24 KB
patch
obsolete
>From 3cb74d90ee4a4f460cdc5280e74b7541457812b6 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 30 Oct 2012 07:42:23 -0400 >Subject: [PATCH] Bug 8985 - Add script to batch modify issuing rule hard due dates. >Content-Type: text/plain; charset="utf-8" > >--- > misc/modify_hard_due_dates.pl | 143 +++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 143 insertions(+), 0 deletions(-) > create mode 100755 misc/modify_hard_due_dates.pl > >diff --git a/misc/modify_hard_due_dates.pl b/misc/modify_hard_due_dates.pl >new file mode 100755 >index 0000000..81d7c1a >--- /dev/null >+++ b/misc/modify_hard_due_dates.pl >@@ -0,0 +1,143 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 ByWater Solutions >+# >+# 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. >+ >+=head1 NAME >+ >+modify_hard_due_dates.pl : update hard due dates in multiple issuing rules at once. >+ >+=head1 SYNOPSIS >+ >+modify_hard_due_dates.pl -d 2013-06-10 -t before -c CC1 -c CC2 -i IT1 -i IT2 -b BC1 -b BC2 >+ >+=head1 DESCRIPTION >+ >+This script will allow you to update the hard due dates in multiple >+issuing rules at once. Setting only --date and --type will affect *all* >+issuing rules. To further limit, use -c, -i and/or -b. Note, using -c '*' or >+-i '*' will not affect all rules, but only rules where the wildcard is set. >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=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; >+ >+$| = 1; >+ >+# command-line parameters >+my $hardduedate = undef; >+my $comparison = undef; >+my $remove = undef; >+my @category_codes; >+my @itemtypes; >+my @branchcodes; >+my $help = 0; >+ >+my $result = GetOptions( >+ 'd|date=s' => \$hardduedate, >+ 't|type=s' => \$comparison, >+ 'r|remove' => \$remove, >+ 'c|categorycode=s' => \@category_codes, >+ 'i|itemtype=s' => \@itemtypes, >+ 'b|branchcode=s' => \@branchcodes, >+ >+ 'h|help' => \$help >+); >+ >+my $hardduedatecompare = undef; >+if ( defined($comparison) ) { >+ $hardduedatecompare = '-1' if ( $comparison eq 'before' ); >+ $hardduedatecompare = '0' if ( $comparison eq 'exactly_on' ); >+ $hardduedatecompare = '1' if ( $comparison eq 'after' ); >+} >+ >+if ($help >+ || ( defined($hardduedate) && !( $hardduedate =~ m /^[0-9]{4}-[0-9]{2}-[0-9]{2}/ ) ) ## date set but not in ISO >+ || ( !$remove && !( $hardduedate && $hardduedatecompare ) ) ## we need either ( -d and -t ) or just -r >+ || ( $remove && ( $hardduedate || $hardduedatecompare ) ) ## but not -r and ( -d or -t ) >+ ) { >+ print_usage(); >+ exit 0; >+} >+ >+my $dbh = C4::Context->dbh; >+ >+my $query = "UPDATE issuingrules SET hardduedate = ?, hardduedatecompare = ?"; >+ >+my @limits; >+my @limit_params; >+ >+if (@category_codes) { >+ push( @limits, " ( " . join( " OR ", ("categorycode = ?") x scalar(@category_codes) ) . " ) " ); >+ push( @limit_params, @category_codes ); >+} >+ >+if (@itemtypes) { >+ push( @limits, " ( " . join( " OR ", ("itemtype = ?") x scalar(@itemtypes) ) . " ) " ); >+ push( @limit_params, @itemtypes ); >+} >+ >+if (@branchcodes) { >+ push( @limits, " ( " . join( " OR ", ("branchcode = ?") x scalar(@branchcodes) ) . " ) " ); >+ push( @limit_params, @branchcodes ); >+} >+ >+$query .= " WHERE " . join( ' AND ', @limits ) if (@limits); >+ >+my $rows_affected = $dbh->do( $query, undef, ( $hardduedate, $hardduedatecompare, @limit_params ) ); >+ >+print "\nUpdate complete!\nRules updated: $rows_affected\n\n"; >+ >+sub print_usage { >+ print <<_USAGE_; >+$0: update hard due dates in multiple issuing rules at once. >+ >+This script will allow you to update the hard due dates in multiple >+issuing rules at once. Setting only --date and --type will affect *all* >+issuing rules. To further limit, use -c, -i and/or -b. Note, using -c '*' or >+-i '*' will not affect all rules, but only rules where the wildcard is set. >+ >+Parameters: >+ -d --date the hard due date in ISO format, YYYY-MM-DD ( required unless -r ) >+ -t --type must be 'before', 'exactly_on', or 'after' ( required unless -r ) >+ -r --remove remove the hard due date from a rule ( forbidden if -d and -t ) >+ >+ -c --categorycode affect only rules with this patron category code ( repeatable ) >+ -i --itemtype affect only rules with this item type ( repeatable ) >+ -b --branchcode affect only rules with this branchcode ( repeatable ) >+ >+ -h --help show this message. >+_USAGE_ >+} >+ >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8985
:
13111
|
13112
|
13113
| 13114