Bug 20180: [sql_modes] Remove GROUP BY clause in manage-marc-import.pl
[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 -utf8);
26
27 # Koha modules used
28 use C4::Context;
29 use C4::Output;
30 use C4::Auth;
31 use C4::Biblio;
32 use C4::ImportBatch;
33
34 use Koha::Biblios;
35
36 # Input params
37 my $input        = new CGI;
38 my $biblionumber = $input->param('id');
39 my $importid     = $input->param('importid');
40 my $batchid      = $input->param('batchid');
41
42 if ( not $biblionumber or not $importid ) {
43     print $input->redirect("/cgi-bin/koha/errors/404.pl");
44     exit;
45 }
46
47 # Init vars
48 my ($recordBiblionumber, $recordImportid, $biblioTitle, $importTitle, $formatted1, $formatted2, $errorFormatted1, $errorFormatted2);
49
50 # Prepare template
51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
52     {
53         template_name   => "tools/showdiffmarc.tt",
54         query           => $input,
55         type            => "intranet",
56         authnotrequired => 0,
57         flagsrequired   => { tools => 'manage_staged_marc' },
58         debug           => 1,
59     }
60 );
61
62 $recordBiblionumber = GetMarcBiblio({
63     biblionumber => $biblionumber,
64     embed_items  => 1,
65 });
66 if( $recordBiblionumber ) {
67     $formatted1 = $recordBiblionumber->as_formatted;
68     my $biblio = Koha::Biblios->find( $biblionumber );
69     $biblioTitle = $biblio->title;
70 } else {
71     $errorFormatted1 = 1;
72 }
73
74 if( $importid ) {
75     $recordImportid = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
76     $formatted2 = $recordImportid->as_formatted;
77     my $biblio = GetImportBiblios($importid);
78     $importTitle = $biblio->[0]->{'title'};
79 } else {
80     $errorFormatted2 = 1;
81 }
82
83 $template->param(
84     SCRIPT_NAME      => '/cgi-bin/koha/tools/showdiffmarc.pl',
85     BIBLIONUMBER     => $biblionumber,
86     IMPORTID         => $importid,
87     BIBLIOTITLE      => $biblioTitle,
88     IMPORTTITLE      => $importTitle,
89     MARC_FORMATTED1  => $formatted1,
90     MARC_FORMATTED2  => $formatted2,
91     ERROR_FORMATTED1 => $errorFormatted1,
92     ERROR_FORMATTED2 => $errorFormatted2,
93     batchid          => $batchid
94 );
95
96 output_html_with_http_headers $input, $cookie, $template->output;