X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fexport.pl;h=0e05e3a61a3193344df07187050ff60195c6b513;hb=3f4d31309203b85b5415788967d4c8cf3ce83570;hp=a4eb6e9ddefdac34cc37e98932e32cc636c16d51;hpb=81ee945a580189e79a268f60d9e7638e92e85f26;p=koha_fer diff --git a/tools/export.pl b/tools/export.pl index a4eb6e9dde..0e05e3a61a 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -17,12 +17,13 @@ # Suite 330, Boston, MA 02111-1307 USA use Modern::Perl; +use MARC::File::XML; use List::MoreUtils qw(uniq); use Getopt::Long; use CGI; use C4::Auth; use C4::AuthoritiesMarc; # GetAuthority -use C4::Biblio; # GetMarcBiblio GetXmlBiblio +use C4::Biblio; # GetMarcBiblio use C4::Branch; # GetBranches use C4::Csv; use C4::Koha; # GetItemTypes @@ -117,13 +118,13 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( ); my $limit_ind_branch = - ( C4::Context->preference('IndependantBranches') + ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !( C4::Context->userenv->{flags} & 1 ) && C4::Context->userenv->{branch} ) ? 1 : 0; my $branch = $query->param("branch") || ''; -if ( C4::Context->preference("IndependantBranches") +if ( C4::Context->preference("IndependentBranches") && C4::Context->userenv && !( C4::Context->userenv->{flags} & 1 ) ) { @@ -309,6 +310,7 @@ if ( $op eq "export" ) { } @{ $sth->fetchall_arrayref }; } + my $xml_header_written = 0; for my $recordid ( uniq @recordids ) { if ($deleted_barcodes) { my $q = " @@ -374,19 +376,30 @@ if ( $op eq "export" ) { } RemoveAllNsb($record) if ($clean); if ( $output_format eq "xml" ) { - if ( $marcflavour eq 'UNIMARC' && $record_type eq 'auths' ) - { - print $record->as_xml_record('UNIMARCAUTH'); - } - else { - print $record->as_xml_record($marcflavour); + unless ($xml_header_written) { + MARC::File::XML->default_record_format( + ( + $marcflavour eq 'UNIMARC' + && $record_type eq 'auths' + ) ? 'UNIMARCAUTH' : $marcflavour + ); + print MARC::File::XML::header(); + print "\n"; + $xml_header_written = 1; } + print MARC::File::XML::record($record); + print "\n"; } else { print $record->as_usmarc(); } } } + if ($xml_header_written) { + print MARC::File::XML::footer(); + print "\n"; + } + exit; } elsif ( $format eq "csv" ) { @@ -466,7 +479,6 @@ else { $template->param( branchloop => \@branchloop, itemtypeloop => \@itemtypesloop, - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), authtypeloop => \@authtypesloop, export_remove_fields => C4::Context->preference("ExportRemoveFields"), ); @@ -538,12 +550,12 @@ sub construct_query { } if ($start_callnumber) { - $sql_query .= " AND itemcallnumber <= ? "; + $sql_query .= " AND itemcallnumber >= ? "; push @sql_params, $start_callnumber; } if ($end_callnumber) { - $sql_query .= " AND itemcallnumber >= ? "; + $sql_query .= " AND itemcallnumber <= ? "; push @sql_params, $end_callnumber; } if ($start_accession) {