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

(-)a/C4/Reserves.pm (-1 / +35 lines)
Lines 3-8 package C4::Reserves; Link Here
3
# Copyright 2000-2002 Katipo Communications
3
# Copyright 2000-2002 Katipo Communications
4
#           2006 SAN Ouest Provence
4
#           2006 SAN Ouest Provence
5
#           2007-2010 BibLibre Paul POULAIN
5
#           2007-2010 BibLibre Paul POULAIN
6
#           2011 Catalyst IT
6
#
7
#
7
# This file is part of Koha.
8
# This file is part of Koha.
8
#
9
#
Lines 86-92 This modules provides somes functions to deal with reservations. Link Here
86
BEGIN {
87
BEGIN {
87
    # set the version for version checking
88
    # set the version for version checking
88
    $VERSION = 3.01;
89
    $VERSION = 3.01;
89
	require Exporter;
90
    require Exporter;
90
    @ISA = qw(Exporter);
91
    @ISA = qw(Exporter);
91
    @EXPORT = qw(
92
    @EXPORT = qw(
92
        &AddReserve
93
        &AddReserve
Lines 121-126 BEGIN { Link Here
121
        &AlterPriority
122
        &AlterPriority
122
        &ToggleLowestPriority
123
        &ToggleLowestPriority
123
    );
124
    );
125
    @EXPORT_OK = qw( MergeHolds );
124
}    
126
}    
125
127
126
=head2 AddReserve
128
=head2 AddReserve
Lines 1794-1799 sub _ShiftPriorityByDateAndPriority { Link Here
1794
    return $new_priority;  # so the caller knows what priority they wind up receiving
1796
    return $new_priority;  # so the caller knows what priority they wind up receiving
1795
}
1797
}
1796
1798
1799
=head2 MergeHolds
1800
1801
  MergeHolds($dbh,$to_biblio, $from_biblio);
1802
1803
This shifts the holds from C<$from_biblio> to C<$to_biblio> and reorders them by the date they were placed
1804
1805
=cut
1806
1807
sub MergeHolds {
1808
    my ($dbh,$to_biblio,$from_biblio) = @_;
1809
    my $sth = $dbh->prepare("SELECT count(*) as reservenumber FROM reserves WHERE biblionumber = ?");
1810
    $sth->execute($from_biblio);
1811
    if (my $data = $sth->fetchrow_hashref()){
1812
        # holds exist on old record, if not we don't need to do anything
1813
        $sth = $dbh->prepare("UPDATE reserves SET biblionumber = ? WHERE biblionumber = ?");
1814
        $sth->execute($to_biblio,$from_biblio);
1815
        # Reorder by date
1816
	# don't reorder those already waiting
1817
1818
        $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? AND found <> ? AND found <> ? ORDER BY reservedate ASC");
1819
        my $upd_sth = $dbh->prepare("UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ?
1820
        AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) ");
1821
        $sth->execute($to_biblio,'W','T');
1822
        my $priority = 1;
1823
        while (my $reserve = $sth->fetchrow_hashref()){
1824
            $upd_sth->execute($priority,$to_biblio,$reserve->{'borrowernumber'},$reserve->{'reservedate'},$reserve->{'constrainttype'},$reserve->{'itemnumber'});
1825
            $priority++;
1826
        }
1827
    }
1828
}
1829
1830
1797
=head1 AUTHOR
1831
=head1 AUTHOR
1798
1832
1799
Koha Development Team <http://koha-community.org/>
1833
Koha Development Team <http://koha-community.org/>
(-)a/cataloguing/merge.pl (-1 / +5 lines)
Lines 2-7 Link Here
2
2
3
3
4
# Copyright 2009 BibLibre
4
# Copyright 2009 BibLibre
5
# Parts Copyright Catalyst IT 2011
5
#
6
#
6
# This file is part of Koha.
7
# This file is part of Koha.
7
#
8
#
Lines 26-31 use C4::Auth; Link Here
26
use C4::Items;
27
use C4::Items;
27
use C4::Biblio;
28
use C4::Biblio;
28
use C4::Serials;
29
use C4::Serials;
30
use C4::Reserves qw/MergeHolds/;
29
31
30
my $input = new CGI;
32
my $input = new CGI;
31
my @biblionumber = $input->param('biblionumber');
33
my @biblionumber = $input->param('biblionumber');
Lines 101-106 if ($merge) { Link Here
101
103
102
    # Deleting the other record
104
    # Deleting the other record
103
    if (scalar(@errors) == 0) {
105
    if (scalar(@errors) == 0) {
106
	# Move holds
107
	MergeHolds($dbh,$tobiblio,$frombiblio);
104
	my $error = DelBiblio($frombiblio);
108
	my $error = DelBiblio($frombiblio);
105
	push @errors, $error if ($error); 
109
	push @errors, $error if ($error); 
106
    }
110
    }
Lines 252-254 sub createKey(){ Link Here
252
}
256
}
253
257
254
258
255
- 
259
    

Return to bug 5459