[freeside-commits] freeside/httemplate/elements location.html, NONE, 1.1 tr-select-part_referral.html, 1.4, 1.5 select-state.html, 1.2, 1.3 select-county.html, 1.1, 1.2 select-country.html, 1.1, 1.2

Ivan,,, ivan at wavetail.420.am
Thu Jan 8 20:06:27 PST 2009


Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv25024/httemplate/elements

Modified Files:
	tr-select-part_referral.html select-state.html 
	select-county.html select-country.html 
Added Files:
	location.html 
Log Message:
pick/enter a location when ordering a package, RT#4499

Index: select-country.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-country.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- select-country.html	28 Dec 2008 18:48:10 -0000	1.1
+++ select-country.html	9 Jan 2009 04:06:25 -0000	1.2
@@ -13,7 +13,7 @@
     disable_empty => 1, #defaults to 1, disable the empty option
     empty_label   => 'all', #label for empty option
     disable_stateupdate => 0, #bool - disabled update of the select-state.html
-    
+    style         => [ 'attribute:value', 'another:value' ],
   );
 
 </%doc>
@@ -70,6 +70,7 @@
         ID       = "<% $pre %>country"
         onChange = "<% $onchange %>"
         <% $opt{'disabled'} %>
+        <% $style %>
 >
 
 % unless ( $opt{'disable_empty'} ) {
@@ -101,6 +102,12 @@
   ( $opt{'disable_stateupdate'} ? '' : $pre.'country_changed(this); ' ).
   $opt{'onchange'};
 
+$opt{'style'} ||= [];
+my $style =
+  scalar(@{$opt{style}})
+    ? 'STYLE="'. join(';', @{$opt{style}}). '"'
+    : '';
+
 my $conf = new FS::Conf;
 my $default = $conf->config('countrydefault') || 'US';
 

Index: select-state.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-state.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- select-state.html	28 Dec 2008 18:48:10 -0000	1.2
+++ select-state.html	9 Jan 2009 04:06:25 -0000	1.3
@@ -14,6 +14,7 @@
     disable_empty => 1, #defaults to 1, disable the empty option
     empty_label   => 'all', #label for empty option
     disable_countyupdate => 0, #bool - disabled update of the select-state.html
+    style         => [ 'attribute:value', 'another:value' ],
   );
 
 </%doc>
@@ -21,6 +22,8 @@
 <SELECT NAME     = "<% $pre %>state"
         ID       = "<% $pre %>state"
         onChange = "<% $onchange %>"
+        <% $opt{'disabled'} %>
+        <% $style %>
 >
 
 % unless ( $opt{'disable_empty'} ) {
@@ -51,6 +54,12 @@
   ( $opt{'disable_countyupdate'} ? '' : $pre.'state_changed(this); ' ).
   $opt{'onchange'};
 
+$opt{'style'} ||= [];
+my $style =
+  scalar(@{$opt{style}})
+    ? 'STYLE="'. join(';', @{$opt{style}}). '"'
+    : '';
+
 tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} ); 
 
 </%init>

Index: tr-select-part_referral.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-part_referral.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- tr-select-part_referral.html	8 Oct 2007 19:14:26 -0000	1.4
+++ tr-select-part_referral.html	9 Jan 2009 04:06:25 -0000	1.5
@@ -12,7 +12,7 @@
 %      } else {
          <TH ALIGN="right"><%$r%>Advertising source</TH>
 %      }
