X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTemplate_Mixin.pm;h=c8e5546584c336cef6069d715a16084b91b695e4;hb=48fc9f425ec3454f4346089318994ae6c1e080a8;hp=840df7558ddc4a263eb541cad0ca14230a90b0c4;hpb=eb3bd392a89b8b666dc512951e78913c05b98810;p=freeside.git diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 840df7558..c8e554658 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -15,6 +15,7 @@ use Locale::Country; use Cwd; use FS::UID; use FS::Record qw( qsearch qsearchs ); +use FS::Conf; use FS::Misc qw( generate_ps generate_pdf ); use FS::pkg_category; use FS::pkg_class; @@ -497,9 +498,9 @@ sub print_generic { '_date' => ( $params{'no_date'} ? '' : $self->_date ), 'date' => ( $params{'no_date'} ? '' - : time2str($date_format, $self->_date) + : $self->time2str_local($date_format, $self->_date) ), - 'today' => time2str($date_format_long, $today), + 'today' => $self->time2str_local($date_format_long, $today), 'terms' => $self->terms, 'template' => $template, #params{'template'}, 'notice_name' => $notice_name, # escape? @@ -544,15 +545,9 @@ sub print_generic { ); #localization - my $lh = FS::L10N->get_handle( $locale ); $invoice_data{'emt'} = sub { &$escape_function($self->mt(@_)) }; - my %info = FS::Locales->locale_info($cust_main->locale || 'en_US'); - # eval to avoid death for unimplemented languages - my $dh = eval { Date::Language->new($info{'name'}) } || - Date::Language->new(); # fall back to English # prototype here to silence warnings - $invoice_data{'time2str'} = sub ($;$$) { $dh->time2str(@_) }; - # eventually use this date handle everywhere in here, too + $invoice_data{'time2str'} = sub ($;$$) { $self->time2str_local(@_) }; my $min_sdate = 999999999999; my $max_edate = 0; @@ -565,8 +560,9 @@ sub print_generic { } $invoice_data{'bill_period'} = ''; - $invoice_data{'bill_period'} = time2str('%e %h', $min_sdate) - . " to " . time2str('%e %h', $max_edate) + $invoice_data{'bill_period'} = $self->time2str_local('%e %h', $min_sdate) + . " to " . + $self->time2str_local('%e %h', $max_edate) if ($max_edate != 0 && $min_sdate != 999999999999); $invoice_data{finance_section} = ''; @@ -581,11 +577,14 @@ sub print_generic { my $countrydefault = $conf->config('countrydefault') || 'US'; foreach ( qw( address1 address2 city state zip country fax) ){ my $method = 'ship_'.$_; - $invoice_data{"ship_$_"} = _latex_escape($cust_main->$method); + $invoice_data{"ship_$_"} = $escape_function->($cust_main->$method); } - foreach ( qw( contact company ) ) { #compatibility - $invoice_data{"ship_$_"} = _latex_escape($cust_main->$_); + if ( length($cust_main->ship_company) ) { + $invoice_data{'ship_company'} = $escape_function->($cust_main->ship_company); + } else { + $invoice_data{'ship_company'} = $escape_function->($cust_main->company); } + $invoice_data{'ship_contact'} = $escape_function->($cust_main->contact); $invoice_data{'ship_country'} = '' if ( $invoice_data{'ship_country'} eq $countrydefault ); @@ -1219,7 +1218,9 @@ sub print_generic { # credits my $credittotal = 0; - foreach my $credit ( $self->_items_credits('trim_len'=>60) ) { + foreach my $credit ( + $self->_items_credits( 'template' => $template, 'trim_len' => 60 ) + ) { my $total; $total->{'total_item'} = &$escape_function($credit->{'description'}); @@ -1245,13 +1246,17 @@ sub print_generic { $invoice_data{'credittotal'} = sprintf('%.2f', $credittotal); #credits (again) - foreach my $credit ( $self->_items_credits('trim_len'=>32) ) { + foreach my $credit ( + $self->_items_credits( 'template' => $template, 'trim_len'=>32 ) + ) { push @buf, [ $credit->{'description'}, $money_char.$credit->{'amount'} ]; } # payments my $paymenttotal = 0; - foreach my $payment ( $self->_items_payments ) { + foreach my $payment ( + $self->_items_payments( 'template' => $template ) + ) { my $total = {}; $total->{'total_item'} = &$escape_function($payment->{'description'}); $paymenttotal += $payment->{'amount'}; @@ -1711,7 +1716,7 @@ sub due_date { sub due_date2str { my $self = shift; - $self->due_date ? time2str(shift, $self->due_date) : ''; + $self->due_date ? $self->time2str_local(shift, $self->due_date) : ''; } sub balance_due_msg { @@ -1733,7 +1738,7 @@ sub balance_due_date { my $duedate = ''; if ( $conf->exists('invoice_default_terms') && $conf->config('invoice_default_terms')=~ /^\s*Net\s*(\d+)\s*$/ ) { - $duedate = time2str($rdate_format, $self->_date + ($1*86400) ); + $duedate = $self->time2str_local($rdate_format, $self->_date + ($1*86400) ); } $duedate; } @@ -1751,7 +1756,7 @@ Returns a string with the date, for example: "3/20/2008" sub _date_pretty { my $self = shift; - time2str($date_format, $self->_date); + $self->time2str_local($date_format, $self->_date); } =item _items_sections OPTIONS @@ -2482,6 +2487,7 @@ sub _items_cust_bill_pkg { if $DEBUG > 1; my $cust_pkg = $cust_bill_pkg->cust_pkg; + my $part_pkg = $cust_pkg->part_pkg; # which pkgpart to show for display purposes? my $pkgpart = $cust_bill_pkg->pkgpart_override || $cust_pkg->pkgpart; @@ -2490,7 +2496,7 @@ sub _items_cust_bill_pkg { # things with them my %item_dates = (); %item_dates = map { $_ => $cust_bill_pkg->$_ } ('sdate', 'edate') - unless $cust_pkg->part_pkg->option('disable_line_item_date_ranges',1); + unless $part_pkg->option('disable_line_item_date_ranges',1); if ( (!$type || $type eq 'S') && ( $cust_bill_pkg->setup != 0 @@ -2508,6 +2514,14 @@ sub _items_cust_bill_pkg { || $discount_show_always || $cust_bill_pkg->recur_show_zero; + $description .= $cust_bill_pkg->time_period_pretty( $part_pkg, + $self->agentnum ) + if $part_pkg->is_prepaid #for prepaid, "display the validity period + # triggered by the recurring charge freq + # (RT#26274) + && $cust_bill_pkg->recur == 0 + && ! $cust_bill_pkg->recur_show_zero; + my @d = (); my $svc_label; unless ( $cust_pkg->part_pkg->hide_svc_detail @@ -2578,37 +2592,8 @@ sub _items_cust_bill_pkg { my $part_pkg = $cust_pkg->part_pkg; - #pry be a bit more efficient to look some of this conf stuff up - # outside the loop - unless ( - $conf->exists('disable_line_item_date_ranges') - || $part_pkg->option('disable_line_item_date_ranges',1) - || ! $cust_bill_pkg->sdate - || ! $cust_bill_pkg->edate - ) { - my $time_period; - my $date_style = ''; - $date_style = $conf->config( 'cust_bill-line_item-date_style-non_monhtly', - $self->agentnum - ) - if $part_pkg && $part_pkg->freq !~ /^1m?$/; - $date_style ||= $conf->config( 'cust_bill-line_item-date_style', - $self->agentnum - ); - if ( defined($date_style) && $date_style eq 'month_of' ) { - $time_period = time2str('The month of %B', $cust_bill_pkg->sdate); - } elsif ( defined($date_style) && $date_style eq 'X_month' ) { - my $desc = $conf->config( 'cust_bill-line_item-date_description', - $self->agentnum - ); - $desc .= ' ' unless $desc =~ /\s$/; - $time_period = $desc. time2str('%B', $cust_bill_pkg->sdate); - } else { - $time_period = time2str($date_format, $cust_bill_pkg->sdate). - " - ". time2str($date_format, $cust_bill_pkg->edate); - } - $description .= " ($time_period)"; - } + $description .= $cust_bill_pkg->time_period_pretty( $part_pkg, + $self->agentnum ); my @d = (); my @seconds = (); # for display of usage info @@ -2771,8 +2756,8 @@ sub _items_cust_bill_pkg { if ( $cust_bill_pkg->recur != 0 ) { push @b, { 'description' => "$desc (". - time2str($date_format, $cust_bill_pkg->sdate). ' - '. - time2str($date_format, $cust_bill_pkg->edate). ')', + $self->time2str_local($date_format, $cust_bill_pkg->sdate). ' - '. + $self->time2str_local($date_format, $cust_bill_pkg->edate). ')', 'amount' => sprintf("%.2f", $cust_bill_pkg->recur), }; }