X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fgraph%2Fmoney_time-graph.cgi;h=76f1bd7bda0dd58e97bd60ec1237c5b7c2474d95;hp=93a80d16504b51075e29c0886bfa0a22a6a8afd1;hb=8d581f6199c27147f417f73cc9f58260efabf327;hpb=dfaabf0c82291f2839922065aa80b2590bab25b0 diff --git a/httemplate/graph/money_time-graph.cgi b/httemplate/graph/money_time-graph.cgi index 93a80d165..76f1bd7bd 100755 --- a/httemplate/graph/money_time-graph.cgi +++ b/httemplate/graph/money_time-graph.cgi @@ -1,12 +1,16 @@ <% +#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +my ($curmon,$curyear) = (localtime(time))[4,5]; + #find first month -my $syear = 2001; -my $smonth = 8; +my $syear = $cgi->param('syear') || 1899+$curyear; +my $smonth = $cgi->param('smonth') || $curmon+1; #find last month -my $eyear = 2002; -my $emonth = 11; +my $eyear = $cgi->param('eyear') || 1900+$curyear; +my $emonth = $cgi->param('emonth') || $curmon+1; +if ( $emonth++>12 ) { $emonth-=12; $eyear++; } my @labels; my %data; @@ -57,7 +61,15 @@ while ( $syear < $eyear || ( $syear == $eyear && $smonth < $emonth ) ) { $refunded_sth->execute or die $refunded_sth->errstr; my $refunded = $refunded_sth->fetchrow_arrayref->[0] || 0; - push @{$data{cash}}, $paid-$refunded; + #horrible local kludge that doesn't even really work right + my $expenses_sql2 = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND 0 < ( select count(*) from cust_bill_pkg, cust_pkg, part_pkg WHERE cust_bill.invnum = cust_bill_pkg.invnum AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%' )"; + +# my $expenses_sql2 = "SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay, cust_bill_pkg, cust_bill, cust_pkg, part_pkg WHERE cust_bill_pay.invnum = cust_bill.invnum AND cust_bill.invnum = cust_bill_pkg.invnum AND cust_bill_pay._date >= $speriod AND cust_bill_pay._date < $eperiod AND cust_pkg.pkgnum = cust_bill_pkg.pkgnum AND cust_pkg.pkgpart = part_pkg.pkgpart AND LOWER(part_pkg.pkg) LIKE 'expense _%'"; + my $expenses_sth2 = dbh->prepare($expenses_sql2) or die dbh->errstr; + $expenses_sth2->execute or die $expenses_sth2->errstr; + my $expenses2 = $expenses_sth2->fetchrow_arrayref->[0] || 0; + + push @{$data{cash}}, $paid-$refunded-$expenses2; } @@ -89,7 +101,7 @@ my @data = ( \@labels, #$chart->cgi_png(\@data); http_header('Content-Type' => 'image/png' ); -$Response->{ContentType} = 'image/png'; +#$Response->{ContentType} = 'image/png'; $chart->_set_colors();