From 4b027bc4c9d9b33238ff67bd6cab6ec1667cb416 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Wed, 10 Mar 2010 22:26:15 +0100 Subject: [PATCH] MT2527 : Adds default empty value for branches when batch modifying items (so they are not modified by mistake) Signed-off-by: Henri-Damien LAURENT Signed-off-by: Galen Charlton --- tools/batchMod.pl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index f7e9557ef1..4962607200 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -87,9 +87,10 @@ if ($op eq "action") { my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); - 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' ); + # Is there something to modify ? + # TODO : We shall use this var to warn the user in case no modification was done to the items + my $something_to_modify = scalar(grep {!/^$/} @values); + foreach my $itemnumber(@itemnumbers){ my $itemdata=GetItem($itemnumber); if ($input->param("del")){ @@ -101,9 +102,14 @@ if ($op eq "action") { push @not_deleted, { 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)}; + } } } # If we have a reasonable amount of items, we display them @@ -182,6 +188,11 @@ my $i=0; my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib"); my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later. + +# Adding a default choice, in case the user does not want to modify the branch +my @nochange_branch = { branchname => '', value => '', selected => 1 }; +unshift (@$branches, @nochange_branch); + my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); -- 2.39.5