diff options
| author | mark <mark> | 2011-12-28 23:56:20 +0000 | 
|---|---|---|
| committer | mark <mark> | 2011-12-28 23:56:20 +0000 | 
| commit | b6dbe0f12dbbe4ea5209367f905f937789b5b607 (patch) | |
| tree | 39434f7f4f20b901bcd27e2f120c46e9b713815d /httemplate/edit | |
| parent | 9ad2437e1cfaffceb657216a48ea3c7cc9414922 (diff) | |
broadband_nas export, #15284
Diffstat (limited to 'httemplate/edit')
| -rw-r--r-- | httemplate/edit/nas.html | 4 | ||||
| -rw-r--r-- | httemplate/edit/part_export.cgi | 15 | ||||
| -rw-r--r-- | httemplate/edit/process/svc_broadband.cgi | 2 | ||||
| -rw-r--r-- | httemplate/edit/svc_broadband.cgi | 58 | 
4 files changed, 67 insertions, 12 deletions
diff --git a/httemplate/edit/nas.html b/httemplate/edit/nas.html index 9d9b8e9fd..2e66fc3be 100644 --- a/httemplate/edit/nas.html +++ b/httemplate/edit/nas.html @@ -48,7 +48,9 @@ sub html_bottom {              'source_obj'    => $nas,              'link_table'    => 'export_nas',              'target_table'  => 'part_export', -            'hashref'       => { 'exporttype' => 'sqlradius' }, +            'hashref'       => { 'exporttype' =>  +                                  { op => 'LIKE', value => '%sqlradius' } +                                },              'name_callback' => sub { $_[0]->label },              'default'       => 'yes',              'target_link'   => $p.'edit/part_export.cgi?', diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi index 9a0e0bd29..1450ac3b3 100644 --- a/httemplate/edit/part_export.cgi +++ b/httemplate/edit/part_export.cgi @@ -51,8 +51,12 @@ $action ||= $part_export->exportnum ? 'Edit' : 'Add';  #my $exports = FS::part_export::export_info($svcdb);  my $exports = FS::part_export::export_info(); -my %layers = map { $_ => "$_ - ". $exports->{$_}{desc} } keys %$exports; -$layers{''}=''; +tie my %layers, 'Tie::IxHash', +  '' => '', +  map { $_ => "$_ - ". $exports->{$_}{desc} }  +  sort { $a cmp $b } +  keys %$exports; +;  my $widget = new HTML::Widgets::SelectLayers(    'selected_layer' => $part_export->exporttype, @@ -83,6 +87,13 @@ my $widget = new HTML::Widgets::SelectLayers(                        ? $optinfo->{default}                        : ''                      ); +      if ( $type eq 'title' ) { +        $html .= qq!<TR><TH COLSPAN=1 ALIGN="right"><FONT SIZE="+1">! . +                 $label . +                 '</FONT></TH></TR>'; +        next; +      } +        # 'freeform': disables table formatting of options.  Instead, each         # option can define "before" and "after" strings which are inserted         # around the selector. diff --git a/httemplate/edit/process/svc_broadband.cgi b/httemplate/edit/process/svc_broadband.cgi index 36c64d11a..4184f5fa6 100644 --- a/httemplate/edit/process/svc_broadband.cgi +++ b/httemplate/edit/process/svc_broadband.cgi @@ -1,6 +1,6 @@  <& elements/svc_Common.html,    table       => 'svc_broadband', -  fields      => [ fields('svc_broadband'), 'usergroup' ], +  fields      => [ fields('svc_broadband'), fields('nas'), 'usergroup' ],    precheck_callback => \&precheck,  &>  <%init> diff --git a/httemplate/edit/svc_broadband.cgi b/httemplate/edit/svc_broadband.cgi index ad4d6046d..b9e2fd2d9 100644 --- a/httemplate/edit/svc_broadband.cgi +++ b/httemplate/edit/svc_broadband.cgi @@ -3,7 +3,9 @@       'name'                 => 'broadband service',       'table'                => 'svc_broadband',       '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, @@ -113,17 +115,57 @@ if ( $conf->exists('svc_broadband-radius') ) {    }  } -  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') {  | 
