|
Lines 156-164
sub AddReserve {
Link Here
|
| 156 |
$bibitems, $priority, $resdate, $expdate, $notes, |
156 |
$bibitems, $priority, $resdate, $expdate, $notes, |
| 157 |
$title, $checkitem, $found |
157 |
$title, $checkitem, $found |
| 158 |
) = @_; |
158 |
) = @_; |
| 159 |
my $fee = |
|
|
| 160 |
GetReserveFee($borrowernumber, $biblionumber, |
| 161 |
$bibitems ); |
| 162 |
my $dbh = C4::Context->dbh; |
159 |
my $dbh = C4::Context->dbh; |
| 163 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
160 |
$resdate = format_date_in_iso( $resdate ) if ( $resdate ); |
| 164 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
161 |
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); |
|
Lines 178-186
sub AddReserve {
Link Here
|
| 178 |
$waitingdate = $resdate; |
175 |
$waitingdate = $resdate; |
| 179 |
} |
176 |
} |
| 180 |
|
177 |
|
| 181 |
#eval { |
|
|
| 182 |
# updates take place here |
178 |
# updates take place here |
| 183 |
if ( $fee > 0 ) { |
179 |
my $fee = GetReserveFee( $borrowernumber ); |
|
|
180 |
if ( $fee ) { |
| 184 |
my $nextacctno = &getnextacctno( $borrowernumber ); |
181 |
my $nextacctno = &getnextacctno( $borrowernumber ); |
| 185 |
my $query = qq{ |
182 |
my $query = qq{ |
| 186 |
INSERT INTO accountlines |
183 |
INSERT INTO accountlines |
|
Lines 652-742
sub GetOtherReserves {
Link Here
|
| 652 |
|
649 |
|
| 653 |
=head2 GetReserveFee |
650 |
=head2 GetReserveFee |
| 654 |
|
651 |
|
| 655 |
$fee = GetReserveFee($borrowernumber,$biblionumber,$biblionumber); |
652 |
$fee = GetReserveFee( $borrowernumber ); |
| 656 |
|
653 |
|
| 657 |
Calculate the fee for a reserve |
654 |
Calculate the fee for a reserve. Returns undef if no fee is found. |
|
|
655 |
|
| 656 |
NOTE: This code is simplified on bug 14702. The old checks were unneeded |
| 657 |
and erroneous. This routine is called at the moment of adding a reserve, |
| 658 |
we just need to pass the hold fee. |
| 658 |
|
659 |
|
| 659 |
=cut |
660 |
=cut |
| 660 |
|
661 |
|
| 661 |
sub GetReserveFee { |
662 |
sub GetReserveFee { |
| 662 |
my ($borrowernumber, $biblionumber, $bibitems ) = @_; |
663 |
my ( $borrowernumber ) = @_; |
| 663 |
|
664 |
my $dbh = C4::Context->dbh; |
| 664 |
#check for issues; |
|
|
| 665 |
my $dbh = C4::Context->dbh; |
| 666 |
my $query = qq{ |
665 |
my $query = qq{ |
| 667 |
SELECT * FROM borrowers |
666 |
SELECT reservefee |
| 668 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode |
667 |
FROM borrowers |
| 669 |
WHERE borrowernumber = ? |
668 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode |
|
|
669 |
WHERE borrowernumber = ? |
| 670 |
}; |
670 |
}; |
| 671 |
my $sth = $dbh->prepare($query); |
671 |
my $sth = $dbh->prepare( $query ); |
| 672 |
$sth->execute($borrowernumber); |
672 |
$sth->execute( $borrowernumber ); |
| 673 |
my $data = $sth->fetchrow_hashref; |
673 |
my $data = $sth->fetchrow_hashref; |
| 674 |
my $fee = $data->{'reservefee'}; |
674 |
if( $data && $data->{'reservefee'} > 0 ) { |
| 675 |
my $cntitems = @- > $bibitems; |
675 |
return $data->{'reservefee'}; |
| 676 |
|
|
|
| 677 |
if ( $fee > 0 ) { |
| 678 |
|
| 679 |
# check for items on issue |
| 680 |
# first find biblioitem records |
| 681 |
my @biblioitems; |
| 682 |
my $sth1 = $dbh->prepare( |
| 683 |
"SELECT * FROM biblio LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber |
| 684 |
WHERE (biblio.biblionumber = ?)" |
| 685 |
); |
| 686 |
$sth1->execute($biblionumber); |
| 687 |
while ( my $data1 = $sth1->fetchrow_hashref ) { |
| 688 |
my $found = 0; |
| 689 |
my $x = 0; |
| 690 |
while ( $x < $cntitems ) { |
| 691 |
if ( @$bibitems->{'biblioitemnumber'} == |
| 692 |
$data->{'biblioitemnumber'} ) |
| 693 |
{ |
| 694 |
$found = 1; |
| 695 |
} |
| 696 |
$x++; |
| 697 |
} |
| 698 |
|
| 699 |
if ( $found == 0 ) { |
| 700 |
push @biblioitems, $data1; |
| 701 |
} |
| 702 |
} |
| 703 |
my $cntitemsfound = @biblioitems; |
| 704 |
my $issues = 0; |
| 705 |
my $x = 0; |
| 706 |
my $allissued = 1; |
| 707 |
while ( $x < $cntitemsfound ) { |
| 708 |
my $bitdata = $biblioitems[$x]; |
| 709 |
my $sth2 = $dbh->prepare( |
| 710 |
"SELECT * FROM items |
| 711 |
WHERE biblioitemnumber = ?" |
| 712 |
); |
| 713 |
$sth2->execute( $bitdata->{'biblioitemnumber'} ); |
| 714 |
while ( my $itdata = $sth2->fetchrow_hashref ) { |
| 715 |
my $sth3 = $dbh->prepare( |
| 716 |
"SELECT * FROM issues |
| 717 |
WHERE itemnumber = ?" |
| 718 |
); |
| 719 |
$sth3->execute( $itdata->{'itemnumber'} ); |
| 720 |
if ( my $isdata = $sth3->fetchrow_hashref ) { |
| 721 |
} |
| 722 |
else { |
| 723 |
$allissued = 0; |
| 724 |
} |
| 725 |
} |
| 726 |
$x++; |
| 727 |
} |
| 728 |
if ( $allissued == 0 ) { |
| 729 |
my $rsth = |
| 730 |
$dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ?"); |
| 731 |
$rsth->execute($biblionumber); |
| 732 |
if ( my $rdata = $rsth->fetchrow_hashref ) { |
| 733 |
} |
| 734 |
else { |
| 735 |
$fee = 0; |
| 736 |
} |
| 737 |
} |
| 738 |
} |
676 |
} |
| 739 |
return $fee; |
677 |
return; |
| 740 |
} |
678 |
} |
| 741 |
|
679 |
|
| 742 |
=head2 GetReservesToBranch |
680 |
=head2 GetReservesToBranch |
| 743 |
- |
|
|