|
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 |
# don't reorder those already waiting |
| 1814 |
$sth = $dbh->prepare("UPDATE reserves SET biblionumber = ? WHERE biblionumber = ? AND found <> ?"); |
| 1815 |
$sth->execute($to_biblio,$from_biblio,'W'); |
| 1816 |
# Reorder by date |
| 1817 |
$sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? ORDER BY reservedate ASC"); |
| 1818 |
my $upd_sth = $dbh->prepare("UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? |
| 1819 |
AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) "); |
| 1820 |
$sth->execute($to_biblio); |
| 1821 |
my $priority = 1; |
| 1822 |
while (my $reserve = $sth->fetchrow_hashref()){ |
| 1823 |
$upd_sth->execute($priority,$to_biblio,$reserve->{'borrowernumber'},$reserve->{'reservedate'},$reserve->{'constrainttype'},$reserve->{'itemnumber'}); |
| 1824 |
$priority++; |
| 1825 |
} |
| 1826 |
} |
| 1827 |
} |
| 1828 |
|
| 1829 |
|
| 1797 |
=head1 AUTHOR |
1830 |
=head1 AUTHOR |
| 1798 |
|
1831 |
|
| 1799 |
Koha Development Team <http://koha-community.org/> |
1832 |
Koha Development Team <http://koha-community.org/> |