don't show invoice resend and payment posting links if you can't do that anyway
[freeside.git] / httemplate / search / cust_pay.cgi
index 6215b4b..80a611d 100755 (executable)
@@ -7,6 +7,7 @@
                  'header'      => [ 'Payment',
                                     'Amount',
                                     'Date',
+                                    'By',
                                     FS::UI::Web::cust_header(),
                                   ],
                  'fields'      => [
                    },
                    sub { sprintf('$%.2f', shift->paid ) },
                    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;
+                       },
                    \&FS::UI::Web::cust_fields,
                  ],
                  #'align' => 'lrrrll',
-                 'align' => 'rrr'.FS::UI::Web::cust_aligns(),
+                 'align' => 'rrrc'.FS::UI::Web::cust_aligns(),
                  'links' => [
+                   $link,
+                   $link,
+                   $link,
                    '',
-                   '',
-                   '',
-                   ( map { $_ ne 'Cust. Status' ? $link : '' }
+                   ( map { $_ ne 'Cust. Status' ? $cust_link : '' }
                          FS::UI::Web::cust_header()
                    ),
                  ],
                               '',
                               '',
                               '',
+                              '',
                               FS::UI::Web::cust_colors(),
                             ],
                  'style' => [ 
                               '',
                               '',
                               '',
+                              '',
                               FS::UI::Web::cust_styles(),
                             ],
       )
@@ -154,6 +163,12 @@ if ( $cgi->param('magic') ) {
       }
     }
 
+    if ( $cgi->param('payinfo') ) {
+      $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/
+        or die "illegal payinfo ". $cgi->param('payinfo');
+      push @search, "cust_pay.payinfo = '$1'";
+    }
+
     my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
     push @search, "_date >= $beginning ",
                   "_date <= $ending";
@@ -198,6 +213,8 @@ if ( $cgi->param('magic') ) {
 
 } else {
 
+  #hmm... is this still used?
+
   $cgi->param('payinfo') =~ /^\s*(\d+)\s*$/ or die "illegal payinfo";
   my $payinfo = $1;
 
@@ -218,7 +235,12 @@ if ( $cgi->param('magic') ) {
 
 }
 
-my $link = sub {
+my $link = '';
+$link = [ "${p}view/cust_pay.html?paynum=", 'paynum' ]
+  if $FS::CurrentUser::CurrentUser->access_right('View invoices'); #XXX for now
+  #later# if $FS::CurrentUser::CurrentUser->access_right('View customer payments');
+
+my $cust_link = sub {
   my $cust_pay = shift;
   $cust_pay->cust_main_custnum
     ? [ "${p}view/cust_main.cgi?", 'custnum' ]