|
Lines 1694-1699
sub MoveItemFromBiblio {
Link Here
|
| 1694 |
return; |
1694 |
return; |
| 1695 |
} |
1695 |
} |
| 1696 |
|
1696 |
|
|
|
1697 |
=head2 MoveItemsFromBiblio |
| 1698 |
|
| 1699 |
MoveItemsFromBiblio($items_number, $frombiblio, $tobiblio); |
| 1700 |
|
| 1701 |
Moves all items from a biblio record to another |
| 1702 |
|
| 1703 |
return a table of items not moved |
| 1704 |
|
| 1705 |
=cut |
| 1706 |
|
| 1707 |
sub MoveItemsFromBiblio { |
| 1708 |
my ($items_number, $frombiblio, $tobiblio) = @_; |
| 1709 |
my $dbh = C4::Context->dbh; |
| 1710 |
|
| 1711 |
my ( $tobiblioitem ) = $dbh->selectrow_array(q| |
| 1712 |
SELECT biblioitemnumber |
| 1713 |
FROM biblioitems |
| 1714 |
WHERE biblionumber = ? |
| 1715 |
|, undef, $tobiblio ); |
| 1716 |
|
| 1717 |
$dbh->do(q| |
| 1718 |
UPDATE items |
| 1719 |
SET biblioitemnumber = ?, |
| 1720 |
biblionumber = ? |
| 1721 |
WHERE biblionumber = ? |
| 1722 |
|, undef, $tobiblioitem, $tobiblio, $frombiblio ); |
| 1723 |
|
| 1724 |
my @notmoveditems = map { $_->[0] } @{$dbh->selectall_arrayref(q| |
| 1725 |
SELECT itemnumber |
| 1726 |
FROM items |
| 1727 |
WHERE biblionumber = ? |
| 1728 |
|, undef, $frombiblio )}; |
| 1729 |
|
| 1730 |
my @all_items_to_biblio = map { $_->[0] } @{$dbh->selectall_arrayref(q| |
| 1731 |
SELECT itemnumber |
| 1732 |
FROM items |
| 1733 |
WHERE biblionumber = ? |
| 1734 |
|, undef, $tobiblio )}; |
| 1735 |
|
| 1736 |
my @moved_items; |
| 1737 |
|
| 1738 |
#take only items moved |
| 1739 |
foreach my $item_number (@$items_number){ |
| 1740 |
foreach my $item_to_biblio (@all_items_to_biblio){ |
| 1741 |
if ( $item_to_biblio == $item_number){ |
| 1742 |
push @moved_items , $item_to_biblio; |
| 1743 |
} |
| 1744 |
} |
| 1745 |
} |
| 1746 |
|
| 1747 |
#unless all_items are not moved |
| 1748 |
unless ( scalar(@notmoveditems) == scalar(@$items_number) ){ |
| 1749 |
ModZebra( $tobiblio, "specialUpdate", "biblioserver" ); |
| 1750 |
ModZebra( $frombiblio, "specialUpdate", "biblioserver" ); |
| 1751 |
# Checking if the items we want to move are in an order |
| 1752 |
require C4::Acquisition; |
| 1753 |
my $where; |
| 1754 |
foreach my $moved_item (@moved_items){ |
| 1755 |
my $order = C4::Acquisition::GetOrderFromItemnumber($moved_item); |
| 1756 |
if ($order) { |
| 1757 |
# Replacing the biblionumber within the order if necessary |
| 1758 |
$order->{'biblionumber'} = $tobiblio; |
| 1759 |
C4::Acquisition::ModOrder($order); |
| 1760 |
} |
| 1761 |
$where .= " itemnumber = " . $moved_item . " OR"; |
| 1762 |
} |
| 1763 |
$where .= " itemnumber = " . $moved_items[0]; |
| 1764 |
# Update reserves, hold_fill_targets, tmp_holdsqueue and linktracker tables |
| 1765 |
for my $table_name ( qw( reserves hold_fill_targets tmp_holdsqueue linktracker ) ) { |
| 1766 |
$dbh->do( qq| |
| 1767 |
UPDATE $table_name |
| 1768 |
SET biblionumber = $tobiblio |
| 1769 |
WHERE $where | ); |
| 1770 |
} |
| 1771 |
} |
| 1772 |
return @notmoveditems; |
| 1773 |
} |
| 1774 |
|
| 1697 |
=head2 ItemSafeToDelete |
1775 |
=head2 ItemSafeToDelete |
| 1698 |
|
1776 |
|
| 1699 |
ItemSafeToDelete( $biblionumber, $itemnumber); |
1777 |
ItemSafeToDelete( $biblionumber, $itemnumber); |