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/> |