X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_broadband.cgi;h=b9e2fd2d96109fe105a2ef61b83fd7dbe0fa0ea4;hp=8a108f891d6e7cf1284e528c0eb7616a1950267b;hb=75e11f1d1a5ced24496b5732e290f7762403feb8;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index 8a108f891..b9e2fd2d9 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -1,27 +1,15 @@ -<% include('elements/svc_Common.html', +<& elements/svc_Common.html, '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, + 'field_callback' => $field_callback, + 'svc_new_callback' => $svc_edit_callback, + 'svc_edit_callback' => $svc_edit_callback, 'dummy' => $cgi->query_string, - ) -%> + 'onsubmit' => 'validate_coords', + 'html_foot' => $js, +&> <%init> die "access denied" @@ -32,29 +20,166 @@ 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 ), + qw( description ip_addr speed_down speed_up ), + { field=>'sectornum', type=>'select-tower_sector', }, + qw( 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 ), ); +if ( $conf->exists('svc_broadband-radius') ) { + push @fields, + { field => 'usergroup', + type => 'select-radius_group', + multiple => 1, + } +} + my $fixedblock = ''; -my $callback = sub { - my ($cgi, $object, $fieldref) = @_; +my $part_svc; + +my $svc_edit_callback = sub { + my ($cgi, $svc_x, $part_svc_x, $cust_pkg, $fields, $opt) = @_; + + $part_svc = $part_svc_x; #for field_callback to use - my $svcpart = $object->svcnum ? $object->cust_svc->svcpart - : $cgi->param('svcpart'); + $opt->{'labels'}{'block_label'} = 'Block'; - my $part_svc = qsearchs( 'part_svc', { svcpart => $svcpart } ); - die "No part_svc entry!" unless $part_svc; + my ($nas_export) = $part_svc->part_export('broadband_nas'); + #can we assume there's only one of these per part_svc? + if ( $nas_export ) { + my $nas; + if ( $svc_x->svcnum ) { + $nas = qsearchs('nas', { 'svcnum' => $svc_x->svcnum }); + } + $nas ||= $nas_export->default_nas; + $svc_x->set($_, $nas->$_) foreach fields('nas'); + + # duplicates the fields in httemplate/edit/nas.html (mostly) + push @$fields, + { type => 'tablebreak-tr-title', + #value => 'Attached NAS', + value => $nas_export->exportname, + colspan => 2, + }, + { field=>'nasnum', type=>'hidden', }, + { field=>'shortname', size=>16, maxlength=>32 }, + { field=>'secret', size=>40, maxlength=>60, required=>1 }, + { field=>'type', type=>'select', + options=>[qw( cisco computone livingston max40xx multitech netserver + pathras patton portslave tc usrhiper other )], + }, + { field=>'ports', size=>5 }, + { field=>'server', size=>40, maxlength=>64 }, + { field=>'community', size=>40, maxlength=>50 }, + ; + + $opt->{'labels'}{'shortname'} = 'Short name'; + $opt->{'labels'}{'secret'} = 'Shared secret'; + $opt->{'labels'}{'type'} = 'Type'; + $opt->{'labels'}{'ports'} = 'Ports'; + $opt->{'labels'}{'server'} = 'Server'; + $opt->{'labels'}{'community'} = 'Community'; + } +}; + +my $field_callback = sub { + my ($cgi, $object, $fieldref) = @_; my $columndef = $part_svc->part_svc_column($fieldref->{'field'}); if ($columndef->columnflag eq 'F') { - $fieldref->{'type'} = 'fixed'; + $fieldref->{'type'} = length($columndef->columnvalue) + ? 'fixed' + : 'hidden'; $fieldref->{'value'} = $columndef->columnvalue; $fixedblock = $fieldref->{value} if $fieldref->{field} eq 'blocknum'; + + if ( $fieldref->{field} eq 'usergroup' ) { + $fieldref->{'formatted_value'} = + [ $object->radius_groups('long_description') ]; + } } if ($object->svcnum) { @@ -63,12 +188,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 +218,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;