-       <TD>
+       <TD COLSPAN="<% $colspan %>">
          <% include( '/elements/select-part_referral.html',
                        'curr_value' => $refnum,
                        %opt
@@ -30,6 +30,8 @@
 $opt{'part_referrals'} ||=
   [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global
 
+my $colspan = delete($opt{'colspan'}) || 1;
+
 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
 </%init>

Index: select-county.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-county.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- select-county.html	28 Dec 2008 18:48:10 -0000	1.1
+++ select-county.html	9 Jan 2009 04:06:25 -0000	1.2
@@ -14,6 +14,7 @@
     disabled      => 0, #bool
     disable_empty => 1, #defaults to 1, disable the empty option
     empty_label   => 'all', #label for empty option
+    style         => [ 'attribute:value', 'another:value' ],
   );
 
 </%doc>
@@ -79,6 +80,7 @@
           ID      = "<% $pre %>county"
           onChange= "<% $opt{'onchange'} %>"
           <% $opt{'disabled'} %>
+          <% $style %>
   >
 
 % unless ( $opt{'disable_empty'} ) {
@@ -123,6 +125,12 @@
 
 my $pre = $opt{'prefix'};
 
+$opt{'style'} ||= [];
+my $style =
+  scalar(@{$opt{style}})
+    ? 'STYLE="'. join(';', @{$opt{style}}). '"'
+    : '';
+
 my @counties = ();
 if ( $countyflag ) {
 

--- NEW FILE: location.html ---
<%doc>

Example:

  include( '/elements/location.html',
             'object'       => $cust_main,  # or $cust_location
             'prefix'       => $pre,        #only for cust_main objects
             'onchange'     => $javascript,
             'disabled'     => $disabled,
             'same_checked' => $same_checked,
             'geocode'      => $geocode, #passed through
             'no_asterisks' => 0, #set true to disable the red asterisks next
                                  #to required fields
         )

</%doc>

<TR>
  <TH ALIGN="right"><%$r%>Address</TH>
  <TD COLSPAN=7>
    <INPUT TYPE     = "text"
           NAME     = "<%$pre%>address1"
           VALUE    = "<% $object->get($pre.'address1') |h %>"
           SIZE     = 70
           onChange = "<% $onchange %>"
           <% $disabled %>
           <% $style %>
    >
  </TD>
</TR>

<TR>
  <TD ALIGN="right"><FONT ID="<% $pre %>address2_required" color="#ff0000" STYLE="<% $address2_label_style %>">*</FONT>&nbsp;<FONT ID="<% $pre %>address2_label" STYLE="<% $address2_label_style %>"><B>Unit&nbsp;#</B></FONT></TD>
  <TD COLSPAN=7>
    <INPUT TYPE     = "text"
           NAME     = "<%$pre%>address2"
           VALUE    = "<% $object->get($pre.'address2') |h %>"
           SIZE     = 70
           onChange = "<% $onchange %>"
           <% $disabled %>
           <% $style %>
    >
  </TD>
</TR>

<TR>
  <TH ALIGN="right"><%$r%>City</TH>
  <TD>
    <INPUT TYPE     = "text"
           NAME     = "<%$pre%>city"
           VALUE    = "<% $object->get($pre.'city') |h %>"
           onChange = "<% $onchange %>"
           <% $disabled %>
           <% $style %>
    >
  </TD>
  <TH ALIGN="right" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</TH>
  <TD>
    <% include('/elements/select-county.html', %select_hash ) %>
  </TD>
  <TH ALIGN="right"><%$r%>State</TH>
  <TD>
    <% include('/elements/select-state.html', %select_hash ) %>
  </TD>
  <TH><%$r%>Zip</TH>
  <TD>
    <INPUT TYPE     = "text"
           NAME     = "<%$pre%>zip"
           VALUE    = "<% $object->get($pre.'zip') |h %>"
           SIZE     = 10
           onChange = "<% $onchange %>"
           <% $disabled %>
           <% $style %>
    >
  </TD>
</TR>

<TR>
  <TH ALIGN="right"><%$r%>Country</TH>
  <TD COLSPAN=5><% include('/elements/select-country.html', %select_hash ) %></TD>
</TR>

% if ( !$pre ) { 
  <INPUT TYPE="hidden" NAME="geocode" VALUE="<% $opt{geocode} %>">
% } 

<%init>

my %opt = @_;

my $pre      = $opt{'prefix'};
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>&nbsp;!;

#false laziness with ship state
my $countrydefault = $conf->config('countrydefault') || 'US';
$object->set($pre.'country', $countrydefault )
  unless $object->get($pre.'country');

my $statedefault = $conf->config('statedefault')
                   || ($countrydefault eq 'US' ? 'CA' : '');
$object->set($pre.'state', $statedefault )
  unless $object->get($pre.'state')
         || $object->get($pre.'country') ne $countrydefault;

my @style = ();
push @style, 'background-color: #dddddd"' if $disabled;

my @address2_label_style = ();
push @address2_label_style, 'visibility:hidden'
  if $disabled
  || ! $conf->exists('cust_main-require_address2')
  || ( !$pre && !$opt{'same_checked'} );

my @counties = counties( $object->get($pre.'state'),
                         $object->get($pre.'country'),
                       );
my @county_style = ();
push @county_style, 'visibility:hidden'
  unless scalar(@counties) > 1;

my $style =
  scalar(@style)
    ? 'STYLE="'. join(';', @style). '"'
    : '';
my $address2_label_style =
  scalar(@address2_label_style)
    ? 'STYLE="'. join(';', @address2_label_style). '"'
    : '';
my $county_style = 
  scalar(@county_style)
    ? 'STYLE="'. join(';', @county_style). '"'
    : '';

my %select_hash = (
  'county'   => $object->get($pre.'county'),
  'state'    => $object->get($pre.'state'),
  'country'  => $object->get($pre.'country'),
  'prefix'   => $pre,
  'onchange' => $onchange,
  'disabled' => $disabled,
  'style'    => \@style,
);

</%init>



More information about the freeside-commits mailing list