Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[ljcom] r8414: Adding support for consolidated month re...

Committer: gariev
Adding support for consolidated month reporsts
U   trunk/htdocs/admin/accounts/paidsummary.bml
Modified: trunk/htdocs/admin/accounts/paidsummary.bml
===================================================================
--- trunk/htdocs/admin/accounts/paidsummary.bml	2010-04-01 08:29:45 UTC (rev 8413)
+++ trunk/htdocs/admin/accounts/paidsummary.bml	2010-04-01 08:50:10 UTC (rev 8414)
@@ -57,26 +57,49 @@
                            $piid_dates_ref, $payments_ref)
                                                             if $payments_ref;
 
-    # Handle CSV output (which outputs different content than HTMl output)
     if ($view_mode eq 'csv') {
+        # Handle CSV output (which outputs different content than HTML output)
         handle_csv(\%stats, $year, $month, $day);
         return;
+    } else {
+        # Generate the HTML
+        my $ret;
+    
+        $ret .= gen_search_form($year, $month, $day, $pay_method, $users);
+        if ($GET{consolidated_report}) {
+            $ret .= gen_consolidated_report(\%stats);
+        } else {
+            $ret .= gen_table_header();
+            $ret .= gen_payments_table(\%row_ctl, \@row_html);
+
+            if ($row_ctl{count}) {            
+                # Show this part only if there are payments
+                $ret .= gen_csv_link($pay_method, $users);
+                $ret .= gen_totals(\%stats);
+                $ret .= gen_breakdown_tables(\%stats);
+            }
+        }
+        return $ret;
     }
-
-    # Generate the HTML
-    my $ret;
-    $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, $users);
-    $ret .= gen_totals(\%stats);
-    $ret .= gen_breakdown_tables(\%stats);
-
-    return $ret;
-
+    
+    sub gen_consolidated_report {
+        my $stats_ref = shift;
+    
+        my $ret;
+        $ret .= "<table cellpadding=4 cellspacing=1 border=1>";
+        $ret .= "<tr><th>Day</th><th>Item</th><th colspan=2>Gross</th><th colspan=2>Coupons</th><th>Refunds</th><th>Net</th></tr>\n";
+        $ret .= "<tr><th>&nbsp</th><th>&nbsp</th><th>Count</th><th>Amount</th><th>Count</th><th>Amount</th><th>Amount</th><th>Amount</th></tr>\n";
+        foreach my $day (sort keys %{$stats_ref->{daily}}) {
+            my $dayref = $stats_ref->{daily}->{$day};
+            foreach my $itemname (sort item_sort keys %{ $dayref->{item} }) {
+                my $r = $dayref->{item}->{$itemname};
+                $ret .= display_item_rows('html', $itemname, $r, '', 0, $day);
+            }
+        }
+        $ret .= "</table>";
+        return $ret;
+    }
+    
     sub gen_csv_link {
         my $method = shift;
         my $users = shift;
@@ -151,7 +174,9 @@
         $html .= "Users: " . LJ::html_select({ 'name' => 'users', 'selected' => $users }, 
                                                'all' => 'All users', 'cyr' => 'Cyrillic only', 'non-cyr' => 'Non-cyrillic only',
                                                'anon' => 'Anonymous' ) . " ";
-        $html .= LJ::html_submit('View') . "</form> (enter * for day to get month report)";
+        $html .= LJ::html_submit('View');
+        $html .= LJ::html_submit('consolidated_report', "Consolidated report");
+        $html .= "</form> (enter * for day to get month report)";
 
         return $html;
     }
@@ -694,24 +719,26 @@
 
     # Display an item row and subordinate rows if it has any
     sub display_item_rows {
-        my ($html_view, $itemname, $ref, $recur, $is_subkey) = @_;
+        my ($html_view, $itemname, $ref, $recur, $is_subkey, $day) = @_;
         return '' unless $ref;
 
+        my $r = ($recur) ? $ref->{$recur} : $ref;
         my $ret = display_item_row(
                                     $html_view,
                                     $itemname,
-                                    $ref->{$recur}->{amount},
-                                    $ref->{$recur}->{cnt_pos},
-                                    $ref->{$recur}->{amt_pos},
-                                    $ref->{$recur}->{cnt_neg},
-                                    $ref->{$recur}->{amt_neg},
-                                    $ref->{$recur}->{refund},
-                                    $is_subkey
+                                    $r->{amount},
+                                    $r->{cnt_pos},
+                                    $r->{amt_pos},
+                                    $r->{cnt_neg},
+                                    $r->{amt_neg},
+                                    $r->{refund},
+                                    $is_subkey,
+                                    $day,
                                   );
 
-        if (%{$ref->{sub}||{}}) {
-            foreach my $key (sort item_sort keys %{$ref->{sub}||{}}) {
-                $ret .= display_item_rows($html_view, $key, $ref->{sub}->{$key}, $recur, 1);
+        if ($ref->{sub}) {
+            foreach my $key (sort item_sort keys %{$ref->{sub}}) {
+                $ret .= display_item_rows($html_view, $key, $ref->{sub}->{$key}, $recur, 1, $day);
             }
         }
 
@@ -719,7 +746,7 @@
     }
 
     sub display_item_row {
-        my ($html_view, $item_name, $gross, $cnt_pos, $amt_pos, $cnt_neg, $amt_neg, $refund, $is_subkey) = @_;
+        my ($html_view, $item_name, $gross, $cnt_pos, $amt_pos, $cnt_neg, $amt_neg, $refund, $is_subkey, $day) = @_;
 
         my $net = $gross + $refund;
 
@@ -728,6 +755,7 @@
             my $align = $is_subkey ? 'center' : 'left';
             $ret .= "<tr>";
             $item_name = '<b>Total</b>' if $item_name eq 'Total';
+            $ret .= "<td>$day</td>" if $day;
             $ret .= "<td align=$align>$item_name</td>";
             $ret .= "<td align=right>" . ($cnt_pos ? $cnt_pos : '&nbsp') . "</td>";
             $ret .= money_cell($amt_pos, 1);

Tags: bml, gariev, ljcom
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