# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
+
use CGI qw ( -utf8 );
-use C4::Auth;
-use C4::Output;
-use C4::AuthoritiesMarc;
-use C4::ImportBatch; #GetImportRecordMarc
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
+use C4::AuthoritiesMarc qw( AddAuthority ModAuthority GetAuthority GetTagsLabels GetAuthMARCFromKohaField FindDuplicateAuthority );
+use C4::ImportBatch qw( GetImportRecordMarc );
use C4::Context;
-use C4::Koha;
-use Date::Calc qw(Today);
+use Date::Calc qw( Today );
use MARC::File::USMARC;
use MARC::File::XML;
-use C4::Biblio;
+use C4::Biblio qw( TransformHtmlToMarc );
use Koha::Authority::Types;
use Koha::ItemTypes;
use vars qw( $tagslib);
#---- branch
- if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
+ my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
+ if ( $category eq "branches" ) {
my $sth =
$dbh->prepare(
"select branchcode,branchname from branches order by branchname");
$authorised_lib{$branchcode} = $branchname;
}
}
- elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
+ elsif ( $category eq "itemtypes" ) {
push @authorised_values, ""
unless ( $tagslib->{$tag}->{$subfield}->{mandatory}
&& ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
values => \@authorised_values,
labels => \%authorised_lib,
default => $value,
+ ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ),
};
}
}
}
+ if ($cgi->param('tagreport') && $subfield_data{tag} == $cgi->param('tagreport')) {
+ $subfield_data{marc_value}{value} = $cgi->param('tag'. $cgi->param('tagbiblio') . 'subfield' . $subfield_data{subfield});
+ }
$subfield_data{'index_subfield'} = $index_subfield;
return \%subfield_data;
}
'110a' => 'authorcorp',
'111a' => 'authormeetingcon',
'130a' => 'uniformtitle',
- '150a' => 'topic',
+ '150a' => 'subject',
};
}else{
return {
}
else {
my @subfields_data;
- foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
- next if ( length $subfield != 1 );
- next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
- next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+ foreach my $subfield (
+ sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} }
+ grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty
+ values %{ $tagslib->{$tag} } )
+ {
+ next if $subfield->{hidden} && $subfield->{subfield} ne '9';
+ next if ( $subfield->{tab} ne $tabloop );
push(
@subfields_data,
&create_input(
- $tag, $subfield, '', $index_tag, $tabloop, $record,
+ $tag, $subfield->{subfield}, '', $index_tag, $tabloop, $record,
$authorised_values_sth,$input
)
);
# ========================
# MAIN
#=========================
-my $input = new CGI;
+my $input = CGI->new;
my $z3950 = $input->param('z3950');
my $error = $input->param('error');
my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority.
my $authtypecode = $input->param('authtypecode');
my $breedingid = $input->param('breedingid');
+
my $dbh = C4::Context->dbh;
if(!$authtypecode) {
$authtypecode = $authid ? Koha::Authorities->find($authid)->authtypecode : '';
= get_template_and_user({template_name => "authorities/authorities.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => {editauthorities => 1},
- debug => 1,
});
-$template->param(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid,);
+$template->param(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid);
$tagslib = GetTagsLabels(1,$authtypecode);
$mandatory_z3950 = GetMandatoryFieldZ3950($authtypecode);
$is_a_modif=0;
if ($authid) {
$is_a_modif=1;
- ($oldauthnumtagfield,$oldauthnumtagsubfield) = &GetAuthMARCFromKohaField("auth_header.authid",$authtypecode);
- ($oldauthtypetagfield,$oldauthtypetagsubfield) = &GetAuthMARCFromKohaField("auth_header.authtypecode",$authtypecode);
+ ($oldauthnumtagfield,$oldauthnumtagsubfield) = GetAuthMARCFromKohaField("auth_header.authid",$authtypecode);
+ ($oldauthtypetagfield,$oldauthtypetagsubfield) = GetAuthMARCFromKohaField("auth_header.authtypecode",$authtypecode);
}
$op ||= q{};
#------------------------------------------------------------------------------------------------------------------------------