# 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( GetAuthority );
+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 ) ),
};
}
my $index_subfield = CreateKey(); # create a specifique key for each subfield
- $value =~ s/"/"/g;
-
# determine maximum length; 9999 bytes per ISO 2709 except for leader and MARC21 008
my $max_length = 9999;
if ($tag eq '000') {
}
$subfield_data{visibility} = "display:none;"
- if ( ($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1) and $value ne ''
+ if( $tagslib->{$tag}->{$subfield}->{hidden} and $value ne ''
or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory})
);
}
}
+ 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;
}
=item GetMandatoryFieldZ3950
- This function return an hashref which containts all mandatory field
+ This function returns a hashref which contains all mandatory field
to search with z3950 server.
=cut
'110a' => 'authorcorp',
'111a' => 'authormeetingcon',
'130a' => 'uniformtitle',
- '150a' => 'topic',
+ '150a' => 'subject',
};
}else{
return {
$subfield = '@';
}
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+ next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
push(
@subfields_data,
&create_input(
my $value = $subfields[$subfieldcount][1];
next if ( length $subfield != 1 );
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+ next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
push(
@subfields_data,
&create_input(
next if ( length $subfield != 1 );
next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
next if ( $tag < 10 );
- next
- if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
- or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
- ); #check for visibility flag
+ next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
next if ( defined( $field->subfield($subfield) ) );
push(
@subfields_data,
}
else {
my @subfields_data;
- foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
- next if ( length $subfield != 1 );
- next if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
- or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
- ; #check for visibility flag
- 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);
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
+my $type = $authority_types->find($authtypecode);
$template->param(
authority_types => $authority_types,
authtypecode => $authtypecode,
authid => $authid,
linkid => $linkid,
- authtypetext => $authority_types->find($authtypecode)->authtypetext,
+ authtypetext => $type ? $type->authtypetext : "",
hide_marc => C4::Context->preference('hide_marc'),
);
output_html_with_http_headers $input, $cookie, $template->output;