|
Lines 53-59
my $query = new CGI;
Link Here
|
| 53 |
my $dbh = C4::Context->dbh; |
53 |
my $dbh = C4::Context->dbh; |
| 54 |
|
54 |
|
| 55 |
my $display_hierarchy = C4::Context->preference("AuthDisplayHierarchy"); |
55 |
my $display_hierarchy = C4::Context->preference("AuthDisplayHierarchy"); |
| 56 |
my $show_marc = $query->param('marc') || 1; # Currently only MARC view is available |
56 |
my $show_marc = $query->param('marc'); |
| 57 |
|
57 |
|
| 58 |
# open template |
58 |
# open template |
| 59 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
59 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
Lines 68-75
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 68 |
|
68 |
|
| 69 |
my $authid = $query->param('authid'); |
69 |
my $authid = $query->param('authid'); |
| 70 |
my $authtypecode = &GetAuthTypeCode( $authid ); |
70 |
my $authtypecode = &GetAuthTypeCode( $authid ); |
| 71 |
my $tagslib = &GetTagsLabels( 0, $authtypecode ); |
|
|
| 72 |
|
| 73 |
|
71 |
|
| 74 |
my $record; |
72 |
my $record; |
| 75 |
if ($display_hierarchy){ |
73 |
if ($display_hierarchy){ |
|
Lines 101-190
else {
Link Here
|
| 101 |
} |
99 |
} |
| 102 |
my $count = CountUsage($authid); |
100 |
my $count = CountUsage($authid); |
| 103 |
|
101 |
|
| 104 |
# find the marc field/subfield used in biblio by this authority |
102 |
|
| 105 |
my $sth = |
103 |
my $authtypes = getauthtypes(); |
| 106 |
$dbh->prepare( |
104 |
my @authtypesloop = (); |
| 107 |
"select distinct tagfield from marc_subfield_structure where authtypecode=?" |
105 |
foreach my $thisauthtype ( keys %{$authtypes} ) { |
| 108 |
); |
106 |
push @authtypesloop, |
| 109 |
$sth->execute($authtypecode); |
107 |
{ value => $thisauthtype, |
| 110 |
my $biblio_fields; |
108 |
selected => $thisauthtype eq $authtypecode, |
| 111 |
while ( my ($tagfield) = $sth->fetchrow ) { |
109 |
authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, |
| 112 |
$biblio_fields .= $tagfield . "9,"; |
110 |
}; |
| 113 |
} |
111 |
} |
| 114 |
chop $biblio_fields; |
112 |
$template->{VARS}->{'authtypesloop'} = \@authtypesloop; |
|
|
113 |
$template->{VARS}->{'authtypetext'} = $authtypes->{$authtypecode}{'authtypetext'}; |
| 114 |
$template->{VARS}->{'authid'} = $authid; |
| 115 |
$template->{VARS}->{'count'} = $count; |
| 116 |
|
| 117 |
# find the marc field/subfield used in biblio by this authority |
| 118 |
if ($show_marc) { |
| 119 |
my $tagslib = &GetTagsLabels( 0, $authtypecode ); |
| 120 |
my $sth = |
| 121 |
$dbh->prepare( |
| 122 |
"select distinct tagfield from marc_subfield_structure where authtypecode=?" |
| 123 |
); |
| 124 |
$sth->execute($authtypecode); |
| 125 |
my $biblio_fields; |
| 126 |
while ( my ($tagfield) = $sth->fetchrow ) { |
| 127 |
$biblio_fields .= $tagfield . "9,"; |
| 128 |
} |
| 129 |
chop $biblio_fields; |
| 115 |
|
130 |
|
| 116 |
# fill arrays |
131 |
# fill arrays |
| 117 |
my @loop_data = (); |
132 |
my @loop_data = (); |
| 118 |
my $tag; |
133 |
my $tag; |
| 119 |
|
134 |
|
| 120 |
# loop through each tab 0 through 9 |
|
|
| 121 |
# for (my $tabloop = 0; $tabloop<=10;$tabloop++) { |
| 122 |
# loop through each tag |
135 |
# loop through each tag |
| 123 |
my @fields = $record->fields(); |
136 |
my @fields = $record->fields(); |
| 124 |
foreach my $field (@fields) { |
137 |
foreach my $field (@fields) { |
| 125 |
my @subfields_data; |
138 |
my @subfields_data; |
| 126 |
|
139 |
|
| 127 |
# skip UNIMARC fields <200, they are useless for a patron |
140 |
# skip UNIMARC fields <200, they are useless for a patron |
| 128 |
next if C4::Context->preference('MarcFlavour') eq 'UNIMARC' && $field->tag() <200; |
141 |
next if C4::Context->preference('MarcFlavour') eq 'UNIMARC' && $field->tag() <200; |
| 129 |
|
142 |
|
| 130 |
# if tag <10, there's no subfield, use the "@" trick |
143 |
# if tag <10, there's no subfield, use the "@" trick |
| 131 |
if ( $field->tag() < 10 ) { |
144 |
if ( $field->tag() < 10 ) { |
| 132 |
next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} ); |
145 |
next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} ); |
| 133 |
my %subfield_data; |
|
|
| 134 |
$subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib}; |
| 135 |
$subfield_data{marc_value} = $field->data(); |
| 136 |
$subfield_data{marc_subfield} = '@'; |
| 137 |
$subfield_data{marc_tag} = $field->tag(); |
| 138 |
push( @subfields_data, \%subfield_data ); |
| 139 |
} |
| 140 |
else { |
| 141 |
my @subf = $field->subfields; |
| 142 |
|
| 143 |
# loop through each subfield |
| 144 |
for my $i ( 0 .. $#subf ) { |
| 145 |
$subf[$i][0] = "@" unless $subf[$i][0]; |
| 146 |
next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} ); |
| 147 |
# skip useless subfields (for patrons) |
| 148 |
next if $subf[$i][0] =~ /7|8|9/; |
| 149 |
my %subfield_data; |
146 |
my %subfield_data; |
| 150 |
$subfield_data{marc_lib} = |
147 |
$subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib}; |
| 151 |
$tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib}; |
148 |
$subfield_data{marc_value} = $field->data(); |
| 152 |
$subfield_data{marc_subfield} = $subf[$i][0]; |
149 |
$subfield_data{marc_subfield} = '@'; |
| 153 |
$subfield_data{marc_tag} = $field->tag(); |
150 |
$subfield_data{marc_tag} = $field->tag(); |
| 154 |
$subfield_data{isurl} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl}; |
|
|
| 155 |
$subfield_data{marc_value} = $subf[$i][1]; |
| 156 |
push( @subfields_data, \%subfield_data ); |
151 |
push( @subfields_data, \%subfield_data ); |
| 157 |
} |
152 |
} |
|
|
153 |
else { |
| 154 |
my @subf = $field->subfields; |
| 155 |
|
| 156 |
# loop through each subfield |
| 157 |
for my $i ( 0 .. $#subf ) { |
| 158 |
$subf[$i][0] = "@" unless $subf[$i][0]; |
| 159 |
next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} ); |
| 160 |
# skip useless subfields (for patrons) |
| 161 |
next if $subf[$i][0] =~ /7|8|9/; |
| 162 |
my %subfield_data; |
| 163 |
$subfield_data{marc_lib} = |
| 164 |
$tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib}; |
| 165 |
$subfield_data{marc_subfield} = $subf[$i][0]; |
| 166 |
$subfield_data{marc_tag} = $field->tag(); |
| 167 |
$subfield_data{isurl} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl}; |
| 168 |
$subfield_data{marc_value} = $subf[$i][1]; |
| 169 |
push( @subfields_data, \%subfield_data ); |
| 170 |
} |
| 171 |
} |
| 172 |
if ( $#subfields_data >= 0 ) { |
| 173 |
my %tag_data; |
| 174 |
$tag_data{tag} = |
| 175 |
$field->tag() |
| 176 |
. ' ' |
| 177 |
. C4::Koha::display_marc_indicators($field) |
| 178 |
. ' - ' . $tagslib->{ $field->tag() }->{lib}; |
| 179 |
$tag_data{subfield} = \@subfields_data; |
| 180 |
push( @loop_data, \%tag_data ); |
| 181 |
} |
| 158 |
} |
182 |
} |
| 159 |
if ( $#subfields_data >= 0 ) { |
183 |
$template->param( "Tab0XX" => \@loop_data ); |
| 160 |
my %tag_data; |
184 |
} else { |
| 161 |
$tag_data{tag} = |
185 |
my $summary = BuildSummary($record, $authid, $authtypecode); |
| 162 |
$field->tag() |
186 |
$template->{VARS}->{'summary'} = $summary; |
| 163 |
. ' ' |
|
|
| 164 |
. C4::Koha::display_marc_indicators($field) |
| 165 |
. ' - ' . $tagslib->{ $field->tag() }->{lib}; |
| 166 |
$tag_data{subfield} = \@subfields_data; |
| 167 |
push( @loop_data, \%tag_data ); |
| 168 |
} |
| 169 |
} |
| 170 |
$template->param( "Tab0XX" => \@loop_data ); |
| 171 |
|
| 172 |
my $authtypes = getauthtypes(); |
| 173 |
my @authtypesloop = (); |
| 174 |
foreach my $thisauthtype ( keys %{$authtypes} ) { |
| 175 |
push @authtypesloop, |
| 176 |
{ value => $thisauthtype, |
| 177 |
selected => $thisauthtype eq $authtypecode, |
| 178 |
authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, |
| 179 |
}; |
| 180 |
} |
187 |
} |
| 181 |
|
188 |
|
| 182 |
$template->param( |
|
|
| 183 |
authid => $authid, |
| 184 |
count => $count, |
| 185 |
biblio_fields => $biblio_fields, |
| 186 |
authtypetext => $authtypes->{$authtypecode}{'authtypetext'}, |
| 187 |
authtypesloop => \@authtypesloop, |
| 188 |
); |
| 189 |
output_html_with_http_headers $query, $cookie, $template->output; |
189 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 190 |
|
190 |
|
| 191 |
- |
|
|