Bug 26290: Make Makefile.PL aware of SMTP configs
[koha.git] / tools / showdiffmarc.pl
blob48f622aab529481228310f377658bfbec71667f4
1 #!/usr/bin/perl
3 # Koha library project www.koha-community.org
5 # Copyright 2011 Libéo
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Modern::Perl;
24 # standard or CPAN modules used
25 use CGI qw(:standard -utf8);
27 # Koha modules used
28 use C4::Context;
29 use C4::Output;
30 use C4::Auth;
31 use C4::Biblio;
32 use C4::AuthoritiesMarc;
33 use C4::ImportBatch;
35 use Koha::Biblios;
37 # Input params
38 my $input = new CGI;
39 my $recordid = $input->param('id');
40 my $importid = $input->param('importid');
41 my $batchid = $input->param('batchid');
42 my $type = $input->param('type');
44 if ( not $recordid or not $importid ) {
45 print $input->redirect("/cgi-bin/koha/errors/404.pl");
46 exit;
49 # Init vars
50 my ($record, $recordImportid, $recordTitle, $importTitle, $formatted1, $formatted2, $errorFormatted1, $errorFormatted2);
52 # Prepare template
53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
55 template_name => "tools/showdiffmarc.tt",
56 query => $input,
57 type => "intranet",
58 flagsrequired => { tools => 'manage_staged_marc' },
59 debug => 1,
63 if ( $type eq 'biblio' ) {
64 $record = GetMarcBiblio({
65 biblionumber => $recordid,
66 embed_items => 1,
67 });
68 my $biblio = Koha::Biblios->find( $recordid );
69 $recordTitle = $biblio->title;
71 elsif ( $type eq 'auth' ) {
72 $record = GetAuthority( $recordid );
73 $recordTitle = "Authority number " . $recordid; #FIXME we should get the main heading
75 if( $record ) {
76 $formatted1 = $record->as_formatted;
77 } else {
78 $errorFormatted1 = 1;
81 if( $importid ) {
82 $recordImportid = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
83 $formatted2 = $recordImportid->as_formatted;
84 my $biblio = GetImportBiblios($importid);
85 $importTitle = $biblio->[0]->{'title'};
86 } else {
87 $errorFormatted2 = 1;
90 $template->param(
91 SCRIPT_NAME => '/cgi-bin/koha/tools/showdiffmarc.pl',
92 RECORDID => $recordid,
93 IMPORTID => $importid,
94 RECORDTITLE => $recordTitle,
95 IMPORTTITLE => $importTitle,
96 MARC_FORMATTED1 => $formatted1,
97 MARC_FORMATTED2 => $formatted2,
98 ERROR_FORMATTED1 => $errorFormatted1,
99 ERROR_FORMATTED2 => $errorFormatted2,
100 batchid => $batchid
103 output_html_with_http_headers $input, $cookie, $template->output;