From 550801cb5da464c7d518b7b6b1547d14fedb753c Mon Sep 17 00:00:00 2001 From: Frederic Demians Date: Wed, 16 Jul 2008 18:11:29 +0200 Subject: [PATCH] Fixed bug #2357 Signed-off-by: Joshua Ferraro --- tools/export.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index 09075f9b14..6ee01455fe 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -73,9 +73,17 @@ if ($op eq "export") { my $strip_nonlocal_items = $query->param("strip_nonlocal_items"); my $dont_export_fields = $query->param("dont_export_fields"); my @sql_params; - my $query = " SELECT DISTINCT biblioitems.biblionumber - FROM biblioitems,items - WHERE biblioitems.biblionumber=items.biblionumber "; + + my $items_filter = + $branch || $start_callnumber || $end_callnumber || + $start_accession || $end_accession || + ($itemtype && C4::Context->preference('item-level_itypes')); + my $query = $items_filter ? + "SELECT DISTINCT biblioitems.biblionumber + FROM biblioitems,items + WHERE biblioitems.biblionumber=items.biblionumber " + : + "SELECT biblioitems.biblionumber FROM biblioitems WHERE biblionumber >0 "; if ( $StartingBiblionumber ) { $query .= " AND biblioitems.biblionumber >= ? "; @@ -120,8 +128,10 @@ if ($op eq "export") { while (my ($biblionumber) = $sth->fetchrow) { my $record = GetMarcBiblio($biblionumber); - my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField( 'items.homebranch', '' ); + if ( $dont_export_items || $strip_nonlocal_items || $limit_ind_branch) { + my ( $homebranchfield, $homebranchsubfield ) = + GetMarcFromKohaField( 'items.homebranch', '' ); for my $itemfield ($record->field($homebranchfield)){ # if stripping nonlocal items, use loggedinuser's branch if they didn't select one $branch = C4::Context->userenv->{'branch'} unless $branch; -- 2.39.5