|
Lines 442-479
Returns item record
Link Here
|
| 442 |
|
442 |
|
| 443 |
=cut |
443 |
=cut |
| 444 |
|
444 |
|
| 445 |
my %default_values_for_mod_from_marc = ( |
445 |
our %default_values_for_mod_from_marc; |
| 446 |
# DO NOT include (internal) item fields here. |
446 |
|
| 447 |
# Only fields that are related to the MARC structure used in additem.pl |
447 |
sub _build_default_values_for_mod_marc { |
| 448 |
# Bug 7817 removed permanent_location. |
448 |
my ($frameworkcode) = @_; |
| 449 |
barcode => undef, |
449 |
return $default_values_for_mod_from_marc{$frameworkcode} |
| 450 |
booksellerid => undef, |
450 |
if exists $default_values_for_mod_from_marc{$frameworkcode}; |
| 451 |
ccode => undef, |
451 |
my $marc_structure = C4::Biblio::GetMarcStructure( 1, $frameworkcode ); |
| 452 |
'items.cn_source' => undef, |
452 |
my $default_values = { |
| 453 |
coded_location_qualifier => undef, |
453 |
barcode => undef, |
| 454 |
copynumber => undef, |
454 |
booksellerid => undef, |
| 455 |
damaged => 0, |
455 |
ccode => undef, |
| 456 |
# dateaccessioned => undef, |
456 |
'items.cn_source' => undef, |
| 457 |
enumchron => undef, |
457 |
coded_location_qualifier => undef, |
| 458 |
holdingbranch => undef, |
458 |
copynumber => undef, |
| 459 |
homebranch => undef, |
459 |
damaged => 0, |
| 460 |
itemcallnumber => undef, |
460 |
enumchron => undef, |
| 461 |
itemlost => 0, |
461 |
holdingbranch => undef, |
| 462 |
itemnotes => undef, |
462 |
homebranch => undef, |
| 463 |
itype => undef, |
463 |
itemcallnumber => undef, |
| 464 |
location => undef, |
464 |
itemlost => 0, |
| 465 |
materials => undef, |
465 |
itemnotes => undef, |
| 466 |
notforloan => 0, |
466 |
itype => undef, |
| 467 |
paidfor => undef, # should not be here: see BZ 12817 |
467 |
location => undef, |
| 468 |
price => undef, |
468 |
permanent_location => undef, |
| 469 |
replacementprice => undef, |
469 |
materials => undef, |
| 470 |
replacementpricedate => undef, |
470 |
notforloan => 0, |
| 471 |
restricted => undef, |
471 |
# paidfor => undef, # commented, see bug 12817 |
| 472 |
stack => undef, |
472 |
price => undef, |
| 473 |
stocknumber => undef, |
473 |
replacementprice => undef, |
| 474 |
uri => undef, |
474 |
replacementpricedate => undef, |
| 475 |
withdrawn => 0, |
475 |
restricted => undef, |
| 476 |
); |
476 |
stack => undef, |
|
|
477 |
stocknumber => undef, |
| 478 |
uri => undef, |
| 479 |
withdrawn => 0, |
| 480 |
}; |
| 481 |
while ( my ( $field, $default_value ) = each %$default_values ) { |
| 482 |
$field =~ s|[^\.]*\.?(.*)|items.$1|; |
| 483 |
$default_values_for_mod_from_marc{$frameworkcode}{$field} = |
| 484 |
$default_value |
| 485 |
if C4::Koha::IsKohaFieldLinked( |
| 486 |
{ kohafield => $field, frameworkcode => $frameworkcode } ); |
| 487 |
} |
| 488 |
return $default_values_for_mod_from_marc{$frameworkcode}; |
| 489 |
} |
| 477 |
|
490 |
|
| 478 |
sub ModItemFromMarc { |
491 |
sub ModItemFromMarc { |
| 479 |
my $item_marc = shift; |
492 |
my $item_marc = shift; |
|
Lines 487-494
sub ModItemFromMarc {
Link Here
|
| 487 |
my $localitemmarc = MARC::Record->new; |
500 |
my $localitemmarc = MARC::Record->new; |
| 488 |
$localitemmarc->append_fields( $item_marc->field($itemtag) ); |
501 |
$localitemmarc->append_fields( $item_marc->field($itemtag) ); |
| 489 |
my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode, 'items' ); |
502 |
my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode, 'items' ); |
| 490 |
foreach my $item_field ( keys %default_values_for_mod_from_marc ) { |
503 |
my $default_values = _build_default_values_for_mod_marc(); |
| 491 |
$item->{$item_field} = $default_values_for_mod_from_marc{$item_field} unless (exists $item->{$item_field}); |
504 |
foreach my $item_field ( keys %$default_values ) { |
|
|
505 |
$item->{$item_field} = $default_values->{$item_field} |
| 506 |
unless exists $item->{$item_field}; |
| 492 |
} |
507 |
} |
| 493 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
508 |
my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); |
| 494 |
|
509 |
|