88eb1560d842c293acd9373c5e422c6e2c6d3663
[koha-equinox.git] / authorities / authorities.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 use strict;
22 use warnings;
23 use CGI qw ( -utf8 );
24 use C4::Auth;
25 use C4::Output;
26 use C4::AuthoritiesMarc;
27 use C4::ImportBatch; #GetImportRecordMarc
28 use C4::Context;
29 use C4::Koha; # XXX subfield_is_koha_internal_p
30 use Date::Calc qw(Today);
31 use MARC::File::USMARC;
32 use MARC::File::XML;
33 use C4::Biblio;
34 use vars qw( $tagslib);
35 use vars qw( $authorised_values_sth);
36 use vars qw( $is_a_modif );
37
38 my $itemtype; # created here because it can be used in build_authorized_values_list sub
39 our($authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
40
41 =head1 FUNCTIONS
42
43 =over
44
45 =item build_authorized_values_list
46
47 builds list, depending on authorised value...
48
49 =cut
50
51 sub MARCfindbreeding_auth {
52     my ( $id ) = @_;
53     my ($marc, $encoding) = GetImportRecordMarc($id);
54     if ($marc) {
55         my $record = MARC::Record->new_from_usmarc($marc);
56         if ( !defined(ref($record)) ) {
57                 return -1;
58         } else {
59             return $record, $encoding;
60         }
61     } else {
62         return -1;
63     }
64 }
65
66 sub build_authorized_values_list {
67     my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
68
69     my @authorised_values;
70     my %authorised_lib;
71
72
73     #---- branch
74     if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
75         my $sth =
76         $dbh->prepare(
77             "select branchcode,branchname from branches order by branchname");
78         $sth->execute;
79         push @authorised_values, ""
80         unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
81
82         while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
83             push @authorised_values, $branchcode;
84             $authorised_lib{$branchcode} = $branchname;
85         }
86
87         #----- itemtypes
88     }
89     elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
90         my $sth =
91         $dbh->prepare(
92             "select itemtype,description from itemtypes order by description");
93         $sth->execute;
94         push @authorised_values, ""
95           unless ( $tagslib->{$tag}->{$subfield}->{mandatory}
96             && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
97         
98         my $itemtype;
99         
100         while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
101             push @authorised_values, $itemtype;
102             $authorised_lib{$itemtype} = $description;
103         }
104         $value = $itemtype unless ($value);
105
106         #---- "true" authorised value
107     }
108     else {
109         $authorised_values_sth->execute(
110             $tagslib->{$tag}->{$subfield}->{authorised_value} );
111
112         push @authorised_values, ""
113           unless ( $tagslib->{$tag}->{$subfield}->{mandatory}
114             && ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
115
116         while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
117             push @authorised_values, $value;
118             $authorised_lib{$value} = $lib;
119         }
120     }
121     return {
122         type     => 'select',
123         id       => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
124         name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
125         values   => \@authorised_values,
126         labels   => \%authorised_lib,
127         default  => $value,
128     };
129 }
130
131
132 =item create_input
133
134 builds the <input ...> entry for a subfield.
135
136 =cut
137
138 sub create_input {
139     my ( $tag, $subfield, $value, $index_tag, $tabloop, $rec, $authorised_values_sth,$cgi ) = @_;
140     
141     my $index_subfield = CreateKey(); # create a specifique key for each subfield
142
143     $value =~ s/"/&quot;/g;
144
145     # determine maximum length; 9999 bytes per ISO 2709 except for leader and MARC21 008
146     my $max_length = 9999;
147     if ($tag eq '000') {
148         $max_length = 24;
149     } elsif ($tag eq '008' and C4::Context->preference('marcflavour') eq 'MARC21')  {
150         $max_length = 40;
151     }
152
153     # if there is no value provided but a default value in parameters, get it
154     if ($value eq '') {
155         $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
156         if (!defined $value) {
157             $value = q{};
158         }
159
160         # get today date & replace YYYY, MM, DD if provided in the default value
161         my ( $year, $month, $day ) = Today();
162         $month = sprintf( "%02d", $month );
163         $day   = sprintf( "%02d", $day );
164         $value =~ s/YYYY/$year/g;
165         $value =~ s/MM/$month/g;
166         $value =~ s/DD/$day/g;
167     }
168     my $dbh = C4::Context->dbh;
169
170     # map '@' as "subfield" label for fixed fields
171     # to something that's allowed in a div id.
172     my $id_subfield = $subfield;
173     $id_subfield = "00" if $id_subfield eq "@";
174
175     my %subfield_data = (
176         tag        => $tag,
177         subfield   => $id_subfield,
178         marc_lib   => substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 22 ),
179         marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, 
180         tag_mandatory  => $tagslib->{$tag}->{mandatory},
181         mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
182         repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
183         kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
184         index          => $index_tag,
185         id             => "tag_".$tag."_subfield_".$id_subfield."_".$index_tag."_".$index_subfield,
186         value          => $value,
187         random         => CreateKey(),
188     );
189
190     if(exists $mandatory_z3950->{$tag.$subfield}){
191         $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
192     }
193     
194     $subfield_data{visibility} = "display:none;"
195         if (    ($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1) and $value ne ''
196             or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory})
197         );
198     
199     # it's an authorised field
200     if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
201         $subfield_data{marc_value} =
202         build_authorized_values_list( $tag, $subfield, $value, $dbh,
203             $authorised_values_sth,$index_tag,$index_subfield );
204
205     # it's a thesaurus / authority field
206     }
207     elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
208         $subfield_data{marc_value} = {
209             type         => 'text1',
210             id           => $subfield_data{id},
211             name         => $subfield_data{id},
212             value        => $value,
213             authtypecode => $tagslib->{$tag}->{$subfield}->{authtypecode},
214         };
215     }
216     elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) { # plugin
217         require Koha::FrameworkPlugin;
218         my $plugin = Koha::FrameworkPlugin->new({
219             name => $tagslib->{$tag}->{$subfield}->{'value_builder'},
220         });
221         my $pars=  { dbh => $dbh, record => $rec, tagslib =>$tagslib,
222             id => $subfield_data{id}, tabloop => $tabloop };
223         $plugin->build( $pars );
224         if( !$plugin->errstr ) {
225             $subfield_data{marc_value} = {
226                 type       => 'text2',
227                 id        => $subfield_data{id},
228                 name      => $subfield_data{id},
229                 value     => $value,
230                 maxlength => $max_length,
231                 javascript => $plugin->javascript,
232                 noclick    => $plugin->noclick,
233             };
234         } else { # warn and supply default field
235             warn $plugin->errstr;
236             $subfield_data{marc_value} = {
237                 type      => 'text',
238                 id        => $subfield_data{id},
239                 name      => $subfield_data{id},
240                 value     => $value,
241                 maxlength => $max_length,
242             };
243         }
244     }
245     # it's an hidden field
246     elsif ( $tag eq '' ) {
247         $subfield_data{marc_value} = {
248             type      => 'hidden',
249             id        => $subfield_data{id},
250             name      => $subfield_data{id},
251             value     => $value,
252             maxlength => $max_length,
253         }
254     }
255     elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) {
256         $subfield_data{marc_value} = {
257             type => 'text',
258             id        => $subfield_data{id},
259             name      => $subfield_data{id},
260             value     => $value,
261             maxlength => $max_length,
262         };
263
264         # it's a standard field
265     }
266     else {
267         if (
268             length($value) > 100
269             or
270             ( C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >= 300
271                 and $tag < 400 && $subfield eq 'a' )
272             or (    $tag >= 600
273                 and $tag < 700
274                 && C4::Context->preference("marcflavour") eq "MARC21" )
275         )
276         {
277             $subfield_data{marc_value} = {
278                 type => 'textarea',
279                 id        => $subfield_data{id},
280                 name      => $subfield_data{id},
281                 value     => $value,
282                 maxlength => $max_length,
283             };
284
285         }
286         else {
287             $subfield_data{marc_value} = {
288                 type => 'text',
289                 id        => $subfield_data{id},
290                 name      => $subfield_data{id},
291                 value     => $value,
292                 maxlength => $max_length,
293             };
294
295         }
296     }
297     $subfield_data{'index_subfield'} = $index_subfield;
298     return \%subfield_data;
299 }
300
301 =item format_indicator
302
303 Translate indicator value for output form - specifically, map
304 indicator = ' ' to ''.  This is for the convenience of a cataloger
305 using a mouse to select an indicator input.
306
307 =cut
308
309 sub format_indicator {
310     my $ind_value = shift;
311     return '' if not defined $ind_value;
312     return '' if $ind_value eq ' ';
313     return $ind_value;
314 }
315
316 =item CreateKey
317
318 Create a random value to set it into the input name
319
320 =cut
321
322 sub CreateKey {
323     return int(rand(1000000));
324 }
325
326 =item GetMandatoryFieldZ3950
327
328     This function return an hashref which containts all mandatory field
329     to search with z3950 server.
330
331 =cut
332
333 sub GetMandatoryFieldZ3950 {
334     my $authtypecode = shift;
335     if ( C4::Context->preference('marcflavour') eq 'MARC21' ){
336         return {
337             '100a' => 'authorpersonal',
338             '110a' => 'authorcorp',
339             '111a' => 'authormeetingcon',
340             '130a' => 'uniformtitle',
341             '150a' => 'topic',
342         };
343     }else{
344         return {
345             '200a' => 'authorpersonal',
346             '210a' => 'authormeetingcon', #210 in UNIMARC is used for both corporation and meeting
347             '230a' => 'uniformtitle',
348         };
349     }
350 }
351
352 sub build_tabs {
353     my ( $template, $record, $dbh, $encoding,$input ) = @_;
354
355     # fill arrays
356     my @loop_data = ();
357     my $tag;
358
359     my $authorised_values_sth = $dbh->prepare(
360         "SELECT authorised_value,lib
361         FROM authorised_values
362         WHERE category=? ORDER BY lib"
363     );
364     
365     # in this array, we will push all the 10 tabs
366     # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
367     my @BIG_LOOP;
368     my %seen;
369     my @tab_data; # all tags to display
370     
371     foreach my $used ( keys %$tagslib ){
372         push @tab_data,$used if not $seen{$used};
373         $seen{$used}++;
374     }
375         
376     my $max_num_tab=9;
377     # loop through each tab 0 through 9
378     for ( my $tabloop = 0 ; $tabloop <= $max_num_tab ; $tabloop++ ) {
379         my @loop_data = (); #innerloop in the template.
380         my $i = 0;
381         foreach my $tag (sort @tab_data) {
382             $i++;
383             next if ! $tag;
384             my ($indicator1, $indicator2);
385             my $index_tag = CreateKey;
386
387             # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
388             # if MARC::Record is empty => use tab as master loop.
389             if ( $record != -1 && ( $record->field($tag) || $tag eq '000' ) ) {
390                 my @fields;
391                 if ( $tag ne '000' ) {
392                                 @fields = $record->field($tag);
393                 }
394                 else {
395                 push @fields, $record->leader(); # if tag == 000
396                 }
397                 # loop through each field
398                 foreach my $field (@fields) {
399                     
400                     my @subfields_data;
401                     if ( $tag < 10 ) {
402                         my ( $value, $subfield );
403                         if ( $tag ne '000' ) {
404                             $value    = $field->data();
405                             $subfield = "@";
406                         }
407                         else {
408                             $value    = $field;
409                             $subfield = '@';
410                         }
411                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
412                         push(
413                             @subfields_data,
414                             &create_input(
415                                 $tag, $subfield, $value, $index_tag, $tabloop, $record,
416                                 $authorised_values_sth,$input
417                             )
418                         );
419                     }
420                     else {
421                         my @subfields = $field->subfields();
422                         foreach my $subfieldcount ( 0 .. $#subfields ) {
423                             my $subfield = $subfields[$subfieldcount][0];
424                             my $value    = $subfields[$subfieldcount][1];
425                             next if ( length $subfield != 1 );
426                             next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
427                             push(
428                                 @subfields_data,
429                                 &create_input(
430                                     $tag, $subfield, $value, $index_tag, $tabloop,
431                                     $record, $authorised_values_sth,$input
432                                 )
433                             );
434                         }
435                     }
436
437                     # now, loop again to add parameter subfield that are not in the MARC::Record
438                     foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
439                     {
440                         next if ( length $subfield != 1 );
441                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
442                         next if ( $tag < 10 );
443                         next
444                         if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
445                             or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
446                         );    #check for visibility flag
447                         next if ( defined( $field->subfield($subfield) ) );
448                         push(
449                             @subfields_data,
450                             &create_input(
451                                 $tag, $subfield, '', $index_tag, $tabloop, $record,
452                                 $authorised_values_sth,$input
453                             )
454                         );
455                     }
456                     if ( $#subfields_data >= 0 ) {
457                         # build the tag entry.
458                         # note that the random() field is mandatory. Otherwise, on repeated fields, you'll 
459                         # have twice the same "name" value, and cgi->param() will return only one, making
460                         # all subfields to be merged in a single field.
461                         my %tag_data = (
462                             tag           => $tag,
463                             index         => $index_tag,
464                             tag_lib       => $tagslib->{$tag}->{lib},
465                             repeatable       => $tagslib->{$tag}->{repeatable},
466                             mandatory       => $tagslib->{$tag}->{mandatory},
467                             subfield_loop => \@subfields_data,
468                             fixedfield    => ($tag < 10)?(1):(0),
469                             random        => CreateKey,
470                         );
471                         if ($tag >= 10){ # no indicator for theses tag
472                             $tag_data{indicator1} = format_indicator($field->indicator(1)),
473                             $tag_data{indicator2} = format_indicator($field->indicator(2)),
474                         }
475                         push( @loop_data, \%tag_data );
476                     }
477                 } # foreach $field end
478
479             # if breeding is empty
480             }
481             else {
482                 my @subfields_data;
483                 foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
484                     next if ( length $subfield != 1 );
485                     next if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
486                                 or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
487                             ;    #check for visibility flag
488                     next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
489                     push(
490                         @subfields_data,
491                         &create_input(
492                             $tag, $subfield, '', $index_tag, $tabloop, $record,
493                             $authorised_values_sth,$input
494                         )
495                     );
496                 }
497                 if ( $#subfields_data >= 0 ) {
498                     my %tag_data = (
499                         tag              => $tag,
500                         index            => $index_tag,
501                         tag_lib          => $tagslib->{$tag}->{lib},
502                         repeatable       => $tagslib->{$tag}->{repeatable},
503                         mandatory       => $tagslib->{$tag}->{mandatory},
504                         indicator1       => $indicator1,
505                         indicator2       => $indicator2,
506                         subfield_loop    => \@subfields_data,
507                         tagfirstsubfield => $subfields_data[0],
508                         fixedfield       => ($tag < 10)?(1):(0)
509                     );
510                     
511                     push @loop_data, \%tag_data ;
512                 }
513             }
514         }
515         if ( $#loop_data >= 0 ) {
516             push @BIG_LOOP, {
517                 number    => $tabloop,
518                 innerloop => \@loop_data,
519             };
520         }
521     }
522     $template->param( BIG_LOOP => \@BIG_LOOP );
523 }
524
525
526 sub build_hidden_data {
527     # build hidden data =>
528     # we store everything, even if we show only requested subfields.
529
530     my @loop_data =();
531     my $i=0;
532     foreach my $tag (keys %{$tagslib}) {
533         my $previous_tag = '';
534
535         # loop through each subfield
536         foreach my $subfield (keys %{$tagslib->{$tag}}) {
537             next if ($subfield eq 'lib');
538             next if ($subfield eq 'tab');
539             next if ($subfield eq 'mandatory');
540                 next if ($subfield eq 'repeatable');
541             next if ($tagslib->{$tag}->{$subfield}->{'tab'}  ne "-1");
542             my %subfield_data;
543             $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
544             $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
545             $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
546             $subfield_data{marc_value} = {
547                 type => 'hidden_simple',
548                 name => 'field_value[]',
549             };
550             push(@loop_data, \%subfield_data);
551             $i++
552         }
553     }
554 }
555
556 =back
557
558 =cut
559
560
561 # ======================== 
562 #          MAIN 
563 #=========================
564 my $input = new CGI;
565 my $z3950 = $input->param('z3950');
566 my $error = $input->param('error');
567 my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority.
568 my $op = $input->param('op');
569 my $nonav = $input->param('nonav');
570 my $myindex = $input->param('index');
571 my $linkid=$input->param('linkid');
572 my $authtypecode = $input->param('authtypecode');
573 my $breedingid    = $input->param('breedingid');
574
575 my $dbh = C4::Context->dbh;
576 if(!$authtypecode) {
577   $authtypecode = $authid? &GetAuthTypeCode($authid): '';
578 }
579
580 my ($template, $loggedinuser, $cookie)
581     = get_template_and_user({template_name => "authorities/authorities.tt",
582                             query => $input,
583                             type => "intranet",
584                             authnotrequired => 0,
585                             flagsrequired => {editauthorities => 1},
586                             debug => 1,
587                             });
588 $template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid,);
589
590 $tagslib = GetTagsLabels(1,$authtypecode);
591 $mandatory_z3950 = GetMandatoryFieldZ3950($authtypecode);
592
593 my $record=-1;
594 my $encoding="";
595 if (($authid) && !($breedingid)){
596     $record = GetAuthority($authid);
597 }
598 if ($breedingid) {
599     ( $record, $encoding ) = MARCfindbreeding_auth( $breedingid );
600 }
601
602 my ($oldauthnumtagfield,$oldauthnumtagsubfield);
603 my ($oldauthtypetagfield,$oldauthtypetagsubfield);
604 $is_a_modif=0;
605 if ($authid) {
606     $is_a_modif=1;
607     ($oldauthnumtagfield,$oldauthnumtagsubfield) = &GetAuthMARCFromKohaField("auth_header.authid",$authtypecode);
608     ($oldauthtypetagfield,$oldauthtypetagsubfield) = &GetAuthMARCFromKohaField("auth_header.authtypecode",$authtypecode);
609 }
610 $op ||= q{};
611 #------------------------------------------------------------------------------------------------------------------------------
612 if ($op eq "add") {
613 #------------------------------------------------------------------------------------------------------------------------------
614     # rebuild
615     my @tags = $input->param('tag');
616     my @subfields = $input->param('subfield');
617     my @values = $input->param('field_value');
618     # build indicator hash.
619     my @ind_tag = $input->param('ind_tag');
620     my @indicator = $input->param('indicator');
621     my $record = TransformHtmlToMarc($input);
622
623     my ($duplicateauthid,$duplicateauthvalue);
624      ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority($record,$authtypecode) if ($op eq "add") && (!$is_a_modif);
625     my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
626     # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
627     if (!$duplicateauthid or $confirm_not_duplicate) {
628         if ($is_a_modif ) {     
629             ModAuthority($authid,$record,$authtypecode);
630         } else {
631             ($authid) = AddAuthority($record,$authid,$authtypecode);
632         }
633         if ($myindex) {
634             print $input->redirect("blinddetail-biblio-search.pl?authid=$authid&index=$myindex");
635         } else {
636             print $input->redirect("detail.pl?authid=$authid");
637         }
638         exit;
639     } else {
640     # it may be a duplicate, warn the user and do nothing
641         build_tabs($template, $record, $dbh, $encoding,$input);
642         build_hidden_data;
643         $template->param(authid =>$authid,
644                         duplicateauthid     => $duplicateauthid,
645                         duplicateauthvalue  => $duplicateauthvalue->{'authorized'}->[0]->{'heading'},
646                         );
647     }
648 } elsif ($op eq "delete") {
649 #------------------------------------------------------------------------------------------------------------------------------
650         &DelAuthority($authid);
651         if ($nonav){
652             print $input->redirect("auth_finder.pl");
653         }else{
654             print $input->redirect("authorities-home.pl?authid=0");
655         }
656                 exit;
657 } else {
658 if ($op eq "duplicate")
659         {
660                 $authid = "";
661         }
662         build_tabs ($template, $record, $dbh,$encoding,$input);
663         build_hidden_data;
664         $template->param(oldauthtypetagfield=>$oldauthtypetagfield, oldauthtypetagsubfield=>$oldauthtypetagsubfield,
665                         oldauthnumtagfield=>$oldauthnumtagfield, oldauthnumtagsubfield=>$oldauthnumtagsubfield,
666                         authid                      => $authid , authtypecode=>$authtypecode,   );
667 }
668
669 $template->param(authid                       => $authid,
670                  authtypecode => $authtypecode,
671                  linkid=>$linkid,
672 );
673
674 my $authtypes = getauthtypes;
675 my @authtypesloop;
676 foreach my $thisauthtype (keys %$authtypes) {
677     my %row =(value => $thisauthtype,
678                 selected => $thisauthtype eq $authtypecode,
679                 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
680             );
681     push @authtypesloop, \%row;
682 }
683
684 $template->param(authtypesloop => \@authtypesloop,
685                 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
686                 hide_marc => C4::Context->preference('hide_marc'),
687                 );
688 output_html_with_http_headers $input, $cookie, $template->output;