Bug 15367: Do not display repeatable patron attributes in the batch patron modification
[koha.git] / tools / showdiffmarc.pl
1 #!/usr/bin/perl
2
3 # Koha library project  www.koha-community.org
4
5 # Copyright 2011 LibĂ©o
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 3 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 use Modern::Perl;
23
24 # standard or CPAN modules used
25 use CGI qw(:standard);
26 use DBI;
27
28 # Koha modules used
29 use C4::Context;
30 use C4::Output;
31 use C4::Auth;
32 use C4::Biblio;
33 use C4::ImportBatch;
34 use XML::LibXSLT;
35 use XML::LibXML;
36
37
38 # Input params
39 my $input        = new CGI;
40 my $biblionumber = $input->param('id');
41 my $importid     = $input->param('importid');
42 my $batchid      = $input->param('batchid');
43
44
45 if ( not $biblionumber or not $importid ) {
46     print $input->redirect("/cgi-bin/koha/errors/404.pl");
47     exit;
48 }
49
50 # Init vars
51 my ($recordBiblionumber, $recordImportid, $biblioTitle, $importTitle, $formatted1, $formatted2,
52     $errorFormatted1, $errorFormatted2);
53
54
55 # Prepare template
56 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57     {
58         template_name   => "tools/showdiffmarc.tt",
59         query           => $input,
60         type            => "intranet",
61         authnotrequired => 0,
62         flagsrequired   => { tools => 'manage_staged_marc' },
63         debug           => 1,
64     }
65 );
66
67
68 $recordBiblionumber = GetMarcBiblio($biblionumber, 'embed_items');
69 if( $recordBiblionumber ) {
70     $formatted1 = $recordBiblionumber->as_formatted;
71     my $data = GetBiblioData($biblionumber);
72     $biblioTitle = $data->{title};
73 } else {
74     $errorFormatted1 = 1;
75 }
76
77 if( $importid ) {
78     $recordImportid = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
79     $formatted2 = $recordImportid->as_formatted;
80     my $biblio = GetImportBiblios($importid);
81     $importTitle = $biblio->[0]->{'title'};
82 } else {
83     $errorFormatted2 = 1;
84 }
85
86
87 $template->param(
88     SCRIPT_NAME      => '/cgi-bin/koha/tools/showdiffmarc.pl',
89     BIBLIONUMBER     => $biblionumber,
90     IMPORTID         => $importid,
91     BIBLIOTITLE      => $biblioTitle,
92     IMPORTTITLE      => $importTitle,
93     MARC_FORMATTED1  => $formatted1,
94     MARC_FORMATTED2  => $formatted2,
95     ERROR_FORMATTED1 => $errorFormatted1,
96     ERROR_FORMATTED2 => $errorFormatted2,
97     batchid          => $batchid
98 );
99
100 output_html_with_http_headers $input, $cookie, $template->output;