Koha/svc/records/preview
Owen Leonard 09874fce6c
Bug 32631: Error when previewing record during batch record modification
This patch corrects an error in the script which outputs MARC data for
preview during batch record modification.

To test, apply the patch and restart services. You will need at least
one MARC modification template in your system.

- Go to Cataloging -> Batch record modification
- Submit a batch of bibliographic records
- In the table of records that follows, click any "Show MARC" button. A
  modal window should appear with a preview of the modified record.

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-01-27 16:16:43 -03:00

75 lines
2.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright (C) 2013 BibLibre
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
use C4::Auth qw( get_template_and_user );
use C4::Biblio qw( ApplyMarcOverlayRules );
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
use C4::Output qw( output_html_with_http_headers );
use Koha::MetadataRecord::Authority;
use Koha::Patrons;
my $query = CGI->new();
my $record_id = $query->param('record_id');
my $record_type = $query->param('record_type') || 'biblio';
my $overlay_context = $query->param('overlay_context');
my $mmtid = $query->param('mmtid'); # Marc modification template id
my $record;
if ( $record_type eq 'biblio' ) {
my $biblio = Koha::Biblios->find( $record_id );
$record = $biblio->metadata->record;
} else {
my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
$record = $authority->record;
}
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
template_name => "catalogue/showmarc.tt",
query => $query,
type => "intranet",
});
if ($mmtid) {
ModifyRecordWithTemplate( $mmtid, $record );
if ( $record_type eq 'biblio'
&& C4::Context->preference('MARCOverlayRules')
&& $overlay_context )
{
my $logged_in_user = Koha::Patrons->find($loggedinuser);
$record = ApplyMarcOverlayRules(
{
biblionumber => $record_id,
record => $record,
overlay_context => {
source => $overlay_context,
categorycode => $logged_in_user->categorycode,
userid => $logged_in_user->userid
},
}
);
}
}
$template->param( MARC_FORMATTED => $record->as_formatted );
output_html_with_http_headers $query, $cookie, $template->output;