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

(-)a/C4/Reserves.pm (-1 / +48 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 1809-1814 sub _ShiftPriorityByDateAndPriority { Link Here
1809
    return $new_priority;  # so the caller knows what priority they wind up receiving
1811
    return $new_priority;  # so the caller knows what priority they wind up receiving
1810
}
1812
}
1811
1813
1814
=head2 MergeHolds
1815
1816
  MergeHolds($dbh,$to_biblio, $from_biblio);
1817
1818
This shifts the holds from C<$from_biblio> to C<$to_biblio> and reorders them by the date they were placed
1819
1820
=cut
1821
1822
sub MergeHolds {
1823
    my ( $dbh, $to_biblio, $from_biblio ) = @_;
1824
    my $sth = $dbh->prepare(
1825
        "SELECT count(*) as reservenumber FROM reserves WHERE biblionumber = ?"
1826
    );
1827
    $sth->execute($from_biblio);
1828
    if ( my $data = $sth->fetchrow_hashref() ) {
1829
1830
        # holds exist on old record, if not we don't need to do anything
1831
        $sth = $dbh->prepare(
1832
            "UPDATE reserves SET biblionumber = ? WHERE biblionumber = ?");
1833
        $sth->execute( $to_biblio, $from_biblio );
1834
1835
        # Reorder by date
1836
        # don't reorder those already waiting
1837
1838
        $sth = $dbh->prepare(
1839
"SELECT * FROM reserves WHERE biblionumber = ? AND (found <> ? AND found <> ? OR found is NULL) ORDER BY reservedate ASC"
1840
        );
1841
        my $upd_sth = $dbh->prepare(
1842
"UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ?
1843
        AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) "
1844
        );
1845
        $sth->execute( $to_biblio, 'W', 'T' );
1846
        my $priority = 1;
1847
        while ( my $reserve = $sth->fetchrow_hashref() ) {
1848
            $upd_sth->execute(
1849
                $priority,                    $to_biblio,
1850
                $reserve->{'borrowernumber'}, $reserve->{'reservedate'},
1851
                $reserve->{'constrainttype'}, $reserve->{'itemnumber'}
1852
            );
1853
            $priority++;
1854
        }
1855
    }
1856
}
1857
1858
1812
=head1 AUTHOR
1859
=head1 AUTHOR
1813
1860
1814
Koha Development Team <http://koha-community.org/>
1861
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 100-105 if ($merge) { Link Here
100
102
101
    # Deleting the other record
103
    # Deleting the other record
102
    if (scalar(@errors) == 0) {
104
    if (scalar(@errors) == 0) {
105
	# Move holds
106
	MergeHolds($dbh,$tobiblio,$frombiblio);
103
	my $error = DelBiblio($frombiblio);
107
	my $error = DelBiblio($frombiblio);
104
	push @errors, $error if ($error); 
108
	push @errors, $error if ($error); 
105
    }
109
    }
Lines 251-253 sub createKey(){ Link Here
251
}
255
}
252
256
253
257
254
- 
258
    

Return to bug 5459