X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_broadband.cgi;h=bcf55fe11a73cd9a1e37f32d8f016634846b885a;hp=a67f6f05aa3b0dbe0f3c3ed45d86887080731cec;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hpb=6361e71971a84c4f798c2f4eef89bbd454a3cb0d diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index a67f6f05a..bcf55fe11 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -1,14 +1,16 @@ -<% include('elements/svc_Common.html', +<& elements/svc_Common.html, 'post_url' => popurl(1). 'process/svc_broadband.cgi', 'name' => 'broadband service', 'table' => 'svc_broadband', 'fields' => \@fields, - 'field_callback' => $callback, + 'svc_field_callback' => $svc_field_callback, + 'svc_new_callback' => $svc_edit_callback, + 'svc_edit_callback' => $svc_edit_callback, + 'svc_error_callback' => $svc_edit_callback, 'dummy' => $cgi->query_string, 'onsubmit' => 'validate_coords', 'html_foot' => $js, - ) -%> +&> <%init> die "access denied" @@ -98,75 +100,89 @@ 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 plan_id ) + qw( description speed_down speed_up speed_test_down speed_test_up speed_test_latency), + { field=>'sectornum', type=>'select-tower_sector', }, + { field=>'routernum', type=>'select-router_block_ip', + include_opt_callback => sub { + my $svc_broadband = shift; + my $part_svc = $svc_broadband->part_svc; + return () unless $part_svc; #sanity check + my $col = $part_svc->part_svc_column('ip_addr'); + return () unless $col; #sanity check + return ('ip_addr_required' => $col->required); + }, + }, + { field=>'mac_addr' , type=>'input-mac_addr' }, + qw( + latitude longitude altitude + radio_serialnum radio_location poe_location rssi suid + ), + { field=>'shared_svcnum', type=>'search-svc_broadband', }, + qw( vlan_profile performance_profile authkey plan_id ), ); -my $fixedblock = ''; - -my $callback = sub { - my ($cgi, $object, $fieldref) = @_; - - my $svcpart = $object->svcnum ? $object->cust_svc->svcpart - : $cgi->param('svcpart'); - - my $part_svc = qsearchs( 'part_svc', { svcpart => $svcpart } ); - die "No part_svc entry!" unless $part_svc; - - my $columndef = $part_svc->part_svc_column($fieldref->{'field'}); - if ($columndef->columnflag eq 'F') { - $fieldref->{'type'} = 'fixed'; - $fieldref->{'value'} = $columndef->columnvalue; - $fixedblock = $fieldref->{value} - if $fieldref->{field} eq 'blocknum'; +if ( $conf->exists('svc_broadband-radius') ) { + push @fields, + { field => 'usergroup', + type => 'select-radius_group', + multiple => 1, } +} - if ($object->svcnum) { +my $part_svc; - $fieldref->{type} = 'hidden' - if $fieldref->{field} eq 'blocknum'; - - $fieldref->{value} = $object->addr_block->label - if $fieldref->{field} eq 'block_label' && $object->addr_block; +my $svc_edit_callback = sub { + my ($cgi, $svc_x, $part_svc_x, $cust_pkg, $fields, $opt) = @_; - } else { + $part_svc = $part_svc_x; #for field_callback to use - if ($fieldref->{field} eq 'block_label') { - if ($fixedblock && $object->addr_block) { - $object->blocknum($fixedblock); - $fieldref->{value} = $object->addr_block->label; - }else{ - $fieldref->{type} = 'hidden'; - } + 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'; + } +}; - if ($fieldref->{field} eq 'blocknum') { - if ( $fixedblock or $conf->exists('auto_router') ) { - $fieldref->{type} = 'hidden'; - $fieldref->{value} = $fixedblock; - return; - } - - my $cust_pkg = qsearchs( 'cust_pkg', {pkgnum => $cgi->param('pkgnum')} ); - die "No cust_pkg entry!" unless $cust_pkg; - - $object->svcpart($part_svc->svcpart); - my @addr_block = - grep { ! $_->agentnum - || $cust_pkg->cust_main->agentnum == $_->agentnum - && $FS::CurrentUser::CurrentUser->agentnum($_->agentnum) - } - map { $_->addr_block } $object->allowed_routers; - 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; - $fieldref->{labels} = \%option_labels; - } +my $svc_field_callback = sub { + my ($cgi, $object, $fieldref) = @_; + my $columndef = $part_svc->part_svc_column($fieldref->{'field'}); + if ($fieldref->{field} eq 'usergroup' && $columndef->columnflag eq 'F') { + $fieldref->{'formatted_value'} = + [ $object->radius_groups('long_description') ]; } + };