Bugzilla – Attachment 7737 Details for
Bug 6027
Delete biblios if deleting all their items in batch deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6027 - Delete biblios if deleting all their items in batch deletion
Bug-6027---Delete-biblios-if-deleting-all-their-it.patch (text/plain), 7.25 KB, created by
Kyle M Hall
on 2012-02-17 15:28:23 UTC
(
hide
)
Description:
Bug 6027 - Delete biblios if deleting all their items in batch deletion
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2012-02-17 15:28:23 UTC
Size:
7.25 KB
patch
obsolete
>From a77b14cd566ab517aaed2ff1b068d7d7467d08a1 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 17 Feb 2012 09:36:38 -0500 >Subject: [PATCH] Bug 6027 - Delete biblios if deleting all their items in batch deletion > >Optionally delete bibliographic record when batch deleting items, if no items remain on the record. > >Adds deleting of reserves to DelBiblio. Since subscriptions are deleted automatically, >it made sense for deletion of reserves to maintain the same behavior. >--- > C4/Biblio.pm | 8 ++++++ > C4/Items.pm | 1 + > C4/Reserves.pm | 6 ++-- > .../prog/en/modules/tools/batchMod-del.tt | 6 +++- > tools/batchMod.pl | 27 ++++++++++++++----- > 5 files changed, 37 insertions(+), 11 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 8d2dd9d..7702fc2 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -35,6 +35,7 @@ use C4::Dates qw/format_date/; > use C4::Log; # logaction > use C4::ClassSource; > use C4::Charset; >+ > require C4::Heading; > require C4::Serials; > require C4::Items; >@@ -423,6 +424,13 @@ sub DelBiblio { > &C4::Serials::DelSubscription( $subscription->{subscriptionid} ); > } > >+ # We delete any existing holds >+ my ($count, $reserves) = C4::Reserves::GetReservesFromBiblionumber($biblionumber); >+ foreach my $res ( @$reserves ) { >+ warn Data::Dumper::Dumper( $res ); >+ C4::Reserves::CancelReserve( $res->{'biblionumber'}, $res->{'itemnumber'}, $res->{'borrowernumber'} ); >+ } >+ > # Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio > # for at least 2 reasons : > # - we need to read the biblio if NoZebra is set (to remove it from the indexes >diff --git a/C4/Items.pm b/C4/Items.pm >index 04cb417..c4f7aa7 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -33,6 +33,7 @@ use C4::Branch; > require C4::Reserves; > use C4::Charset; > use C4::Acquisition; >+use C4::Search; > use List::MoreUtils qw/any/; > use Data::Dumper; # used as part of logging item record changes, not just for > # debugging; so please don't remove this >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 359bbad..07421ba 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -98,7 +98,7 @@ BEGIN { > &GetReservesToBranch > &GetReserveCount > &GetReserveFee >- &GetReserveInfo >+ &GetReserveInfo > &GetReserveStatus > > &GetOtherReserves >@@ -880,8 +880,8 @@ sub CancelExpiredReserves { > Cancels a reserve. > > Use either C<$biblionumber> or C<$itemnumber> to specify the item to >-cancel, but not both: if both are given, C<&CancelReserve> does >-nothing. >+cancel, but not both: if both are given, C<&CancelReserve> uses >+C<$itemnumber>. > > C<$borrowernumber> is the borrower number of the patron on whose > behalf the book was reserved. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt >index af2a239..3f0f4b9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt >@@ -133,6 +133,7 @@ for( x=0; x<allColumns.length; x++ ){ > <div id="jobfailed"></div> > </div> > [% IF ( too_many_items ) %]<input type="submit" name="mainformsubmit" value="Delete ALL submitted items" onclick="return submitBackgroundJob(this.form);" />[% ELSE %] >+ <input type="checkbox" name="del_records" id="del_records" /> <label for="del_records">Delete records if no items remain.</label><p> > <input type="submit" name="mainformsubmit" value="Delete selected items" onclick="return submitBackgroundJob(this.form);" />[% END %] > > <a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a> >@@ -146,7 +147,10 @@ for( x=0; x<allColumns.length; x++ ){ > [% END %] > > [% IF ( action ) %] >- <div class="dialog message"><p>[% deleted_items %] item(s) deleted.</p></div> >+ <div class="dialog message"> >+ <p>[% deleted_items %] item(s) deleted.</p> >+ [% IF delete_records %] <p>[% deleted_records %] record(s) deleted.</p> [% END %] >+ </div> > [% IF ( not_deleted_items ) %] > <div style="width:55%;margin:auto;"> > <p>[% not_deleted_items %] item(s) could not be deleted: [% FOREACH not_deleted_itemnumber IN not_deleted_itemnumbers %][% not_deleted_itemnumber.itemnumber %][% END %]</p> >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 94cfa69..9e106dd 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -41,6 +41,7 @@ my $error = $input->param('error'); > my @itemnumbers = $input->param('itemnumber'); > my $op = $input->param('op'); > my $del = $input->param('del'); >+my $del_records = $input->param('del_records'); > my $completedJobID = $input->param('completedJobID'); > my $runinbackground = $input->param('runinbackground'); > >@@ -76,8 +77,9 @@ my $items_display_hashref; > my $frameworkcode=""; > my $tagslib = &GetMarcStructure(1,$frameworkcode); > >-my $deleted_items = 0; # Numbers of deleted items >-my $not_deleted_items = 0; # Numbers of items that could not be deleted >+my $deleted_items = 0; # Number of deleted items >+my $deleted_records = 0; # Number of deleted records ( with no items attached ) >+my $not_deleted_items = 0; # Number of items that could not be deleted > my @not_deleted; # List of the itemnumbers that could not be deleted > > my %cookies = parse CGI::Cookie($cookie); >@@ -156,7 +158,7 @@ if ($op eq "action") { > foreach my $itemnumber(@itemnumbers){ > > $job->progress($i) if $runinbackground; >- my $itemdata=GetItem($itemnumber); >+ my $itemdata = GetItem($itemnumber); > if ($input->param("del")){ > my $return = DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'}); > if ($return == 1) { >@@ -171,15 +173,24 @@ if ($op eq "action") { > $return => 1 > }; > } >+ >+ # If there are no items left, delete the biblio >+ if ( $del_records ) { >+ my $itemscount = GetItemsCount($itemdata->{'biblionumber'}); >+ if ( $itemscount == 0 ) { >+ my $error = DelBiblio($itemdata->{'biblionumber'}); >+ $deleted_records++ unless ( $error ); >+ } >+ } > } else { > if ($values_to_modify || $values_to_blank) { > my $localmarcitem = Item2Marc($itemdata); > UpdateMarcWith( $marcitem, $localmarcitem ); > eval{ >- if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) { >- LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $item->{itemlost}; >- } >- }; >+ if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) { >+ LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $item->{itemlost}; >+ } >+ }; > } > } > $i++; >@@ -432,6 +443,8 @@ if ($op eq "action") { > $template->param( > not_deleted_items => $not_deleted_items, > deleted_items => $deleted_items, >+ delete_records => $del_records, >+ deleted_records => $deleted_records, > not_deleted_loop => \@not_deleted > ); > } >-- >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 6027
:
3590
|
7737
|
8235
|
8239
|
8733