Bug 17469: Add missing sample notices to fr-CA web installer
[koha.git] / catalogue / labeledMARCdetail.pl
blobc4b9019df54f7f698a576f48004f92d9531019e0
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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use strict;
21 use warnings;
22 use CGI qw ( -utf8 );
23 use HTML::Entities;
24 use MARC::Record;
25 use C4::Auth;
26 use C4::Context;
27 use C4::Output;
28 use C4::Biblio;
29 use C4::Items;
30 use C4::Members; # to use GetMember
31 use C4::Search; # enabled_staff_search_views
32 use C4::Acquisition qw(GetOrdersByBiblionumber);
34 use Koha::BiblioFrameworks;
36 my $query = new CGI;
37 my $dbh = C4::Context->dbh;
38 my $biblionumber = $query->param('biblionumber');
39 $biblionumber = HTML::Entities::encode($biblionumber);
40 my $frameworkcode = $query->param('frameworkcode');
41 $frameworkcode = GetFrameworkCode( $biblionumber ) unless ($frameworkcode);
42 my $popup =
43 $query->param('popup')
44 ; # if set to 1, then don't insert links, it's just to show the biblio
46 # open template
47 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
49 template_name => "catalogue/labeledMARCdetail.tt",
50 query => $query,
51 type => "intranet",
52 authnotrequired => 0,
53 flagsrequired => { catalogue => 1 },
54 debug => 1,
58 my $record = GetMarcBiblio($biblionumber);
59 if ( not defined $record ) {
60 # biblionumber invalid -> report and exit
61 $template->param( unknownbiblionumber => 1,
62 biblionumber => $biblionumber
64 output_html_with_http_headers $query, $cookie, $template->output;
65 exit;
68 my $tagslib = GetMarcStructure(1,$frameworkcode);
69 my $biblio = GetBiblioData($biblionumber);
71 if($query->cookie("holdfor")){
72 my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
73 $template->param(
74 holdfor => $query->cookie("holdfor"),
75 holdfor_surname => $holdfor_patron->{'surname'},
76 holdfor_firstname => $holdfor_patron->{'firstname'},
77 holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
81 #count of item linked
82 my $itemcount = GetItemsCount($biblionumber);
83 $template->param( count => $itemcount,
84 bibliotitle => $biblio->{title}, );
86 my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
87 $template->param(
88 frameworks => $frameworks,
89 frameworkcode => $frameworkcode,
92 my @marc_data;
93 my $prevlabel = '';
94 for my $field ($record->fields)
96 my $tag = $field->tag;
97 next if ! exists $tagslib->{$tag}->{lib};
98 my $label = $tagslib->{$tag}->{lib};
99 if ($label eq $prevlabel)
101 $label = '';
103 else
105 $prevlabel = $label;
107 my $value = $tag < 10
108 ? $field->data
109 : join ' ', map { $_->[1] } $field->subfields;
110 push @marc_data, {
111 label => $label,
112 value => $value,
116 $template->param (
117 marc_data => \@marc_data,
118 biblionumber => $biblionumber,
119 popup => $popup,
120 labeledmarcview => 1,
121 z3950_search_params => C4::Search::z3950_search_args($biblio),
122 C4::Search::enabled_staff_search_views,
123 searchid => scalar $query->param('searchid'),
126 my @allorders_using_biblio = GetOrdersByBiblionumber ($biblionumber);
127 my @deletedorders_using_biblio;
128 my @orders_using_biblio;
129 my @baskets_orders;
130 my @baskets_deletedorders;
132 foreach my $myorder (@allorders_using_biblio) {
133 my $basket = $myorder->{'basketno'};
134 if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
135 push @deletedorders_using_biblio, $myorder;
136 unless (grep(/^$basket$/, @baskets_deletedorders)){
137 push @baskets_deletedorders,$myorder->{'basketno'};
140 else {
141 push @orders_using_biblio, $myorder;
142 unless (grep(/^$basket$/, @baskets_orders)){
143 push @baskets_orders,$myorder->{'basketno'};
148 my $count_orders_using_biblio = scalar @orders_using_biblio ;
149 $template->param (countorders => $count_orders_using_biblio);
151 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
152 $template->param (countdeletedorders => $count_deletedorders_using_biblio);
154 my $holds= C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
155 my $holdcount = scalar( @$holds );
156 $template->param( holdcount => scalar ( @$holds ) );
158 output_html_with_http_headers $query, $cookie, $template->output;