log in." unless $remote; return "You don't have access to see this." unless LJ::remote_has_priv($remote, "moneyview"); my $dbh = LJ::get_dbh("slow", "slave", "master") or return "database unavailable"; my ($ret, $sth); my $wholemonth = 0; if ($GET{'day'} eq "*") { $wholemonth = 1; } my $year = $GET{'year'}+0; my $month = $GET{'month'}+0; my $day = $GET{'day'}+0; unless ($year && $month) { my @time = localtime(); $year = $time[5]+1900; $month = $time[4]+1; $day = $time[3]; } if ($wholemonth) { $day = "*"; } $ret .= "
"; $ret .= "Year: " . LJ::html_text({ 'name' => 'year', 'size' => 4, 'value' => $year }) . " "; $ret .= "Month: " . LJ::html_text({ 'name' => 'month', 'size' => 2, 'value' => $month }) . " "; $ret .= "Day: " . LJ::html_text({ 'name' => 'day', 'size' => 2, 'value' => $day }) . " "; $ret .= LJ::html_submit('View') . "
(enter * for day to get month report)"; my ($date_low, $date_high); # whole month my $fmt = sub { $dbh->quote(sprintf("%02d-%02d-%02d 00:00:00", @_)) }; if ($day eq '*') { $date_low = $fmt->($year, $month, '01'); if ($month+1 > 12) { $date_high = $fmt->($year+1, 1, '01'); } else { $date_high = $fmt->($year, $month+1, '01'); } } else { $date_low = $fmt->($year, $month, $day); if ($day+1 > LJ::days_in_month($month, $year)) { if ($month+1 > 12) { $date_high = $fmt->($year+1, 1, '01'); } else { $date_high = $fmt->($year, $month+1, '01'); } } else { $date_high = $fmt->($year, $month, $day+1); } } $sth = $dbh->prepare("SELECT * FROM payments WHERE mailed<>'C' AND daterecv>$date_low AND daterecv<$date_high"); $sth->execute; my @rows = (); push @rows, $_ while $_ = $sth->fetchrow_hashref; my $u = LJ::load_userids( map { $_->{userid} } @rows ); $ret .= "\n"; my $totalmoney = 0; my %methodcount = (); my %methodtotal = (); my %daycount = (); my %daytotal = (); my $row_ct = 0; my $row_show = 0; my $row_skip = 0; my $row_html; foreach my $row (@rows) { my $amount = sprintf("\$%.02f", $row->{'amount'}); $totalmoney += $row->{'amount'}; $methodcount{$row->{'method'}}++; $methodtotal{$row->{'method'}} += $row->{'amount'}; if ($row->{'daterecv'} =~ /^(\d\d\d\d-\d\d-\d\d)/) { my $day = $1; $daycount{$day}++; $daytotal{$day} += $row->{'amount'}; } $row_ct++; next if $GET{'skip'} && ++$row_skip <= $GET{'skip'}; if ($row_show < 500) { my $user = $u->{$row->{userid}}->{user}; $row_show++; $row_html .= ""; } } my $slinks; if ($GET{'skip'}) { $slinks .= " $GET{'skip'} - 500}) . "\"><< Back "; } if ($row_show != $row_ct) { my $from = $GET{'skip'}+1; my $to = $row_show+$GET{'skip'}; $slinks .= "(Records $from-$to of $row_ct) "; } if ($GET{'skip'} + $row_show < $row_ct) { $slinks .= " $GET{'skip'} + 500}) . "\">Forward >> "; } my $bar_html; $bar_html .= "\n" if $slinks; $ret .= $bar_html; $ret .= $row_html; $ret .= $bar_html; $ret .= "
Pay ID#UserDate Sent/RecvAmountUsed/MailedMethod
{'payid'}\">#$row->{'payid'}$user$row->{'datesent'}
$row->{'daterecv'}
$amount$row->{'used'}/$row->{'mailed'}$row->{'method'}
$slinks
\n"; return $ret unless @rows; $ret .= "

Statistics:

"; return $ret; } _code?>