X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_svc.cgi;h=b80118f898fe7cc2c051169e77667fffd295287d;hp=ea429678d45f7e321a3d34beea4121871c9d4998;hb=aad287228dfbe5ef01be73ebaaa9a06dfbe11226;hpb=9eb89294e2909ca9a8043b05f2492b7018b14adb diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index ea429678d..b80118f89 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -1,4 +1,226 @@ -<% +<& /elements/header.html, "$action Service Definition" &> +<& /elements/menubar.html, + 'View all service definitions' => "${p}browse/part_svc.cgi" + #" onLoad=\"visualize()\"" +&> + +<& /elements/init_overlib.html &> + +

+ + + + +
+ +Service Part #<% $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %> + +<& /elements/tr-input-locale-text.html, + 'object' => $part_svc, + 'cgi' => $cgi, + 'field' => 'svc', + 'label' => 'Service', + 'curr_value' => $hashref->{svc}, +&> +%# +%# +%# +%# + +<& /elements/tr-select-part_svc_class.html, curr_value=>$hashref->{classnum} &> + + + + + + + + + + + + + + +
Service
Self-service access + + +
Disable new orders + {disabled} eq 'Y' ? ' CHECKED' : '' %>>
Preserve this service on package cancellation + {'preserve'} eq 'Y' ? ' CHECKED' : '' %>> 
+ + + +
+ +Table <% $widget->html %> + +<& /elements/footer.html &> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = FS::Conf->new; my $part_svc; my $clone = ''; if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {#clone @@ -21,271 +243,43 @@ my $hashref = $part_svc->hashref; # my $p_svcdb = $part_svc->svcdb || 'svc_acct'; - #" onLoad=\"visualize()\"" -%> - -<%= header("$action Service Definition", - menubar( 'Main Menu' => $p, - 'View all service definitions' => "${p}browse/part_svc.cgi" - ), - ) -%> - - - - Service Part #<%= $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %> -

-Service
-Disable new orders {disabled} eq 'Y' ? ' CHECKED' : '' %>>
- -
-Services are items you offer to your customers. - -For the selected table, you can give fields default or fixed (unchangable) -values. For example, a SLIP/PPP account may have a default (or perhaps fixed) -slipip of 0.0.0.0, while a POP mailbox will probably have a fixed -blank slipip as well as a fixed shell something like /bin/true or -/usr/bin/passwd. -

- -<% +my @dbs = $hashref->{svcdb} + ? ( $hashref->{svcdb} ) + : FS::part_svc->svc_tables(); -my %vfields; +my $help = ''; +unless ( $hashref->{svcpart} ) { + $help = ' '. + include('/elements/popup_link.html', + 'action' => $p.'docs/part_svc-table.html', + 'label' => 'help', + 'actionlabel' => 'Service table help', + 'width' => 960, + 'height' => 400, + ); +} -#these might belong somewhere else for other user interfaces -#pry need to eventually create stuff that's shared amount UIs -my $conf = new FS::Conf; -my %defs = ( - 'svc_acct' => { - 'dir' => 'Home directory', - 'uid' => 'UID (set to fixed and blank for no UIDs)', - 'slipip' => 'IP address', -# 'popnum' => qq!POP number!, - 'popnum' => { - desc => 'Access number', - type => 'select', - select_table => 'svc_acct_pop', - select_key => 'popnum', - select_label => 'city', - }, - 'username' => { - desc => 'Username', - type => 'disabled', - }, - 'quota' => '', - '_password' => 'Password', - 'gid' => 'GID (when blank, defaults to UID)', - 'shell' => { - desc =>'Shell (all service definitions should have a default or fixed shell that is present in the shells configuration file, set to blank for no shell tracking)', - type =>'select', - select_list => [ $conf->config('shells') ], - }, - 'finger' => 'GECOS', - 'domsvc' => { - desc =>'svcnum from svc_domain', - type =>'select', - select_table => 'svc_domain', - select_key => 'svcnum', - select_label => 'domain', - }, - 'usergroup' => { - desc =>'ICRADIUS/FreeRADIUS groups', - type =>'radius_usergroup_selector', - }, - }, - 'svc_domain' => { - 'domain' => 'Domain', - }, - 'svc_forward' => { - 'srcsvc' => 'service from which mail is to be forwarded', - 'dstsvc' => 'service to which mail is to be forwarded', - 'dst' => 'someone@another.domain.com to use when dstsvc is 0', - }, -# 'svc_charge' => { -# 'amount' => 'amount', -# }, -# 'svc_wo' => { -# 'worker' => 'Worker', -# '_date' => 'Date', -# }, - 'svc_www' => { - #'recnum' => '', - #'usersvc' => '', - }, - 'svc_broadband' => { - 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', - 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', - 'ip_addr' => 'IP address. Leave blank for automatic assignment.', - 'blocknum' => 'Address block.', - }, - 'svc_external' => { - #'id' => '', - #'title' => '', - }, +tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs; +my $widget = new HTML::Widgets::SelectLayers( + #'selected_layer' => $p_svcdb, + 'selected_layer' => $hashref->{svcdb} || 'svc_acct', + 'options' => \%svcdb, + 'form_name' => 'SvcEditMain', + #'form_action' => 'process/part_svc.cgi', + 'form_action' => 'part_svc.cgi', #self +# 'form_elements' => [qw( svc svcpart classnum selfservice_access +# disabled preserve +# )], + 'html_between' => $help, + 'layer_callback' => sub { + include('elements/part_svc_column.html', + shift, + 'part_svc' => $part_svc, + 'clone' => $clone + ) + } ); + - foreach my $svcdb (grep dbdef->table($_), keys %defs ) { - my $self = "FS::$svcdb"->new; - $vfields{$svcdb} = {}; - foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them - my $pvf = $self->pvf($field); - my @list = $pvf->list; - if (scalar @list) { - $defs{$svcdb}->{$field} = { desc => $pvf->label, - type => 'select', - select_list => \@list }; - } else { - $defs{$svcdb}->{$field} = $pvf->label; - } #endif - $vfields{$svcdb}->{$field} = $pvf; - warn "\$vfields{$svcdb}->{$field} = $pvf"; - } #next $field - } #next $svcdb - - my @dbs = $hashref->{svcdb} - ? ( $hashref->{svcdb} ) - : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_external ); - - tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs; - my $widget = new HTML::Widgets::SelectLayers( - #'selected_layer' => $p_svcdb, - 'selected_layer' => $hashref->{svcdb} || 'svc_acct', - 'options' => \%svcdb, - 'form_name' => 'dummy', - #'form_action' => 'process/part_svc.cgi', - 'form_action' => 'part_svc.cgi', #self - 'form_text' => [ qw( svc svcpart ) ], - 'form_checkbox' => [ 'disabled' ], - 'layer_callback' => sub { - my $layer = shift; - - my $html = qq!!; - - my $columns = 3; - my $count = 0; - my @part_export = - map { qsearch( 'part_export', {exporttype => $_ } ) } - keys %{FS::part_export::export_info($layer)}; - $html .= '

'. table(). - table(). "Exports"; - foreach my $part_export ( @part_export ) { - $html .= 'svcpart ) #null svcpart search causing error - && qsearchs( 'export_svc', { - exportnum => $part_export->exportnum, - svcpart => $clone || $part_svc->svcpart }); - $html .= '>'. $part_export->exportnum. ': '. $part_export->exporttype. - ' to '. $part_export->machine. ''; - $count++; - $html .= '' unless $count % $columns; - } - $html .= '

