|
Lines 649-655
sub BatchCommitRecords {
Link Here
|
| 649 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); |
649 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); |
| 650 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
650 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
| 651 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
651 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
| 652 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
652 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, $biblioitemnumber); |
| 653 |
$num_items_added += $bib_items_added; |
653 |
$num_items_added += $bib_items_added; |
| 654 |
$num_items_replaced += $bib_items_replaced; |
654 |
$num_items_replaced += $bib_items_replaced; |
| 655 |
$num_items_errored += $bib_items_errored; |
655 |
$num_items_errored += $bib_items_errored; |
|
Lines 735-746
sub BatchCommitRecords {
Link Here
|
| 735 |
=head2 BatchCommitItems |
735 |
=head2 BatchCommitItems |
| 736 |
|
736 |
|
| 737 |
($num_items_added, $num_items_errored) = |
737 |
($num_items_added, $num_items_errored) = |
| 738 |
BatchCommitItems($import_record_id, $biblionumber); |
738 |
BatchCommitItems($import_record_id, $biblionumber, [$action, $biblioitemnumber]); |
| 739 |
|
739 |
|
| 740 |
=cut |
740 |
=cut |
| 741 |
|
741 |
|
| 742 |
sub BatchCommitItems { |
742 |
sub BatchCommitItems { |
| 743 |
my ( $import_record_id, $biblionumber, $action ) = @_; |
743 |
my ( $import_record_id, $biblionumber, $action, $biblioitemnumber ) = @_; |
| 744 |
|
744 |
|
| 745 |
my $dbh = C4::Context->dbh; |
745 |
my $dbh = C4::Context->dbh; |
| 746 |
|
746 |
|
|
Lines 765-771
sub BatchCommitItems {
Link Here
|
| 765 |
my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' ); |
765 |
my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' ); |
| 766 |
$item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); |
766 |
$item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); |
| 767 |
|
767 |
|
| 768 |
my $item = TransformMarcToKoha({ record => $item_marc }); |
768 |
my $item = TransformMarcToKoha({ record => $item_marc, kohafields => ['items.barcode','items.itemnumber'] }); |
| 769 |
|
769 |
|
| 770 |
my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} }); |
770 |
my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} }); |
| 771 |
my $duplicate_itemnumber = exists( $item->{'itemnumber'} ); |
771 |
my $duplicate_itemnumber = exists( $item->{'itemnumber'} ); |
|
Lines 800-806
sub BatchCommitItems {
Link Here
|
| 800 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
800 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
| 801 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
801 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
| 802 |
|
802 |
|
| 803 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); |
803 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, {biblioitemnumber => $biblioitemnumber} ); |
| 804 |
if( $itemnumber ) { |
804 |
if( $itemnumber ) { |
| 805 |
$updsth->bind_param( 1, 'imported' ); |
805 |
$updsth->bind_param( 1, 'imported' ); |
| 806 |
$updsth->bind_param( 2, $itemnumber ); |
806 |
$updsth->bind_param( 2, $itemnumber ); |