Bug 14957: Fix record preview

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-10-18 13:04:55 +02:00
parent 6ab1ca2428
commit f756d9534e
2 changed files with 30 additions and 8 deletions

View file

@ -198,7 +198,7 @@
<td>[% biblio.biblionumber | html %]</td>
<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a></td>
<td class="actions">
<a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber | uri %]&mmtid=[% mmtid | uri %]" class="previewMARC btn btn-default btn-xs" data-record_type="biblio" data-record_id="[% biblio.biblionumber | html %]" data-mmtid="[% mmtid | html %]" title="Preview MARC"><i class="fa fa-eye"></i> Show MARC</a>
<a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber | uri %]&mmtid=[% mmtid | uri %]&overlay_context=batchmod" class="previewMARC btn btn-default btn-xs" data-record_type="biblio" data-record_id="[% biblio.biblionumber | html %]" data-mmtid="[% mmtid | html %]" title="Preview MARC"><i class="fa fa-eye"></i> Show MARC</a>
</td>
</tr>
[% END %]
@ -225,7 +225,7 @@
<td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
<td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
<td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td>
<td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid | uri %]&mmtid=[% mmtid | uri %]" data-record_type="authority" data-record_id="[% authority.authid | html %]" data-mmtid="[% mmtid | html %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a>
<td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid | uri %]&mmtid=[% mmtid | uri %]&overlay_context=batchmod" data-record_type="authority" data-record_id="[% authority.authid | html %]" data-mmtid="[% mmtid | html %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a>
</tr>
[% END %]
</tbody>
@ -355,7 +355,7 @@
var url = "/cgi-bin/koha/svc/records/preview?"
var mmtid = $(this).val();
$("a.previewMARC").each(function() {
$(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
$(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod");
});
});

View file

@ -20,14 +20,17 @@
use Modern::Perl;
use CGI;
use C4::Auth qw( get_template_and_user );
use C4::Biblio qw( GetMarcBiblio );
use C4::Biblio qw( GetMarcBiblio 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;
@ -38,15 +41,34 @@ if ( $record_type eq 'biblio' ) {
$record = $authority->record;
}
if ( $mmtid ) {
ModifyRecordWithTemplate( $mmtid, $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;