'; - - $html .= table(). "FieldModifier"; - #yucky kludge - my @fields = defined( dbdef->table($layer) ) - ? grep { $_ ne 'svcnum' } fields($layer) - : (); - push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge - $part_svc->svcpart($clone) if $clone; #haha, undone below - foreach my $field (@fields) { - my $part_svc_column = $part_svc->part_svc_column($field); - my $value = $part_svc_column->columnvalue; - my $flag = $part_svc_column->columnflag; - my $def = $defs{$layer}{$field}; - my $desc = ref($def) ? $def->{desc} : $def; - - $html .= "$field"; - $html .= "- $desc" if $desc; - $html .= ""; - $flag = '' if ref($def) && $def->{type} eq 'disabled'; - $html .= - qq!Off". - ''; - unless ( ref($def) && $def->{type} eq 'disabled' ) { - $html .= - qq!Default ". - qq!Fixed "; - $html .= '
'; - } - if ( ref($def) ) { - if ( $def->{type} eq 'select' ) { - $html .= qq!'; - } elsif ( $def->{type} eq 'radius_usergroup_selector' ) { - $html .= FS::svc_acct::radius_usergroup_selector( - [ split(',', $value) ], "${layer}__${field}" ); - } elsif ( $def->{type} eq 'disabled' ) { - $html .= - qq!!; - } else { - $html .= 'unknown type'. $def->{type}; - } - } else { - $html .= - qq!!; - } - - if($vfields{$layer}->{$field}) { - $html .= qq!
Excluded "; - } - $html .= "\n"; - } - $part_svc->svcpart('') if $clone; #undone - $html .= ""; - - $html .= include('/elements/progress-init.html', - $layer, #form name - [ qw(svc svcpart disabled exportnum), @fields ], - 'process/part_svc.cgi', - $p.'browse/part_svc.cgi', - $layer, - ); - $html .= '
'; - - #$html .= '
'; - - $html; - - }, - ); -%> -Table <%= $widget->html %> - -