Bug 24526: Add the confirm flag to the cronjob files
[koha.git] / tools / showdiffmarc.pl
blobf8219aa3b66f97a232a92934d65f976779198a01
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::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 authnotrequired => 0,
59 flagsrequired => { tools => 'manage_staged_marc' },
60 debug => 1,
64 if ( $type eq 'biblio' ) {
65 $record = GetMarcBiblio({
66 biblionumber => $recordid,
67 embed_items => 1,
68 });
69 my $biblio = Koha::Biblios->find( $recordid );
70 $recordTitle = $biblio->title;
72 elsif ( $type eq 'auth' ) {
73 $record = GetAuthority( $recordid );
74 $recordTitle = "Authority number " . $recordid; #FIXME we should get the main heading
76 if( $record ) {
77 $formatted1 = $record->as_formatted;
78 } else {
79 $errorFormatted1 = 1;
82 if( $importid ) {
83 $recordImportid = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
84 $formatted2 = $recordImportid->as_formatted;
85 my $biblio = GetImportBiblios($importid);
86 $importTitle = $biblio->[0]->{'title'};
87 } else {
88 $errorFormatted2 = 1;
91 $template->param(
92 SCRIPT_NAME => '/cgi-bin/koha/tools/showdiffmarc.pl',
93 RECORDID => $recordid,
94 IMPORTID => $importid,
95 RECORDTITLE => $recordTitle,
96 IMPORTTITLE => $importTitle,
97 MARC_FORMATTED1 => $formatted1,
98 MARC_FORMATTED2 => $formatted2,
99 ERROR_FORMATTED1 => $errorFormatted1,
100 ERROR_FORMATTED2 => $errorFormatted2,
101 batchid => $batchid
104 output_html_with_http_headers $input, $cookie, $template->output;