Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

  1. #!/usr/bin/perl
  2. #written 11/1/2000 by chris@katipo.co.nz
  3. #script to write off accounts
  4. use strict;
  5. use CGI;
  6. use C4::Database;
  7. my $input=new CGI;
  8. #print $input->header;
  9. #print $input->dump;
  10. my%inp;
  11. my @name=$input->param;
  12. for (my $i=0;$i<@name;$i++){
  13. my $test=$input->param($name[$i]);
  14. if ($test eq 'wo'){
  15. my $temp=$name[$i];
  16. $temp=~ s/payfine//;
  17. $inp{$name[$i]}=$temp;
  18. }
  19. }
  20. my $bornum=$input->param('bornum');
  21. while ( my ($key, $value) = each %inp){
  22. # print $key,$value;
  23. my $accounttype=$input->param("accounttype$value");
  24. my $itemno=$input->param("itemnumber$value");
  25. if ($accounttype eq 'Res'){
  26. my $accountno=$input->param("accountno$value");
  27. writeoff($bornum,$accountno,$itemno,$accounttype);
  28. } else {
  29. writeoff($bornum,'',$itemno,$accounttype);
  30. }
  31. }
  32. print $input->redirect("/cgi-bin/koha/pay.pl?bornum=$bornum");
  33. #needs to be shifted to a module when time permits
  34. sub writeoff{
  35. my ($bornum,$accountnum,$itemnum,$accounttype)=@_;
  36. my $dbh=C4Connect;
  37. my $query="Update accountlines set amountoutstanding=0 where ";
  38. if ($accounttype eq 'Res'){
  39. $query.="accounttype='Res' and accountno='$accountnum' and borrowernumber='$bornum'";
  40. } else {
  41. $query.="accounttype='$accounttype' and itemnumber='$itemnum' and borrowernumber='$bornum'";
  42. }
  43. my $sth=$dbh->prepare($query);
  44. # print $query;
  45. $sth->execute;
  46. $sth->finish;
  47. $dbh->disconnect;
  48. }