Bugzilla – Attachment 5467 Details for
Bug 5459
merging records loses holds from one
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5459 - Holds not being shifted when merging biblios
Bug-5459---Holds-not-being-shifted-when-merging-bi.patch (text/plain), 3.16 KB, created by
Chris Cormack
on 2011-09-19 22:57:06 UTC
(
hide
)
Description:
Bug 5459 - Holds not being shifted when merging biblios
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-09-19 22:57:06 UTC
Size:
3.16 KB
patch
obsolete
>From 20d4870eacf0fc9e31777049b8f7be930b2bad2c Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Mon, 5 Sep 2011 11:02:19 +1200 >Subject: [PATCH] Bug 5459 - Holds not being shifted when merging biblios > >Holds are now shifted and reordered by date placed. >Holds already marked waiting are not reordered. >--- > C4/Reserves.pm | 32 ++++++++++++++++++++++++++++++++ > cataloguing/merge.pl | 5 +++++ > 2 files changed, 37 insertions(+), 0 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 8373840..58ddbfe 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -3,6 +3,7 @@ package C4::Reserves; > # Copyright 2000-2002 Katipo Communications > # 2006 SAN Ouest Provence > # 2007-2010 BibLibre Paul POULAIN >+# 2011 Catalyst IT > # > # This file is part of Koha. > # >@@ -121,6 +122,7 @@ BEGIN { > &AlterPriority > &ToggleLowestPriority > ); >+ @EXPORT_OK = qw( MergeHolds ); > } > > =head2 AddReserve >@@ -1794,6 +1796,36 @@ sub _ShiftPriorityByDateAndPriority { > return $new_priority; # so the caller knows what priority they wind up receiving > } > >+=head2 MergeHolds >+ >+ MergeHolds($dbh,$to_biblio, $from_biblio); >+ >+This shifts the holds from C<$from_biblio> to C<$to_biblio> and reorders them by the date they were placed >+ >+=cut >+ >+sub MergeHolds { >+ my ($dbh,$to_biblio,$from_biblio) = @_; >+ my $sth = $dbh->prepare("SELECT count(*) as reservenumber FROM reserves WHERE biblionumber = ?"); >+ $sth->execute($from_biblio); >+ if (my $data = $sth->fetchrow_hashref()){ >+ # holds exist on old record if not we don't need to do anything >+ $sth = $dbh->prepare("UPDATE reserves SET biblionumber = ? WHERE biblionumber = ?"); >+ $sth->execute($to_biblio,$from_biblio); >+ # Reorder by date >+ $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? ORDER BY reservedate ASC"); >+ my $upd_sth = $dbh->prepare("UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? >+ AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) "); >+ $sth->execute($to_biblio); >+ my $priority = 1; >+ while (my $reserve = $sth->fetchrow_hashref()){ >+ $upd_sth->execute($priority,$to_biblio,$reserve->{'borrowernumber'},$reserve->{'reservedate'},$reserve->{'constrainttype'},$reserve->{'itemnumber'}); >+ $priority++; >+ } >+ } >+} >+ >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl >index cc2d01d..f32991e 100755 >--- a/cataloguing/merge.pl >+++ b/cataloguing/merge.pl >@@ -2,6 +2,7 @@ > > > # Copyright 2009 BibLibre >+# Parts Copyright Catalyst IT 2011 > # > # This file is part of Koha. > # >@@ -26,6 +27,7 @@ use C4::Auth; > use C4::Items; > use C4::Biblio; > use C4::Serials; >+use C4::Reserves qw/MergeHolds/; > > my $input = new CGI; > my @biblionumber = $input->param('biblionumber'); >@@ -101,6 +103,8 @@ if ($merge) { > > # Deleting the other record > if (scalar(@errors) == 0) { >+ # Move holds >+ MergeHolds($dbh,$tobiblio,$frombiblio); > my $error = DelBiblio($frombiblio); > push @errors, $error if ($error); > } >@@ -252,3 +256,4 @@ sub createKey(){ > } > > >+ >-- >1.7.4.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5459
:
5302
|
5317
|
5318
|
5467
|
5468
|
5611
|
5612
|
5613
|
5614
|
5617
|
5618
|
5629
|
5726
|
5727
|
5732
|
5848