Lines 146-166
BEGIN {
Link Here
|
146 |
|
146 |
|
147 |
=head2 AddReserve |
147 |
=head2 AddReserve |
148 |
|
148 |
|
149 |
AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found) |
149 |
AddReserve($branch,$borrowernumber,$biblionumber,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found) |
150 |
|
150 |
|
151 |
=cut |
151 |
=cut |
152 |
|
152 |
|
153 |
sub AddReserve { |
153 |
sub AddReserve { |
154 |
my ( |
154 |
my ( |
155 |
$branch, $borrowernumber, $biblionumber, |
155 |
$branch, $borrowernumber, $biblionumber, |
156 |
$constraint, $bibitems, $priority, $resdate, $expdate, $notes, |
156 |
$bibitems, $priority, $resdate, $expdate, $notes, |
157 |
$title, $checkitem, $found |
157 |
$title, $checkitem, $found |
158 |
) = @_; |
158 |
) = @_; |
159 |
my $fee = |
159 |
my $fee = |
160 |
GetReserveFee($borrowernumber, $biblionumber, $constraint, |
160 |
GetReserveFee($borrowernumber, $biblionumber, |
161 |
$bibitems ); |
161 |
$bibitems ); |
162 |
my $dbh = C4::Context->dbh; |
162 |
my $dbh = C4::Context->dbh; |
163 |
my $const = lc substr( $constraint, 0, 1 ); |
|
|
164 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
163 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
165 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
164 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
166 |
if ($expdate) { |
165 |
if ($expdate) { |
Lines 194-213
sub AddReserve {
Link Here
|
194 |
"Reserve Charge - $title", $fee ); |
193 |
"Reserve Charge - $title", $fee ); |
195 |
} |
194 |
} |
196 |
|
195 |
|
197 |
#if ($const eq 'a'){ |
|
|
198 |
my $query = qq{ |
196 |
my $query = qq{ |
199 |
INSERT INTO reserves |
197 |
INSERT INTO reserves |
200 |
(borrowernumber,biblionumber,reservedate,branchcode,constrainttype, |
198 |
(borrowernumber,biblionumber,reservedate,branchcode, |
201 |
priority,reservenotes,itemnumber,found,waitingdate,expirationdate) |
199 |
priority,reservenotes,itemnumber,found,waitingdate,expirationdate) |
202 |
VALUES |
200 |
VALUES |
203 |
(?,?,?,?,?, |
201 |
(?,?,?,?,?, |
204 |
?,?,?,?,?,?) |
202 |
?,?,?,?,?) |
205 |
}; |
203 |
}; |
206 |
my $sth = $dbh->prepare($query); |
204 |
my $sth = $dbh->prepare($query); |
207 |
$sth->execute( |
205 |
$sth->execute( |
208 |
$borrowernumber, $biblionumber, $resdate, $branch, |
206 |
$borrowernumber, $biblionumber, $resdate, $branch, $priority, |
209 |
$const, $priority, $notes, $checkitem, |
207 |
$notes, $checkitem, $found, $waitingdate, $expdate |
210 |
$found, $waitingdate, $expdate |
|
|
211 |
); |
208 |
); |
212 |
my $reserve_id = $sth->{mysql_insertid}; |
209 |
my $reserve_id = $sth->{mysql_insertid}; |
213 |
|
210 |
|
Lines 240-248
sub AddReserve {
Link Here
|
240 |
} |
237 |
} |
241 |
} |
238 |
} |
242 |
|
239 |
|
243 |
#} |
|
|
244 |
($const eq "o" || $const eq "e") or return $reserve_id; |
245 |
|
246 |
return $reserve_id; |
240 |
return $reserve_id; |
247 |
} |
241 |
} |
248 |
|
242 |
|
Lines 302-308
sub GetReservesFromBiblionumber {
Link Here
|
302 |
biblionumber, |
296 |
biblionumber, |
303 |
borrowernumber, |
297 |
borrowernumber, |
304 |
reservedate, |
298 |
reservedate, |
305 |
constrainttype, |
|
|
306 |
found, |
299 |
found, |
307 |
itemnumber, |
300 |
itemnumber, |
308 |
reservenotes, |
301 |
reservenotes, |
Lines 659-676
sub GetOtherReserves {
Link Here
|
659 |
|
652 |
|
660 |
=head2 GetReserveFee |
653 |
=head2 GetReserveFee |
661 |
|
654 |
|
662 |
$fee = GetReserveFee($borrowernumber,$biblionumber,$constraint,$biblionumber); |
655 |
$fee = GetReserveFee($borrowernumber,$biblionumber,$biblionumber); |
663 |
|
656 |
|
664 |
Calculate the fee for a reserve |
657 |
Calculate the fee for a reserve |
665 |
|
658 |
|
666 |
=cut |
659 |
=cut |
667 |
|
660 |
|
668 |
sub GetReserveFee { |
661 |
sub GetReserveFee { |
669 |
my ($borrowernumber, $biblionumber, $constraint, $bibitems ) = @_; |
662 |
my ($borrowernumber, $biblionumber, $bibitems ) = @_; |
670 |
|
663 |
|
671 |
#check for issues; |
664 |
#check for issues; |
672 |
my $dbh = C4::Context->dbh; |
665 |
my $dbh = C4::Context->dbh; |
673 |
my $const = lc substr( $constraint, 0, 1 ); |
|
|
674 |
my $query = qq{ |
666 |
my $query = qq{ |
675 |
SELECT * FROM borrowers |
667 |
SELECT * FROM borrowers |
676 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode |
668 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode |
Lines 693-722
sub GetReserveFee {
Link Here
|
693 |
); |
685 |
); |
694 |
$sth1->execute($biblionumber); |
686 |
$sth1->execute($biblionumber); |
695 |
while ( my $data1 = $sth1->fetchrow_hashref ) { |
687 |
while ( my $data1 = $sth1->fetchrow_hashref ) { |
696 |
if ( $const eq "a" ) { |
688 |
my $found = 0; |
697 |
push @biblioitems, $data1; |
689 |
my $x = 0; |
698 |
} |
690 |
while ( $x < $cntitems ) { |
699 |
else { |
691 |
if ( @$bibitems->{'biblioitemnumber'} == |
700 |
my $found = 0; |
692 |
$data->{'biblioitemnumber'} ) |
701 |
my $x = 0; |
693 |
{ |
702 |
while ( $x < $cntitems ) { |
694 |
$found = 1; |
703 |
if ( @$bibitems->{'biblioitemnumber'} == |
|
|
704 |
$data->{'biblioitemnumber'} ) |
705 |
{ |
706 |
$found = 1; |
707 |
} |
708 |
$x++; |
709 |
} |
710 |
if ( $const eq 'o' ) { |
711 |
if ( $found == 1 ) { |
712 |
push @biblioitems, $data1; |
713 |
} |
714 |
} |
715 |
else { |
716 |
if ( $found == 0 ) { |
717 |
push @biblioitems, $data1; |
718 |
} |
719 |
} |
695 |
} |
|
|
696 |
$x++; |
697 |
} |
698 |
|
699 |
if ( $found == 0 ) { |
700 |
push @biblioitems, $data1; |
720 |
} |
701 |
} |
721 |
} |
702 |
} |
722 |
my $cntitemsfound = @biblioitems; |
703 |
my $cntitemsfound = @biblioitems; |
Lines 1795-1801
sub _FixPriority {
Link Here
|
1795 |
|
1776 |
|
1796 |
# get whats left |
1777 |
# get whats left |
1797 |
my $query = " |
1778 |
my $query = " |
1798 |
SELECT reserve_id, borrowernumber, reservedate, constrainttype |
1779 |
SELECT reserve_id, borrowernumber, reservedate |
1799 |
FROM reserves |
1780 |
FROM reserves |
1800 |
WHERE biblionumber = ? |
1781 |
WHERE biblionumber = ? |
1801 |
AND ((found <> 'W' AND found <> 'T') OR found IS NULL) |
1782 |
AND ((found <> 'W' AND found <> 'T') OR found IS NULL) |
Lines 1857-1869
sub _FixPriority {
Link Here
|
1857 |
|
1838 |
|
1858 |
@results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead, $ignore_borrowers); |
1839 |
@results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead, $ignore_borrowers); |
1859 |
|
1840 |
|
1860 |
Looks for an item-specific match first, then for a title-level match, returning the |
1841 |
Looks for a holds-queue based item-specific match first, then for a holds-queue title-level match, returning the |
1861 |
first match found. If neither, then we look for a 3rd kind of match based on |
1842 |
first match found. If neither, then we look for non-holds-queue based holds. |
1862 |
reserve constraints. |
|
|
1863 |
Lookahead is the number of days to look in advance. |
1843 |
Lookahead is the number of days to look in advance. |
1864 |
|
1844 |
|
1865 |
TODO: add more explanation about reserve constraints |
|
|
1866 |
|
1867 |
C<&_Findgroupreserve> returns : |
1845 |
C<&_Findgroupreserve> returns : |
1868 |
C<@results> is an array of references-to-hash whose keys are mostly |
1846 |
C<@results> is an array of references-to-hash whose keys are mostly |
1869 |
fields from the reserves table of the Koha database, plus |
1847 |
fields from the reserves table of the Koha database, plus |
Lines 2238-2244
sub MergeHolds {
Link Here
|
2238 |
); |
2216 |
); |
2239 |
my $upd_sth = $dbh->prepare( |
2217 |
my $upd_sth = $dbh->prepare( |
2240 |
"UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? |
2218 |
"UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? |
2241 |
AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) " |
2219 |
AND reservedate = ? AND (itemnumber = ? or itemnumber is NULL) " |
2242 |
); |
2220 |
); |
2243 |
$sth->execute( $to_biblio, 'W', 'T' ); |
2221 |
$sth->execute( $to_biblio, 'W', 'T' ); |
2244 |
my $priority = 1; |
2222 |
my $priority = 1; |
Lines 2246-2252
sub MergeHolds {
Link Here
|
2246 |
$upd_sth->execute( |
2224 |
$upd_sth->execute( |
2247 |
$priority, $to_biblio, |
2225 |
$priority, $to_biblio, |
2248 |
$reserve->{'borrowernumber'}, $reserve->{'reservedate'}, |
2226 |
$reserve->{'borrowernumber'}, $reserve->{'reservedate'}, |
2249 |
$reserve->{'constrainttype'}, $reserve->{'itemnumber'} |
2227 |
$reserve->{'itemnumber'} |
2250 |
); |
2228 |
); |
2251 |
$priority++; |
2229 |
$priority++; |
2252 |
} |
2230 |
} |