Bug 3212 Force leader 9 position to 'a' for new biblios
[koha.git] / catalogue / labeledMARCdetail.pl
blobe72a6d115d41d6d7b4d7be42847846bc2d5b8bd5
1 #!/usr/bin/perl
3 # Copyright 2008-2009 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
22 use CGI;
23 use MARC::Record;
24 use C4::Auth;
25 use C4::Context;
26 use C4::Output;
27 use C4::Biblio;
28 use C4::Items;
29 use C4::Search; # enabled_staff_search_views
31 my $query = new CGI;
32 my $dbh = C4::Context->dbh;
33 my $biblionumber = $query->param('biblionumber');
34 my $frameworkcode = $query->param('frameworkcode');
35 $frameworkcode = GetFrameworkCode( $biblionumber ) unless ($frameworkcode);
36 my $popup =
37 $query->param('popup')
38 ; # if set to 1, then don't insert links, it's just to show the biblio
40 my $tagslib = GetMarcStructure(1,$frameworkcode);
41 my $record = GetMarcBiblio($biblionumber);
42 my $biblio = GetBiblioData($biblionumber);
43 # open template
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46 template_name => "catalogue/labeledMARCdetail.tmpl",
47 query => $query,
48 type => "intranet",
49 authnotrequired => 0,
50 flagsrequired => { catalogue => 1 },
51 debug => 1,
55 #count of item linked
56 my $itemcount = GetItemsCount($biblionumber);
57 $template->param( count => $itemcount,
58 bibliotitle => $biblio->{title}, );
60 #Getting the list of all frameworks
61 my $queryfwk =
62 $dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
63 $queryfwk->execute;
64 my %select_fwk;
65 my @select_fwk;
66 my $curfwk;
67 push @select_fwk, "Default";
68 $select_fwk{"Default"} = "Default";
70 while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) {
71 push @select_fwk, $fwk;
72 $select_fwk{$fwk} = $description;
74 $curfwk=$frameworkcode;
75 my $framework=CGI::scrolling_list( -name => 'Frameworks',
76 -id => 'Frameworks',
77 -default => $curfwk,
78 -OnChange => 'Changefwk(this);',
79 -values => \@select_fwk,
80 -labels => \%select_fwk,
81 -size => 1,
82 -multiple => 0 );
83 $template->param(framework => $framework);
85 my @marc_data;
86 my $prevlabel = '';
87 for my $field ($record->fields)
89 my $tag = $field->tag;
90 next if ! exists $tagslib->{$tag}->{lib};
91 my $label = $tagslib->{$tag}->{lib};
92 if ($label eq $prevlabel)
94 $label = '';
96 else
98 $prevlabel = $label;
100 my $value = $tag < 10
101 ? $field->data
102 : join ' ', map { $_->[1] } $field->subfields;
103 push @marc_data, {
104 label => $label,
105 value => $value,
109 $template->param (
110 marc_data => \@marc_data,
111 biblionumber => $biblionumber,
112 popup => $popup,
113 labeledmarcview => 1,
114 z3950_search_params => C4::Search::z3950_search_args($biblio),
115 C4::Search::enabled_staff_search_views,
118 output_html_with_http_headers $query, $cookie, $template->output;