Bug 17820: use ->find instead of search->next
[koha.git] / tools / showdiffmarc.pl
blobec0f73518103ca39dd60622cca37963dc337950a
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 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.
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.
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.
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::ImportBatch;
34 # Input params
35 my $input = new CGI;
36 my $biblionumber = $input->param('id');
37 my $importid = $input->param('importid');
38 my $batchid = $input->param('batchid');
40 if ( not $biblionumber or not $importid ) {
41 print $input->redirect("/cgi-bin/koha/errors/404.pl");
42 exit;
45 # Init vars
46 my ($recordBiblionumber, $recordImportid, $biblioTitle, $importTitle, $formatted1, $formatted2, $errorFormatted1, $errorFormatted2);
48 # Prepare template
49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51 template_name => "tools/showdiffmarc.tt",
52 query => $input,
53 type => "intranet",
54 authnotrequired => 0,
55 flagsrequired => { tools => 'manage_staged_marc' },
56 debug => 1,
60 $recordBiblionumber = GetMarcBiblio($biblionumber, 'embed_items');
61 if( $recordBiblionumber ) {
62 $formatted1 = $recordBiblionumber->as_formatted;
63 my $data = GetBiblioData($biblionumber);
64 $biblioTitle = $data->{title};
65 } else {
66 $errorFormatted1 = 1;
69 if( $importid ) {
70 $recordImportid = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
71 $formatted2 = $recordImportid->as_formatted;
72 my $biblio = GetImportBiblios($importid);
73 $importTitle = $biblio->[0]->{'title'};
74 } else {
75 $errorFormatted2 = 1;
78 $template->param(
79 SCRIPT_NAME => '/cgi-bin/koha/tools/showdiffmarc.pl',
80 BIBLIONUMBER => $biblionumber,
81 IMPORTID => $importid,
82 BIBLIOTITLE => $biblioTitle,
83 IMPORTTITLE => $importTitle,
84 MARC_FORMATTED1 => $formatted1,
85 MARC_FORMATTED2 => $formatted2,
86 ERROR_FORMATTED1 => $errorFormatted1,
87 ERROR_FORMATTED2 => $errorFormatted2,
88 batchid => $batchid
91 output_html_with_http_headers $input, $cookie, $template->output;