[freeside-commits] freeside/httemplate/search/elements cust_pay_or_refund.html, 1.2, 1.3

Ivan,,, ivan at wavetail.420.am
Mon Feb 16 15:54:40 PST 2009


Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv20615/httemplate/search/elements

Modified Files:
	cust_pay_or_refund.html 
Log Message:
add reporting on (and resolution of) stuck pending transactions, RT#4837 (RT#3572)

Index: cust_pay_or_refund.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_pay_or_refund.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cust_pay_or_refund.html	1 Jun 2008 22:48:15 -0000	1.2
+++ cust_pay_or_refund.html	16 Feb 2009 23:54:38 -0000	1.3
@@ -16,6 +16,18 @@
                'name_verb'     => 'refunded',
          )
 
+  include( 'elements/cust_pay_or_refund.html',
+               'thing'         => 'pay_pending',
+               'amount_field'  => 'paid',
+               'name_singular' => 'pending payment',
+               'name_verb'     => 'pending',
+               'disable_link'  => 1,
+               'disable_by'    => 1,
+               'html_init'     => '',
+               'addl_header'   => [],
+               'addl_fields'   => [],
+          )
+
 </%doc>
 <% include( 'search.html',
                 'title'         => $title,
@@ -26,27 +38,25 @@
                 'header'        => [ "\u$name_singular",
                                      'Amount',
                                      'Date',
-                                     'By',
+                                     @header,
                                      FS::UI::Web::cust_header(),
                                    ],
                 'fields'      => [
                   'payby_payinfo_pretty',
                   sub { sprintf('$%.2f', shift->$amount_field() ) },
                   sub { time2str('%b %d %Y', shift->_date ) },
-                  sub { my $o = shift->otaker;
-                        $o = 'auto billing'          if $o eq 'fs_daily';
-                        $o = 'customer self-service' if $o eq 'fs_selfservice';
-                        $o;
-                      },
+                  @fields,
                   \&FS::UI::Web::cust_fields,
                 ],
                 #'align' => 'lrrrll',
-                'align' => 'rrrc'.FS::UI::Web::cust_aligns(),
+                'align' => 'rrr'.
+                           join('', map 'c', @fields ).
+                           FS::UI::Web::cust_aligns(),
                 'links' => [
                   $link,
                   $link,
                   $link,
-                  '',
+                  ( map '', @fields ),
                   ( map { $_ ne 'Cust. Status' ? $cust_link : '' }
                         FS::UI::Web::cust_header()
                   ),
@@ -55,14 +65,14 @@
                              '',
                              '',
                              '',
-                             '',
+                             ( map '', @fields ),
                              FS::UI::Web::cust_colors(),
                            ],
                 'style' => [ 
                              '',
                              '',
                              '',
-                             '',
+                             ( map '', @fields ),
                              FS::UI::Web::cust_styles(),
                            ],
           )
@@ -71,14 +81,35 @@
 
 my %opt = @_;
 
+my $curuser = $FS::CurrentUser::CurrentUser;
+
 die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
+  unless $curuser->access_right('Financial reports');
 
 my $thing = $opt{'thing'};
 my $amount_field = $opt{'amount_field'};
 my $name_singular = $opt{'name_singular'};
 
 my $title = "\u$name_singular Search Results";
+
+my @header = ();
+my @fields = ();
+unless ( $opt{'disable_by'} ) {
+  push @header, 'By';
+  push @fields, sub {
+                  sub { my $o = shift->otaker;
+                        $o = 'auto billing'          if $o eq 'fs_daily';
+                        $o = 'customer self-service' if $o eq 'fs_selfservice';
+                        $o;
+                      },
+  };
+}
+
+push @header, @{ $opt{'addl_header'} }
+  if $opt{'addl_header'};
+push @fields, @{ $opt{'addl_fields'} }
+  if $opt{'addl_fields'};
+
 my( $count_query, $sql_query );
 if ( $cgi->param('magic') ) {
 
@@ -93,7 +124,11 @@
       die "unknown agentnum $1" unless $agent;
       $title = $agent->agent. " $title";
     }
-  
+
+    if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+      push @search, "custnum = $1";
+    }
+
     if ( $cgi->param('payby') ) {
       $cgi->param('payby') =~
         /^(CARD|CHEK|BILL|PREP|CASH|WEST|MCRD)(-(VisaMC|Amex|Discover|Maestro))?$/
@@ -175,6 +210,11 @@
       push @search, "cust_$thing.payinfo = '$1'";
     }
 
+    #for cust_pay_pending...  statusNOT=done
+    if ( $cgi->param('statusNOT') =~ /^(\w+)$/ ) {
+      push @search, "status != '$1'";
+    }
+
     my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
     push @search, "_date >= $beginning ",
                   "_date <= $ending";
@@ -197,7 +237,7 @@
   }
 
   #here is the agent virtualization
-  push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
+  push @search, $curuser->agentnums_sql;
 
   my $search = ' WHERE '. join(' AND ', @search);
 
@@ -229,21 +269,25 @@
 
   $count_query = "SELECT COUNT(*), SUM($amount_field) FROM cust_$thing".
                  "  WHERE payinfo = '$payinfo' AND payby = '$payby'".
-                 "  AND ". $FS::CurrentUser::CurrentUser->agentnums_sql;
+                 "  AND ". $curuser->agentnums_sql;
 
   $sql_query = {
     'table'     => "cust_$thing",
     'hashref'   => { 'payinfo' => $payinfo,
                      'payby'   => $payby    },
-    'extra_sql' => $FS::CurrentUser::CurrentUser->agentnums_sql.
+    'extra_sql' => $curuser->agentnums_sql.
                    " ORDER BY _date",
   };
 
 }
 
 my $link = '';
-if ( $FS::CurrentUser::CurrentUser->access_right('View invoices') #XXX for now
-     || $FS::CurrentUser::CurrentUser->access_right('View customer payments') ){
+if (    ( $curuser->access_right('View invoices') #XXX for now
+          || $curuser->access_right('View customer payments')
+        )
+     && ! $opt{'disable_link'}
+   )
+{
   $link = [ "${p}view/cust_$thing.html?${thing}num=", $thing.'num' ]
 }
 



More information about the freeside-commits mailing list