Bug 6536: QA Follow-up for string changes referring to Z39.50
[koha.git] / catalogue / labeledMARCdetail.pl
blob11f8f8555e691b56119ee2a760010abd38b282a9
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::Members; # to use GetMember
30 use C4::Search; # enabled_staff_search_views
31 use C4::Acquisition qw(GetOrdersByBiblionumber);
32 use C4::Koha qw( GetFrameworksLoop );
34 my $query = new CGI;
35 my $dbh = C4::Context->dbh;
36 my $biblionumber = $query->param('biblionumber');
37 my $frameworkcode = $query->param('frameworkcode');
38 $frameworkcode = GetFrameworkCode( $biblionumber ) unless ($frameworkcode);
39 my $popup =
40 $query->param('popup')
41 ; # if set to 1, then don't insert links, it's just to show the biblio
43 # open template
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46 template_name => "catalogue/labeledMARCdetail.tt",
47 query => $query,
48 type => "intranet",
49 authnotrequired => 0,
50 flagsrequired => { catalogue => 1 },
51 debug => 1,
55 my $record = GetMarcBiblio($biblionumber);
56 if ( not defined $record ) {
57 # biblionumber invalid -> report and exit
58 $template->param( unknownbiblionumber => 1,
59 biblionumber => $biblionumber
61 output_html_with_http_headers $query, $cookie, $template->output;
62 exit;
65 my $tagslib = GetMarcStructure(1,$frameworkcode);
66 my $biblio = GetBiblioData($biblionumber);
68 if($query->cookie("holdfor")){
69 my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
70 $template->param(
71 holdfor => $query->cookie("holdfor"),
72 holdfor_surname => $holdfor_patron->{'surname'},
73 holdfor_firstname => $holdfor_patron->{'firstname'},
74 holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
78 #count of item linked
79 my $itemcount = GetItemsCount($biblionumber);
80 $template->param( count => $itemcount,
81 bibliotitle => $biblio->{title}, );
83 #Getting framework loop
84 $template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) );
86 my @marc_data;
87 my $prevlabel = '';
88 for my $field ($record->fields)
90 my $tag = $field->tag;
91 next if ! exists $tagslib->{$tag}->{lib};
92 my $label = $tagslib->{$tag}->{lib};
93 if ($label eq $prevlabel)
95 $label = '';
97 else
99 $prevlabel = $label;
101 my $value = $tag < 10
102 ? $field->data
103 : join ' ', map { $_->[1] } $field->subfields;
104 push @marc_data, {
105 label => $label,
106 value => $value,
110 $template->param (
111 marc_data => \@marc_data,
112 biblionumber => $biblionumber,
113 popup => $popup,
114 labeledmarcview => 1,
115 z3950_search_params => C4::Search::z3950_search_args($biblio),
116 C4::Search::enabled_staff_search_views,
117 searchid => $query->param('searchid'),
120 my @allorders_using_biblio = GetOrdersByBiblionumber ($biblionumber);
121 my @deletedorders_using_biblio;
122 my @orders_using_biblio;
123 my @baskets_orders;
124 my @baskets_deletedorders;
126 foreach my $myorder (@allorders_using_biblio) {
127 my $basket = $myorder->{'basketno'};
128 if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
129 push @deletedorders_using_biblio, $myorder;
130 unless (grep(/^$basket$/, @baskets_deletedorders)){
131 push @baskets_deletedorders,$myorder->{'basketno'};
134 else {
135 push @orders_using_biblio, $myorder;
136 unless (grep(/^$basket$/, @baskets_orders)){
137 push @baskets_orders,$myorder->{'basketno'};
142 my $count_orders_using_biblio = scalar @orders_using_biblio ;
143 $template->param (countorders => $count_orders_using_biblio);
145 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
146 $template->param (countdeletedorders => $count_deletedorders_using_biblio);
148 my $holds= C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
149 my $holdcount = scalar( @$holds );
150 $template->param( holdcount => scalar ( @$holds ) );
152 output_html_with_http_headers $query, $cookie, $template->output;