ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[ljcom] r8324: LJSUP-5563: paidsummary needs to separat...

Committer: ssafronova
LJSUP-5563: paidsummary needs to separate SUP and non-SUP payments
U   trunk/htdocs/admin/accounts/paidsummary.bml
Modified: trunk/htdocs/admin/accounts/paidsummary.bml
===================================================================
--- trunk/htdocs/admin/accounts/paidsummary.bml	2010-03-22 10:47:26 UTC (rev 8323)
+++ trunk/htdocs/admin/accounts/paidsummary.bml	2010-03-22 11:10:35 UTC (rev 8324)
@@ -30,11 +30,14 @@
         }
     }
 
+    my $users = LJ::ehtml($GET{users});
+    $users = 'all' unless $users eq 'cyr' or $users eq 'non-cyr'; # correcting bad input to 'all'
+
     # Get all the relevant dates: current date and date range for reporting
     my ($year, $month, $day, $date_low, $date_high) = get_dates();
 
     # Get the Payments
-    my $payments_ref = get_payments($date_low, $date_high, $pay_method);
+    my $payments_ref = get_payments($date_low, $date_high, $pay_method, $users);
 
     # Get the Items for these Payments
     my ($payitems_ref, $payid_piids_ref, $piid_dates_ref) = get_payitems($payments_ref);
@@ -62,13 +65,13 @@
 
     # Generate the HTML
     my $ret;
-    $ret .= gen_search_form($year, $month, $day, $pay_method);
+    $ret .= gen_search_form($year, $month, $day, $pay_method, $users);
     $ret .= gen_table_header();
     $ret .= gen_payments_table(\%row_ctl, \@row_html);
 
     return $ret unless $row_ctl{count};                  # Bail if there are no payments
 
-    $ret .= gen_csv_link($pay_method);
+    $ret .= gen_csv_link($pay_method, $users);
     $ret .= gen_totals(\%stats);
     $ret .= gen_breakdown_tables(\%stats);
 
@@ -76,6 +79,7 @@
 
     sub gen_csv_link {
         my $method = shift;
+        my $users = shift;
         my $html;
 
         $html .= "<p><b>Statistics:</b>";
@@ -84,6 +88,7 @@
         my $getargs = join('&', "view=csv",
                            map { "$_=$GET{$_}" } grep { $GET{$_} } qw(year month day skip));
         $getargs .= "&pay_method=$method" if $method;
+        $getargs .= "&users=$users";
         $html .= " [<a href='?$getargs'>Generate CSV (Excludes Refunds)</a>]";
 
         return $html;
@@ -133,7 +138,7 @@
     }
 
     sub gen_search_form {
-        my ($year, $month, $day, $method) = @_;
+        my ($year, $month, $day, $method, $users) = @_;
 
         my $html;
         $html .= "<form method='GET'>";
@@ -143,6 +148,8 @@
         $html .= "Method: "   . LJ::html_select({ 'name' => 'pay_method',
                                                   'selected' => $method || ''},
                                                   "", "", map { $_ => $_ } @pay_list) . " ";
+        $html .= "Users: " . LJ::html_select({ 'name' => 'users', 'selected' => $users }, 
+                                               'all' => 'All users', 'cyr' => 'Cyrillic only', 'non-cyr' => 'Non-cyrillic only' ) . " ";
         $html .= LJ::html_submit('View') . "</form> (enter * for day to get month report)";
 
         return $html;
@@ -320,8 +327,10 @@
     }
 
     sub get_payments {
-        my ($date_low, $date_high, $method) = @_;
+        my ($date_low, $date_high, $method, $users) = @_;
 
+        $users = 'all' unless $users;
+
         my $method_sql;
         if ($method && $method ne '') {
             $method_sql = "AND method='$method' ";
@@ -336,10 +345,24 @@
         $sth->execute;
         $sth->{mysql_use_result} = 1;
         my %payids;
+        my @users;
         while (my $row = $sth->fetchrow_hashref) {
             $payids{$row->{payid}} = $row;
+            push @users, $row->{userid} if $users ne 'all';
         }
 
+        return \%payids if $users eq 'all';
+
+        my $us = LJ::load_userids(@users);
+
+        foreach my $payid (keys %payids) {
+            my $userid = $payids{$payid}->{userid};
+            delete $payids{$payid}
+                if not $us->{$userid} 
+                   or $users eq 'cyr' and not LJ::SUP->is_sup_enabled($us->{$userid})
+                   or $users eq 'non-cyr' and LJ::SUP->is_sup_enabled($us->{$userid});
+        }
+
         return \%payids;
     }
 

Tags: bml, ljcom, ssafronova
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments