self-service view usage customization and CDR display fixes, RT11761
authorlevinse <levinse>
Thu, 5 May 2011 06:54:11 +0000 (06:54 +0000)
committerlevinse <levinse>
Thu, 5 May 2011 06:54:11 +0000 (06:54 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/Conf.pm
FS/FS/cdr.pm
fs_selfservice/FS-SelfService/cgi/view_cdr_details.html
fs_selfservice/FS-SelfService/cgi/view_usage.html

index 33143e2..fa0bbb8 100644 (file)
@@ -1090,6 +1090,7 @@ sub list_svcs {
     'svcnum'   => $session->{'svcnum'},
     'custnum'  => $custnum,
     'date_format' => $conf->config('date_format') || '%m/%d/%Y',
+    'view_usage_nodomain' => $conf->exists('selfservice-view_usage_nodomain'),
     'svcs'     => [
       map { 
             my $svc_x = $_->svc_x;
@@ -1195,8 +1196,8 @@ sub list_support_usage {
 
 sub _list_cdr_usage {
   my($svc_phone, $begin, $end) = @_;
-  map [ $_->downstream_csv('format' => 'default') ], #XXX config for format
-      $svc_phone->get_cdrs( 'begin'=>$begin, 'end'=>$end, );
+  map [ $_->downstream_csv('format' => 'default', 'keeparray' => 1) ], #XXX config for format
+                       $svc_phone->get_cdrs( 'begin'=>$begin, 'end'=>$end, );
 }
 
 sub list_cdr_usage {
index 92f2d9f..785b74a 100644 (file)
@@ -3867,6 +3867,13 @@ and customer address. Include units.',
     'type'        => 'image',
     'per_agent'   => 1,
   },
+  
+  {
+    'key'         => 'selfservice-view_usage_nodomain',
+    'section'     => 'self-service',
+    'description' => 'Show usernames without their domains in "View my usage" in the self-service interface.',
+    'type'        => 'checkbox',
+  },
 
   {
     'key'         => 'selfservice-bulk_format',
index 3157b6b..0107659 100644 (file)
@@ -560,11 +560,11 @@ sub export_formats {
   my $duration_sub = sub {
     my($cdr, %opt) = @_;
     my $sec = $opt{seconds} || $cdr->billsec;
-    if ( length($opt{granularity}) && 
+    if ( defined $opt{granularity} && 
          $opt{granularity} == 0 ) { #per call
       return '1 call';
     }
-    elsif ( $opt{granularity} == 60 ) {#full minutes
+    elsif ( defined $opt{granularity} && $opt{granularity} == 60 ) {#full minutes
       my $min = int($sec/60);
       $min++ if $sec%60;
       return $min.'m';
@@ -620,7 +620,10 @@ sub export_formats {
       $duration_sub,
 
       #PRICE
-      sub { my($cdr, %opt) = @_; $opt{money_char}. $opt{charge}; },
+      sub { my($cdr, %opt) = @_; 
+        $opt{charge} = '0.00' unless defined $opt{charge};
+        $opt{money_char}.$opt{charge}; 
+      },
 
     ],
   );
@@ -660,6 +663,8 @@ sub downstream_csv {
         }
     @{ $formats{$format} };
 
+  return @columns if defined $opt{'keeparray'};
+
   my $status = $csv->combine(@columns);
   die "FS::CDR: error combining ". $csv->error_input(). "into downstream CSV"
     unless $status;
index 170237a..fd5426a 100644 (file)
 <%= foreach my $svc ( @svc_acct ) {
       my $link = "${url}view_usage_details;".
         "svcnum=$svc->{'svcnum'};beginning=0;ending=0";
+    my $username = $svc->{'value'};
+    $username =~ s/@.*?$//g if $view_usage_nodomain;
   $OUT .= '<TR><TD>';
-    $OUT .= qq!<A HREF="$link">!. $svc->{'label'}. ': '. $svc->{'value'}.'</A>';
+    $OUT .= qq!<A HREF="$link">!. $svc->{'label'}. ': '. $username .'</A>';
     $OUT .= '</TD><TD ALIGN="right">';
     $OUT .= $svc->{'seconds'};
     $OUT .= '</TD><TD ALIGN="right">';