[freeside-commits] branch FREESIDE_3_BRANCH updated. 9aaccf56a9cb4367a72450911f26cd9b324c3717

Jeremy Davis jeremyd at 420.am
Fri Feb 7 10:49:21 PST 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  9aaccf56a9cb4367a72450911f26cd9b324c3717 (commit)
      from  8f6ff231e419250cb3bb75b5048649f0eb396a63 (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 9aaccf56a9cb4367a72450911f26cd9b324c3717
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Jan 29 18:34:16 2014 -0800

    make date_format a localized config option, #27276

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 2d9dc64..b860668 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1047,6 +1047,7 @@ sub reason_type_options {
                        '%d/%m/%Y' => 'DD/MM/YYYY',
 		       '%Y/%m/%d' => 'YYYY/MM/DD',
                      ],
+    'per_locale'  => 1,
   },
 
   {
@@ -1061,6 +1062,7 @@ sub reason_type_options {
                        '%d/%m/%Y'  => 'DD/MM/YYYY',
 		       '%Y/%m/%d'  => 'YYYY/MM/DD',
                      ],
+    'per_locale'  => 1,
   },
 
   {
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index c8e5546..00151ae 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2,7 +2,7 @@ package FS::Template_Mixin;
 
 use strict;
 use vars qw( $DEBUG $me
-             $money_char $date_format $rdate_format $date_format_long );
+             $money_char );
              # but NOT $conf
 use vars qw( $invoice_lines @buf ); #yuck
 use List::Util qw(sum);
@@ -27,9 +27,6 @@ $me = '[FS::Template_Mixin]';
 FS::UID->install_callback( sub { 
   my $conf = new FS::Conf; #global
   $money_char       = $conf->config('money_char')       || '$';  
-  $date_format      = $conf->config('date_format')      || '%x'; #/YY
-  $rdate_format     = $conf->config('date_format')      || '%m/%d/%Y';  #/YYYY
-  $date_format_long = $conf->config('date_format_long') || '%b %o, %Y';
 } );
 
 =item conf [ MODE ]
