X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTemplate_Mixin.pm;h=c97e84e8392027d2142f33492765f9bfdd97186b;hb=57d4a5ffe7b86d032339d6eefe1a22277f3ca113;hp=8734a78b4a1038fdc1e777f3e638128a51ab3199;hpb=01f9e027252b87d21c76b8dad737a761e61bb1f7;p=freeside.git diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 8734a78b4..c97e84e83 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -566,6 +566,7 @@ sub print_generic { 'notice_name' => $notice_name, # escape? 'current_charges' => sprintf("%.2f", $self->charged), 'duedate' => $self->due_date2str('rdate'), #date_format? + 'duedate_long' => $self->due_date2str('long'), #customer info 'custnum' => $cust_main->display_custnum, @@ -1155,14 +1156,27 @@ sub print_generic { if ( $invoice_data{finance_section} && $section->{'description'} eq $invoice_data{finance_section} ); - $section->{'subtotal'} = $other_money_char. - sprintf('%.2f', $section->{'subtotal'}) - if $multisection; + if ( $multisection ) { + + if ( ref($section->{'subtotal'}) ) { + + $section->{'subtotal'} = + sprintf("$other_money_char%.2f to $other_money_char%.2f", + $section->{'subtotal'}[0], + $section->{'subtotal'}[1] + ); + + } else { + + $section->{'subtotal'} = $other_money_char. + sprintf('%.2f', $section->{'subtotal'}) - # continue some normalization - $section->{'amount'} = $section->{'subtotal'} - if $multisection; + } + # continue some normalization + $section->{'amount'} = $section->{'subtotal'} + + } if ( $section->{'description'} ) { push @buf, ( [ &$escape_function($section->{'description'}), '' ], @@ -1361,7 +1375,16 @@ sub print_generic { foreach ( @new_total_items ) { my ($item, $amount) = ($_->{'total_item'}, $_->{'total_amount'}); $_->{'total_item'} = &$embolden_function( $item ); + + if ( ref($amount) ) { + $_->{'total_amount'} = &$embolden_function( + $other_money_char.$amount->[0]. ' to '. + $other_money_char.$amount->[1] + ); + } else { $_->{'total_amount'} = &$embolden_function( $other_money_char.$amount ); + } + # but if it's multisection, don't append to @total_items. the adjust # section has all this stuff push @total_items, $_ if !$multisection; @@ -1640,24 +1663,24 @@ sub print_generic { die "no invoice_lines() functions in template?" if ( $format eq 'template' && !$wasfunc ); - if ($format eq 'template') { + if ( $invoice_lines ) { + $invoice_data{'total_pages'} = int( scalar(@buf) / $invoice_lines ); + $invoice_data{'total_pages'}++ + if scalar(@buf) % $invoice_lines; + } - if ( $invoice_lines ) { - $invoice_data{'total_pages'} = int( scalar(@buf) / $invoice_lines ); - $invoice_data{'total_pages'}++ - if scalar(@buf) % $invoice_lines; + #setup subroutine for the template + $invoice_data{invoice_lines} = sub { + my $lines = shift || scalar(@buf); + map { + scalar(@buf) + ? shift @buf + : [ '', '' ]; } + ( 1 .. $lines ); + }; - #setup subroutine for the template - $invoice_data{invoice_lines} = sub { - my $lines = shift || scalar(@buf); - map { - scalar(@buf) - ? shift @buf - : [ '', '' ]; - } - ( 1 .. $lines ); - }; + if ($format eq 'template') { my $lines; my @collect; @@ -1953,8 +1976,11 @@ sub balance_due_msg { # _items_total) and not here # (yes, or if invoice_sections is enabled; this is just for compatibility) if ( $self->due_date ) { - $msg .= ' - ' . $self->mt('Please pay by'). ' '. - $self->due_date2str('short') + my $please_pay_by = + $self->conf->config('invoice_pay_by_msg', $self->agentnum) + || 'Please pay by [_1]'; + $msg .= ' - ' . $self->mt($please_pay_by, $self->due_date2str('short')). + ' ' unless $self->conf->config_bool('invoice_omit_due_date',$self->agentnum); } elsif ( $self->terms ) { $msg .= ' - '. $self->mt($self->terms); @@ -2081,6 +2107,7 @@ Returns an argument list to be passed to L. =cut use MIME::Entity; +use Encode; sub generate_email { @@ -2148,7 +2175,7 @@ sub generate_email { if $DEBUG; # 'print_text' argument is no longer used - @text = $self->print_text(\%args); + @text = map Encode::encode_utf8($_), $self->print_text(\%args); } else { @@ -2243,7 +2270,7 @@ sub generate_email { ' ', ' ', ' ', - $html, + Encode::encode_utf8($html), ' ', '', ], @@ -2417,6 +2444,7 @@ sub postal_mail_fsinc { 'ssl_opts' => { verify_hostname => 0, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + SSL_version => 'SSLv3', } ); my $response = $ua->request( POST $url, [ @@ -2450,7 +2478,8 @@ sub postal_mail_fsinc { 'country' => $bill_location->country, ]); - die "Print connection error: ". $response->message. "\n" + die "Print connection error: ". $response->message. + ' ('. $response->as_string. ")\n" unless $response->is_success; local $@;