diff options
Diffstat (limited to 'httemplate')
| -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 |
7 files changed, 58 insertions, 10 deletions
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> |
