summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/location.html150
-rw-r--r--httemplate/elements/select-country.html9
-rw-r--r--httemplate/elements/select-county.html8
-rw-r--r--httemplate/elements/select-state.html9
-rw-r--r--httemplate/elements/tr-select-part_referral.html4
5 files changed, 178 insertions, 2 deletions
diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html
new file mode 100644
index 000000000..bf340894a
--- /dev/null
+++ b/httemplate/elements/location.html
@@ -0,0 +1,150 @@
+<%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>
diff --git a/httemplate/elements/select-country.html b/httemplate/elements/select-country.html
index c4368c271..45b0ccd5f 100644
--- a/httemplate/elements/select-country.html
+++ b/httemplate/elements/select-country.html
@@ -13,7 +13,7 @@ Example:
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 @@ Example:
ID = "<% $pre %>country"
onChange = "<% $onchange %>"
<% $opt{'disabled'} %>
+ <% $style %>
>
% unless ( $opt{'disable_empty'} ) {
@@ -101,6 +102,12 @@ my $onchange =
( $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';
diff --git a/httemplate/elements/select-county.html b/httemplate/elements/select-county.html
index 8ef34dbe6..59f235a23 100644
--- a/httemplate/elements/select-county.html
+++ b/httemplate/elements/select-county.html
@@ -14,6 +14,7 @@ Example:
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 @@ Example:
ID = "<% $pre %>county"
onChange= "<% $opt{'onchange'} %>"
<% $opt{'disabled'} %>
+ <% $style %>
>
% unless ( $opt{'disable_empty'} ) {
@@ -123,6 +125,12 @@ $opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'});
my $pre = $opt{'prefix'};
+$opt{'style'} ||= [];
+my $style =
+ scalar(@{$opt{style}})
+ ? 'STYLE="'. join(';', @{$opt{style}}). '"'
+ : '';
+
my @counties = ();
if ( $countyflag ) {
diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html
index f7ac2c7bf..9b358e24d 100644
--- a/httemplate/elements/select-state.html
+++ b/httemplate/elements/select-state.html
@@ -14,6 +14,7 @@ Example:
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 @@ Example:
<SELECT NAME = "<% $pre %>state"
ID = "<% $pre %>state"
onChange = "<% $onchange %>"
+ <% $opt{'disabled'} %>
+ <% $style %>
>
% unless ( $opt{'disable_empty'} ) {
@@ -51,6 +54,12 @@ my $onchange =
( $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>
diff --git a/httemplate/elements/tr-select-part_referral.html b/httemplate/elements/tr-select-part_referral.html
index 62795e9b2..a589528d7 100644
--- a/httemplate/elements/tr-select-part_referral.html
+++ b/httemplate/elements/tr-select-part_referral.html
@@ -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 @@ my $refnum = $opt{'curr_value'} || $opt{'value'};
$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>