Bugzilla – Attachment 3590 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]
Proposed Patch
0001-Bug-6027-MT3532-Deletes-biblio-record-when-there-are.patch (text/plain), 4.75 KB, created by
Chris Cormack
on 2011-03-31 21:01:38 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-03-31 21:01:38 UTC
Size:
4.75 KB
patch
obsolete
>From d3bad28b3bd437ef9c2e94083e506db3e8f29b86 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 22 Jun 2010 17:46:22 +0200 >Subject: [PATCH] Bug 6027 : MT3532: Deletes biblio record when there are no more items left for this biblio while batch item deleting > >--- > .../prog/en/modules/tools/batchMod-del.tmpl | 2 +- > tools/batchMod.pl | 56 +++++++++++-------- > 2 files changed, 33 insertions(+), 25 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >index 61e901b..183d330 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >@@ -145,7 +145,7 @@ for( x=0; x<allColumns.length; x++ ){ > <!-- /TMPL_UNLESS --> > > <!-- TMPL_IF name="action" --> >- <div class="dialog message"><p><!-- TMPL_VAR NAME="deleted_items" --> item(s) deleted.</p></div> >+ <div class="dialog message"><p><!-- TMPL_VAR NAME="deleted_items" --> item(s) deleted.<br /><!-- TMPL_VAR NAME="deleted_biblios" --> biblio(s) deleted.</p></div> > <!-- TMPL_IF NAME="not_deleted_items" --> > <div style="width:55%;margin:auto;"> > <p><!-- TMPL_VAR NAME="not_deleted_items" --> item(s) could not be deleted: <!-- TMPL_LOOP NAME="not_deleted_itemnumbers" --><!-- TMPL_VAR NAME="itemnumber" --><!-- /TMPL_LOOP --></p> >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index d9a0b76..4947814 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -2,6 +2,7 @@ > > > # Copyright 2000-2002 Katipo Communications >+# Copyright Biblibre 2010 > # > # This file is part of Koha. > # >@@ -76,6 +77,7 @@ my $frameworkcode=""; > my $tagslib = &GetMarcStructure(1,$frameworkcode); > > my $deleted_items = 0; # Numbers of deleted items >+my $deleted_biblios = 0; # Numbers of deleted biblios (when they have no more items) > my $not_deleted_items = 0; # Numbers of items that could not be deleted > my @not_deleted; # List of the itemnumbers that could not be deleted > >@@ -129,31 +131,36 @@ if ($op eq "action") { > } > > # For each item >- my $i = 1; >- foreach my $itemnumber(@itemnumbers){ >- >- $job->progress($i) if $runinbackground; >- my $itemdata=GetItem($itemnumber); >- if ($input->param("del")){ >- my $return = DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'}); >- if ($return == 1) { >- $deleted_items++; >- } else { >- $not_deleted_items++; >- push @not_deleted, { biblionumber => $itemdata->{'biblionumber'}, itemnumber => $itemdata->{'itemnumber'}, barcode => $itemdata->{'barcode'}, title => $itemdata->{'title'}, $return => 1 }; >- } >- } else { >- if ($something_to_modify) { >- my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag, 'ITEM'); >- my $marcitem = MARC::Record::new_from_xml($xml, 'UTF-8'); >- my $localitem = TransformMarcToKoha( $dbh, $marcitem, "", 'items' ); >- my $localmarcitem=Item2Marc($itemdata); >- UpdateMarcWith($marcitem,$localmarcitem); >- eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)}; >- } >+ my $i = 1; >+ foreach my $itemnumber(@itemnumbers){ >+ >+ $job->progress($i) if $runinbackground; >+ my $itemdata=GetItem($itemnumber); >+ if ($input->param("del")){ >+ my $return = DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'}); >+ if ($return == 1) { >+ $deleted_items++; >+ } else { >+ $not_deleted_items++; >+ push @not_deleted, { biblionumber => $itemdata->{'biblionumber'}, itemnumber => $itemdata->{'itemnumber'}, barcode => $itemdata->{'barcode'}, title => $itemdata->{'title'}, $return => 1 }; >+ } >+ >+ # If there are no items left, we delete the biblio >+ my $icount = GetItemsCount($itemdata->{'biblionumber'}); >+ if ($icount == 0) { >+ DelBiblio($itemdata->{'biblionumber'}); >+ $deleted_biblios++; > } >- $i++; >- } >+ >+ } else { >+ if ($values_to_modify||$values_to_blank) { >+ my $localmarcitem=Item2Marc($itemdata); >+ UpdateMarcWith($marcitem,$localmarcitem); >+ eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)}; >+ } >+ } >+ $i++; >+ } > } > } > # >@@ -401,6 +408,7 @@ if ($op eq "action") { > > $template->param( > not_deleted_items => $not_deleted_items, >+ deleted_biblios => $deleted_biblios, > deleted_items => $deleted_items, > not_deleted_loop => \@not_deleted > ); >-- >1.7.1 >
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