[freeside-commits] branch master updated. 36e4318e1ccec27ae76a3d1505718a3d47af67c9

Mark Wells mark at 420.am
Tue Aug 28 18:46:02 PDT 2012


The branch, master has been updated
       via  36e4318e1ccec27ae76a3d1505718a3d47af67c9 (commit)
       via  f98d0226901f7355652add424783f7f207aef596 (commit)
       via  7acc76e0ead0d88cb225c88016c778c8feb9a075 (commit)
       via  abb5095e4f202875934937166af1efe912f77d34 (commit)
       via  dfa1e92c5af9bd54186cd46f47ea528622f60894 (commit)
      from  9f2220031123f06ab275840a3129c9807b9a782a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 36e4318e1ccec27ae76a3d1505718a3d47af67c9
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Aug 28 18:45:30 2012 -0700

    sqlradius data volume report improvements, #18823

diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index e67db43..7ce79ae 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -2808,6 +2808,13 @@ Arrayref of additional WHERE clauses, will be ANDed together.
 sub search {
   my ($class, $params) = @_;
 
+  my @from = (
+    ' LEFT JOIN cust_svc  USING ( svcnum  ) ',
+    ' LEFT JOIN part_svc  USING ( svcpart ) ',
+    ' LEFT JOIN cust_pkg  USING ( pkgnum  ) ',
+    ' LEFT JOIN cust_main USING ( custnum ) ',
+  );
+
   my @where = ();
 
   # domain
@@ -2852,9 +2859,17 @@ sub search {
     push @where, "svcpart = $1";
   }
 
+  if ( $params->{'exportnum'} =~ /^(\d+)$/ ) {
+    push @from, ' LEFT JOIN export_svc USING ( svcpart )';
+    push @where, "exportnum = $1";
+  }
+
   # sector and tower
   my @where_sector = $class->tower_sector_sql($params);
-  push @where, @where_sector if @where_sector;
+  if ( @where_sector ) {
+    push @where, @where_sector;
+    push @from, ' LEFT JOIN tower_sector USING ( sectornum )';
+  }
 
   # here is the agent virtualization
   #if ($params->{CurrentUser}) {
@@ -2875,16 +2890,9 @@ sub search {
 
   push @where, @{ $params->{'where'} } if $params->{'where'};
 
+  my $addl_from = join(' ', @from);
   my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : '';
 
-  my $addl_from = ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
-                  ' LEFT JOIN part_svc  USING ( svcpart ) '.
-                  ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
-                  ' LEFT JOIN cust_main USING ( custnum ) ';
-
-  $addl_from .= ' LEFT JOIN tower_sector USING ( sectornum )'
-    if @where_sector;
-
   my $count_query = "SELECT COUNT(*) FROM svc_acct $addl_from $extra_sql";
   #if ( keys %svc_acct ) {
   #  $count_query .= ' WHERE '.
diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm
index 8210269..26659d5 100755
--- a/FS/FS/svc_broadband.pm
+++ b/FS/FS/svc_broadband.pm
@@ -245,6 +245,12 @@ sub search {
     push @where, "svcpart = $1";
   }
 
+  #exportnum
+  if ( $params->{'exportnum'} =~ /^(\d+)$/ ) {
+    push @from, 'LEFT JOIN export_svc USING ( svcpart )';
+    push @where, "exportnum = $1";
+  }
+
   #ip_addr
   if ( $params->{'ip_addr'} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/ ) {
     push @where, "ip_addr = '$1'";
diff --git a/httemplate/search/sqlradius_usage.html b/httemplate/search/sqlradius_usage.html
index dd06c10..29ef4c0 100644
--- a/httemplate/search/sqlradius_usage.html
+++ b/httemplate/search/sqlradius_usage.html
@@ -27,9 +27,9 @@
                      'Customer',
                      'Package',
                      @svc_header,
-                     'Upload',
-                     'Download',
-                     'Total',
+                     'Upload (GB)',
+                     'Download (GB)',
+                     'Total (GB)',
                    ],
   'footer'      => \@footer,
   'fields'      => [ #\&FS::UI::Web::cust_fields,
@@ -139,7 +139,8 @@ my @svc_usage = map {
     return '' if !exists($usage_by_username{$username});
     my $value = $usage_by_username{ $username }->[$i];
     $total_usage[$i] += $value;
-    FS::UI::bytecount::display_bytecount($value);
+    # for now, always show in GB, rounded to 3 digits
+    bytes_to_gb($value);
   }
 } (0,1,2);
 
@@ -167,7 +168,8 @@ my @svc_header = @{ $svc_header{$svcdb} };
 my @svc_fields = @{ $svc_fields{$svcdb} };
 
 # svc_x search params
-my %search_hash = ( 'agentnum' => $agentnum );
+my %search_hash = ( 'agentnum' => $agentnum,
+                    'exportnum' => $export->exportnum );
 
 my $sql_query = $class->search(\%search_hash);
 $sql_query->{'select'}    .= ', part_pkg.pkg';
@@ -183,12 +185,17 @@ my $skip_cols = 1 + scalar(@svc_header);
 my @footer = (
   '',
   FS::Record->scalar_sql($sql_query->{count_query}) . ' services',
-  (' ') x $skip_cols,
-  map { 
+  ('') x $skip_cols,
+  map {
+    my $i = $_;
     sub { # defer this until the rows have been processed
-        FS::UI::bytecount::display_bytecount($total_usage[$_])
+      bytes_to_gb($total_usage[$i])
     }
   } (0,1,2)
 );
 
+sub bytes_to_gb {
+  $_[0] ?  sprintf('%.3f', $_[0] / (1024*1024*1024.0)) : '';
+}
+
 </%init>

commit f98d0226901f7355652add424783f7f207aef596
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Aug 28 18:44:42 2012 -0700

    show footers in XLS and CSV reports, #18823

diff --git a/httemplate/search/elements/search-csv.html b/httemplate/search/elements/search-csv.html
index 9eb1b66..90230e6 100644
--- a/httemplate/search/elements/search-csv.html
+++ b/httemplate/search/elements/search-csv.html
@@ -27,10 +27,21 @@
 %     $csv->combine(@$row); #or die $csv->status;
 %   }
 %
-%      
 <% $csv->string %>\
 %
 % }
+% 
+% if ( $opt{'footer'} and !$opt{'no_csv_header'} ) {
+%   my @footer;
+%   foreach my $item (@{ $opt{'footer'} }) {
+%     if ( ref($item) eq 'CODE' ) {
+%       $item = &{$item}();
+%     }
+%     push @footer, $item;
+%   }
+%   $csv->combine(@footer);
+<% $csv->string %>\
+% }
 <%init>
 
 my %args = @_;
diff --git a/httemplate/search/elements/search-xls.html b/httemplate/search/elements/search-xls.html
index 09dbe46..94d88b0 100644
--- a/httemplate/search/elements/search-xls.html
+++ b/httemplate/search/elements/search-xls.html
@@ -55,6 +55,10 @@ my $writer = sub {
   # Wrapper for $worksheet->write.
   # Do any massaging of the value/format here.
   my ($r, $c, $value, $format) = @_;
+  # convert HTML entities
+  # both Spreadsheet::WriteExcel and Excel::Writer::XLSX accept UTF-8 strings
+  $value = decode_entities($value);
+
   if ( $value =~ /^\Q$money_char\E(-?\d+\.?\d*)$/ ) {
     # Currency: strip the symbol, clone the requested format,
     # and format it for currency
@@ -130,6 +134,17 @@ foreach my $row ( @$rows ) {
 
 }
 
+if ( $opt{'footer'} ) {
+  $r++;
+  $c = 0;
+  foreach my $item (@{ $opt{'footer'} }) {
+    if ( ref($item) eq 'CODE' ) {
+      $item = &{$item}();
+    }
+    $writer->( $r, $c++, $item, $header_format );
+  }
+}
+
 $workbook->close();# or die "Error creating .xls file: $!";
 
 http_header('Content-Length' => length($data) );

commit 7acc76e0ead0d88cb225c88016c778c8feb9a075
Author: Mark Wells <mark at freeside.biz>
Date:   Sun Aug 26 23:05:04 2012 -0700

    only show coordinate fields where necessary, #940

diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 9b30d31..e3e812f 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -53,6 +53,7 @@
     <& /elements/location.html,
         object => $cust_main->bill_location,
         prefix => 'bill_',
+        enable_coords => 1,
     &>
     <& cust_main/after_bill_location.html, $cust_main &>
     </TABLE>
@@ -77,6 +78,7 @@
         prefix => 'ship_',
         enable_censustract => 1,
         enable_district => 1,
+        enable_coords => 1,
     &>
     </TABLE>
     <TABLE CLASS="fsinnerbox" ID="table_ship_location_blank"
diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html
index 7672318..5c7c888 100644
--- a/httemplate/elements/location.html
+++ b/httemplate/elements/location.html
@@ -11,8 +11,10 @@ Example:
              'no_asterisks'   => 0, #set true to disable the red asterisks next
                                     #to required fields
              'address1_label' => 'Address', #label for address
+             'enable_coords'  => 1, #show latitude/longitude fields
              'enable_district' => 1, #show tax district field
              'enable_censustract' => 1, #show censustract field
+             
          )
 
 </%doc>
@@ -175,6 +177,7 @@ Example:
   <TD COLSPAN=6><% include('/elements/select-country.html', %select_hash ) %></TD>
 </TR>
 
+% if ( $opt{enable_coords} ) {
 <TR>
   <TD ALIGN="right"><% mt('Latitude') |h %></TH>
   <TD COLSPAN=7>
@@ -195,6 +198,11 @@ Example:
     >
   </TD>
 </TR>
+% } else {
+%   foreach (qw(latitude longitude)) {
+<INPUT TYPE="hidden" NAME="<% $_ %>" VALUE="<% $object->get($_) |h%>">
+%   }
+% }
 <INPUT TYPE="hidden" NAME="<%$pre%>coord_auto" VALUE="<% $object->coord_auto %>">
 
 <INPUT TYPE="hidden" NAME="<%$pre%>geocode" VALUE="<% $object->geocode %>">
diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html
index d9e3e9e..b804f45 100644
--- a/httemplate/elements/tr-select-cust_location.html
+++ b/httemplate/elements/tr-select-cust_location.html
@@ -216,6 +216,7 @@ Example:
              'no_asterisks' => 1,
              'no_bold'      => $opt{'no_bold'},
              'alt_format'   => $opt{'alt_format'},
+             'enable_coords'=> 1,
           )
 %>
 <SCRIPT TYPE="text/javascript">
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 2d73072..b4e3a6f 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -78,7 +78,7 @@
     </TR>
 
     <& /elements/location.html,
-                  'object'         => $cust_main, #XXX errors???
+                  'object'         => $cust_main->bill_location,
                   'no_asterisks'   => 1,
                   'address1_label' => emt('Card billing address'),
     &>
@@ -251,6 +251,10 @@ my $custnum = $1;
 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
 die "unknown custnum $custnum" unless $cust_main;
 
+my $location = $cust_main->bill_location;
+# no proper error handling on this anyway, but when we have it,
+# remember to repopulate fields in $location
+
 my $balance = $cust_main->balance;
 
 my $payinfo = '';

commit abb5095e4f202875934937166af1efe912f77d34
Author: Mark Wells <mark at freeside.biz>
Date:   Sun Aug 26 23:04:19 2012 -0700

    make address fields work in customer search results, #940

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index 7b2f30d..b07223e 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -798,6 +798,9 @@ sub search {
 
   my @select = (
                  'cust_main.custnum',
+                 # there's a good chance that we'll need these
+                 'cust_main.bill_locationnum',
+                 'cust_main.ship_locationnum',
                  FS::UI::Web::cust_sql_fields($params->{'cust_fields'}),
                );
 

commit dfa1e92c5af9bd54186cd46f47ea528622f60894
Author: Mark Wells <mark at freeside.biz>
Date:   Sun Aug 26 23:03:51 2012 -0700

    avoid displaying default service addresses on invoices, #940

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 8277c00..d35fd55 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -894,7 +894,6 @@ sub print_generic {
     warn "$me   setting options\n"
       if $DEBUG > 1;
 
-    my $multilocation = scalar($cust_main->cust_location); #too expensive?
     my %options = ();
     $options{'section'} = $section if $multisection;
     $options{'format'} = $format;
@@ -904,7 +903,6 @@ sub print_generic {
     $options{'summary_page'} = $summarypage;
     $options{'skip_usage'} =
       scalar(@$extra_sections) && !grep{$section == $_} @$extra_sections;
-    $options{'multilocation'} = $multilocation;
     $options{'multisection'} = $multisection;
 
     warn "$me   searching for line items\n"
@@ -2111,8 +2109,6 @@ ignored.
 multisection: a flag indicating that this is a multisection invoice,
 which does something complicated.
 
-multilocation: a flag to display the location label for the package.
-
 Returns a list of hashrefs, each of which may contain:
 
 pkgnum, description, amount, unit_amount, quantity, _is_setup, and 
@@ -2134,13 +2130,13 @@ sub _items_cust_bill_pkg {
   my $unsquelched = $opt{unsquelched} || ''; #unused
   my $section = $opt{section}->{description} if $opt{section};
   my $summary_page = $opt{summary_page} || ''; #unused
-  my $multilocation = $opt{multilocation} || '';
   my $multisection = $opt{multisection} || '';
   my $discount_show_always = 0;
 
   my $maxlength = $conf->config('cust_bill-latex_lineitem_maxlength') || 50;
 
   my $cust_main = $self->cust_main;#for per-agent cust_bill-line_item-ate_style
+                                   # and location labels
 
   my @b = ();
   my ($s, $r, $u) = ( undef, undef, undef );
@@ -2255,7 +2251,7 @@ sub _items_cust_bill_pkg {
                          $cust_pkg->h_labels_short($self->_date, undef, 'I')
               unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
 
-            if ( $multilocation ) {
+            if ( $cust_pkg->locationnum != $cust_main->ship_locationnum  ) {
               my $loc = $cust_pkg->location_label;
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;
@@ -2357,7 +2353,7 @@ sub _items_cust_bill_pkg {
             warn "$me _items_cust_bill_pkg done adding service details\n"
               if $DEBUG > 1;
 
-            if ( $multilocation ) {
+            if ( $cust_pkg->locationnum != $cust_main->ship_locationnum ) {
               my $loc = $cust_pkg->location_label;
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Template_Mixin.pm                          |   10 ++------
 FS/FS/cust_main/Search.pm                        |    3 ++
 FS/FS/svc_acct.pm                                |   26 ++++++++++++++-------
 FS/FS/svc_broadband.pm                           |    6 +++++
 httemplate/edit/cust_main.cgi                    |    2 +
 httemplate/elements/location.html                |    8 ++++++
 httemplate/elements/tr-select-cust_location.html |    1 +
 httemplate/misc/payment.cgi                      |    6 ++++-
 httemplate/search/elements/search-csv.html       |   13 ++++++++++-
 httemplate/search/elements/search-xls.html       |   15 ++++++++++++
 httemplate/search/sqlradius_usage.html           |   23 ++++++++++++------
 11 files changed, 87 insertions(+), 26 deletions(-)




More information about the freeside-commits mailing list