|
Lines 995-1000
sub subscriptions {
Link Here
|
| 995 |
return Koha::Subscriptions->_new_from_dbic($rs); |
995 |
return Koha::Subscriptions->_new_from_dbic($rs); |
| 996 |
} |
996 |
} |
| 997 |
|
997 |
|
|
|
998 |
=head3 serials |
| 999 |
|
| 1000 |
my $serials = $self->serials |
| 1001 |
|
| 1002 |
Returns the related Koha::Serials object for this Biblio object |
| 1003 |
|
| 1004 |
=cut |
| 1005 |
|
| 1006 |
sub serials { |
| 1007 |
my ($self) = @_; |
| 1008 |
my $rs = $self->_result->serials; |
| 1009 |
return Koha::Serials->_new_from_dbic($rs); |
| 1010 |
} |
| 1011 |
|
| 1012 |
=head3 subscription_histories |
| 1013 |
|
| 1014 |
my $subscription_histories = $self->subscription_histories |
| 1015 |
|
| 1016 |
Returns the related Koha::Subscription::Histories object for this Biblio object |
| 1017 |
|
| 1018 |
=cut |
| 1019 |
|
| 1020 |
sub subscription_histories { |
| 1021 |
my ($self) = @_; |
| 1022 |
my $rs = $self->_result->subscriptionhistories; |
| 1023 |
return Koha::Subscription::Histories->_new_from_dbic($rs); |
| 1024 |
} |
| 1025 |
|
| 998 |
=head3 has_items_waiting_or_intransit |
1026 |
=head3 has_items_waiting_or_intransit |
| 999 |
|
1027 |
|
| 1000 |
my $itemsWaitingOrInTransit = $biblio->has_items_waiting_or_intransit |
1028 |
my $itemsWaitingOrInTransit = $biblio->has_items_waiting_or_intransit |
|
Lines 1953-1979
sub merge_with {
Link Here
|
| 1953 |
foreach my $bn_merge (@biblio_ids_to_merge) { |
1981 |
foreach my $bn_merge (@biblio_ids_to_merge) { |
| 1954 |
my $from_biblio = Koha::Biblios->find($bn_merge); |
1982 |
my $from_biblio = Koha::Biblios->find($bn_merge); |
| 1955 |
$from_biblio->items->move_to_biblio($self); |
1983 |
$from_biblio->items->move_to_biblio($self); |
|
|
1984 |
|
| 1985 |
# Move article requests |
| 1956 |
$from_biblio->article_requests->update( |
1986 |
$from_biblio->article_requests->update( |
| 1957 |
{ biblionumber => $ref_biblionumber }, |
1987 |
{ biblionumber => $ref_biblionumber }, |
| 1958 |
{ no_triggers => 1 } |
1988 |
{ no_triggers => 1 } |
| 1959 |
); |
1989 |
); |
| 1960 |
|
1990 |
|
| 1961 |
for my $resultset_name (qw(Subscription Subscriptionhistory Serial Suggestion)) { |
1991 |
# Move subscriptions |
| 1962 |
$schema->resultset($resultset_name)->search( { biblionumber => $bn_merge } ) |
1992 |
$from_biblio->subscriptions->update( |
| 1963 |
->update( { biblionumber => $ref_biblionumber } ); |
1993 |
{ biblionumber => $ref_biblionumber }, |
| 1964 |
} |
1994 |
{ no_triggers => 1 } |
|
|
1995 |
); |
| 1965 |
|
1996 |
|
| 1966 |
# TODO should this be ported to more modern DB usage (i.e. DBIx::Class)? |
1997 |
# Move subscription histories |
| 1967 |
my @allorders = GetOrdersByBiblionumber($bn_merge); |
1998 |
$from_biblio->subscription_histories->update( |
| 1968 |
foreach my $myorder (@allorders) { |
1999 |
{ biblionumber => $ref_biblionumber }, |
| 1969 |
$myorder->{'biblionumber'} = $ref_biblionumber; |
2000 |
{ no_triggers => 1 } |
| 1970 |
ModOrder($myorder); |
2001 |
); |
|
|
2002 |
|
| 2003 |
# Move serials |
| 2004 |
$from_biblio->serials->update( |
| 2005 |
{ biblionumber => $ref_biblionumber }, |
| 2006 |
{ no_triggers => 1 } |
| 2007 |
); |
| 2008 |
|
| 2009 |
# Move suggestions |
| 2010 |
$from_biblio->suggestions->update( |
| 2011 |
{ biblionumber => $ref_biblionumber }, |
| 2012 |
{ no_triggers => 1 } |
| 2013 |
); |
| 2014 |
|
| 2015 |
my $orders = $from_biblio->orders->unblessed; |
| 2016 |
for my $order (@$orders) { |
| 2017 |
$order->{'biblionumber'} = $ref_biblionumber; |
| 2018 |
|
| 2019 |
# TODO Do we really need to call ModOrder here? |
| 2020 |
ModOrder($order); |
| 1971 |
|
2021 |
|
| 1972 |
# TODO : add error control (in ModOrder?) |
2022 |
# TODO : add error control (in ModOrder?) |
| 1973 |
} |
2023 |
} |
| 1974 |
|
2024 |
|
| 1975 |
# Move holds |
2025 |
# Move holds |
| 1976 |
MergeHolds( $schema->storage->dbh, $ref_biblionumber, $bn_merge ); |
2026 |
MergeHolds( $schema->storage->dbh, $ref_biblionumber, $bn_merge ); |
|
|
2027 |
|
| 1977 |
my $error = DelBiblio($bn_merge); #DelBiblio return undef unless an error occurs |
2028 |
my $error = DelBiblio($bn_merge); #DelBiblio return undef unless an error occurs |
| 1978 |
if ($error) { |
2029 |
if ($error) { |
| 1979 |
die $error; |
2030 |
die $error; |