Bugzilla – Attachment 17208 Details for
Bug 7131
way to overlay items in in marc import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7131 - Followup 1 - Clean up sub BatchCommitItems
Bug-7131---Followup-1---Clean-up-sub-BatchCommitIt.patch (text/plain), 5.32 KB, created by
Kyle M Hall (khall)
on 2013-04-05 11:55:51 UTC
(
hide
)
Description:
Bug 7131 - Followup 1 - Clean up sub BatchCommitItems
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-04-05 11:55:51 UTC
Size:
5.32 KB
patch
obsolete
>From 7900e23d34ed8a3c0c8763b25153d1db16f4836f Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 5 Apr 2013 07:26:43 -0400 >Subject: [PATCH] Bug 7131 - Followup 1 - Clean up sub BatchCommitItems > >--- > C4/ImportBatch.pm | 74 ++++++++++++++++++++++++++++------------------------- > 1 files changed, 39 insertions(+), 35 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index c92c5eb..3f1ceab 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -682,55 +682,59 @@ sub BatchCommitRecords { > =cut > > sub BatchCommitItems { >- my ($import_record_id, $biblionumber, $action) = @_; >+ my ( $import_record_id, $biblionumber, $action ) = @_; > > my $dbh = C4::Context->dbh; > >- my ($num_items_added, $num_items_errored, $num_items_replaced) = 0; >- my $sth = $dbh->prepare("SELECT import_items_id, import_items.marcxml, encoding >- FROM import_items >- JOIN import_records USING (import_record_id) >- WHERE import_record_id = ? >- ORDER BY import_items_id"); >- $sth->bind_param(1, $import_record_id); >+ my ( $num_items_added, $num_items_errored, $num_items_replaced ) = 0; >+ my $sth = $dbh->prepare(" >+ SELECT import_items_id, import_items.marcxml, encoding >+ FROM import_items >+ JOIN import_records USING (import_record_id) >+ WHERE import_record_id = ? >+ ORDER BY import_items_id >+ "); >+ $sth->bind_param( 1, $import_record_id ); > $sth->execute(); >- while (my $row = $sth->fetchrow_hashref()) { >- my $item_marc = MARC::Record->new_from_xml(StripNonXmlChars($row->{'marcxml'}), 'UTF-8', $row->{'encoding'}); >- #delete date_due subfield as to not accidentally delete item checkout due dates >- my ($MARCfield,$MARCsubfield) = GetMarcFromKohaField('items.onloan', GetFrameworkCode($biblionumber)); >- $item_marc->field($MARCfield)->delete_subfield(code => $MARCsubfield); >- # FIXME - duplicate barcode check needs to become part of AddItemFromMarc() >- my $item = TransformMarcToKoha($dbh, $item_marc); >- my $duplicate_barcode = exists($item->{'barcode'}) && GetItemnumberFromBarcode($item->{'barcode'}); >- my $duplicate_itemnumber = exists($item->{'itemnumber'}); >- my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); >- if($action eq "replace" && $duplicate_itemnumber){ >- ModItemFromMarc($item_marc, $biblionumber, $item->{itemnumber}); >- $updsth->bind_param(1, 'imported'); >- $updsth->bind_param(2, $item->{itemnumber}); >- $updsth->bind_param(3, $row->{'import_items_id'}); >+ while ( my $row = $sth->fetchrow_hashref() ) { >+ my $item_marc = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); >+ >+ #delete date_due subfield as to not accidentally delete item checkout due dates >+ my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) ); >+ $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); >+ >+ my $item = TransformMarcToKoha( $dbh, $item_marc ); >+ >+ my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} ); >+ my $duplicate_itemnumber = exists( $item->{'itemnumber'} ); >+ >+ my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); >+ if ( $action eq "replace" && $duplicate_itemnumber ) { >+ ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); >+ $updsth->bind_param( 1, 'imported' ); >+ $updsth->bind_param( 2, $item->{itemnumber} ); >+ $updsth->bind_param( 3, $row->{'import_items_id'} ); > $updsth->execute(); > $updsth->finish(); >- $num_items_replaced++; >- } >- elsif ($duplicate_barcode) { >- $updsth->bind_param(1, 'error'); >- $updsth->bind_param(2, 'duplicate item barcode'); >- $updsth->bind_param(3, $row->{'import_items_id'}); >+ $num_items_replaced++; >+ } elsif ($duplicate_barcode) { >+ $updsth->bind_param( 1, 'error' ); >+ $updsth->bind_param( 2, 'duplicate item barcode' ); >+ $updsth->bind_param( 3, $row->{'import_items_id'} ); > $updsth->execute(); > $num_items_errored++; > } else { >- my ($item_biblionumber, $biblioitemnumber, $itemnumber) = AddItemFromMarc($item_marc, $biblionumber); >- $updsth->bind_param(1, 'imported'); >- $updsth->bind_param(2, $itemnumber); >- $updsth->bind_param(3, $row->{'import_items_id'}); >+ my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); >+ $updsth->bind_param( 1, 'imported' ); >+ $updsth->bind_param( 2, $itemnumber ); >+ $updsth->bind_param( 3, $row->{'import_items_id'} ); > $updsth->execute(); > $updsth->finish(); > $num_items_added++; > } > } >- $sth->finish(); >- return ($num_items_added, $num_items_replaced, $num_items_errored); >+ >+ return ( $num_items_added, $num_items_replaced, $num_items_errored ); > } > > =head2 BatchRevertRecords >-- >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 7131
:
14344
|
14475
|
15954
|
15957
|
16887
|
16889
|
17208
|
17209
|
17210
|
17211
|
17212
|
18708
|
18709
|
18710
|
18711
|
18967
|
18968
|
18969
|
20455
|
21797