summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/cust_payby_new.html222
-rw-r--r--httemplate/elements/link-replace_element_text.html45
-rw-r--r--httemplate/elements/tr-select-cust_payby.html2
-rw-r--r--httemplate/elements/tr-select-router_block_ip.html128
4 files changed, 373 insertions, 24 deletions
diff --git a/httemplate/elements/cust_payby_new.html b/httemplate/elements/cust_payby_new.html
new file mode 100644
index 000000000..7ed049686
--- /dev/null
+++ b/httemplate/elements/cust_payby_new.html
@@ -0,0 +1,222 @@
+% my $auto = 0;
+% if ( $payby eq 'CARD' ) {
+%
+% my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
+% my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
+% my $location = $cust_main->bill_location;
+
+ <TR>
+ <TH ALIGN="right"><% mt('Card number') |h %></TH>
+ <TD COLSPAN=7>
+ <TABLE>
+ <TR>
+ <TD>
+ <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
+ <TH><% mt('Exp.') |h %></TH>
+ <TD>
+ <SELECT NAME="month">
+% for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
+
+ <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
+% }
+
+ </SELECT>
+ </TD>
+ <TD> / </TD>
+ <TD>
+ <SELECT NAME="year">
+% my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
+
+ <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
+% }
+
+ </SELECT>
+ </TD>
+ </TR>
+ </TABLE>
+ </TD>
+ </TR>
+ <TR>
+ <TH ALIGN="right"><% mt('CVV2') |h %></TH>
+ <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
+ (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>)
+ </TD>
+ </TR>
+ <TR>
+ <TH ALIGN="right"><% mt('Exact name on card') |h %></TH>
+ <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
+ </TR>
+
+ <& /elements/location.html,
+ 'object' => $location,
+ 'no_asterisks' => 1,
+ 'address1_label' => emt('Card billing address'),
+ &>
+
+% } elsif ( $payby eq 'CHEK' ) {
+%
+% my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
+% $stateid, $stateid_state )
+% = ( '', '', '', '', '', '', '', '', '' );
+%
+% #false laziness w/{edit,view}/cust_main/billing.html
+% my $routing_label = $conf->config('echeck-country') eq 'US'
+% ? 'ABA/Routing number'
+% : 'Routing number';
+% my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
+% my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
+
+ <INPUT TYPE="hidden" NAME="month" VALUE="12">
+ <INPUT TYPE="hidden" NAME="year" VALUE="2037">
+ <TR>
+ <TD ALIGN="right"><% mt('Account number') |h %></TD>
+ <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
+ <TD ALIGN="right"><% mt('Type') |h %></TD>
+ <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } FS::cust_payby->paytypes) %></SELECT></TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt($routing_label) |h %></TD>
+ <TD>
+ <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>">
+ (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>)
+ </TD>
+ </TR>
+% if ( $conf->config('echeck-country') eq 'CA' ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Branch number') |h %></TD>
+ <TD>
+ <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5>
+ </TD>
+ </TR>
+% }
+ <TR>
+ <TD ALIGN="right"><% mt('Bank name') |h %></TD>
+ <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
+ </TR>
+
+% if ( $conf->exists('show_bankstate') ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Bank state') |h %></TD>
+ <TD><& /elements/select-state.html,
+ 'disable_empty' => 0,
+ 'empty_label' => emt('(choose)'),
+ 'state' => $paystate,
+ 'country' => $cust_main->country,
+ 'prefix' => 'pay',
+ &>
+ </TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
+% }
+
+% if ( $conf->exists('show_ss') ) {
+ <TR>
+ <TD ALIGN="right">
+ <% mt('Account holder') |h %><BR>
+ <% mt('Social security or tax ID #') |h %>
+ </TD>
+ <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
+% }
+
+% if ( $conf->exists('show_stateid') ) {
+ <TR>
+ <TD ALIGN="right">
+ <% mt('Account holder') |h %><BR>
+ <% mt("Driver's license or state ID #") |h %>
+ </TD>
+ <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
+ <TD ALIGN="right"><% mt('State') |h %></TD>
+ <TD><& /elements/select-state.html,
+ 'disable_empty' => 0,
+ 'empty_label' => emt('(choose)'),
+ 'state' => $stateid_state,
+ 'country' => $cust_main->country,
+ 'prefix' => 'stateid_',
+ &>
+ </TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
+ <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
+% }
+
+% } #end CARD/CHEK-specific section
+
+
+<TR>
+ <TD COLSPAN=8>
+ <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
+ <% mt('Remember this information') |h %>
+ </TD>
+</TR>
+
+<TR>
+ <TD COLSPAN=8>
+ <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
+ <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %>
+% if ( @cust_payby ) {
+ <% mt('as') |h %>
+ <SELECT NAME="weight">
+% for ( 1 .. 1+scalar(grep { $_->payby =~ /^(CARD|CHEK)$/ } @cust_payby) ) {
+ <OPTION VALUE="<%$_%>"><% mt( $weight{$_} ) |h %>
+% }
+ </SELECT>
+% } else {
+ <INPUT TYPE="hidden" NAME="weight" VALUE="1">
+% }
+ </TD>
+</TR>
+
+<%once>
+
+my %weight = (
+ 1 => 'Primary',
+ 2 => 'Secondary',
+ 3 => 'Tertiary',
+ 4 => 'Fourth',
+ 5 => 'Fifth',
+ 6 => 'Sixth',
+ 7 => 'Seventh',
+);
+
+</%once>
+
+<%init>
+
+my %opt = @_;
+
+my @cust_payby = @{$opt{cust_payby}};
+
+my %type = ( 'CARD' => 'credit card',
+ 'CHEK' => 'electronic check (ACH)',
+ );
+
+$cgi->param('payby') =~ /^(CARD|CHEK)$/
+ or die "unknown payby ". $cgi->param('payby');
+my $payby = $1;
+
+$cgi->param('custnum') =~ /^(\d+)$/
+ or die "illegal custnum ". $cgi->param('custnum');
+my $custnum = $1;
+
+my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
+die "unknown custnum $custnum" unless $cust_main;
+
+my $balance = $cust_main->balance;
+
+my $payinfo = '';
+
+my $conf = new FS::Conf;
+
+#false laziness w/selfservice make_payment.html shortcut for one-country
+my %states = map { $_->state => 1 }
+ qsearch('cust_main_county', {
+ 'country' => $conf->config('countrydefault') || 'US'
+ } );
+my @states = sort { $a cmp $b } keys %states;
+
+</%init> \ No newline at end of file
diff --git a/httemplate/elements/link-replace_element_text.html b/httemplate/elements/link-replace_element_text.html
new file mode 100644
index 000000000..8e611954c
--- /dev/null
+++ b/httemplate/elements/link-replace_element_text.html
@@ -0,0 +1,45 @@
+<%doc>
+
+Display a link with javascript to replace text within a element.
+
+Usage:
+
+<& /elements/link-replace_element_text.html, {
+ target_id => 'input_id',
+ replace_text => 'hello',
+
+ element_type => 'input', # Uses jquery val() method to replace text
+ element_type => 'div', # Uses jquery text() method to replace text
+
+ href => ...
+ style => ...
+ class => ...
+ }
+&>
+
+</%doc>
+<a href="<% $param{href} %>"
+ style="<% $param{style} %>"
+% if ($param{class}) {
+ class="<% $param{class} %>"
+% }
+ onClick="$('#<% $param{target_id} %>').<% $param{jmethod} %>('<% $param{replace_text} |h %>');">&#x25C1;</a>
+<%init>
+
+die "template call requires a parameter hashref" unless ref $_[0];
+
+# Defaults that can be overridden in param hashref
+my %param = (
+ target_id => 'SPECIFY_AN_INPUT_ELEMENT_ID',
+ replace_text => 'REPLACEMENT_TEXT_FOR_INPUT_ELEMENT',
+ element_type => 'input',
+
+ link_text => '%#x25C1;', # ◁
+ href => 'javascript:void(0)',
+ style => 'text-decoration:none;',
+ class => undef,
+
+ %{ $_[0] },
+);
+$param{jmethod} = $param{element_type} eq 'input' ? 'val' : 'text';
+</%init>
diff --git a/httemplate/elements/tr-select-cust_payby.html b/httemplate/elements/tr-select-cust_payby.html
index e2b2e09d1..e5ace4d39 100644
--- a/httemplate/elements/tr-select-cust_payby.html
+++ b/httemplate/elements/tr-select-cust_payby.html
@@ -1,4 +1,4 @@
-% if ( scalar(@{ $opt{'cust_payby'} }) == 0 ) {
+% if ( scalar(@{ $opt{'cust_payby'} }) == 0 ) {
<INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'custpaybynum' %>" VALUE="">
diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html
index 2aa715e29..72640d3d5 100644
--- a/httemplate/elements/tr-select-router_block_ip.html
+++ b/httemplate/elements/tr-select-router_block_ip.html
@@ -2,34 +2,110 @@
var manual_addr_routernum = <% encode_json(\%manual_addr_routernum) %>;
var ip_addr_curr_value = <% $opt{'ip_addr'} |js_string %>;
var blocknum_curr_value = <% $opt{'blocknum'} |js_string %>;
-function update_ip_addr(obj, i) {
- var routernum = document.getElementById('router_select_0').value;
- var select_blocknum = document.getElementById('router_select_1');
- var blocknum = select_blocknum.value;
- var input_ip_addr = document.getElementById('input_ip_addr');
+
+function update_ip_addr() {
+ var routernum = $('#router_select_0').val() || "";
+ var blocknum = $('#router_select_1').val() || "";
+ var e_input_ip_addr = $('#input_ip_addr');
+ var e_router_select_1 = $('#router_select_1');
+
+ <% # Is block is automatically selected for this router? %>
if ( manual_addr_routernum[routernum] == 'Y' ) {
-%# hide block selection and default ip address to its previous value
- select_blocknum.style.display = 'none';
- input_ip_addr.value = ip_addr_curr_value;
- }
- else {
-%# the reverse
- select_blocknum.style.display = '';
-%# default ip address to null, unless the router/block are set to the
-%# previous value, in which case default it to current value
+ show_ip_input();
+ hide_ip_select();
+ e_router_select_1.hide();
+ e_input_ip_addr.val( ip_addr_curr_value );
+ } else {
+ e_router_select_1.show();
+ e_input_ip_addr.attr('placeholder', <% mt('(automatic)') | js_string %> );
if ( routernum == router_curr_values[0] &&
- blocknum == router_curr_values[1] ) {
- input_ip_addr.value = ip_addr_curr_value;
+ blocknum == router_curr_values[1] ) {
+ e_input_ip_addr.val( ip_addr_curr_value );
} else {
- input_ip_addr.value = <% mt('(automatic)') |js_string %>;
+ e_input_ip_addr.val('');
}
}
+ show_or_hide_toggle_ip();
+ populate_ip_select();
+}
+
+function toggle_ip_input() {
+ if ( $('#input_ip_addr').is(':hidden') ) {
+ show_ip_input();
+ } else {
+ show_ip_select();
+ }
+}
+
+function show_ip_input() {
+ $('#input_ip_addr').show();
+ $('#select_ip_addr').hide();
+ depopulate_ip_select();
+}
+
+function show_ip_select() {
+ var e_input_ip_addr = $('#input_ip_addr');
+ var e_select_ip_addr = $('#select_ip_addr');
+
+ e_select_ip_addr.width( e_input_ip_addr.width() );
+ e_input_ip_addr.hide();
+ e_select_ip_addr.show();
+ populate_ip_select();
+}
+
+function populate_ip_select() {
+ depopulate_ip_select();
+ var e = $('#select_ip_addr');
+ var blocknum = $('#router_select_1').val();
+
+ var opts = [ '<option value="">loading...</option>' ];
+ e.html(opts.join(''));
+
+% if ( $opt{ip_addr} ) {
+ opts = [
+ '<option value="<% $opt{ip_addr} |h %>"><% $opt{ip_addr} |h %></option>',
+ '<option value="">-----------</option>'
+ ];
+% } else {
+ opts = [ '<option value=""><% mt('(automatic)') |h %></option>' ];
+% }
+ if ( blocknum && $.isNumeric(blocknum) && ! e.is(':hidden')) {
+ $.getJSON(
+ '<% $p %>misc/xmlhttp-free_addresses_in_block.json.html',
+ {blocknum: blocknum},
+ function(ip_json) {
+ $.each( ip_json, function(idx, val) {
+ opts.push(
+ '<option' + (val == ip_addr_curr_value ? 'selected' : '') + '>'
+ + val
+ + '</option>'
+ );
+ });
+ e.html(opts.join(''));
+ }
+ );
+ }
}
-function clearhint_ip_addr (what) {
- if ( what.value == <% mt('(automatic)') |js_string %> )
- what.value = '';
+
+function depopulate_ip_select() {
+ $('#select_ip_addr').children().remove();
}
+
+function propogate_ip_select() {
+ $('#input_ip_addr').val( $('#select_ip_addr').val() );
+}
+
+function show_or_hide_toggle_ip() {
+ if ( $('#router_select_1').val() ) {
+ $('#toggle_ip').show();
+ } else {
+ show_ip_input();
+ $('#toggle_ip').hide();
+ }
+}
+
</script>
+
<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router'), required => $opt{'required'} &>
<td>
<& /elements/select-tiered.html, prefix => 'router_', tiers => [
@@ -58,14 +134,20 @@ function clearhint_ip_addr (what) {
</td></tr>
<& /elements/tr-td-label.html, label => ($opt{'ip_addr_label'} || 'IP address'), required => $opt{'ip_addr_required'} &>
<td>
-% #warn Dumper \%fixed;
% if ( exists $fixed{$ip_field} ) {
<input type="hidden" id="input_ip_addr" name="<% $ip_field %>"
value="<% $opt{'ip_addr'} |h%>"><% $opt{'ip_addr'} || '' %>
% }
% else {
- <input type="text" id="input_ip_addr" name="<% $ip_field %>"
- value="<% $opt{'ip_addr'} |h%>" onfocus="clearhint_ip_addr(this)">
+ <input type="text"
+ id="input_ip_addr"
+ name="<% $ip_field %>"
+ value="<% $opt{'ip_addr'} | h %>"
+ onfocus="clearhint_ip_addr(this)">
+ <select id="select_ip_addr" style="display: none;" onChange='javascript:propogate_ip_select();'>
+ <option><% mt('loading') |h %>...</option>
+ </select>
+ <button type="button" onClick='javascript:toggle_ip_input();' id="toggle_ip" style="display: none;">&#9660;</button>
% }
</td> </tr>
<script type="text/javascript">