@@ -406,14 +403,6 @@ sub print_generic {
   my $escape_function_nonbsp = ($format eq 'html')
                                  ? \&_html_escape : $escape_function;
 
-  my %date_formats = ( 'latex'    => $date_format_long,
-                       'html'     => $date_format_long,
-                       'template' => '%s',
-                     );
-  $date_formats{'html'} =~ s/ / /g;
-
-  my $date_format = $date_formats{$format};
-
   my %newline_tokens = (  'latex'     => '\\\\',
                           'html'      => '<br>',
                           'template'  => "\n",
@@ -498,14 +487,14 @@ sub print_generic {
     '_date'           => ( $params{'no_date'} ? '' : $self->_date ),
     'date'            => ( $params{'no_date'}
                              ? ''
-                             : $self->time2str_local($date_format, $self->_date)
+                             : $self->time2str_local('long', $self->_date, $format)
                          ),
-    'today'           => $self->time2str_local($date_format_long, $today),
+    'today'           => $self->time2str_local('long', $today, $format),
     'terms'           => $self->terms,
     'template'        => $template, #params{'template'},
     'notice_name'     => $notice_name, # escape?
     'current_charges' => sprintf("%.2f", $self->charged),
-    'duedate'         => $self->due_date2str($rdate_format), #date_format?
+    'duedate'         => $self->due_date2str('rdate'), #date_format?
 
     #customer info
     'custnum'         => $cust_main->display_custnum,
@@ -547,7 +536,7 @@ sub print_generic {
   #localization
   $invoice_data{'emt'} = sub { &$escape_function($self->mt(@_)) };
   # prototype here to silence warnings
-  $invoice_data{'time2str'} = sub ($;$$) { $self->time2str_local(@_) };
+  $invoice_data{'time2str'} = sub ($;$$) { $self->time2str_local(@_, $format) };
 
   my $min_sdate = 999999999999;
   my $max_edate = 0;
@@ -560,9 +549,10 @@ sub print_generic {
   }
 
   $invoice_data{'bill_period'} = '';
-  $invoice_data{'bill_period'} = $self->time2str_local('%e %h', $min_sdate) 
-                                 . " to " .
-                                 $self->time2str_local('%e %h', $max_edate)
+  $invoice_data{'bill_period'} =
+      $self->time2str_local('%e %h', $min_sdate, $format) 
+      . " to " .
+      $self->time2str_local('%e %h', $max_edate, $format)
     if ($max_edate != 0 && $min_sdate != 999999999999);
 
   $invoice_data{finance_section} = '';
@@ -670,7 +660,7 @@ sub print_generic {
         next if $cust_pay->_date > $self->_date;
         push @payments, {
             '_date'       => $cust_pay->_date,
-            'date'        => time2str($date_format, $cust_pay->_date),
+            'date'        => $self->time2str_local('long', $cust_pay->_date, $format),
             'payinfo'     => $cust_pay->payby_payinfo_pretty,
             'amount'      => sprintf('%.2f', $cust_pay->paid),
         };
@@ -685,7 +675,7 @@ sub print_generic {
         next if $cust_credit->_date > $self->_date;
         push @credits, {
             '_date'       => $cust_credit->_date,
-            'date'        => time2str($date_format, $cust_credit->_date),
+            'date'        => $self->time2str_local('long', $cust_credit->_date, $format),
             'creditreason'=> $cust_credit->reason,
             'amount'      => sprintf('%.2f', $cust_credit->amount),
         };
@@ -1725,7 +1715,7 @@ sub balance_due_msg {
   return $msg unless $self->terms;
   if ( $self->due_date ) {
     $msg .= ' - ' . $self->mt('Please pay by'). ' '.
-      $self->due_date2str($date_format);
+      $self->due_date2str('short');
   } elsif ( $self->terms ) {
     $msg .= ' - '. $self->terms;
   }
@@ -1738,7 +1728,7 @@ sub balance_due_date {
   my $duedate = '';
   if (    $conf->exists('invoice_default_terms') 
        && $conf->config('invoice_default_terms')=~ /^\s*Net\s*(\d+)\s*$/ ) {
-    $duedate = $self->time2str_local($rdate_format, $self->_date + ($1*86400) );
+    $duedate = $self->time2str_local('rdate', $self->_date + ($1*86400) );
   }
   $duedate;
 }
@@ -1756,7 +1746,7 @@ Returns a string with the date, for example: "3/20/2008"
 
 sub _date_pretty {
   my $self = shift;
-  $self->time2str_local($date_format, $self->_date);
+  $self->time2str_local('short', $self->_date);
 }
 
 =item _items_sections OPTIONS
@@ -2756,8 +2746,8 @@ sub _items_cust_bill_pkg {
         if ( $cust_bill_pkg->recur != 0 ) {
           push @b, {
             'description' => "$desc (".
-                             $self->time2str_local($date_format, $cust_bill_pkg->sdate). ' - '.
-                             $self->time2str_local($date_format, $cust_bill_pkg->edate). ')',
+                             $self->time2str_local('short', $cust_bill_pkg->sdate). ' - '.
+                             $self->time2str_local('short', $cust_bill_pkg->edate). ')',
             'amount'      => sprintf("%.2f", $cust_bill_pkg->recur),
           };
         }
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 4f8cb1d..4f4d438 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2,7 +2,7 @@ package FS::cust_bill;
 use base qw( FS::Template_Mixin FS::cust_main_Mixin FS::Record );
 
 use strict;
-use vars qw( $DEBUG $me $date_format );
+use vars qw( $DEBUG $me );
              # but NOT $conf
 use Fcntl qw(:flock); #for spool_csv
 use Cwd;
@@ -47,7 +47,6 @@ $me = '[FS::cust_bill]';
 #ask FS::UID to run this stuff for us later
 FS::UID->install_callback( sub { 
   my $conf = new FS::Conf; #global
-  $date_format      = $conf->config('date_format')      || '%x'; #/YY
 } );
 
 =head1 NAME
@@ -1984,7 +1983,7 @@ sub print_csv {
     my $taxtotal = 0;
     $taxtotal += $_->{'amount'} foreach $self->_items_tax;
 
-    my $duedate = $self->due_date2str('%m/%d/%Y'); #date_format?
+    my $duedate = $self->due_date2str('%m/%d/%Y'); # hardcoded, NOT date_format
 
     my( $previous_balance, @unused ) = $self->previous; #previous balance
 
@@ -2984,8 +2983,8 @@ sub _items_previous {
   my @b = ();
   foreach ( @pr_cust_bill ) {
     my $date = $conf->exists('invoice_show_prior_due_date')
-               ? 'due '. $_->due_date2str($date_format)
-               : $self->time2str_local($date_format, $_->_date);
+               ? 'due '. $_->due_date2str('short')
+               : $self->time2str_local('short', $_->_date);
     push @b, {
       'description' => $self->mt('Previous Balance, Invoice #'). $_->invnum. " ($date)",
       #'pkgpart'     => 'N/A',
@@ -3049,7 +3048,7 @@ sub _items_credits {
       #                 " (". time2str("%x",$_->cust_credit->_date) .")".
       #                 $reason,
       'description' => $self->mt('Credit applied').' '.
-                       $self->time2str_local($date_format,$obj->_date). $reason,
+                       $self->time2str_local('short', $obj->_date). $reason,
       'amount'      => sprintf("%.2f",$obj->amount),
     };
   }
@@ -3093,7 +3092,7 @@ sub _items_payments {
   foreach my $obj (@objects) {
     my $cust_pay = $obj->isa('FS::cust_pay') ? $obj : $obj->cust_pay;
     my $desc = $self->mt('Payment received').' '.
-               $self->time2str_local($date_format, $cust_pay->_date );
+               $self->time2str_local('short', $cust_pay->_date );
     $desc .= $self->mt(' via ') .
              $cust_pay->payby_payinfo_pretty( $self->cust_main->locale )
       if $detailed;

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

Summary of changes:
 FS/FS/Conf.pm           |    2 ++
 FS/FS/Template_Mixin.pm |   42 ++++++++++++++++--------------------------
 FS/FS/cust_bill.pm      |   13 ++++++-------
 3 files changed, 24 insertions(+), 33 deletions(-)




More information about the freeside-commits mailing list