[freeside-commits] branch FREESIDE_3_BRANCH updated. f1e9e0cd3fb22e3e615142889f5f3df799841cc2

Ivan ivan at 420.am
Sat Oct 25 12:08:10 PDT 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  f1e9e0cd3fb22e3e615142889f5f3df799841cc2 (commit)
       via  39f27ad350fab89f189018b9c7a9880df66712ed (commit)
      from  ad42ef0fd23caae66f911e0e3630b39d86e8bef6 (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 f1e9e0cd3fb22e3e615142889f5f3df799841cc2
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Oct 25 12:08:06 2014 -0700

    user-defined site ID / location codes per location, RT#30856, RT#27545

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index b4cd7d8..6b59574 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3477,7 +3477,8 @@ and customer address. Include units.',
     'description' => 'Optional "site ID" to show in the location label',
     'type'        => 'select',
     'select_hash' => [ '' => '',
-                       'CoStAg' => 'CoStAgXXXXX (country, state, agent name, locationnum)',
+                       'CoStAg'    => 'CoStAgXXXXX (country, state, agent name, locationnum)',
+                       '_location' => 'Manually defined per location',
                       ],
   },
 
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 9b1fa94..cb5fb85 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1358,6 +1358,7 @@ sub tables_hashref {
         'locationnum',      'serial',     '',      '', '', '',
         'prospectnum',         'int', 'NULL',      '', '', '',
         'custnum',             'int', 'NULL',      '', '', '',
+        'locationname',    'varchar', 'NULL', $char_d, '', '',
         'address1',        'varchar',     '', $char_d, '', '', 
         'address2',        'varchar', 'NULL', $char_d, '', '', 
         'city',            'varchar',     '', $char_d, '', '', 
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index d652d53..ce7efca 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2090,8 +2090,9 @@ sub _items_sections {
           $section->{'sort_weight'} = sprintf('%012s',$location->zip) .
                                       $locationnum;
           $section->{'location'} = {
+            label_prefix => &{ $escape }($location->label_prefix),
             map { $_ => &{ $escape }($location->get($_)) }
-            $location->fields
+              $location->fields
           };
         } else {
           $section->{'category'} = $sectionname;
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm
index 2e0871d..23dbce9 100644
--- a/FS/FS/cust_location.pm
+++ b/FS/FS/cust_location.pm
@@ -322,6 +322,7 @@ sub check {
     $self->ut_numbern('locationnum')
     || $self->ut_foreign_keyn('prospectnum', 'prospect_main', 'prospectnum')
     || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
+    || $self->ut_alphan('locationname')
     || $self->ut_text('address1')
     || $self->ut_textn('address2')
     || $self->ut_text('city')
@@ -604,14 +605,61 @@ sub dealternize {
 
 =item location_label
 
-Returns the label of the location object, with an optional site ID
-string (based on the cust_location-label_prefix config option).
+Returns the label of the location object.
+
+Options:
+
+=over 4
+
+=item cust_main
+
+Customer object (see L<FS::cust_main>)
+
+=item prospect_main
+
+Prospect object (see L<FS::prospect_main>)
+
+=item join_string
+
+String used to join location elements
+
+=back
 
 =cut
 
 sub location_label {
   my( $self, %opt ) = @_;
 
+  my $prefix = $self->label_prefix;
+  $prefix .= ($opt{join_string} ||  ': ') if $prefix;
+
+  $prefix . $self->SUPER::location_label(%opt);
+}
+
+=item label_prefix
+
+Returns the optional site ID string (based on the cust_location-label_prefix
+config option), "Default service location", or the empty string.
+
+Options:
+
+=over 4
+
+=item cust_main
+
+Customer object (see L<FS::cust_main>)
+
+=item prospect_main
+
+Prospect object (see L<FS::prospect_main>)
+
+=back
+
+=cut
+
+sub label_prefix {
+  my( $self, %opt ) = @_;
+
   my $cust_or_prospect = $opt{cust_main} || $opt{prospect_main};
   unless ( $cust_or_prospect ) {
     if ( $self->custnum ) {
@@ -633,14 +681,16 @@ sub location_label {
         ($agent =~ /^(..)/),
         sprintf('%05d', $self->locationnum)
     ) );
-  }
-  elsif (    ( $opt{'cust_main'} || $self->custnum )
+
+  } elsif ( $label_prefix eq '_location' && $self->locationname ) {
+    $prefix = $self->locationname;
+
+  } elsif (    ( $opt{'cust_main'} || $self->custnum )
           && $self->locationnum == $cust_or_prospect->ship_locationnum ) {
     $prefix = 'Default service location';
   }
 
-  $prefix .= ($opt{join_string} ||  ': ') if $prefix;
-  $prefix . $self->SUPER::location_label(%opt);
+  $prefix;
 }
 
 =item county_state_county
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index c0d8dbe..57abc18 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2092,6 +2092,7 @@ Returns a list of fields which have ship_ duplicates.
 
 sub addr_fields {
   qw( last first company
+      locationname
       address1 address2 city county state zip country
       latitude longitude
       daytime night fax mobile
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index 095bbe7..9f38297 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -17,10 +17,12 @@ BEGIN {
   # set up accessors for location fields
   if (!$init) {
     no strict 'refs';
-    @location_fields = 
-      qw( address1 address2 city county state zip country district
-        latitude longitude coord_auto censustract censusyear geocode
-        addr_clean );
+    @location_fields = qw(
+      locationname
+      address1 address2 city county state zip country
+      district latitude longitude coord_auto censustract censusyear geocode
+      addr_clean
+    );
 
     foreach my $f (@location_fields) {
       *{"FS::cust_main::Location::$f"} = sub {
diff --git a/conf/invoice_html b/conf/invoice_html
index 35de6cf..795242d 100644
--- a/conf/invoice_html
+++ b/conf/invoice_html
@@ -115,6 +115,8 @@
           $OUT .= '<p class="allcaps"><b>';
           my $sectionhead;
           if ( $section->{'location'} ) {
+            $sectionhead .= $section->{'location'}{'label_prefix'}. ': '.
+              if length($section->{'location'}{'label_prefix'});
             $sectionhead = $section->{'location'}{'address1'};
             $sectionhead .= ', '.$section->{'location'}{'address2'}
               if length($section->{'location'}{'address2'});
diff --git a/conf/invoice_latex b/conf/invoice_latex
index 70b36b1..6a5b53d 100644
--- a/conf/invoice_latex
+++ b/conf/invoice_latex
@@ -259,6 +259,8 @@
       $OUT .= '\begin{longtable}{cllllllr}';
       $OUT .= '\caption*{ ';
       if ($section->{'location'}) {
+        $OUT .= $section->{'location'}{'label_prefix'}. ': '
+          if length($section->{'location'}{'label_prefix'});
         $OUT .= $section->{'location'}{'address1'};
         $OUT .= ', ' . $section->{'location'}{'address2'}
           if length($section->{'location'}{'address2'});
diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index f3fde53..41dd563 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -39,8 +39,10 @@
 
 
   var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
-  var ship_fields = ['address1', 'city', 'state', 'zip', 'country', 
-    'latitude', 'longitude', 'district'];
+  var ship_fields = [
+    'locationname', 'address1', 'city', 'state', 'zip', 'country', 
+    'latitude', 'longitude', 'district'
+  ];
 
   function agent_changed(what) {
     var agentnum = what.value;
@@ -270,7 +272,7 @@ foreach (qsearch('agent',{})) {
   my $agent_ship_location = $cust_main->ship_location;
   $ship_locked_agents{$agentnum} = +{
     map { $_ => $agent_ship_location->$_ }
-    qw(address1 city state zip country latitude longitude district)
+    qw(locationname address1 city state zip country latitude longitude district)
   };
 }
 
diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html
index 799531e..5cdc424 100644
--- a/httemplate/elements/location.html
+++ b/httemplate/elements/location.html
@@ -41,6 +41,33 @@ Example:
 
 % } 
 
+% if ( $label_prefix eq '_location' ) {
+
+    <TR>
+      <TD ALIGN="right" ><% $opt{'locationname_label'} || emt('Location ID') %></TD>
+      <TD COLSPAN=7>
+        <INPUT TYPE     = "text"
+               NAME     = "<%$pre%>locationname"
+               ID       = "<%$pre%>locationname"
+               VALUE    = "<% $object->get('locationname') |h %>"
+               SIZE     = 24
+               onChange = "<% $onchange %>"
+               <% $disabled %>
+               <% $style %>
+        >
+      </TD>
+    </TR>
+
+% } else {
+
+    <INPUT TYPE     = "hidden"
+           NAME     = "<%$pre%>locationname"
+           ID       = "<%$pre%>locationname"
+           VALUE    = "<% $object->get('locationname') |h %>"
+    >
+
+% }
+
 <TR>
   <<%$th%> STYLE="width:16ex" ALIGN="right"><%$r%><% $opt{'address1_label'} || emt('Address') %></<%$th%>>
   <TD COLSPAN=7>
@@ -291,13 +318,14 @@ my $object   = $opt{'object'};
 my $onchange = $opt{'onchange'};
 my $disabled = $opt{'disabled'};
 
-my $conf = new FS::Conf;
-
 my $r = $opt{'no_asterisks'} ? '' : qq!<font color="#ff0000">*</font> !;
 
+my $conf = new FS::Conf;
 my $countrydefault = $conf->config('countrydefault') || 'US';
-my $statedefault = $conf->config('statedefault') 
-                   || ($countrydefault eq 'US' ? 'CA' : '');
+my $statedefault   = $conf->config('statedefault') 
+                       || ($countrydefault eq 'US' ? 'CA' : '');
+my $label_prefix   = $conf->config('cust_location-label_prefix');
+
 $object ||= FS::cust_location->new({
   'country' => $countrydefault,
   'state'   => $statedefault,
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index dbc491a..5b61e74 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -60,6 +60,14 @@
 %   }
 % }
 % # now the actual address
+
+% if ( $location->locationname ) {
+    <TR>
+      <TD ALIGN="right"><% mt('Location ID') |h %></TD>
+      <TD COLSPAN=7 BGCOLOR="#ffffff"><% $location->locationname |h %></TD>
+    </TR>
+% }
+
 <TR>
   <TD ALIGN="right"><% mt('Address') |h %></TD>
   <TD COLSPAN=7 BGCOLOR="#ffffff"><% $location->address1 |h %></TD>

commit 39f27ad350fab89f189018b9c7a9880df66712ed
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Oct 24 11:13:12 2014 -0700

    git master is the unstable version of freeside

diff --git a/debian/changelog b/debian/changelog
index f8eae44..dc027a0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
 freeside (3.5git~20141024-1) UNRELEASED; urgency=low
 
-  * Unstable version of freeside.
+  * Testing version of freeside.
 
  -- Jeremy Davis <jeremyd-debian at freeside.biz>  Thu, 18 Feb 2014 15:50:36 -0500
 

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

Summary of changes:
 FS/FS/Conf.pm                           |    3 +-
 FS/FS/Schema.pm                         |    1 +
 FS/FS/Template_Mixin.pm                 |    3 +-
 FS/FS/cust_location.pm                  |   62 ++++++++++++++++++++++++++++---
 FS/FS/cust_main.pm                      |    1 +
 FS/FS/cust_main/Location.pm             |   10 +++--
 conf/invoice_html                       |    2 +
 conf/invoice_latex                      |    2 +
 debian/changelog                        |    2 +-
 httemplate/edit/cust_main/top_misc.html |    8 ++--
 httemplate/elements/location.html       |   36 ++++++++++++++++--
 httemplate/view/cust_main/contacts.html |    8 ++++
 12 files changed, 118 insertions(+), 20 deletions(-)




More information about the freeside-commits mailing list