From 82cec5445468e733c5067fec3d5042355fa44c1d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 22 Apr 2020 16:03:01 +0200 Subject: [PATCH] Bug 25253: Allow to apply modification template when exporting checkouts Test plan: 0. Apply bug 24679 1. Enable ExportCircHistory syspref 2. Create a MARC modification template 3. Go to 'Check out' or 'Details' tab of a borrower with checkouts 4. Make the checkouts table appear 5. Under the checkouts table, choose a MARC modification template, and click on 'Export' 6. Verify that the modification template has been applied in the exported file --- .../Plugin/MarcModificationTemplates.pm | 48 +++++++++++++++++++ .../prog/en/includes/checkouts-table.inc | 13 +++++ .../Plugin/MarcModificationTemplates.t | 47 ++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 Koha/Template/Plugin/MarcModificationTemplates.pm create mode 100644 t/db_dependent/Template/Plugin/MarcModificationTemplates.t diff --git a/Koha/Template/Plugin/MarcModificationTemplates.pm b/Koha/Template/Plugin/MarcModificationTemplates.pm new file mode 100644 index 0000000000..72ebf57dfa --- /dev/null +++ b/Koha/Template/Plugin/MarcModificationTemplates.pm @@ -0,0 +1,48 @@ +package Koha::Template::Plugin::MarcModificationTemplates; + +# Copyright 2020 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 . + +use Modern::Perl; + +use C4::MarcModificationTemplates; + +use base 'Template::Plugin'; + +=head1 NAME + +Koha::Template::Plugin::MarcModificationTemplates + +=head1 SYNOPSIS + + [% USE MarcModificationTemplates %] + + [% marc_modification_templates = MarcModificationTemplates.all() %] + +=head1 METHODS + +=head2 all + +Returns all modification templates + + [% marc_modification_templates = MarcModificationTemplates.all() %] + +=cut + +sub all { + return [ C4::MarcModificationTemplates::GetModificationTemplates() ]; +} + +1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index 7b967bec89..44d310edeb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE MarcModificationTemplates %]
[% IF ( issuecount ) %]
@@ -71,6 +72,18 @@ [% END %] [% END %] + + [% marc_modification_templates = MarcModificationTemplates.all() %] + [% IF marc_modification_templates %] + + + [% END %] + diff --git a/t/db_dependent/Template/Plugin/MarcModificationTemplates.t b/t/db_dependent/Template/Plugin/MarcModificationTemplates.t new file mode 100644 index 0000000000..9e4aa6985c --- /dev/null +++ b/t/db_dependent/Template/Plugin/MarcModificationTemplates.t @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +use Modern::Perl; + +use Test::More tests => 2; + +use Koha::Database; + +use t::lib::TestBuilder; + +BEGIN { + use_ok('Koha::Template::Plugin::MarcModificationTemplates'); +} + +my $schema = Koha::Database->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'all() tests' => sub { + plan tests => 3; + + $schema->storage->txn_begin; + + $schema->resultset('MarcModificationTemplate')->delete(); + + $builder->build({ + source => 'MarcModificationTemplate', + value => { + name => 'template1', + } + }); + $builder->build({ + source => 'MarcModificationTemplate', + value => { + name => 'template2', + } + }); + + my $plugin = Koha::Template::Plugin::MarcModificationTemplates->new(); + + my $templates = $plugin->all(); + + is(scalar @$templates, 2, 'all() returns all templates'); + is($templates->[0]->{name}, 'template1', 'all() returns all templates'); + is($templates->[1]->{name}, 'template2', 'all() returns all templates'); + + $schema->storage->txn_rollback; +}; -- 2.20.1