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.

80 lines
1.6 KiB

  1. #!/usr/bin/perl
  2. #written 14/1/2000
  3. #script to display reports
  4. use C4::Stats;
  5. use strict;
  6. use Date::Manip;
  7. use CGI;
  8. use C4::Output;
  9. use DBI;
  10. use C4::Database;
  11. my $input=new CGI;
  12. my $time=$input->param('time');
  13. print $input->header;
  14. print startpage;
  15. print startmenu('report');
  16. print center;
  17. my $date;
  18. my $date2;
  19. if ($time eq 'yesterday'){
  20. $date=ParseDate('yesterday');
  21. $date2=ParseDate('today');
  22. }
  23. if ($time eq 'today'){
  24. $date=ParseDate('today');
  25. $date2=ParseDate('tomorrow');
  26. }
  27. if ($time eq 'daybefore'){
  28. $date=ParseDate('2 days ago');
  29. $date2=ParseDate('yesterday');
  30. }
  31. if ($time=~ /\//){
  32. $date=ParseDate($time);
  33. $date2=ParseDateDelta('+ 1 day');
  34. $date2=DateCalc($date,$date2);
  35. }
  36. $date=UnixDate($date,'%Y-%m-%d');
  37. $date2=UnixDate($date2,'%Y-%m-%d');
  38. my $dbh=C4Connect;
  39. my $query="select *
  40. from accountlines,accountoffsets,borrowers where
  41. accountlines.borrowernumber=accountoffsets.borrowernumber and
  42. (accountlines.accountno=accountoffsets.accountno or accountlines.accountno
  43. =accountoffsets.offsetaccount) and accountlines.timestamp >=20000621000000
  44. and borrowers.borrowernumber=accountlines.borrowernumber
  45. group by accountlines.borrowernumber,accountlines.accountno";
  46. my $sth=$dbh->prepare($query);
  47. $sth->execute;
  48. print mktablehdr;
  49. while (my $data=$sth->fetchrow_hashref){
  50. print "<TR><Td>$data->{'surname'}</td><td>$data->{'description'}</td><td>$data->{'amount'}
  51. </td>";
  52. if ($data->{'accountype'}='Pay'){
  53. my $branch=Getpaidbranch($data->{'timestamp'});
  54. print "<td>$branch</td>";
  55. }
  56. print "</tr>";
  57. }
  58. print mktableft;
  59. print endcenter;
  60. #print "<p><b>$total</b>";
  61. print endmenu('report');
  62. print endpage;
  63. $sth->finish;
  64. $dbh->disconnect;