From b2c9dabcf1179fcbc46cd29f681016601bfecd5f Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 3 Apr 2001 21:32:37 +0000 Subject: [PATCH] Making a change to the way charges are handled, the system originally worked such that if a borrower owed more than $5 issues werent allowed. This worked fine except that often borrowers wish to borrows say 3 pay videos at $2 each, then 2 books say. The three pay videos rack up charges of $6 and then they cant issue the books until that is paid. Reworked so that it cares about previous charges, not the ones accrued during current issue process. --- C4/Circulation/Circ2.pm | 16 +++++++++++----- circ/circulation.pl | 42 +++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/C4/Circulation/Circ2.pm b/C4/Circulation/Circ2.pm index 45aad816f4..027cfcfb42 100755 --- a/C4/Circulation/Circ2.pm +++ b/C4/Circulation/Circ2.pm @@ -186,7 +186,7 @@ sub findborrower { sub issuebook { - my ($env, $patroninformation, $barcode, $responses) = @_; + my ($env, $patroninformation, $barcode, $responses, $date) = @_; my $dbh=&C4Connect; my $iteminformation=getiteminformation($env, 0, $barcode); my ($datedue); @@ -204,7 +204,7 @@ sub issuebook { $rejected="Patron is Debarred"; last SWITCH; } - my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh); + my $amount = checkaccount($env,$patroninformation->{'borrowernumber'}, $dbh,$date); if ($amount>5) { $rejected=sprintf "Patron owes \$%.02f.", $amount; last SWITCH; @@ -317,6 +317,7 @@ sub issuebook { if ($env->{'datedue'}) { $dateduef=$env->{'datedue'}; } + $dateduef=~ s/2001\-4\-25/2001\-4\-26/; my $sth=$dbh->prepare("insert into issues (borrowernumber, itemnumber, date_due, branchcode) values ($patroninformation->{'borrowernumber'}, $iteminformation->{'itemnumber'}, '$dateduef', '$env->{'branchcode'}')"); $sth->execute; $sth->finish; @@ -642,9 +643,14 @@ sub checkaccount { # Stolen from Accounts.pm #take borrower number #check accounts and list amounts owing - my ($env,$bornumber,$dbh)=@_; - my $sth=$dbh->prepare("Select sum(amountoutstanding) from accountlines where - borrowernumber=$bornumber and amountoutstanding<>0"); + my ($env,$bornumber,$dbh,$date)=@_; + my $select="Select sum(amountoutstanding) from accountlines where + borrowernumber=$bornumber and amountoutstanding<>0"; + if ($date ne ''){ + $select.=" and date < '$date'"; + } +# print $select; + my $sth=$dbh->prepare($select); $sth->execute; my $total=0; while (my $data=$sth->fetchrow_hashref){ diff --git a/circ/circulation.pl b/circ/circulation.pl index 2913e31bf3..bf54fda73a 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -72,8 +72,16 @@ my $printercookie=$query->cookie(-name=>'printer', -value=>"$printer", -expires= print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]); #print $query->dump; print startpage(); -print startmenu('circulation'); - +#print startmenu('circulation'); +my @inp=startmenu('circulation'); +if ($query->param('module') eq 'issues' && $query->param('barcode') eq '' && $query->param('charges') eq 'yes'){ + my $count=@inp; + for (my $i=0;$i<$count;$i++){ + my $bornum=$query->param('borrnumber'); + $inp[$i]=~ s/onLoad=focusinput\(\)/onLoad=focusinput\(\)\;messenger\(\"\/cgi-bin\/koha\/pay.pl?bornum=$bornum\"\)\;window1.focus\(\)/; + } +} +print @inp; print < @@ -84,7 +92,7 @@ function messenger(url){ //--> EOF - +; if ($printer && $branch) { SWITCH: { @@ -225,7 +233,7 @@ EOF } my $barcodeentrytext= << "EOF"; -
+ @@ -487,7 +495,9 @@ EOF $responses{$qnumber}=$query->param('answer'); } unless ($invalidduedate) { - my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borrower, $barcode, \%responses); + my @time=localtime(time); + my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3]; + my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) = issuebook(\%env, $borrower, $barcode, \%responses,$date); unless ($iteminformation) { print << "EOF";
Enter Book Barcode
Item Barcode:
@@ -505,8 +515,8 @@ EOF } else { print << "EOF"
- - + +
Error Issuing Book
$rejected
Error Issuing Book
$rejected

EOF @@ -697,7 +707,18 @@ EOF -
+ +EOF +; + my $amountold=$flags->{'CHARGES'}->{'message'}; + my @temp=split(/\$/,$amountold); + $amountold=$temp[1]; + print ""; + if ($flags->{'CHARGES'}){ + print ""; + } +print < @@ -805,7 +826,7 @@ sub patrontable { } } else { if ($flag eq 'CHARGES') { - $flaginfotext.="$flag{$flag}->{'message'} {'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment\n"; + $flaginfotext.="$flag $flags->{$flag}->{'message'} {'borrowernumber'} onClick=\"openWindow(this, 'Payment', 480,640)\">Payment\n"; } elsif ($flag eq 'WAITING') { my $itemswaiting=''; my $items=$flags->{$flag}->{'itemlist'}; @@ -837,7 +858,8 @@ sub patrontable { } } } - ($flaginfotext) && ($flaginfotext="Flags$flaginfotext\n"); + ($flaginfotext) && ($flaginfotext="Flags$flaginfotext\n"); + $flaginfotext.=""; my $patrontable= << "EOF"; -- 2.39.5