Bugzilla – Attachment 11090 Details for
Bug 7901
Add option to delete_borrowers.pl for using a file with cardnumbers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7901 - Add batch delete borrowers script
Bug-7901---Add-batch-delete-borrowers-script.patch (text/plain), 3.41 KB, created by
Kyle M Hall (khall)
on 2012-07-23 20:45:52 UTC
(
hide
)
Description:
Bug 7901 - Add batch delete borrowers script
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-07-23 20:45:52 UTC
Size:
3.41 KB
patch
obsolete
>From 5fca5ef12650091ab01ec54aa0642b9607d19326 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 5 Apr 2012 08:59:14 -0400 >Subject: [PATCH] Bug 7901 - Add batch delete borrowers script > >Simple script that takes a file of borrower >cardnumbers and deletes those borrowers. >--- > misc/batch_delete_borrowers.pl | 99 ++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 99 insertions(+), 0 deletions(-) > create mode 100755 misc/batch_delete_borrowers.pl > >diff --git a/misc/batch_delete_borrowers.pl b/misc/batch_delete_borrowers.pl >new file mode 100755 >index 0000000..627eed8 >--- /dev/null >+++ b/misc/batch_delete_borrowers.pl >@@ -0,0 +1,99 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2012 Bywater Solutions >+# >+# 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 this program; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+BEGIN { >+ >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/kohalib.pl" }; >+} >+ >+use C4::Members; >+use C4::VirtualShelves; >+ >+use Getopt::Long; >+ >+my ( $help, $confirm, $file, $verbose, $delete ); >+GetOptions( >+ 'c|confirm' => \$confirm, >+ 'h|help' => \$help, >+ 'v|verbose' => \$verbose, >+ 'd|delete' => \$delete, >+ 'f|file:s' => \$file, >+); >+ >+if ($help) { >+ print <<EOF >+This script is used to batch delete borrowers from Koha. >+It accepts a file with a list of borrower cardnumbers to >+be deleted, one per line. >+ >+Example: batch_delete_borrowers.pl -c -v --file borrowers.list >+ >+Options: >+ --confirm -c If this option is not passed, nothing will be deleted >+ >+ --verbose -v Verbose, print output >+ >+ --help -h Display help >+ >+ --delete -d Delete the borrower completely, rather than moving >+ the borrower to the deletedborrowers table >+ >+ --file -f File of borrower cardnumbers to be deleted >+EOF >+ ; >+ exit; >+} >+ >+print "\nRunning in test mode, no borrowers will be deleted\n\n" >+ unless ($confirm); >+ >+open( FILE, $file ) or die "Couldn't open file: $!"; >+while (<FILE>) { >+ chomp($_); >+ >+ print "Working on cardnumber $_ \n" if ($verbose); >+ >+ my $borrower = GetMember( cardnumber => $_ ); >+ my $borrowernumber = $borrower->{'borrowernumber'}; >+ >+ if ($verbose) { >+ if ($borrowernumber) { >+ print "Deleting borrower $borrower->{firstname} $borrower->{surname} ( $borrower->{cardnumber} ) ... "; >+ } >+ else { >+ print "No deletion needed, cardnumber $_ not in database."; >+ } >+ } >+ >+ if ($confirm) { >+ MoveMemberToDeleted($borrowernumber) unless ($delete); >+ C4::VirtualShelves::HandleDelBorrower($borrowernumber); >+ DelMember($borrowernumber); >+ >+ } >+ >+ print "deleted." if ( $verbose && borrowernumber ); >+ print "\n\n" if ($verbose); >+ >+} >-- >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 7901
:
8914
| 11090