diff options
author | Ivan Kohler <ivan@freeside.biz> | 2012-08-29 15:19:17 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2012-08-29 15:19:17 -0700 |
commit | 33aa032478e29000c8c0d4fbe7bf8cb25c277606 (patch) | |
tree | dca9779a3f3990ee26268575bb135081f9f1b23c | |
parent | 0e17277ed0cc243452dfc07d1bd702502c7d50c3 (diff) | |
parent | 36e4318e1ccec27ae76a3d1505718a3d47af67c9 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r-- | FS/FS/Template_Mixin.pm | 10 | ||||
-rw-r--r-- | FS/FS/cust_main/Search.pm | 3 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 26 | ||||
-rwxr-xr-x | FS/FS/svc_broadband.pm | 6 | ||||
-rwxr-xr-x | httemplate/edit/cust_main.cgi | 2 | ||||
-rw-r--r-- | httemplate/elements/location.html | 8 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cust_location.html | 1 | ||||
-rw-r--r-- | httemplate/misc/payment.cgi | 6 | ||||
-rw-r--r-- | httemplate/search/elements/search-csv.html | 13 | ||||
-rw-r--r-- | httemplate/search/elements/search-xls.html | 15 | ||||
-rw-r--r-- | httemplate/search/sqlradius_usage.html | 23 |
11 files changed, 87 insertions, 26 deletions
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 8277c0046..d35fd55f2 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; diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 7b2f30dc4..b07223ec5 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'}), ); diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index e67db43c6..7ce79ae01 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 82102697d..26659d52a 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/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 9b30d31b0..e3e812f19 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 767231856..5c7c888de 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 d9e3e9e27..b804f4548 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 2d7307233..b4e3a6f82 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 = ''; diff --git a/httemplate/search/elements/search-csv.html b/httemplate/search/elements/search-csv.html index 9eb1b66d1..90230e6dc 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 09dbe46e0..94d88b096 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) ); diff --git a/httemplate/search/sqlradius_usage.html b/httemplate/search/sqlradius_usage.html index dd06c10fa..29ef4c0e8 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> |