|
Lines 30-35
use C4::Koha; # XXX subfield_is_koha_internal_p
Link Here
|
| 30 |
use C4::Branch; # XXX subfield_is_koha_internal_p |
30 |
use C4::Branch; # XXX subfield_is_koha_internal_p |
| 31 |
use C4::ClassSource; |
31 |
use C4::ClassSource; |
| 32 |
use C4::Dates; |
32 |
use C4::Dates; |
|
|
33 |
use List::MoreUtils qw/any/; |
| 33 |
|
34 |
|
| 34 |
use MARC::File::XML; |
35 |
use MARC::File::XML; |
| 35 |
|
36 |
|
|
Lines 91-97
sub _increment_barcode {
Link Here
|
| 91 |
} |
92 |
} |
| 92 |
|
93 |
|
| 93 |
|
94 |
|
| 94 |
my $input = new CGI; |
95 |
sub generate_subfield_form { |
|
|
96 |
my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_; |
| 97 |
|
| 98 |
my %subfield_data; |
| 99 |
my $dbh = C4::Context->dbh; |
| 100 |
my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib"); |
| 101 |
|
| 102 |
my $index_subfield = int(rand(1000000)); |
| 103 |
if ($subfieldtag eq '@'){ |
| 104 |
$subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield; |
| 105 |
} else { |
| 106 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield; |
| 107 |
} |
| 108 |
|
| 109 |
$subfield_data{tag} = $tag; |
| 110 |
$subfield_data{subfield} = $subfieldtag; |
| 111 |
$subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms? |
| 112 |
$subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$subfieldlib->{lib}."\">".$subfieldlib->{lib}."</span>"; |
| 113 |
$subfield_data{mandatory} = $subfieldlib->{mandatory}; |
| 114 |
$subfield_data{repeatable} = $subfieldlib->{repeatable}; |
| 115 |
|
| 116 |
$value =~ s/"/"/g; |
| 117 |
if ( ! defined( $value ) || $value eq '') { |
| 118 |
$value = $subfieldlib->{defaultvalue}; |
| 119 |
# get today date & replace YYYY, MM, DD if provided in the default value |
| 120 |
my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas! |
| 121 |
$value =~ s/YYYY/$year/g; |
| 122 |
$value =~ s/MM/$month/g; |
| 123 |
$value =~ s/DD/$day/g; |
| 124 |
} |
| 125 |
|
| 126 |
$subfield_data{visibility} = "display:none;" if (($subfieldlib->{hidden} > 4) || ($subfieldlib->{hidden} < -4)); |
| 127 |
|
| 128 |
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); |
| 129 |
if (!$value && $subfieldlib->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) { |
| 130 |
my $CNtag = substr($pref_itemcallnumber, 0, 3); |
| 131 |
my $CNsubfield = substr($pref_itemcallnumber, 3, 1); |
| 132 |
my $CNsubfield2 = substr($pref_itemcallnumber, 4, 1); |
| 133 |
my $temp2 = $temp->field($CNtag); |
| 134 |
if ($temp2) { |
| 135 |
$value = ($temp2->subfield($CNsubfield)).' '.($temp2->subfield($CNsubfield2)); |
| 136 |
#remove any trailing space incase one subfield is used |
| 137 |
$value =~ s/^\s+|\s+$//g; |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" ); |
| 142 |
my $attributes = qq($attributes_no_value value="$value" ); |
| 143 |
|
| 144 |
if ( $subfieldlib->{authorised_value} ) { |
| 145 |
my @authorised_values; |
| 146 |
my %authorised_lib; |
| 147 |
# builds list, depending on authorised value... |
| 148 |
if ( $subfieldlib->{authorised_value} eq "branches" ) { |
| 149 |
foreach my $thisbranch (@$branches) { |
| 150 |
push @authorised_values, $thisbranch->{value}; |
| 151 |
$authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname}; |
| 152 |
$value = $thisbranch->{value} if $thisbranch->{selected}; |
| 153 |
} |
| 154 |
} |
| 155 |
elsif ( $subfieldlib->{authorised_value} eq "itemtypes" ) { |
| 156 |
push @authorised_values, "" unless ( $subfieldlib->{mandatory} ); |
| 157 |
my $sth = $dbh->prepare("SELECT itemtype,description FROM itemtypes ORDER BY description"); |
| 158 |
$sth->execute; |
| 159 |
while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) { |
| 160 |
push @authorised_values, $itemtype; |
| 161 |
$authorised_lib{$itemtype} = $description; |
| 162 |
} |
| 163 |
|
| 164 |
unless ( $value ) { |
| 165 |
my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
| 166 |
$itype_sth->execute( $biblionumber ); |
| 167 |
( $value ) = $itype_sth->fetchrow_array; |
| 168 |
} |
| 169 |
|
| 170 |
#---- class_sources |
| 171 |
} |
| 172 |
elsif ( $subfieldlib->{authorised_value} eq "cn_source" ) { |
| 173 |
push @authorised_values, "" unless ( $subfieldlib->{mandatory} ); |
| 174 |
|
| 175 |
my $class_sources = GetClassSources(); |
| 176 |
my $default_source = C4::Context->preference("DefaultClassificationSource"); |
| 177 |
|
| 178 |
foreach my $class_source (sort keys %$class_sources) { |
| 179 |
next unless $class_sources->{$class_source}->{'used'} or |
| 180 |
($value and $class_source eq $value) or |
| 181 |
($class_source eq $default_source); |
| 182 |
push @authorised_values, $class_source; |
| 183 |
$authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'}; |
| 184 |
} |
| 185 |
$value = $default_source unless ($value); |
| 186 |
|
| 187 |
#---- "true" authorised value |
| 188 |
} |
| 189 |
else { |
| 190 |
push @authorised_values, "" unless ( $subfieldlib->{mandatory} ); |
| 191 |
$authorised_values_sth->execute( $subfieldlib->{authorised_value} ); |
| 192 |
while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { |
| 193 |
push @authorised_values, $value; |
| 194 |
$authorised_lib{$value} = $lib; |
| 195 |
} |
| 196 |
} |
| 197 |
|
| 198 |
$subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list |
| 199 |
-name => "field_value", |
| 200 |
-values => \@authorised_values, |
| 201 |
-default => $value, |
| 202 |
-labels => \%authorised_lib, |
| 203 |
-override => 1, |
| 204 |
-size => 1, |
| 205 |
-multiple => 0, |
| 206 |
-tabindex => 1, |
| 207 |
-id => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield, |
| 208 |
-class => "input_marceditor", |
| 209 |
); |
| 210 |
|
| 211 |
# it's a thesaurus / authority field |
| 212 |
} |
| 213 |
elsif ( $subfieldlib->{authtypecode} ) { |
| 214 |
$subfield_data{marc_value} = "<input type=\"text\" $attributes /> |
| 215 |
<a href=\"#\" class=\"buttonDot\" |
| 216 |
onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$subfieldlib->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a> |
| 217 |
"; |
| 218 |
# it's a plugin field |
| 219 |
} |
| 220 |
elsif ( $subfieldlib->{value_builder} ) { |
| 221 |
# opening plugin |
| 222 |
my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $subfieldlib->{'value_builder'}; |
| 223 |
if (do $plugin) { |
| 224 |
my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, $loop_data ); |
| 225 |
my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, $loop_data ); |
| 226 |
my $change = index($javascript, 'function Change') > -1 ? |
| 227 |
"return Change$function_name($subfield_data{random}, '$subfield_data{id}');" : |
| 228 |
'return 1;'; |
| 229 |
$subfield_data{marc_value} = qq[<input $attributes |
| 230 |
onfocus="Focus$function_name($subfield_data{random}, '$subfield_data{id}');" |
| 231 |
onchange=" $change" |
| 232 |
onblur=" Blur$function_name($subfield_data{random}, '$subfield_data{id}');" /> |
| 233 |
<a href="#" class="buttonDot" onclick="Clic$function_name('$subfield_data{id}'); return false;" title="Tag Editor">...</a> |
| 234 |
$javascript]; |
| 235 |
} else { |
| 236 |
warn "Plugin Failed: $plugin"; |
| 237 |
$subfield_data{marc_value} = "<input $attributes />"; # supply default input form |
| 238 |
} |
| 239 |
} |
| 240 |
elsif ( $tag eq '' ) { # it's an hidden field |
| 241 |
$subfield_data{marc_value} = qq(<input type="hidden" $attributes />); |
| 242 |
} |
| 243 |
elsif ( $subfieldlib->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ? |
| 244 |
$subfield_data{marc_value} = qq(<input type="text" $attributes />); |
| 245 |
} |
| 246 |
elsif ( length($value) > 100 |
| 247 |
or (C4::Context->preference("marcflavour") eq "UNIMARC" and |
| 248 |
300 <= $tag && $tag < 400 && $subfieldtag eq 'a' ) |
| 249 |
or (C4::Context->preference("marcflavour") eq "MARC21" and |
| 250 |
500 <= $tag && $tag < 600 ) |
| 251 |
) { |
| 252 |
# oversize field (textarea) |
| 253 |
$subfield_data{marc_value} = "<textarea $attributes_no_value>$value</textarea>\n"; |
| 254 |
} else { |
| 255 |
# it's a standard field |
| 256 |
$subfield_data{marc_value} = "<input $attributes />"; |
| 257 |
} |
| 258 |
|
| 259 |
return \%subfield_data; |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
my $input = new CGI; |
| 264 |
my $dbh = C4::Context->dbh; |
| 95 |
my $error = $input->param('error'); |
265 |
my $error = $input->param('error'); |
| 96 |
my $biblionumber = $input->param('biblionumber'); |
266 |
my $biblionumber = $input->param('biblionumber'); |
| 97 |
my $itemnumber = $input->param('itemnumber'); |
267 |
my $itemnumber = $input->param('itemnumber'); |
|
Lines 318-347
my ( $itemtagfield, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumb
Link Here
|
| 318 |
my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", $frameworkcode); |
488 |
my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", $frameworkcode); |
| 319 |
|
489 |
|
| 320 |
foreach my $field (@fields) { |
490 |
foreach my $field (@fields) { |
| 321 |
next if ($field->tag()<10); |
491 |
next if ( $field->tag() < 10 ); |
| 322 |
my @subf = $field->subfields or (); # don't use ||, as that forces $field->subfelds to be interpreted in scalar context |
492 |
|
|
|
493 |
my @subf = $field->subfields or (); # don't use ||, as that forces $field->subfelds to be interpreted in scalar context |
| 323 |
my %this_row; |
494 |
my %this_row; |
| 324 |
# loop through each subfield |
495 |
# loop through each subfield |
| 325 |
for my $i (0..$#subf) { |
496 |
my $i = 0; |
| 326 |
next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10 |
497 |
foreach my $subfield (@subf){ |
| 327 |
&& ($field->tag() ne $itemtagfield |
498 |
my $subfieldcode = $subfield->[0]; |
| 328 |
&& $subf[$i][0] ne $itemtagsubfield)); |
499 |
my $subfieldvalue= $subfield->[1]; |
| 329 |
|
500 |
|
| 330 |
$witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib} if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} eq 10); |
501 |
next if ($tagslib->{$field->tag()}->{$subfieldcode}->{tab} ne 10 |
| 331 |
if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} eq 10) { |
502 |
&& ($field->tag() ne $itemtagfield |
| 332 |
$this_row{$subf[$i][0]}=GetAuthorisedValueDesc( $field->tag(), |
503 |
&& $subfieldcode ne $itemtagsubfield)); |
| 333 |
$subf[$i][0], $subf[$i][1], '', $tagslib) |
504 |
$witness{$subfieldcode} = $tagslib->{$field->tag()}->{$subfieldcode}->{lib} if ($tagslib->{$field->tag()}->{$subfieldcode}->{tab} eq 10); |
| 334 |
|| $subf[$i][1]; |
505 |
if ($tagslib->{$field->tag()}->{$subfieldcode}->{tab} eq 10) { |
| 335 |
} |
506 |
$this_row{$subfieldcode} .= " | " if($this_row{$subfieldcode}); |
|
|
507 |
$this_row{$subfieldcode} .= GetAuthorisedValueDesc( $field->tag(), |
| 508 |
$subfieldcode, $subfieldvalue, '', $tagslib) |
| 509 |
|| $subfieldvalue; |
| 510 |
} |
| 336 |
|
511 |
|
| 337 |
if (($field->tag eq $branchtagfield) && ($subf[$i][$0] eq $branchtagsubfield) && C4::Context->preference("IndependantBranches")) { |
512 |
if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependantBranches")) { |
| 338 |
#verifying rights |
513 |
#verifying rights |
| 339 |
my $userenv = C4::Context->userenv(); |
514 |
my $userenv = C4::Context->userenv(); |
| 340 |
unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subf[$i][1]))){ |
515 |
unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subfieldvalue))){ |
| 341 |
$this_row{'nomod'}=1; |
516 |
$this_row{'nomod'} = 1; |
| 342 |
} |
517 |
} |
| 343 |
} |
518 |
} |
| 344 |
$this_row{itemnumber} = $subf[$i][1] if ($field->tag() eq $itemtagfield && $subf[$i][0] eq $itemtagsubfield); |
519 |
$this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield); |
| 345 |
} |
520 |
} |
| 346 |
if (%this_row) { |
521 |
if (%this_row) { |
| 347 |
push(@big_array, \%this_row); |
522 |
push(@big_array, \%this_row); |
|
Lines 374-550
foreach my $subfield_code (sort keys(%witness)) {
Link Here
|
| 374 |
my @loop_data =(); |
549 |
my @loop_data =(); |
| 375 |
my $i=0; |
550 |
my $i=0; |
| 376 |
|
551 |
|
| 377 |
my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later. |
|
|
| 378 |
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); |
552 |
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); |
| 379 |
|
553 |
|
| 380 |
# Getting the fields where the item location is |
554 |
my $onlymine = C4::Context->preference('IndependantBranches') && |
| 381 |
my ($location_field, $location_subfield) = GetMarcFromKohaField('items.location', $frameworkcode); |
555 |
C4::Context->userenv && |
| 382 |
|
556 |
C4::Context->userenv->{flags}!=1 && |
| 383 |
# Getting the name of the authorised values' category for item location |
557 |
C4::Context->userenv->{branch}; |
| 384 |
my $item_location_category = $tagslib->{$location_field}->{$location_subfield}->{'authorised_value'}; |
558 |
my $branches = GetBranchesLoop(undef,$onlymine); # build once ahead of time, instead of multiple times later. |
| 385 |
|
|
|
| 386 |
foreach my $tag (sort keys %{$tagslib}) { |
| 387 |
# loop through each subfield |
| 388 |
foreach my $subfield (sort keys %{$tagslib->{$tag}}) { |
| 389 |
next if subfield_is_koha_internal_p($subfield); |
| 390 |
next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); |
| 391 |
my %subfield_data; |
| 392 |
|
| 393 |
my $index_subfield = int(rand(1000000)); |
| 394 |
if ($subfield eq '@'){ |
| 395 |
$subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield; |
| 396 |
} else { |
| 397 |
$subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield; |
| 398 |
} |
| 399 |
$subfield_data{tag} = $tag; |
| 400 |
$subfield_data{subfield} = $subfield; |
| 401 |
$subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms? |
| 402 |
# $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib}; |
| 403 |
$subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>"; |
| 404 |
$subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory}; |
| 405 |
$subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable}; |
| 406 |
my ($x,$value); |
| 407 |
($x,$value) = find_value($tag,$subfield,$itemrecord) if ($itemrecord); |
| 408 |
$value =~ s/"/"/g; |
| 409 |
unless ($value) { |
| 410 |
$value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; |
| 411 |
# get today date & replace YYYY, MM, DD if provided in the default value |
| 412 |
my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas! |
| 413 |
$value =~ s/YYYY/$year/g; |
| 414 |
$value =~ s/MM/$month/g; |
| 415 |
$value =~ s/DD/$day/g; |
| 416 |
} |
| 417 |
$subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4)); |
| 418 |
# testing branch value if IndependantBranches. |
| 419 |
if (!$value && $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) { |
| 420 |
my $CNtag = substr($pref_itemcallnumber, 0, 3); |
| 421 |
my $CNsubfield = substr($pref_itemcallnumber, 3, 1); |
| 422 |
my $CNsubfield2 = substr($pref_itemcallnumber, 4, 1); |
| 423 |
my $temp2 = $temp->field($CNtag); |
| 424 |
if ($temp2) { |
| 425 |
$value = ($temp2->subfield($CNsubfield)).' '.($temp2->subfield($CNsubfield2)); |
| 426 |
#remove any trailing space incase one subfield is used |
| 427 |
$value =~ s/^\s+|\s+$//g; |
| 428 |
} |
| 429 |
} |
| 430 |
|
559 |
|
| 431 |
my $attributes_no_value = qq(id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" ); |
560 |
# We generate form, from actuel record |
| 432 |
my $attributes = qq($attributes_no_value value="$value" ); |
561 |
my @fields; |
| 433 |
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { |
562 |
if($itemrecord){ |
| 434 |
my @authorised_values; |
563 |
foreach my $field ($itemrecord->fields()){ |
| 435 |
my %authorised_lib; |
564 |
my $tag = $field->{_tag}; |
| 436 |
# builds list, depending on authorised value... |
565 |
foreach my $subfield ( $field->subfields() ){ |
| 437 |
|
566 |
|
| 438 |
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) { |
567 |
my $subfieldtag = $subfield->[0]; |
| 439 |
foreach my $thisbranch (@$branches) { |
568 |
my $value = $subfield->[1]; |
| 440 |
push @authorised_values, $thisbranch->{value}; |
569 |
my $subfieldlib = $tagslib->{$tag}->{$subfieldtag}; |
| 441 |
$authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname}; |
570 |
|
| 442 |
# in edit item this is set to the data value otherwise use default |
571 |
next if subfield_is_koha_internal_p($subfieldtag); |
| 443 |
if ($op ne 'edititem' && $thisbranch->{selected} ) { |
572 |
next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); |
| 444 |
$value = $thisbranch->{value}; |
573 |
|
| 445 |
} |
574 |
my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); |
| 446 |
} |
575 |
|
| 447 |
} |
576 |
push @fields, "$tag$subfieldtag"; |
| 448 |
elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { |
577 |
push (@loop_data, $subfield_data); |
| 449 |
push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
578 |
$i++; |
| 450 |
my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description"); |
579 |
} |
| 451 |
$sth->execute; |
580 |
|
| 452 |
while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) { |
581 |
} |
| 453 |
push @authorised_values, $itemtype; |
582 |
} |
| 454 |
$authorised_lib{$itemtype} = $description; |
583 |
# and now we add fields that are empty |
| 455 |
} |
584 |
|
| 456 |
|
585 |
foreach my $tag ( keys %{$tagslib}){ |
| 457 |
unless ( $value ) { |
586 |
foreach my $subtag (keys %{$tagslib->{$tag}}){ |
| 458 |
my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
587 |
next if subfield_is_koha_internal_p($subtag); |
| 459 |
$itype_sth->execute( $biblionumber ); |
588 |
next if ($tagslib->{$tag}->{$subtag}->{'tab'} ne "10"); |
| 460 |
( $value ) = $itype_sth->fetchrow_array; |
589 |
next if any { /^$tag$subtag$/ } @fields; |
| 461 |
} |
590 |
|
| 462 |
|
591 |
my $value = ""; |
| 463 |
#---- class_sources |
592 |
my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); |
| 464 |
} |
593 |
|
| 465 |
elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) { |
594 |
push (@loop_data, $subfield_data); |
| 466 |
push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
595 |
$i++; |
| 467 |
|
|
|
| 468 |
my $class_sources = GetClassSources(); |
| 469 |
my $default_source = C4::Context->preference("DefaultClassificationSource"); |
| 470 |
|
| 471 |
foreach my $class_source (sort keys %$class_sources) { |
| 472 |
next unless $class_sources->{$class_source}->{'used'} or |
| 473 |
($value and $class_source eq $value) or |
| 474 |
($class_source eq $default_source); |
| 475 |
push @authorised_values, $class_source; |
| 476 |
$authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'}; |
| 477 |
} |
| 478 |
$value = $default_source unless ($value); |
| 479 |
|
| 480 |
#---- "true" authorised value |
| 481 |
} |
| 482 |
else { |
| 483 |
push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); |
| 484 |
|
| 485 |
# Are we dealing with item location ? |
| 486 |
my $item_location = ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) ? 1 : 0; |
| 487 |
|
| 488 |
# If so, we sort by authorised_value, else by libelle |
| 489 |
my $orderby = $item_location ? 'authorised_value' : 'lib'; |
| 490 |
|
| 491 |
my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY $orderby"); |
| 492 |
|
| 493 |
$authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value}); |
| 494 |
|
| 495 |
|
| 496 |
while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { |
| 497 |
push @authorised_values, $value; |
| 498 |
if ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) { |
| 499 |
$authorised_lib{$value} = $value . " - " . $lib; |
| 500 |
} else { |
| 501 |
$authorised_lib{$value} = $lib; |
| 502 |
} |
| 503 |
|
| 504 |
# For item location, we show the code and the libelle |
| 505 |
$authorised_lib{$value} = ($item_location) ? $value . " - " . $lib : $lib; |
| 506 |
} |
| 507 |
} |
| 508 |
$subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list |
| 509 |
-name => "field_value", |
| 510 |
-values => \@authorised_values, |
| 511 |
-default => $value, |
| 512 |
-labels => \%authorised_lib, |
| 513 |
-override => 1, |
| 514 |
-size => 1, |
| 515 |
-multiple => 0, |
| 516 |
# -tabindex => 1, |
| 517 |
-id => "tag_".$tag."_subfield_".$subfield."_".$index_subfield, |
| 518 |
-class => "input_marceditor", |
| 519 |
); |
| 520 |
# it's a thesaurus / authority field |
| 521 |
} |
| 522 |
elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) { |
| 523 |
$subfield_data{marc_value} = "<input type=\"text\" $attributes /> |
| 524 |
<a href=\"#\" class=\"buttonDot\" |
| 525 |
onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a> |
| 526 |
"; |
| 527 |
# it's a plugin field |
| 528 |
} |
| 529 |
elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) { |
| 530 |
# opening plugin |
| 531 |
my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $tagslib->{$tag}->{$subfield}->{'value_builder'}; |
| 532 |
if (do $plugin) { |
| 533 |
my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, \@loop_data ); |
| 534 |
my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, \@loop_data ); |
| 535 |
my $change = index($javascript, 'function Change') > -1 ? |
| 536 |
"return Change$function_name($subfield_data{random}, '$subfield_data{id}');" : |
| 537 |
'return 1;'; |
| 538 |
$subfield_data{marc_value} = qq[<input $attributes |
| 539 |
onfocus="Focus$function_name($subfield_data{random}, '$subfield_data{id}');" |
| 540 |
onchange=" $change" |
| 541 |
onblur=" Blur$function_name($subfield_data{random}, '$subfield_data{id}');" /> |
| 542 |
<a href="#" class="buttonDot" onclick="Clic$function_name('$subfield_data{id}'); return false;" title="Tag Editor">...</a> |
| 543 |
$javascript]; |
| 544 |
} else { |
| 545 |
warn "Plugin Failed: $plugin"; |
| 546 |
$subfield_data{marc_value} = "<input $attributes />"; # supply default input form |
| 547 |
} |
| 548 |
} |
596 |
} |
| 549 |
elsif ( $tag eq '' ) { # it's an hidden field |
597 |
elsif ( $tag eq '' ) { # it's an hidden field |
| 550 |
$subfield_data{marc_value} = qq(<input type="hidden" $attributes />); |
598 |
$subfield_data{marc_value} = qq(<input type="hidden" $attributes />); |
|
Lines 569-575
foreach my $tag (sort keys %{$tagslib}) {
Link Here
|
| 569 |
$i++ |
617 |
$i++ |
| 570 |
} |
618 |
} |
| 571 |
} |
619 |
} |
| 572 |
|
|
|
| 573 |
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. |
620 |
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. |
| 574 |
$template->param( title => $record->title() ) if ($record ne "-1"); |
621 |
$template->param( title => $record->title() ) if ($record ne "-1"); |
| 575 |
$template->param( |
622 |
$template->param( |
| 576 |
- |
|
|