X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2Ffines2.pl;h=f6be01897b4c9518877d650e192bd84712703e6c;hb=e82eca42c934a22d172f6693c9195598f509d834;hp=00f9197943ca9afb2d849402e8a8824bbe6da4c7;hpb=5e454c418bd1aea6f52c7c00b46fc81263a88bed;p=koha.git diff --git a/misc/fines2.pl b/misc/fines2.pl index 00f9197943..f6be01897b 100755 --- a/misc/fines2.pl +++ b/misc/fines2.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl # This script loops through each overdue item, determines the fine, -# and updates the total amount of fines due by each user. It relies on +# and updates the total amount of fines due by each user. It relies on # the existence of /tmp/fines, which is created by ??? # Doesnt really rely on it, it relys on being able to write to /tmp/ # It creates the fines file @@ -80,7 +80,7 @@ my $maxFine=5; # for (my $i=0;$i<$numOverdueItems;$i++){ my @dates=split('-',$data->[$i]->{'date_due'}); - my $date2=Date_DaysSince1BC($dates[1],$dates[2],$dates[0]); + my $date2=Date_DaysSince1BC($dates[1],$dates[2],$dates[0]); my $due="$dates[2]/$dates[1]/$dates[0]"; my $borrower=BorType($data->[$i]->{'borrowernumber'}); if ($date2 <= $date){ @@ -89,7 +89,7 @@ for (my $i=0;$i<$numOverdueItems;$i++){ my ($amount,$type,$printout)= CalcFine($data->[$i]->{'itemnumber'}, $borrower->{'categorycode'}, - $difference); + $difference); if ($amount > $maxFine){ $amount=$maxFine; } @@ -109,17 +109,16 @@ for (my $i=0;$i<$numOverdueItems;$i++){ # separate function # my $dbh = C4::Context->dbh; - my $query="Select * from borrowers where borrowernumber='$borrower->{'guarantor'}'"; - my $sth=$dbh->prepare($query); - $sth->execute; + my $sth=$dbh->prepare("Select * from borrowers where borrowernumber=?"); + $sth->execute($borrower->{'guarantor'}); my $tdata=$sth->fetchrow_hashref; $sth->finish; $borrower->{'phone'}=$tdata->{'phone'}; } print "$printout\t$borrower->{'cardnumber'}\t$borrower->{'categorycode'}\t$borrower->{'firstname'}\t$borrower->{'surname'}\t$data->[$i]->{'date_due'}\t$type\t$difference\t$borrower->{'emailaddress'}\t$borrower->{'phone'}\t$borrower->{'streetaddress'}\t$borrower->{'city'}\t$amount\n"; } else { # FIXME - # if this is really useless, the whole else clause should be - # deleted. + # if this is really useless, the whole else clause should be + # deleted. # # print "$borrower->{'cardnumber'}\t$borrower->{'categorycode'}\t0 fine\n"; } @@ -128,31 +127,25 @@ for (my $i=0;$i<$numOverdueItems;$i++){ # my $borrower=BorType($data->[$i]->{'borrowernumber'}); if ($borrower->{'cardnumber'} ne ''){ - my $cost=ReplacementCost($data->[$i]->{'itemnumber'}); + my $cost=ReplacementCost($data->[$i]->{'itemnumber'}); my $dbh = C4::Context->dbh; my $env; my $accountno=C4::Circulation::Circ2::getnextacctno($env,$data->[$i]->{'borrowernumber'},$dbh); - my $item=itemnodata($env,$dbh,$data->[$i]->{'itemnumber'}); + my $item=getbibliofromitemnumber($env,$dbh,$data->[$i]->{'itemnumber'}); if ($item->{'itemlost'} ne '1' && $item->{'itemlost'} ne '2' ){ # FIXME # this should be a separate function # - $item->{'title'}=~ s/\'/\\'/g; - my $query="Insert into accountlines + my $sth=$dbh->prepare("Insert into accountlines (borrowernumber,itemnumber,accountno,date,amount, description,accounttype,amountoutstanding) values - ($data->[$i]->{'borrowernumber'},$data->[$i]->{'itemnumber'}, - '$accountno',now(),'$cost','Lost item $item->{'title'} $item->{'barcode'} $due','L','$cost')"; - my $sth=$dbh->prepare($query); - $sth->execute; + (?,?,?,now(),?,?,'L',?)"); + $sth->execute($data->[$i]->{'borrowernumber'},$data->[$i]->{'itemnumber'}, + $accountno,$cost,"Lost item $item->{'title'} $item->{'barcode'} $due",$cost); $sth->finish; - $query="update items set itemlost=2 where itemnumber='$data->[$i]->{'itemnumber'}'"; - $sth=$dbh->prepare($query); - $sth->execute; + $sth=$dbh->prepare("update items set itemlost=2 where itemnumber=?"); + $sth->execute($data->[$i]->{'itemnumber'}); $sth->finish; - } else { # FIXME - # this should be deleted - # } } }