Fixes to issues

This commit is contained in:
fisheye 1999-11-14 08:09:17 +00:00
parent 8e1dd1b578
commit 47fdc75f6c
4 changed files with 28 additions and 32 deletions

View file

@ -90,20 +90,24 @@ sub findborrower {
my $line = $borrower->{'cardnumber'}.' '.$borrower->{'surname'}.
', '.$borrower->{'othernames'};
@borrows[$cntbor] = fmtstr($env,$line,"L50");
$bornums[$cntbor]=$borrower->{'borroernumber'};
$cntbor++;
$bornums[$cntbor]=$borrower->{'borrowernumber'};
$cntbor++;
}
if ($cntbor == 1) {
$bornum = $bornums[0];
$bornum = $bornums[0];
my $query = "select * from borrowers where borrowernumber = '$bornum'";
$sth = $dbh->prepare($query);
$sth->execute;
$borrower =$sth->fetchrow_hashref;
$sth->finish;
} elsif ($cntbor > 0) {
my ($cardnum) = selborrower($env,$dbh,@borrows,@bornums);
my $query = "select * from borrowers where cardnumber = '$cardnum'";
# debug_msg("",$query);
$sth = $dbh->prepare($query);
$sth->execute;
$borrower =$sth->fetchrow_hashref;
$sth->finish;
$bornum=$borrower->{'borrowernumber'};
my $query = "select * from borrowers where cardnumber = '$cardnum'";
$sth = $dbh->prepare($query);
$sth->execute;
$borrower =$sth->fetchrow_hashref;
$sth->finish;
$bornum=$borrower->{'borrowernumber'};
}
if ($bornum eq '') {
output(1,1,"Borrower not found, please rescan or re-enter borrower code");
@ -186,7 +190,8 @@ sub Borenq {
}
# debug_msg("",$reason);
# debug_msg("",$data);
}
END { } # module clean-up code here (global destructor)

View file

@ -70,7 +70,6 @@ sub Issue {
clearscreen();
$done = "Circ";
} else {
debug_msg("","bornum = $bornum");
#deal with alternative loans
#now check items
clearscreen();
@ -104,7 +103,7 @@ sub processitems {
my $i=0;
my $amountdue = 0;
my ($itemnum,$reason) = issuewindow($env,'Issues',$items,$items2,$borrower,
fmtdec($env,$amountdue,"$32"));
fmtdec($env,$amountdue,"32"));
if ($itemnum ne ""){
my ($item,$charge) = &issueitem($env,$dbh,$itemnum,$bornum,$items);
if ($item) {
@ -112,8 +111,8 @@ sub processitems {
(fmtstr($env,$item->{'title'},"L23")." ".fmtdec($env,$charge,"22"));
$row2++;
$it2p++;
$amountdue += $charge;
}
$amountdue += $charge;
}
}
$dbh->disconnect;
#check to see if more books to process for this user
@ -156,14 +155,11 @@ sub issueitem{
#check if item is on issue already
my $currbor = &previousissue($env,$item->{'itemnumber'},$dbh,$bornum);
#check reserve
debug_msg($env,"before check reserve");
my $resbor = &checkreserve($env,$dbh,$item->{'itemnumber'});
debug_msg($env,"after check reserve");
#if charge deal with it
}
if ($canissue == 1) {
$charge = calc_charges($env,$dbh,$item->{'itemnumber'},$bornum);
debug_msg($env,"after charge");
}
if ($canissue == 1) {
#now mark as issued
@ -180,7 +176,6 @@ sub updateissues{
# issue the book
my ($env,$itemno,$bitno,$dbh,$bornum)=@_;
my $loanlength=21;
debug_msg($env,"loan length");
my $query="Select * from biblioitems,itemtypes
where (biblioitems.biblioitemnumber='$bitno')
and (biblioitems.itemtype = itemtypes.itemtype)";
@ -190,13 +185,11 @@ sub updateissues{
$loanlength = $data->{'loanlength'}
}
$sth->finish;
debug_msg($env,"issue");
my $datedue = time + $loanlength;
my @datearr = localtime($datedue);
my $dateduef = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
$query = "Insert into issues (borrowernumber,itemnumber, date_due,branchcode)
values
($bornum,$itemno,'$dateduef','$env->{'branchcode'}')";
values ($bornum,$itemno,'$dateduef','$env->{'branchcode'}')";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
@ -216,7 +209,7 @@ sub calc_charges {
if (my $data1=$sth1->fetchrow_hashref) {
$item_type = $data1->{'itemtype'};
$charge = $data1->{'rentalcharge'};
my $q2 = "select rentaldiscount from borrowers,categoryitem
my $q2 = "select rentaldiscount from borrowers,categoryitem
where (borrowers.borrowernumber = '$bornum')
and (borrowers.categorycode = categories.categorycode)
and (categoryitem.itemtype = '$item_type')";
@ -224,7 +217,7 @@ sub calc_charges {
$sth2->execute;
if (my $data2=$sth2->fetchrow_hashref) {
my $discount = $data2->{'rentaldiscount'};
$charge = ($charge * $discount) / 100;
$charge = ($charge *(100 - $discount)) / 100;
}
$sth2->{'finish'};
}

View file

@ -74,12 +74,10 @@ sub Returns {
if (($reason ne "") && ($reason ne "Circ") && ($reason ne "Quit")) {
if ($reason eq "Returned") {
my $fmtitem = fmtstr($env,$itemrec->{'title'},"L50");
debug_msg($env,$fmtitem);
unshift @items,$fmtitem;
unshift @items,$fmtitem;
} else {
debug_msg($env,$reason);
error_msg($env,$reason);
}
}
}
@ -135,16 +133,13 @@ sub returnrecord {
my $amt_owing = calc_odues($env,$dbh,$bornum,$itemno);
my @datearr = localtime(time);
my $dateret = (1900+$datearr[5])."-".$datearr[4]."-".$datearr[3];
debug_msg($env,"before return $itemno $bornum");
my $query = "update issues set returndate = '$dateret', branchcode ='$env->{'branchcode'}' where
(borrowernumber = '$bornum') and (itemnumber = '$itemno')
and (returndate is null)";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
debug_msg($env,"after return before stats");
UpdateStats($env,'branch','return','0');
debug_msg($env,"after stats");
return($amt_owing);
}

View file

@ -3,6 +3,7 @@ package C4::Format; #asummes C4/Format
use strict;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
@ -102,7 +103,9 @@ sub fmtdec {
substr($tempint,-3,3) = "";
}
$fnumb = substr($tempint,-3,3).$fnumb;
}
} else {
$fnumb = $tempint;
}
}
if ($curr eq "\$") {
$fnumb = fmtstr($env,$curr.$fnumb,"R".$left+1);