Lines 36-42
use vars qw( $tagslib);
Link Here
|
36 |
use vars qw( $authorised_values_sth); |
36 |
use vars qw( $authorised_values_sth); |
37 |
use vars qw( $is_a_modif ); |
37 |
use vars qw( $is_a_modif ); |
38 |
|
38 |
|
39 |
my $itemtype; # created here because it can be used in build_authorized_values_list sub |
|
|
40 |
our($authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950); |
39 |
our($authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950); |
41 |
|
40 |
|
42 |
=head1 FUNCTIONS |
41 |
=head1 FUNCTIONS |
Lines 70-119
sub build_authorized_values_list {
Link Here
|
70 |
my @authorised_values; |
69 |
my @authorised_values; |
71 |
my %authorised_lib; |
70 |
my %authorised_lib; |
72 |
|
71 |
|
73 |
|
|
|
74 |
#---- branch |
75 |
my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'}; |
72 |
my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'}; |
|
|
73 |
push @authorised_values, q{} unless $tagslib->{$tag}->{$subfield}->{mandatory} && $value; |
74 |
|
76 |
if ( $category eq "branches" ) { |
75 |
if ( $category eq "branches" ) { |
77 |
my $sth = |
76 |
my $sth = $dbh->prepare( "select branchcode,branchname from branches order by branchname" ); |
78 |
$dbh->prepare( |
|
|
79 |
"select branchcode,branchname from branches order by branchname"); |
80 |
$sth->execute; |
77 |
$sth->execute; |
81 |
push @authorised_values, "" |
|
|
82 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
83 |
|
84 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
78 |
while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) { |
85 |
push @authorised_values, $branchcode; |
79 |
push @authorised_values, $branchcode; |
86 |
$authorised_lib{$branchcode} = $branchname; |
80 |
$authorised_lib{$branchcode} = $branchname; |
87 |
} |
81 |
} |
88 |
} |
82 |
} |
89 |
elsif ( $category eq "itemtypes" ) { |
83 |
elsif ( $category eq "itemtypes" ) { |
90 |
push @authorised_values, "" |
|
|
91 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} |
92 |
&& ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) ); |
93 |
|
94 |
my $itemtype; |
95 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
84 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
96 |
while ( $itemtype = $itemtypes->next ) { |
85 |
while ( my $itemtype = $itemtypes->next ) { |
97 |
push @authorised_values, $itemtype->itemtype; |
86 |
push @authorised_values, $itemtype->itemtype; |
98 |
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; |
87 |
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; |
99 |
} |
88 |
} |
100 |
$value = $itemtype unless ($value); |
|
|
101 |
|
102 |
#---- "true" authorised value |
103 |
} |
89 |
} |
104 |
else { |
90 |
else { # "true" authorised value |
105 |
$authorised_values_sth->execute( |
91 |
$authorised_values_sth->execute( |
106 |
$tagslib->{$tag}->{$subfield}->{authorised_value} ); |
92 |
$tagslib->{$tag}->{$subfield}->{authorised_value} |
107 |
|
93 |
); |
108 |
push @authorised_values, "" |
|
|
109 |
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} |
110 |
&& ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) ); |
111 |
|
112 |
while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { |
94 |
while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { |
113 |
push @authorised_values, $value; |
95 |
push @authorised_values, $value; |
114 |
$authorised_lib{$value} = $lib; |
96 |
$authorised_lib{$value} = $lib; |
115 |
} |
97 |
} |
116 |
} |
98 |
} |
|
|
99 |
|
117 |
return { |
100 |
return { |
118 |
type => 'select', |
101 |
type => 'select', |
119 |
id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, |
102 |
id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, |
Lines 125-131
sub build_authorized_values_list {
Link Here
|
125 |
}; |
108 |
}; |
126 |
} |
109 |
} |
127 |
|
110 |
|
128 |
|
|
|
129 |
=item create_input |
111 |
=item create_input |
130 |
|
112 |
|
131 |
builds the <input ...> entry for a subfield. |
113 |
builds the <input ...> entry for a subfield. |
Lines 133-139
builds the <input ...> entry for a subfield.
Link Here
|
133 |
=cut |
115 |
=cut |
134 |
|
116 |
|
135 |
sub create_input { |
117 |
sub create_input { |
136 |
my ( $tag, $subfield, $value, $index_tag, $rec, $authorised_values_sth,$cgi ) = @_; |
118 |
my ( $tag, $subfield, $value, $index_tag, $rec, $authorised_values_sth, $cgi ) = @_; |
137 |
|
119 |
|
138 |
my $index_subfield = CreateKey(); # create a specifique key for each subfield |
120 |
my $index_subfield = CreateKey(); # create a specifique key for each subfield |
139 |
|
121 |
|
Lines 147-153
sub create_input {
Link Here
|
147 |
|
129 |
|
148 |
# if there is no value provided but a default value in parameters, get it |
130 |
# if there is no value provided but a default value in parameters, get it |
149 |
if ($value eq '') { |
131 |
if ($value eq '') { |
150 |
$value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; |
132 |
$value = $tagslib->{$tag}->{$subfield}->{defaultvalue} if !$cgi->param('authid'); # only for new records |
151 |
if (!defined $value) { |
133 |
if (!defined $value) { |
152 |
$value = q{}; |
134 |
$value = q{}; |
153 |
} |
135 |
} |
154 |
- |
|
|