log in."; } } my $from = $GET{'from'}; unless (defined $from) { $ret .= "
after (yyyy-mm-dd[ hh:mm[:ss]]): Opt. end:
"; return $ret; } my $to = $GET{'to'} || $dbh->selectrow_array("SELECT NOW()"); $sth = $dbh->prepare("SELECT p.payid, u.user, p.daterecv, p.amount, p.months, p.forwhat, p.used, p.mailed, p.method FROM payments p LEFT JOIN useridmap u ON u.userid=p.userid WHERE p.mailed<>'C' AND method IN ('cash', 'check', 'moneyorder') AND p.daterecv > ? AND p.daterecv <= ? ORDER BY p.daterecv"); $sth->execute($from, $to); my @pays; push @pays, $_ while $_ = $sth->fetchrow_hashref; return "(none)" unless @pays; my $in = join(',', map { $_->{'payid'} } @pays); $sth = $dbh->prepare("SELECT payid, pval FROM payvars WHERE payid IN ($in) AND pkey='notes'"); $sth->execute; my %notes; while (my ($id, $v) = $sth->fetchrow_array) { $notes{$id} .= ", " if $notes{$id}; $notes{$id} = $v; } $ret .= "

Received Payments

" . $pays[0]->{'daterecv'} . " to " . $pays[-1]->{'daterecv'} . ""; $ret .= "

\n"; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "\n"; my $tot = 0; foreach my $p (@pays) { my $amount = sprintf("\$%.02f", $p->{'amount'}); $tot += $p->{'amount'}; my $date = substr($p->{'daterecv'}, 0, 10); $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= "\n"; } $ret .= "\n"; $ret .= "
Order#DateTypeUserNotesAmount
$p->{'payid'}$date$p->{'method'}$p->{'user'}$notes{$p->{'payid'}}$amount
\$" . sprintf("%.02f", $tot) . "
"; return $ret; } _code?>