[freeside-commits] freeside/httemplate/elements tr-input-text.html, 1.4, 1.5 input-text.html, NONE, 1.1 tr-select-did.html, NONE, 1.1 select-state.html, NONE, 1.1 select-phonenum.html, NONE, 1.1 select-areacode.html, NONE, 1.1 select-exchange.html, NONE, 1.1 select-did.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Sat Jun 28 16:03:11 PDT 2008
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv26113/httemplate/elements
Modified Files:
tr-input-text.html
Added Files:
input-text.html tr-select-did.html select-state.html
select-phonenum.html select-areacode.html select-exchange.html
select-did.html
Log Message:
get DIDs from globalpops
--- NEW FILE: select-phonenum.html ---
<% include('/elements/xmlhttp.html',
'url' => $p.'misc/phonenums.cgi',
'subs' => [ $opt{'prefix'}. 'get_phonenums' ],
)
%>
<SCRIPT TYPE="text/javascript">
function opt(what,value,text) {
var optionName = new Option(text, value, false, false);
var length = what.length;
what.options[length] = optionName;
}
function <% $opt{'prefix'} %>exchange_changed(what, callback) {
what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
what.form.<% $opt{'prefix'} %>phonenum.style.display = 'none';
var phonenumwait = document.getElementById('<% $opt{'prefix'} %>phonenumwait');
phonenumwait.style.display = '';
var phonenumerror = document.getElementById('<% $opt{'prefix'} %>phonenumerror');
phonenumerror.style.display = 'none';
exchange = what.options[what.selectedIndex].value;
function <% $opt{'prefix'} %>update_phonenums(phonenums) {
// blank the current phonenum
for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
% if ($opt{empty}) {
opt(what.form.<% $opt{'prefix'} %>phonenum, '', '<% $opt{empty} %>');
% }
// add the new phonenums
var phonenumArray = eval('(' + phonenums + ')' );
for ( var s = 0; s < phonenumArray.length; s++ ) {
var phonenumLabel = phonenumArray[s];
if ( phonenumLabel == "" )
phonenumLabel = '(n/a)';
opt(what.form.<% $opt{'prefix'} %>phonenum, phonenumArray[s], phonenumLabel);
}
//var phonenumFormLabel = document.getElementById('<% $opt{'prefix'} %>phonenumlabel');
what.form.<% $opt{'prefix'} %>phonenum.disabled = '';
phonenumwait.style.display = 'none';
if ( phonenumArray.length >= 1 ) {
what.form.<% $opt{'prefix'} %>phonenum.disabled = '';
what.form.<% $opt{'prefix'} %>phonenum.style.display = '';
} else {
var phonenumerror = document.getElementById('<% $opt{'prefix'} %>phonenumerror');
phonenumerror.style.display = '';
}
//run the callback
if ( callback != null )
callback();
}
// go get the new phonenums
<% $opt{'prefix'} %>get_phonenums( exchange, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_phonenums );
}
</SCRIPT>
<DIV ID="phonenumwait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding phone numbers</B></DIV>
<DIV ID="phonenumerror" STYLE="display:none"><IMG SRC="<%$fsurl%>images/cross.png"> <B>Select a different city/exchange</B></DIV>
<SELECT NAME="<% $opt{'prefix'} %>phonenum" onChange="<% $opt{'prefix'} %>phonenum_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
<OPTION VALUE="">Select phone number</OPTION>
</SELECT>
<%init>
my %opt = @_;
$opt{disabled} = 'disabled' unless exists $opt{disabled};
</%init>
--- NEW FILE: input-text.html ---
<% $opt{'prefix'} %><INPUT TYPE = "<% $opt{type} || 'text' %>"
NAME = "<% $opt{field} %>"
ID = "<% $opt{id} %>"
VALUE = "<% $value |h %>"
<% $size %>
<% $maxlength %>
<% $style %>
<% $opt{disabled} %>
<% $onchange %>
><% $opt{'postfix'} %>
<%init>
my %opt = @_;
my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value};
my $onchange = $opt{'onchange'}
? 'onChange="'. $opt{'onchange'}. '(this)"'
: '';
my $size = $opt{'size'}
? 'SIZE="'. $opt{'size'}. '"'
: '';
my $maxlength = $opt{'maxlength'}
? 'MAXLENGTH="'. $opt{'maxlength'}. '"'
: '';
$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
if ref($opt{'disabled'}) eq 'CODE';
$opt{'disabled'} = 'DISABLED'
if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
my @style = ();
push @style, 'text-align: '. $opt{'text-align'}
if $opt{'text-align'};
push @style, 'background-color: #dddddd'
if $opt{'disabled'};
my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
</%init>
--- NEW FILE: select-exchange.html ---
<% include('/elements/xmlhttp.html',
'url' => $p.'misc/exchanges.cgi',
'subs' => [ $opt{'prefix'}. 'get_exchanges' ],
)
%>
<SCRIPT TYPE="text/javascript">
function opt(what,value,text) {
var optionName = new Option(text, value, false, false);
var length = what.length;
what.options[length] = optionName;
}
function <% $opt{'prefix'} %>areacode_changed(what, callback) {
what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
what.form.<% $opt{'prefix'} %>exchange.style.display = 'none';
var exchangewait = document.getElementById('<% $opt{'prefix'} %>exchangewait');
exchangewait.style.display = '';
var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
exchangeerror.style.display = 'none';
what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
areacode = what.options[what.selectedIndex].value;
function <% $opt{'prefix'} %>update_exchanges(exchanges) {
// blank the current exchange
for ( var i = what.form.<% $opt{'prefix'} %>exchange.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>exchange.options[i] = null;
// blank the current phonenum too
for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number');
% if ($opt{empty}) {
opt(what.form.<% $opt{'prefix'} %>exchange, '', '<% $opt{empty} %>');
% }
// add the new exchanges
var exchangeArray = eval('(' + exchanges + ')' );
for ( var s = 0; s < exchangeArray.length; s++ ) {
var exchangeLabel = exchangeArray[s];
if ( exchangeLabel == "" )
exchangeLabel = '(n/a)';
opt(what.form.<% $opt{'prefix'} %>exchange, exchangeArray[s], exchangeLabel);
}
exchangewait.style.display = 'none';
if ( exchangeArray.length >= 1 ) {
what.form.<% $opt{'prefix'} %>exchange.disabled = '';
what.form.<% $opt{'prefix'} %>exchange.style.display = '';
} else {
var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
exchangeerror.style.display = '';
}
//run the callback
if ( callback != null )
callback();
}
// go get the new exchanges
<% $opt{'prefix'} %>get_exchanges( areacode, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_exchanges );
}
</SCRIPT>
<DIV ID="exchangewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding cities / exchanges</B></DIV>
<DIV ID="exchangeerror" STYLE="display:none"><IMG SRC="<%$fsurl%>images/cross.png"> <B>Select a different area code</B></DIV>
<SELECT NAME="<% $opt{'prefix'} %>exchange" onChange="<% $opt{'prefix'} %>exchange_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
<OPTION VALUE="">Select city / exchange</OPTION>
</SELECT>
<%init>
my %opt = @_;
$opt{disabled} = 'disabled' unless exists $opt{disabled};
</%init>
--- NEW FILE: select-state.html ---
<SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
% if ($opt{empty}) {
<OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty} %>
% }
% foreach my $state ( keys %states ) {
<OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %>
% }
</SELECT>
<%init>
my %opt = @_;
foreach my $opt (qw( county state country prefix onchange disabled empty )) {
$opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
}
tie my %states, 'Tie::IxHash', states_hash( $opt{'country'} );
</%init>
Index: tr-input-text.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-input-text.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- tr-input-text.html 15 Apr 2008 13:42:40 -0000 1.4
+++ tr-input-text.html 28 Jun 2008 23:03:09 -0000 1.5
@@ -1,19 +1,6 @@
<% include('tr-td-label.html', @_ ) %>
- <TD <% $cell_style %>>
-
- <% $opt{'prefix'} %><INPUT TYPE = "<% $opt{type} || 'text' %>"
- NAME = "<% $opt{field} %>"
- ID = "<% $opt{id} %>"
- VALUE = "<% $value |h %>"
- <% $size %>
- <% $maxlength %>
- <% $style %>
- <% $opt{disabled} %>
- <% $onchange %>
- ><% $opt{'postfix'} %>
-
- </TD>
+ <TD <% $cell_style %>><% include('input-text.html', @_ ) %></TD>
</TR>
@@ -21,35 +8,6 @@
my %opt = @_;
-my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value};
-
-my $onchange = $opt{'onchange'}
- ? 'onChange="'. $opt{'onchange'}. '(this)"'
- : '';
-
-my $size = $opt{'size'}
- ? 'SIZE="'. $opt{'size'}. '"'
- : '';
-
-my $maxlength = $opt{'maxlength'}
- ? 'MAXLENGTH="'. $opt{'maxlength'}. '"'
- : '';
-
-$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
- if ref($opt{'disabled'}) eq 'CODE';
-$opt{'disabled'} = 'DISABLED'
- if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
-
-my @style = ();
-
-push @style, 'text-align: '. $opt{'text-align'}
- if $opt{'text-align'};
-
-push @style, 'background-color: #dddddd'
- if $opt{'disabled'};
-
-my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
-
my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
</%init>
--- NEW FILE: select-did.html ---
<%doc>
Example:
include('/elements/select-did.html',
'field' => 'phonenum',
'svcpart' => 5,
);
</%doc>
% if ( $use_selector ) {
<TABLE>
<TR>
<TD>
<% include('/elements/select-state.html',
'country' => $country,
'empty' => 'Select state',
)
%>
</TD>
<TD>
<% include('/elements/select-areacode.html',
'svcpart' => $svcpart,
'empty' => 'Select area code',
)
%>
</TD>
<TD>
<% include('/elements/select-exchange.html',
'svcpart' => $svcpart,
'empty' => 'Select exchange',
)
%>
</TD>
<TD>
<% include('/elements/select-phonenum.html',
'svcpart' => $svcpart,
'empty' => 'Select phone number',
)
%>
</TD>
</TR>
<TR>
<TD><FONT SIZE="-1">State</FONT></TD>
<TD><FONT SIZE="-1">Area code</FONT></TD>
<TD><FONT SIZE="-1">City / Exchange</FONT></TD>
<TD><FONT SIZE="-1">Phone number</FONT></TD>
</TR>
</TABLE>
% } else {
<% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
% }
<%init>
my %opt = @_;
my $conf = new FS::Conf;
my $country = $conf->config('countrydefault') || 'US';
#XXX make sure this comes through on errors too
my $svcpart = $opt{'object'}->svcpart;
my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
die "unknown svcpart $svcpart" unless $part_svc;
my @exports = $part_svc->part_export_did;
if ( scalar(@exports) > 1 ) {
die "more than one DID-providing export attached to svcpart $svcpart";
}
my $use_selector = scalar(@exports) ? 1 : 0;
</%init>
--- NEW FILE: tr-select-did.html ---
<% include('tr-td-label.html', @_ ) %>
% if ( $opt{'curr_value'} ne '' ) {
<TD BGCOLOR="#dddddd" <% $cell_style %>><% $opt{'formatted_value'} || $opt{'curr_value'} || $opt{'value'} |h %></TD>
% } else {
<TD <% $cell_style %>>
<% include('/elements/select-did.html', %opt ) %>
</TD>
% }
</TR>
<%init>
my %opt = @_;
my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
</%init>
--- NEW FILE: select-areacode.html ---
<% include('/elements/xmlhttp.html',
'url' => $p.'misc/areacodes.cgi',
'subs' => [ $opt{'prefix'}. 'get_areacodes' ],
)
%>
<SCRIPT TYPE="text/javascript">
function opt(what,value,text) {
var optionName = new Option(text, value, false, false);
var length = what.length;
what.options[length] = optionName;
}
function <% $opt{'prefix'} %>state_changed(what, callback) {
what.form.<% $opt{'prefix'} %>areacode.disabled = 'disabled';
what.form.<% $opt{'prefix'} %>areacode.style.display = 'none';
var areacodewait = document.getElementById('<% $opt{'prefix'} %>areacodewait');
areacodewait.style.display = '';
var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
areacodeerror.style.display = 'none';
what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
state = what.options[what.selectedIndex].value;
function <% $opt{'prefix'} %>update_areacodes(areacodes) {
// blank the current areacode
for ( var i = what.form.<% $opt{'prefix'} %>areacode.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>areacode.options[i] = null;
// blank the current exchange too
for ( var i = what.form.<% $opt{'prefix'} %>exchange.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>exchange.options[i] = null;
opt(what.form.<% $opt{'prefix'} %>exchange, '', 'Select city / exchange');
// blank the current phonenum too
for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number');
% if ($opt{empty}) {
opt(what.form.<% $opt{'prefix'} %>areacode, '', '<% $opt{empty} %>');
% }
// add the new areacodes
var areacodeArray = eval('(' + areacodes + ')' );
for ( var s = 0; s < areacodeArray.length; s++ ) {
var areacodeLabel = areacodeArray[s];
if ( areacodeLabel == "" )
areacodeLabel = '(n/a)';
opt(what.form.<% $opt{'prefix'} %>areacode, areacodeArray[s], areacodeLabel);
}
areacodewait.style.display = 'none';
if ( areacodeArray.length >= 1 ) {
what.form.<% $opt{'prefix'} %>areacode.disabled = '';
what.form.<% $opt{'prefix'} %>areacode.style.display = '';
} else {
var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
areacodeerror.style.display = '';
}
//run the callback
if ( callback != null )
callback();
}
// go get the new areacodes
<% $opt{'prefix'} %>get_areacodes( state, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_areacodes );
}
</SCRIPT>
<DIV ID="areacodewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding area codes</B></DIV>
<DIV ID="areacodeerror" STYLE="display:none"><IMG SRC="<%$fsurl%>images/cross.png"> <B>Select a different state</B></DIV>
<SELECT NAME="<% $opt{'prefix'} %>areacode" onChange="<% $opt{'prefix'} %>areacode_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
<OPTION VALUE="">Select area code</OPTION>
</SELECT>
<%init>
my %opt = @_;
$opt{disabled} = 'disabled' unless exists $opt{disabled};
</%init>
More information about the freeside-commits
mailing list