Add simple script to batch delete borrowers via a list of cardnumbers.
Created attachment 8914 [details] [review] Bug 7901 - Add batch delete borrowers script Simple script that takes a file of borrower cardnumbers and deletes those borrowers.
why i can't load the cardnumber file in koha it will be more easy for the users... i have this message perl batch_delete_borrowers.pl --f file_test -c DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 1. DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 2. DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at /home/koha/src/C4/Members.pm line 1679, <FILE> line 3.
I tried loading a file which included one patron with checkouts, one without. The patron with no checkouts was deleted without error, the one with checkouts prompted this: Working on cardnumber 0093698 DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at /home/oleonard/kohaclone/C4/Members.pm line 1708, <FILE> line 2. Deleting borrower John Smith ( 0093698 ) ... deleted. Sounds like the script tries its best to delete and it's the error that prevents it? I would think that unless there is an explicit plan for how to handle checkouts the script should skip these accounts and report it. After that I tried loading the same file again (including the patron record which had already been deleted) and got this error: Working on cardnumber 0049138 Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1. Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1. Use of uninitialized value in concatenation (.) or string at batch_delete_borrowers.pl line 80, <FILE> line 1. Deleting borrower ( ) ... deleted. It would be nice to handle that situation gracefully.
Looks like the script deletes holds which were on a deleted patron's account but doesn't move them to old_reserves? I assume it should, since deleting a hold via reserve/request.pl does so.
Created attachment 11090 [details] [review] Bug 7901 - Add batch delete borrowers script Simple script that takes a file of borrower cardnumbers and deletes those borrowers.
This revision seems to address the problem with handling patron barcodes which don't exist but doesn't fix the problem deleting patrons with checkouts and still doesn't move holds to old_reserves.
(In reply to comment #6) > This revision seems to address the problem with handling patron barcodes > which don't exist but doesn't fix the problem deleting patrons with > checkouts and still doesn't move holds to old_reserves. I was under the assumption that MoveMemberToDeleted took care of this. Is there a sub call the script should be making that it doesn't?
I wonder if those options should be added to the delete_borrowers.pl script that already is in Koha. If we have 2 scripts, we should make clear where the differences are and they should both delete patrons the same way, taking fines, holds etc. into account.
Still valid?
Still valid (16.05), the only way to do this is batch add patrons into a category and use cleanborrowers.pl to delete the category.
Just a little update on this, there is another way to batch delete patrons from the GUI with 17.11: 1) Add patrons to a list 2) Go to the patron lists summary page 3) Actions > Batch delete patrons Maybe adding an option to add to patron list by cardnumber list/input would help? Similar to the batch edit/delete item tools.
(In reply to Katrin Fischer from comment #8) > I wonder if those options should be added to the delete_borrowers.pl script > that already is in Koha. If we have 2 scripts, we should make clear where > the differences are and they should both delete patrons the same way, taking > fines, holds etc. into account. I see that delete_borrowers.pl already has a --file option that works with a list of borrowernumber. I really think it would make most sense now to extend the existing script now so that we only have one script dealing with patron deletes from CLI. --file Delete patrons whose borrower numbers are in this file. If other criteria are defined it will only delete those in the file that match those criteria.