diff options
Diffstat (limited to 'httemplate/elements')
22 files changed, 696 insertions, 175 deletions
diff --git a/httemplate/elements/broadband_snmp_get.html b/httemplate/elements/broadband_snmp_get.html index 213bc4460..1164504ee 100644 --- a/httemplate/elements/broadband_snmp_get.html +++ b/httemplate/elements/broadband_snmp_get.html @@ -26,7 +26,7 @@ function broadband_snmp_get (svcnum) { if (obj.error) { var row = document.createElement('tr'); var cell = document.createElement('td'); - cell.colSpan = '2'; + cell.colSpan = '3'; cell.innerHTML = obj['error']; row.appendChild(cell); table.appendChild(row); @@ -36,6 +36,9 @@ function broadband_snmp_get (svcnum) { var value = obj['values'][j]; var label = (obj['values'].length > 1) ? (value[0] + '.' + value[1]) : obj['label']; var cell = document.createElement('td'); + cell.innerHTML = obj['name']; + row.appendChild(cell); + cell = document.createElement('td'); cell.innerHTML = label; row.appendChild(cell); cell = document.createElement('td'); diff --git a/httemplate/elements/change_password.html b/httemplate/elements/change_password.html index 7d95e19dc..068d7d73c 100644 --- a/httemplate/elements/change_password.html +++ b/httemplate/elements/change_password.html @@ -11,9 +11,9 @@ % if (!$opt{'no_label_display'}) { <A ID="<%$pre%>link" HREF="javascript:void(0)" onclick="<%$pre%>toggle(true)">(<% emt( $change_title ) %>)</A> % } -<DIV ID="<%$pre%>form" CLASS="passwordbox"> +<DIV ID="<%$pre%>div" CLASS="passwordbox"> % if (!$opt{'noformtag'}) { - <FORM METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return checkPasswordValidation()"> + <FORM ID="<%$pre%>form" METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return <%$pre%>checkPasswordValidation()"> % } <% $change_id_input %> @@ -44,11 +44,9 @@ function <%$pre%>toggle(toggle, clear) { if (clear) { document.getElementById('<%$pre%>password').value = ''; document.getElementById('<%$pre%>password_result').innerHTML = ''; -% if ($opt{'contact_num'}) { - document.getElementById('<% $opt{'pre_pwd_field_label'} %>selfservice_access').value = 'Y'; -% } -} - document.getElementById('<%$pre%>form').style.display = + document.getElementById('<%$change_button_id%>').disabled = true; + } + document.getElementById('<%$pre%>div').style.display = toggle ? 'inline-block' : 'none'; % if (!$opt{'no_label_display'}) { document.getElementById('<%$pre%>link').style.display = @@ -56,7 +54,7 @@ function <%$pre%>toggle(toggle, clear) { % } } -function checkPasswordValidation() { +function <%$pre%>checkPasswordValidation(resultId) { var validationResult = document.getElementById('<%$pre%>password_result').innerHTML; if (validationResult.match(/Password valid!/)) { return true; @@ -83,8 +81,8 @@ if ($opt{'svc_acct'}) { } elsif ($opt{'contact_num'}) { $change_id_input = ' - <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'contactnum" VALUE="' . $opt{'contact_num'} . '"> - <INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'custnum" VALUE="' . $opt{'custnum'} . '"> + <INPUT TYPE="hidden" NAME="contactnum" VALUE="' . $opt{'contact_num'} . '"> + <INPUT TYPE="hidden" NAME="custnum" VALUE="' . $opt{'custnum'} . '"> '; $pre .= $opt{'pre_pwd_field_label'}; } diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html index 4e9a60940..05250fef5 100644 --- a/httemplate/elements/city.html +++ b/httemplate/elements/city.html @@ -132,14 +132,14 @@ function <% $pre %>county_changed(what, callback) {} > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE="" <% $opt{city} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %> + <OPTION VALUE="" <% $opt{city} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %></OPTION> % } % foreach my $city ( @cities ) { <OPTION VALUE="<% $city |h %>" <% $city eq $opt{city} ? 'SELECTED' : '' %> - ><% $city eq $opt{empty_data_value} ? $opt{empty_data_label} : $city %> + ><% $city eq $opt{empty_data_value} ? $opt{empty_data_label} : $city %></OPTION> % } diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html index 43e520155..48b5e2ce2 100644 --- a/httemplate/elements/contact.html +++ b/httemplate/elements/contact.html @@ -1,4 +1,6 @@ -% unless ( $opt{'js_only'} ) { +% if ( $opt{'js_only'} ) { +<% $js %> +% } else { <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>"> @@ -40,6 +42,8 @@ % } % } elsif ( $field eq 'emailaddress' ) { % $value = join(', ', map $_->emailaddress, $contact->contact_email); +% } elsif ( $field eq 'password' ) { +% $value = $contact->get('_password') ? '********' : ''; % } elsif ( $field eq 'selfservice_access' % or $field eq 'comment' % or $field eq 'invoice_dest' @@ -56,28 +60,25 @@ ID = "<%$id%>_<%$field%>" STYLE = "width: 140px" > - <OPTION VALUE="">Disabled + <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled % if ( $value || $self_base_url ) { <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled % if ( $value eq 'Y' && $self_base_url ) { <OPTION VALUE="R">Re-email - <OPTION VALUE="P"><% $pwd_change_label %> % } % } </SELECT> - <& /elements/change_password.html, - 'contact_num' => $curr_value, - 'custnum' => $opt{'custnum'}, - 'curr_value' => '', - 'no_label_display' => '1', - 'noformtag' => '1', - 'pre_pwd_field_label' => $id.'_', - &> - <SCRIPT TYPE="text/javascript"> - document.getElementById("<%$id%>_<%$field%>").onchange = function() { - if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); } - return false - } +% #password form +% } elsif ( $field eq 'password') { + <INPUT TYPE = "text" + NAME = "<%$name%>_<%$field%>" + ID = "changepw<%$id%>_<%$field%>" + SIZE = "<% $size{$field} || 14 %>" + VALUE = "" + placeholder = "<% $value |h %>" + > + <SCRIPT> + <% $js %> </SCRIPT> % } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) { % my $curr_value = $cgi->param($name . '_' . $field); @@ -101,6 +102,9 @@ % } <BR> <FONT SIZE="-1"><% $label{$field} %></FONT> +% if ( $field eq 'password' ) { + <DIV ID="changepw<%$id%>_<%$field%>_result" STYLE="font-size: smaller"></DIV> +% } </TD> % } </TR> @@ -119,6 +123,7 @@ my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum'; my $id = $opt{'id'} || 'contactnum'; my $curr_value = $opt{'curr_value'} || $opt{'value'}; +my $contactnum = $curr_value ? $curr_value : '0'; my $onchange = ''; if ( $opt{'onchange'} ) { @@ -171,6 +176,7 @@ unless ($opt{'for_prospect'}) { $label{'invoice_dest'} = 'Send invoices'; $label{'message_dest'} = 'Send messages'; $label{'selfservice_access'} = 'Self-service'; + $label{'password'} = 'Password'; } my $first = 0; @@ -185,7 +191,21 @@ $label{'comment'} = 'Comment'; my @fields = $opt{'name_only'} ? qw( first last ) : keys %label; -my $pwd_change_label = 'Change Password'; -$pwd_change_label = 'Setup Password' unless $contact->_password; +my $submitid = $opt{'submit_id'} ? $opt{'submit_id'} : 'submit'; + +my $js = qq( + add_password_validation('changepw$id\_password', '$submitid', '', '$contactnum'); + + var selfService = document.getElementById("$id\_selfservice_access").value; + + if (selfService !== "Y") { document.getElementById("changepw$id\_password").disabled = 'true'; } + document.getElementById("$id\_selfservice_access").onchange = function() { + if (this.value == "P" || this.value == "E" || this.value =="Y") { + document.getElementById("changepw$id\_password").disabled = ''; + } + else { document.getElementById("changepw$id\_password").disabled = 'true'; } + return false; + } +); </%init> diff --git a/httemplate/elements/cust_payby_new.html b/httemplate/elements/cust_payby_new.html new file mode 100644 index 000000000..8b1d93d59 --- /dev/null +++ b/httemplate/elements/cust_payby_new.html @@ -0,0 +1,217 @@ +% 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 my $mm ( map{ sprintf( '%02d', $_ ) } (1..12) ) { + <OPTION value="<% $mm %>"<% $mm == $month ? ' SELECTED' : '' %>><% $mm %></OPTION> +% } + </SELECT> + </TD> + <TD> / </TD> + <TD> + <SELECT NAME="year"> +% my @a = localtime; for my $yyyy ( $a[5]+1900 .. $a[5]+1915 ) { + <OPTION value="<% $yyyy %>"<% $yyyy == $year ? ' SELECTED' : '' %>><% $yyyy %></OPTION> +% } + </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 %></OPTION> +% } + </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/header.html b/httemplate/elements/header.html index c6b10e301..6df45fb07 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -4,3 +4,4 @@ % } else { <& header-full.html, @_ &> % } +<& /misc/edge_browser_check-header.html &> 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 %>');">◁</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/menu.html b/httemplate/elements/menu.html index eb065b668..cae0cdbfb 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -418,7 +418,9 @@ if( $curuser->access_right('Financial reports') ) { $report_financial{'Customer Accounting Summary'} = [ $fsurl.'search/report_customer_accounting_summary.html', 'Customer accounting summary report' ]; - $report_financial{'Upcoming Auto-Bill Transactions'} = [ $fsurl.'search/report_future_autobill.html', 'Upcoming auto-bill transactions' ]; + if ( my $report_title = FS::cust_payby->future_autobill_report_title ) { + $report_financial{$report_title} = [ $fsurl.'search/report_future_autobill.html', "$report_title for customers with automatic payment methods (by date)" ]; + } } elsif($curuser->access_right('Receivables report')) { diff --git a/httemplate/elements/polygon.html b/httemplate/elements/polygon.html index 469ae7f13..a0d380bb8 100644 --- a/httemplate/elements/polygon.html +++ b/httemplate/elements/polygon.html @@ -5,12 +5,15 @@ my $id = $opt{'id'} || $opt{'field'}; my $div_id = "div_$id"; my $vertices_json = $opt{'curr_value'} || '[]'; + +my $apikey = FS::Conf->new->config('google_maps_api_key'); + </%init> <& hidden.html, %opt &> <div id="<% $div_id %>" style="height: 600px; width: 600px"></div> <div id="<% $div_id %>_hint" style="width: 100%; border: 2px solid black; text-align: center; box-sizing: border-box; padding: 4px"> </div> -<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22"></script> +<script src="https://maps.googleapis.com/maps/api/js?libraries=drawing&v=3.22<% $apikey ? "&key=$apikey" : '' %>"></script> <script> var map; var drawingManager; diff --git a/httemplate/elements/random_pass.html b/httemplate/elements/random_pass.html index 778aa20e6..3a632b9af 100644 --- a/httemplate/elements/random_pass.html +++ b/httemplate/elements/random_pass.html @@ -19,6 +19,7 @@ function <% $id %>randomPass() { for(var j, x, i = pass.length; i; j = Math.floor(Math.random() * i), x = pass[--i], pass[i] = pass[j], pass[j] = x); pass = pass.join(''); document.getElementById('<% $id %>').value = pass; + document.getElementById('<% $id %>_result').innerHTML = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em"> <SPAN STYLE="color: green;">Password valid!</SPAN>'; % if ($submitid) { document.getElementById('<% $submitid %>').disabled = false; % } diff --git a/httemplate/elements/select-country.html b/httemplate/elements/select-country.html index c98147907..286826752 100644 --- a/httemplate/elements/select-country.html +++ b/httemplate/elements/select-country.html @@ -91,15 +91,13 @@ Example: > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %> + <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %></OPTION> % } % foreach my $country ( @all_countries ) { - - <OPTION VALUE="<% $country |h %>" - <% $country eq $opt{'country'} ? ' SELECTED' : '' %> - ><% FS::geocode_Mixin->code2country($country). " ($country)" %> - + <OPTION VALUE="<% $country |h %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>> + <% FS::geocode_Mixin->code2country($country). " ($country)" |h %> + </OPTION> % } </SELECT> diff --git a/httemplate/elements/select-month_year.html b/httemplate/elements/select-month_year.html index 62c10b15f..406c13b21 100644 --- a/httemplate/elements/select-month_year.html +++ b/httemplate/elements/select-month_year.html @@ -3,16 +3,15 @@ <% $empty ? '<OPTION VALUE="">' : '' %> % foreach ( 1 .. 12 ) { - <OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $mon[$_-1] %> + <OPTION<% $_ == $mon ? ' SELECTED' : '' %> VALUE="<% sprintf('%02d', $_) %>"><% $mon[$_-1] %></OPTION> % } - </SELECT>/<SELECT NAME="<% $prefix %>_year" SIZE="1" <% $disabled%>> <% $empty ? '<OPTION VALUE="">' : '' %> % for ( $start_year .. $end_year ) { - <OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %> + <OPTION<% $_ == $year ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $_ %></OPTION> % } </SELECT> diff --git a/httemplate/elements/select-state.html b/httemplate/elements/select-state.html index 3fb559734..8db157b92 100644 --- a/httemplate/elements/select-state.html +++ b/httemplate/elements/select-state.html @@ -27,16 +27,13 @@ Example: > % unless ( $opt{'disable_empty'} ) { - <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %> + <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty_label} %></OPTION> % } % foreach my $state ( keys %states ) { - - <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %> - + <OPTION VALUE="<% $state |h %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' |h %></OPTION> % } - </SELECT> <%init> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index a52fdfaaa..d86b7ee43 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -83,11 +83,11 @@ Example: % || ( $value eq $pre_opt ); <OPTION VALUE="<% $pre_opt %>" <% $selected ? 'SELECTED' : '' %> - ><% $pre_label %> + ><% $pre_label %></OPTION> % } % unless ( $opt{'multiple'} || $opt{'disable_empty'} ) { - <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %> + <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %></OPTION> % } % foreach my $record ( @@ -118,7 +118,7 @@ Example: ? &{ $opt{'label_callback'} }( $record ) : $record->$name_col() |h - %> + %></OPTION> % } % while ( @post_options ) { @@ -128,7 +128,7 @@ Example: % || ( $value eq $post_opt ); <OPTION VALUE="<% $post_opt %>" <% $selected ? 'SELECTED' : '' %> - ><% $post_label %> + ><% $post_label %></OPTION> % } </SELECT> diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html index 9c13f5952..a84fef6ec 100644 --- a/httemplate/elements/tr-amount_fee.html +++ b/httemplate/elements/tr-amount_fee.html @@ -1,6 +1,6 @@ - <TR ID="payment_amount_row" <% $opt{'row_style'} %>> + <TR ID="payment_amount_row"> <TH ALIGN="right"><% mt('Payment amount') |h %></TH> - <TD COLSPAN=7> + <TD> <TABLE><TR><TD BGCOLOR="#ffffff"> <% $money_char %><INPUT NAME = "amount" ID = "amount" @@ -8,7 +8,7 @@ VALUE = "<% $amount %>" SIZE = 8 STYLE = "text-align:right;" -% if ( $fee ) { +% if ( $fee || $surcharge_percentage || $surcharge_flatfee ) { onChange = "amount_changed(this)" onKeyDown = "amount_changed(this)" onKeyUp = "amount_changed(this)" @@ -28,17 +28,23 @@ <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT> % } +% if ( $surcharge_percentage || $surcharge_flatfee ) { + <INPUT TYPE="hidden" NAME="surcharge_percentage" ID="surcharge_percentage" VALUE="<% $surcharge_percentage %>"> + <INPUT TYPE="hidden" NAME="surcharge_flatfee" ID="surcharge_flatfee" VALUE="<% $surcharge_flatfee %>"> + </TD><TD ID="ajax_surcharge_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue"> + <FONT SIZE="+1">A credit card surcharge of <% $money_char. sprintf('%.2f', $surcharge) %> is included in this payment</FONT> +% } </TD></TR></TABLE> </TD> </TR> -% if ( $fee ) { +% if ($fee || $surcharge_percentage || $surcharge_flatfee ) { <SCRIPT TYPE="text/javascript"> function amount_changed(what) { - +% if ( $fee ) { var total = ''; if ( what.value.length ) { total = parseFloat(what.value) <% $fee_op %> <% $fee %>; @@ -48,6 +54,13 @@ var total_cell = document.getElementById('ajax_total_cell'); total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT>'; +% } + +% if ( $surcharge_percentage || $surcharge_flatfee ) { + var surcharge_cell = document.getElementById('ajax_surcharge_cell'); + var surcharge = ((what.value - <% $surcharge_flatfee %>) * <% $surcharge_percentage %>) + <% $surcharge_flatfee %>; + surcharge_cell.innerHTML = '<FONT SIZE="+1">A credit card surcharge of ' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; +% } } @@ -66,6 +79,9 @@ my $fee = ''; my $fee_pkg = ''; my $fee_display = ''; my $fee_op = ''; +my $surcharge = ''; +my $surcharge_percentage = 0; +my $surcharge_flatfee = 0; if ( $opt{'process-pkgpart'} and ! $opt{'process-skip_first'} || $opt{'num_payments'} @@ -86,13 +102,21 @@ if ( $opt{'process-pkgpart'} } my $amount = $opt{'amount'}; -if ( $amount > 0 ) { +if ( $amount ) { + # probably should not happen, but will prevent surcharge being applied to negative due amounts + unless ($amount > 0) { $amount = 0; } + $amount += $fee if $fee && $fee_display eq 'subtract'; #&{ $opt{post_fee_callback} }( \$amount ) if $opt{post_fee_callback}; - $amount += $amount * $opt{'surcharge_percentage'}/100 - if $opt{'surcharge_percentage'} > 0; + + $surcharge_percentage = $opt{'surcharge_percentage'}/100 if $opt{'surcharge_percentage'} > 0; + $surcharge_flatfee = $opt{'surcharge_flatfee'} if $opt{'surcharge_flatfee'} > 0; + $surcharge = $amount * $surcharge_percentage if $surcharge_percentage > 0; + $surcharge += $surcharge_flatfee if ( $surcharge_flatfee > 0 && $amount > 0 ); + + $amount += $surcharge; $amount = sprintf("%.2f", $amount); } 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-invoice.html b/httemplate/elements/tr-select-invoice.html index 3728d348d..d35813fc5 100644 --- a/httemplate/elements/tr-select-invoice.html +++ b/httemplate/elements/tr-select-invoice.html @@ -5,7 +5,11 @@ Example: include( '/elements/tr-select-invoice.html', #opt - most get used in /elements/tr-amount-fee - 'custnum' => 4, # customer number, + 'cust_main' => $cust_main, # cust_main, + 'status' => 'open' # type of invoices to show. Possible values are: + # open - shows only open invoices + # void - shows only voided invoices + # all - shows all invoices, this is default if no status is set. 'prefix' => 'pre', # prefix to fields and row ID's ) @@ -13,31 +17,35 @@ Example: <TR ID="invoice_row" STYLE="display:none;"> <TH ALIGN="right"><% mt('Open invoices') |h %></TH> - <TD COLSPAN=7> + <TD> <SELECT ID = "<% $opt{prefix} %>invoice" NAME = "<% $opt{prefix} %>invoice" onChange = "<% $opt{prefix} %>invoice_select_changed(this)" > <OPTION VALUE="select">Select an invoice to pay</OPTION> -% foreach my $record (@records) { +% foreach my $record (@invoices) { % my $read_date = time2str("%b %o, %Y", $record->_date); - <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION> +% $hidden .= '<INPUT TYPE="hidden" ID="inv'.$record->invnum.'" NAME="inv'.$record->invnum.'" VALUE="'.$record->owed.'">'; + <OPTION VALUE="<% $record->invnum %>"><% $record->invnum %> (<% $read_date %>) - <% $record->owed %></OPTION> % } - </SELECT> + </SELECT> + + <% $hidden %> + </TD> </TR> <%init> my %opt = @_; +my $status = $opt{'status'} ? $opt{'status'} : 'all'; +my $hidden; -my @records = qsearch( { - 'select' => '*', - 'table' => 'cust_bill', - 'hashref' => { 'custnum' => $opt{custnum} }, - 'order_by' => 'ORDER BY _date', -}); +my @invoices; +if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; } +elsif ($status eq "open") { @invoices = $opt{'cust_main'}->open_cust_bill; } +elsif ($status eq "void") { @invoices = $opt{'cust_main'}->cust_bill_void; } </%init> diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html index 2304c22d0..f86f3edfd 100644 --- a/httemplate/elements/tr-select-payment_options.html +++ b/httemplate/elements/tr-select-payment_options.html @@ -5,9 +5,9 @@ Example: include( '/elements/tr-select-payment_options.html', #opt - most get used in /elements/tr-amount-fee - 'custnum' => 4, # customer number needed for selecting invoices + 'cust_main' => $cust_main, # custmain needed for selecting invoices 'prefix' => 'pre', # prefix to fields and row ID's - 'amount' => 1, # payment amount + 'amount' => 1, # payment amount optional, if no amount will grab balance due from cust_main 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)), 'process-display' => scalar($conf->config('manual_process-display')), 'process-skip_first' => $conf->exists('manual_process-skip_first'), @@ -17,70 +17,139 @@ Example: ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum)) : 0 ), + 'surcharge_flatfee' => + ( $payby eq 'CARD' + ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum)) + : 0 + ), ) </%doc> - <TR STYLE="display:block"> - <TH ALIGN="right"><% mt('Payment options') |h %></TH> - <TD COLSPAN=7> + <TR ID="payment_option_row"> + <TH ALIGN="right"><% mt('What would you like to pay') |h %></TH> + <TD> <SELECT ID = "<% $opt{prefix} %>payment_option" NAME = "<% $opt{prefix} %>payment_option" onChange = "<% $opt{prefix} %>payment_option_changed(this)" <% $opt{disabled} %> - > - <OPTION VALUE="select">Select payment option</OPTION> - <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION> - <OPTION VALUE="invoice">Pay specific invoice</OPTION> - <OPTION VALUE="">Pay specific amount</OPTION> - </SELECT> + > + <OPTION VALUE="select">Select the amount you would like to pay</OPTION> + <% ($amount > 0) ? '<OPTION VALUE="'.$amount.'">Pay full balance</OPTION>' : '' %> + <% (@open_invoices) ? '<OPTION VALUE="invoice">Pay specific invoice</OPTION>' : '' %> + <OPTION VALUE="specific">Pay specific amount</OPTION> + </SELECT> </TD> </TR> <& /elements/tr-select-invoice.html, - 'custnum' => $opt{custnum}, - 'prefix' => $opt{prefix}, + 'cust_main' => $cust_main, + 'status' => 'open', + 'prefix' => $opt{prefix}, &> <& /elements/tr-amount_fee.html, - 'row_style' => 'STYLE="display:none;"', + 'amount' => $amount, + 'custnum' => $custnum, %opt &> <SCRIPT TYPE="text/javascript"> + $('#payment_option_row').<% $payment_option_row %>(); + $('#payment_amount_row').<% $payment_amount_row %>(); + + if($('#payment_amount_row').is(':visible')) { + var surcharge; + var amount = document.getElementById('amount').value; + + if ((document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) && amount > 0) { + surcharge = (+amount * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } + } + function <% $opt{prefix} %>payment_option_changed(what) { + var surcharge; + if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) { + surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + var amount = +what.value + +surcharge; + document.getElementById('amount').disabled = true; + if ( what.value == 'select' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('invoice_row').style.display = 'none'; - document.getElementById('<% $opt{prefix} %>invoice').value = 'select'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#invoice_row').hide(); + $("#<% $opt{prefix} %>invoice").val('select'); + $('#amount').val(''); } else if ( what.value == 'invoice' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('invoice_row').style.display = 'block'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#invoice_row').show(); + $('#apply_box_row').hide(); + $('#apply_box').val('yes'); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + var selectExists = ($("#<% $opt{prefix} %>invoice option[value='select']").length > 0); + if(!selectExists) { + $("#<% $opt{prefix} %>invoice").prepend("<option value='select'>Select an invoice to pay</option>"); + $("#<% $opt{prefix} %>invoice").val($('option:first', "#<% $opt{prefix} %>invoice").val()); + } + $('#amount').val(''); + } + else if ( what.value == 'specific' ) { + $('#payment_amount_row').show(); + $('#invoice_row').hide(); + $('#apply_box_row').show(); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + $('#amount').val('0.00'); + document.getElementById('amount').disabled = false; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>0.00 is included in this payment</FONT>'; + } } else { - document.getElementById('payment_amount_row').style.display = 'block'; - document.getElementById('invoice_row').style.display = 'none'; - document.getElementById('<% $opt{prefix} %>invoice').value = 'select'; - document.getElementById('amount').value = what.value; + $('#payment_amount_row').show(); + $('#invoice_row').hide(); + $('#apply_box_row').hide(); + $('#apply_box').val('yes'); + $("#<% $opt{prefix} %>payment_option option[value='select']").remove(); + $('#amount').val(amount.toFixed(2)); + document.getElementById('amount').disabled = true; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } } } function <% $opt{prefix} %>invoice_select_changed(what) { + var surcharge; + var invdue = document.getElementById("<% $opt{prefix} %>inv" + what.value); + if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) { + surcharge = (+invdue.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value; + } + else { surcharge = 0; } + var amount = +invdue.value + +surcharge; + if ( what.value == 'select' ) { - document.getElementById('payment_amount_row').style.display = 'none'; - document.getElementById('amount').value = ''; + $('#payment_amount_row').hide(); + $('#amount').val(''); } else { - document.getElementById('payment_amount_row').style.display = 'block'; - document.getElementById('amount').value = what.value; + $('#payment_amount_row').show(); + $("#<% $opt{prefix} %>invoice option[value='select']").remove(); + $('#amount').val(amount.toFixed(2)); + document.getElementById('amount').disabled = true; + if (document.getElementById('ajax_surcharge_cell')) { + document.getElementById('ajax_surcharge_cell').innerHTML = '<FONT SIZE="+1">A credit card surcharge of <% $money_char %>' + surcharge.toFixed(2) + ' is included in this payment</FONT>'; + } } } @@ -91,4 +160,21 @@ Example: my %opt = @_; +my $cust_main = $opt{'cust_main'}; +my $amount = $opt{'amount'} ? $opt{'amount'} : $cust_main->balance; +my $custnum = $cust_main->custnum; + +my @open_invoices = $cust_main->open_cust_bill; + +my $payment_option_row = "show"; +my $payment_amount_row = "hide"; + +unless ($amount > 0 && @open_invoices) { + $payment_option_row = "hide"; + $payment_amount_row = "show"; +} + +my $conf = new FS::Conf; +my $money_char = $conf->config('money_char') || '$'; + </%init>
\ No newline at end of file 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;">▼</button> % } </td> </tr> <script type="text/javascript"> diff --git a/httemplate/elements/tr-tower_sectors.html b/httemplate/elements/tr-tower_sectors.html index 106fc76f6..8acedb84b 100644 --- a/httemplate/elements/tr-tower_sectors.html +++ b/httemplate/elements/tr-tower_sectors.html @@ -17,7 +17,7 @@ my $tabcounter = 0; my @fields = qw( sectorname ip_addr height freq_mhz direction width downtilt v_width db_high db_low sector_range - power line_loss antenna_gain hardware_typenum + power line_loss antenna_gain hardware_typenum up_rate_limit down_rate_limit ); my @sectors; @@ -291,6 +291,20 @@ $(function() { value="<% $sector->db_low |h %>"> <% emt('dB (low quality)') %> </div> + <p> + <label><% emt('Up Rate (Kbps)') %></label> + <input style="text-align: left" + id="<% $id %>_up_rate_limit" + name="<% $id %>_up_rate_limit" + value="<% $sector->up_rate_limit |h %>"> + </p> + <p> + <label><% emt('Down Rate (Kbps)') %></label> + <input style="text-align: left" + id="<% $id %>_down_rate_limit" + name="<% $id %>_down_rate_limit" + value="<% $sector->down_rate_limit |h %>"> + </p> </div> </%def> diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html index 4057f5d3f..6aada2fee 100644 --- a/httemplate/elements/validate_password.html +++ b/httemplate/elements/validate_password.html @@ -14,58 +14,10 @@ should be the input id plus '_result'. </%doc> -<& '/elements/xmlhttp.html', - 'url' => $p.'misc/xmlhttp-validate_password.html', - 'subs' => [ 'validate_password' ], - 'method' => 'POST', # important not to put passwords in url -&> -<SCRIPT> -function add_password_validation (fieldid, submitid) { - var inputfield = document.getElementById(fieldid); - inputfield.onkeydown = function(e) { - var key; - if (window.event) { key = window.event.keyCode; } - else { key = e.which; } // for ff browsers - // some browsers allow the enter key to submit a form even if the submit button is disabled - // below prevents enter key from submiting form if password has not been validated. - if (key == '13') { - var check = checkPasswordValidation(); - return check; - } - } - inputfield.onkeyup = function () { - var fieldid = this.id+'_result'; - var resultfield = document.getElementById(fieldid); - if (this.value) { - resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>'; - validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','contactnum','<% $opt{'contactnum'} %>','password',this.value, - function (result) { - result = JSON.parse(result); - var resultfield = document.getElementById(result.fieldid); - if (resultfield) { - var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">'; - var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">'; - if (result.valid) { - resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = false; } - } else if (result.error) { - resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = true; } - } else { - result.syserror = result.syserror || 'Server error'; - resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>'; - if (submitid){ document.getElementById(submitid).disabled = true; } - } - } - } - ); - } else { - resultfield.innerHTML = ''; - } - }; -} +<& '/elements/validate_password_js.html', %opt &> -add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>'); +<SCRIPT> + add_password_validation('<% $opt{'fieldid'} %>', '<% $opt{'submitid'} %>', '<% $opt{'svcnum'} %>', '<% $opt{'contactnum'} %>'); </SCRIPT> <%init> diff --git a/httemplate/elements/validate_password_js.html b/httemplate/elements/validate_password_js.html new file mode 100644 index 000000000..64db0a97b --- /dev/null +++ b/httemplate/elements/validate_password_js.html @@ -0,0 +1,71 @@ +<%doc> + +JavaScript to perform password validation + + <& '/elements/validate_password_js.html', + contactnum => $contactnum, + svcnum => $svcnum + &> + +The ID of the input field can be anything; the ID of the DIV in which to display results +should be the input id plus '_result'. + +</%doc> + +<& '/elements/xmlhttp.html', + 'url' => $p.'misc/xmlhttp-validate_password.html', + 'subs' => [ 'validate_password' ], + 'method' => 'POST', # important not to put passwords in url +&> +<SCRIPT> +function add_password_validation (fieldid, submitid, svcnum, contactnum) { + var inputfield = document.getElementById(fieldid); + inputfield.onkeydown = function(e) { + var key; + if (window.event) { key = window.event.keyCode; } + else { key = e.which; } // for ff browsers + // some browsers allow the enter key to submit a form even if the submit button is disabled + // below prevents enter key from submiting form if password has not been validated. + if (key == '13') { + var check = checkPasswordValidation(fieldid); + return check; + } + } + inputfield.onkeyup = function () { + var fieldid = this.id+'_result'; + var resultfield = document.getElementById(fieldid); + if (this.value) { + resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>'; + validate_password('fieldid',fieldid,'svcnum','<% $opt{'svcnum'} %>','contactnum', contactnum,'password',this.value, + function (result) { + result = JSON.parse(result); + var resultfield = document.getElementById(result.fieldid); + if (resultfield) { + var errorimg = '<IMG SRC="<% $p %>images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">'; + var validimg = '<IMG SRC="<% $p %>images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">'; + if (result.valid) { + resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = false; } + } else if (result.error) { + resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.error+'</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = true; } + } else { + result.syserror = result.syserror || 'Server error'; + resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.syserror+'</SPAN>'; + if (submitid){ document.getElementById(submitid).disabled = true; } + } + } + } + ); + } else { + resultfield.innerHTML = ''; + if (submitid){ document.getElementById(submitid).disabled = false; } + } + }; +} + +</SCRIPT> + +<%init> +my %opt = @_; +</%init>
\ No newline at end of file |