Bug 23710: Use API to place holds for patrons
[koha.git] / authorities / blinddetail-biblio-search.pl
blob993615dfdbdcb2dfb1aa86847b237ec24d80e235
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
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 =head1 NAME
22 blinddetail-biblio-search.pl : script to show an authority in MARC format
24 =head1 SYNOPSIS
26 =cut
28 =head1 DESCRIPTION
30 This script needs an authid
32 It shows the authority in a (nice) MARC format depending on authority MARC
33 parameters tables.
35 =head1 FUNCTIONS
37 =cut
39 use Modern::Perl;
41 use C4::AuthoritiesMarc;
42 use C4::Auth;
43 use C4::Context;
44 use C4::Output;
45 use CGI qw ( -utf8 );
46 use MARC::Record;
47 use C4::Koha;
49 use Koha::Authorities;
50 use Koha::Authority::Types;
52 my $query = new CGI;
54 my $dbh = C4::Context->dbh;
56 my $authid = $query->param('authid');
57 my $index = $query->param('index');
58 my $tagid = $query->param('tagid');
59 my $relationship = $query->param('relationship');
61 # open template
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
64 template_name => "authorities/blinddetail-biblio-search.tt",
65 query => $query,
66 type => "intranet",
67 authnotrequired => 0,
68 flagsrequired => { editcatalogue => 'edit_catalogue' },
72 # Extract the tag number from the index
73 my $tag_number = $index;
74 $tag_number =~ s/^tag_(\d*)_.*$/$1/;
76 # fill arrays
77 my @subfield_loop;
78 my ($indicator1, $indicator2);
79 if ($authid) {
80 my $auth = Koha::Authorities->find( $authid );
81 my $authtypecode = $auth ? $auth->authtypecode : q{};
82 my $auth_type = Koha::Authority::Types->find($authtypecode);
83 my $record = GetAuthority($authid);
84 my @fields = $record->field( $auth_type->auth_tag_to_report );
85 my $repet = ($query->param('repet') || 1) - 1;
86 my $field = $fields[$repet];
88 # Get all values for each distinct subfield and add to subfield loop
89 my %done_subfields;
90 for ( $field->subfields ) {
91 next if $_->[0] eq '9'; # $9 will be set with authid value
92 my $letter = $_->[0];
93 $letter ||= '@';
94 next if defined $done_subfields{$letter};
95 my @values = $field->subfield($letter);
96 push @subfield_loop, {marc_subfield => $letter, marc_values => \@values };
97 $done_subfields{$letter} = 1;
100 push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship );
102 my $controlled_ind = $auth->controlled_indicators({ record => $record, biblio_tag => $tag_number });
103 $indicator1 = $controlled_ind->{ind1};
104 $indicator2 = $controlled_ind->{ind2};
105 if( defined $controlled_ind->{sub2} ) {
106 my $v = $controlled_ind->{sub2};
107 push @subfield_loop, { marc_subfield => '2', marc_values => [ $v ] };
109 } else {
110 # authid is empty => the user want to empty the entry.
111 $template->param( "clear" => 1 );
116 $template->param(
117 authid => $authid ? $authid : "",
118 index => $index,
119 tagid => $tagid,
120 update_ind1 => defined($indicator1),
121 indicator1 => $indicator1,
122 update_ind2 => defined($indicator2),
123 indicator2 => $indicator2,
124 SUBFIELD_LOOP => \@subfield_loop,
125 tag_number => $tag_number,
126 rancor => $index =~ /rancor$/,
130 output_html_with_http_headers $query, $cookie, $template->output;