Lines 235-242
sub AddItemFromMarc {
Link Here
|
235 |
my $dbh = C4::Context->dbh; |
235 |
my $dbh = C4::Context->dbh; |
236 |
|
236 |
|
237 |
# parse item hash from MARC |
237 |
# parse item hash from MARC |
238 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
238 |
my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); |
239 |
my ($itemtag,$itemsubfield)=GetMarcFromKohaField("items.itemnumber",$frameworkcode); |
239 |
my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode); |
240 |
|
240 |
|
241 |
my $localitemmarc=MARC::Record->new; |
241 |
my $localitemmarc=MARC::Record->new; |
242 |
$localitemmarc->append_fields($source_item_marc->field($itemtag)); |
242 |
$localitemmarc->append_fields($source_item_marc->field($itemtag)); |
Lines 271-277
sub AddItem {
Link Here
|
271 |
my $biblionumber = shift; |
271 |
my $biblionumber = shift; |
272 |
|
272 |
|
273 |
my $dbh = @_ ? shift : C4::Context->dbh; |
273 |
my $dbh = @_ ? shift : C4::Context->dbh; |
274 |
my $frameworkcode = @_ ? shift : GetFrameworkCode($biblionumber); |
274 |
my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode($biblionumber); |
275 |
my $unlinked_item_subfields; |
275 |
my $unlinked_item_subfields; |
276 |
if (@_) { |
276 |
if (@_) { |
277 |
$unlinked_item_subfields = shift; |
277 |
$unlinked_item_subfields = shift; |
Lines 364-370
sub AddItemBatchFromMarc {
Link Here
|
364 |
$record = $record->clone(); |
364 |
$record = $record->clone(); |
365 |
# loop through the item tags and start creating items |
365 |
# loop through the item tags and start creating items |
366 |
my @bad_item_fields = (); |
366 |
my @bad_item_fields = (); |
367 |
my ($itemtag, $itemsubfield) = &GetMarcFromKohaField("items.itemnumber",''); |
367 |
my ($itemtag, $itemsubfield) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",''); |
368 |
my $item_sequence_num = 0; |
368 |
my $item_sequence_num = 0; |
369 |
ITEMFIELD: foreach my $item_field ($record->field($itemtag)) { |
369 |
ITEMFIELD: foreach my $item_field ($record->field($itemtag)) { |
370 |
$item_sequence_num++; |
370 |
$item_sequence_num++; |
Lines 499-506
sub ModItemFromMarc {
Link Here
|
499 |
my $itemnumber = shift; |
499 |
my $itemnumber = shift; |
500 |
|
500 |
|
501 |
my $dbh = C4::Context->dbh; |
501 |
my $dbh = C4::Context->dbh; |
502 |
my $frameworkcode = GetFrameworkCode($biblionumber); |
502 |
my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber); |
503 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
503 |
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
504 |
|
504 |
|
505 |
my $localitemmarc = MARC::Record->new; |
505 |
my $localitemmarc = MARC::Record->new; |
506 |
$localitemmarc->append_fields( $item_marc->field($itemtag) ); |
506 |
$localitemmarc->append_fields( $item_marc->field($itemtag) ); |
Lines 552-558
sub ModItem {
Link Here
|
552 |
} |
552 |
} |
553 |
|
553 |
|
554 |
my $dbh = @_ ? shift : C4::Context->dbh; |
554 |
my $dbh = @_ ? shift : C4::Context->dbh; |
555 |
my $frameworkcode = @_ ? shift : GetFrameworkCode( $biblionumber ); |
555 |
my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode( $biblionumber ); |
556 |
|
556 |
|
557 |
my $unlinked_item_subfields; |
557 |
my $unlinked_item_subfields; |
558 |
if (@_) { |
558 |
if (@_) { |
Lines 1321-1327
references on array of itemnumbers.
Link Here
|
1321 |
|
1321 |
|
1322 |
sub get_hostitemnumbers_of { |
1322 |
sub get_hostitemnumbers_of { |
1323 |
my ($biblionumber) = @_; |
1323 |
my ($biblionumber) = @_; |
1324 |
my $marcrecord = GetMarcBiblio({ biblionumber => $biblionumber }); |
1324 |
my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); |
1325 |
|
1325 |
|
1326 |
return unless $marcrecord; |
1326 |
return unless $marcrecord; |
1327 |
|
1327 |
|
Lines 1479-1485
sub GetMarcItem {
Link Here
|
1479 |
|
1479 |
|
1480 |
my $itemrecord = GetItem($itemnumber); |
1480 |
my $itemrecord = GetItem($itemnumber); |
1481 |
|
1481 |
|
1482 |
# Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. |
1482 |
# Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. |
1483 |
# Also, don't emit a subfield if the underlying field is blank. |
1483 |
# Also, don't emit a subfield if the underlying field is blank. |
1484 |
|
1484 |
|
1485 |
|
1485 |
|
Lines 1493-1500
sub Item2Marc {
Link Here
|
1493 |
defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () |
1493 |
defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () |
1494 |
} keys %{ $itemrecord } |
1494 |
} keys %{ $itemrecord } |
1495 |
}; |
1495 |
}; |
1496 |
my $itemmarc = TransformKohaToMarc($mungeditem); |
1496 |
my $itemmarc = C4::Biblio::TransformKohaToMarc($mungeditem); |
1497 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",GetFrameworkCode($biblionumber)||''); |
1497 |
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",C4::Biblio::GetFrameworkCode($biblionumber)||''); |
1498 |
|
1498 |
|
1499 |
my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); |
1499 |
my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); |
1500 |
if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { |
1500 |
if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { |
Lines 2120-2126
sub _marc_from_item_hash {
Link Here
|
2120 |
|
2120 |
|
2121 |
my $item_marc = MARC::Record->new(); |
2121 |
my $item_marc = MARC::Record->new(); |
2122 |
foreach my $item_field ( keys %{$mungeditem} ) { |
2122 |
foreach my $item_field ( keys %{$mungeditem} ) { |
2123 |
my ( $tag, $subfield ) = GetMarcFromKohaField( $item_field, $frameworkcode ); |
2123 |
my ( $tag, $subfield ) = C4::Biblio::GetMarcFromKohaField( $item_field, $frameworkcode ); |
2124 |
next unless defined $tag and defined $subfield; # skip if not mapped to MARC field |
2124 |
next unless defined $tag and defined $subfield; # skip if not mapped to MARC field |
2125 |
my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1); |
2125 |
my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1); |
2126 |
foreach my $value (@values){ |
2126 |
foreach my $value (@values){ |
Lines 2334-2340
sub _SearchItems_build_where_fragment {
Link Here
|
2334 |
# items.more_subfields_xml, depending on the MARC field. |
2334 |
# items.more_subfields_xml, depending on the MARC field. |
2335 |
my $xpath; |
2335 |
my $xpath; |
2336 |
my $sqlfield; |
2336 |
my $sqlfield; |
2337 |
my ($itemfield) = GetMarcFromKohaField('items.itemnumber'); |
2337 |
my ($itemfield) = C4::Biblio::GetMarcFromKohaField('items.itemnumber'); |
2338 |
if ($marcfield eq $itemfield) { |
2338 |
if ($marcfield eq $itemfield) { |
2339 |
$sqlfield = 'more_subfields_xml'; |
2339 |
$sqlfield = 'more_subfields_xml'; |
2340 |
$xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]'; |
2340 |
$xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]'; |
Lines 2541-2548
sub PrepareItemrecordDisplay {
Link Here
|
2541 |
my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; |
2541 |
my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; |
2542 |
|
2542 |
|
2543 |
my $dbh = C4::Context->dbh; |
2543 |
my $dbh = C4::Context->dbh; |
2544 |
$frameworkcode = &GetFrameworkCode($bibnum) if $bibnum; |
2544 |
$frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum; |
2545 |
my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
2545 |
my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
2546 |
|
2546 |
|
2547 |
# Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is |
2547 |
# Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is |
2548 |
# a shared data structure. No plugin (including custom ones) should change |
2548 |
# a shared data structure. No plugin (including custom ones) should change |