X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_broadband.cgi;h=a67f6f05aa3b0dbe0f3c3ed45d86887080731cec;hb=8c59634ee0d66d79b27f76818ca5ba41f797359b;hp=01e58cdc4fbc9a49beababaf6ffe9689c852f9d6;hpb=d3784b40552e9f00c9d803ac0833e09828c73d96;p=freeside.git diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index 01e58cdc4..a67f6f05a 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -2,24 +2,11 @@ 'post_url' => popurl(1). 'process/svc_broadband.cgi', 'name' => 'broadband service', 'table' => 'svc_broadband', - 'labels' => { 'svcnum' => 'Service #', - 'description' => 'Description', - 'ip_addr' => 'IP address', - 'speed_down' => 'Download speed', - 'speed_up' => 'Upload speed', - 'blocknum' => 'Router/Block', - 'block_label' => 'Router/Block', - 'mac_addr' => 'MAC address', - 'latitude' => 'Latitude', - 'longitude' => 'Longitude', - 'altitude' => 'Altitude', - 'vlan_profile' => 'VLAN profile', - 'performance_profile' => 'Performance profile', - 'authkey' => 'Authentication key', - }, 'fields' => \@fields, 'field_callback' => $callback, 'dummy' => $cgi->query_string, + 'onsubmit' => 'validate_coords', + 'html_foot' => $js, ) %> <%init> @@ -32,10 +19,88 @@ die "access denied" my $conf = new FS::Conf; +my $js = < + function validate_coords(f){ +END +; +if ( $conf->exists('svc_broadband-require-nw-coordinates') ) { +$js .= < 59 ) { + s /= 1000; + } else { + s /= 60; + } + s /= 60; + + m /= 60; + if ( m > 59 ) { + alert('Invalid coordinate with minutes > 59'); + return false; + } + + var tmp = parseInt(d)+parseInt(m)+parseInt(s); + tmp = tmp.toFixed(8); + coord = (neg ? -1 : 1) * tmp; + + if(coord < lower) { + alert('Error: invalid coordinate < '+lower); + return false; + } + if(coord > upper) { + alert('Error: invalid coordinate > '+upper); + return false; + } + + return true; +END +; +} +$js .= < +END +; + my @fields = ( qw( description ip_addr speed_down speed_up blocknum ), { field=>'block_label', type=>'fixed' }, - qw( mac_addr latitude longitude altitude vlan_profile performance_profile authkey ) + qw( mac_addr latitude longitude altitude vlan_profile performance_profile authkey plan_id ) ); my $fixedblock = ''; @@ -63,12 +128,12 @@ my $callback = sub { if $fieldref->{field} eq 'blocknum'; $fieldref->{value} = $object->addr_block->label - if $fieldref->{field} eq 'block_label'; + if $fieldref->{field} eq 'block_label' && $object->addr_block; } else { if ($fieldref->{field} eq 'block_label') { - if ($fixedblock) { + if ($fixedblock && $object->addr_block) { $object->blocknum($fixedblock); $fieldref->{value} = $object->addr_block->label; }else{ @@ -93,7 +158,8 @@ my $callback = sub { && $FS::CurrentUser::CurrentUser->agentnum($_->agentnum) } map { $_->addr_block } $object->allowed_routers; - my @options = map { $_->blocknum } @addr_block; + my @options = map { $_->blocknum } + sort { $a->label cmp $b->label } @addr_block; my %option_labels = map { ( $_->blocknum => $_->label ) } @addr_block; $fieldref->{type} = 'select'; $fieldref->{options} = \@options;