View | Details | Raw Unified | Return to bug 34678
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-7 / +13 lines)
Lines 773-790 sub CreatePicklistFromItemMap { Link Here
773
sub AddToHoldTargetMap {
773
sub AddToHoldTargetMap {
774
    my $item_map = shift;
774
    my $item_map = shift;
775
775
776
    my $dbh = C4::Context->dbh;
776
    my $dbh    = C4::Context->dbh;
777
    my $schema = Koha::Database->new->schema;
777
778
778
    my $insert_sql = q(
779
    my $insert_sql = q(
779
        INSERT INTO hold_fill_targets (borrowernumber, biblionumber, itemnumber, source_branchcode, item_level_request, reserve_id)
780
        INSERT INTO hold_fill_targets (borrowernumber, biblionumber, itemnumber, source_branchcode, item_level_request, reserve_id) VALUES (?, ?, ?, ?, ?, ?)
780
                               VALUES (?, ?, ?, ?, ?, ?)
781
    );
781
    );
782
    my $sth_insert = $dbh->prepare($insert_sql);
782
    my $sth_insert = $dbh->prepare($insert_sql);
783
783
784
    foreach my $itemnumber (keys %$item_map) {
784
    foreach my $itemnumber ( keys %$item_map ) {
785
        my $mapped_item = $item_map->{$itemnumber};
785
        my $mapped_item = $item_map->{$itemnumber};
786
        $sth_insert->execute($mapped_item->{borrowernumber}, $mapped_item->{biblionumber}, $itemnumber,
786
        $schema->txn_do(
787
                             $mapped_item->{holdingbranch}, $mapped_item->{item_level}, $mapped_item->{reserve_id});
787
            sub {
788
                $dbh->do( 'DELETE FROM hold_fill_targets WHERE itemnumber = ?', {}, $itemnumber );
789
                $sth_insert->execute(
790
                    $mapped_item->{borrowernumber}, $mapped_item->{biblionumber}, $itemnumber,
791
                    $mapped_item->{holdingbranch},  $mapped_item->{item_level},   $mapped_item->{reserve_id}
792
                );
793
            }
794
        );
788
    }
795
    }
789
}
796
}
790
797
791
- 

Return to bug 34678