MT 1487 : Ability to cancel orders when receiving shipments
[koha.git] / catalogue / labeledMARCdetail.pl
blob60ee95367df1c79c6ca1213a25f6b89f89a08966
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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 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::Search; # enabled_staff_search_views
30 my $query = new CGI;
31 my $dbh = C4::Context->dbh;
32 my $biblionumber = $query->param('biblionumber');
33 my $frameworkcode = $query->param('frameworkcode');
34 $frameworkcode = GetFrameworkCode( $biblionumber ) unless ($frameworkcode);
35 my $popup =
36 $query->param('popup')
37 ; # if set to 1, then don't insert links, it's just to show the biblio
39 my $tagslib = GetMarcStructure(1,$frameworkcode);
40 my $record = GetMarcBiblio($biblionumber);
41 my $biblio = GetBiblioData($biblionumber);
42 # open template
43 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45 template_name => "catalogue/labeledMARCdetail.tmpl",
46 query => $query,
47 type => "intranet",
48 authnotrequired => 0,
49 flagsrequired => { catalogue => 1 },
50 debug => 1,
54 $template->param( count => 1, bibliotitle => $biblio->{title} );
56 #Getting the list of all frameworks
57 my $queryfwk =
58 $dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
59 $queryfwk->execute;
60 my %select_fwk;
61 my @select_fwk;
62 my $curfwk;
63 push @select_fwk, "Default";
64 $select_fwk{"Default"} = "Default";
66 while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) {
67 push @select_fwk, $fwk;
68 $select_fwk{$fwk} = $description;
70 $curfwk=$frameworkcode;
71 my $framework=CGI::scrolling_list( -name => 'Frameworks',
72 -id => 'Frameworks',
73 -default => $curfwk,
74 -OnChange => 'Changefwk(this);',
75 -values => \@select_fwk,
76 -labels => \%select_fwk,
77 -size => 1,
78 -multiple => 0 );
79 $template->param(framework => $framework);
81 my @marc_data;
82 my $prevlabel = '';
83 for my $field ($record->fields)
85 my $tag = $field->tag;
86 next if ! exists $tagslib->{$tag}->{lib};
87 my $label = $tagslib->{$tag}->{lib};
88 if ($label eq $prevlabel)
90 $label = '';
92 else
94 $prevlabel = $label;
96 my $value = $tag < 10
97 ? $field->data
98 : join ' ', map { $_->[1] } $field->subfields;
99 push @marc_data, {
100 label => $label,
101 value => $value,
105 $template->param (
106 marc_data => \@marc_data,
107 biblionumber => $biblionumber,
108 popup => $popup,
109 labeledmarcview => 1,
110 z3950_search_params => C4::Search::z3950_search_args($biblio),
111 C4::Search::enabled_staff_search_views,
114 output_html_with_http_headers $query, $cookie, $template->output;