X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_svc.cgi;h=2ec0242694a01498ada1ccdb74a36a5558abfe71;hb=f31a9212ab3835b815aa87a86cca3b19babcaaff;hp=10b4c77fb20892fc67ee083477d829edbb98141d;hpb=7d964ae317fc7405a9428f3e06dbdd5dcdecf07f;p=freeside.git diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 10b4c77fb..2ec024269 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -1,389 +1,170 @@ -<% include('/elements/header.html', "$action Service Definition", - menubar('View all service definitions' => "${p}browse/part_svc.cgi"), +<& /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)" %>

-Service
-{disabled} eq 'Y' ? ' CHECKED' : '' %>> Disable new orders
-{'preserve'} eq 'Y' ? ' CHECKED' : '' %>> Preserve this service on package cancellation
- -
+ +', -% ); -% -% } -% -% $html .= qq!!; -% -% my $disabled = $flag ? '' -% : 'DISABLED STYLE="background-color: #dddddd"'; -% my $nodisplay = ' STYLE="display:none"'; -% -% if ( !$def->{type} || $def->{type} eq 'text' ) { -% -% my $is_inv = ( $flag =~ /^[MA]$/ ); -% -% $html .= -% qq!'; -% -% $html .= include('/elements/select-table.html', -% 'element_name' => "${layer}__${field}_classnum", -% 'element_etc' => ( $is_inv -% ? $disabled -% : $nodisplay -% ), -% 'table' => 'inventory_class', -% 'name_col' => 'classname', -% 'value' => $value, -% 'empty_label' => 'Select inventory class', -% ); -% -% } elsif ( $def->{type} eq 'checkbox' ) { -% -% $html .= include('/elements/checkbox.html', -% 'field' => $layer.'__'.$field, -% 'curr_value' => $value, -% 'value' => 'Y', -% ); -% -% } elsif ( $def->{type} eq 'select' ) { -% -% $html .= qq!'; -% -% } elsif ( $def->{type} eq 'textarea' ) { -% -% $html .= -% qq!'; -% -% } elsif ( $def->{type} =~ /select-(.*?).html/ ) { -% -% $html .= include("/elements/".$def->{type}, -% 'curr_value' => $value, -% 'element_name' => "${layer}__${field}", -% 'element_etc' => $disabled, -% 'multiple' => ($def->{multiple} || -% $flag eq 'S'), -% # allow the table def to force 'multiple' -% ); -% -% } elsif ( $def->{type} eq 'communigate_pro-accessmodes' ) { -% -% $html .= include('/elements/communigate_pro-accessmodes.html', -% 'element_name_prefix' => "${layer}__${field}_", -% 'curr_value' => $value, -% #doesn't work#'element_etc' => $disabled, -% ); -% -% } elsif ( $def->{type} eq 'select-hardware' ) { -% -% $html .= qq!!; -% $html .= include('/elements/select-hardware_class.html', -% 'curr_value' => $value, -% 'element_name' => "${layer}__${field}_classnum", -% 'element_etc' => $flag ne 'H' && $nodisplay, -% 'empty_label' => 'Select hardware class', -% ); -% -% } elsif ( $def->{type} eq 'disabled' ) { -% -% $html .= -% qq!!; -% -% } else { -% -% $html .= 'unknown type '. $def->{type}; -% -% } -% -% $html .= "\n"; +function flag_changed(obj) { + var newflag = obj.value; + var a = obj.name.match(/(.*)__(.*)_flag/); + var layer = a[1]; + var field = a[2]; + var input = document.getElementById(layer + '__' + field); + // for fields that have both 'input' and 'select', 'select' is 'select from + // inventory class'. + var select = document.getElementById(layer + '__' + field + '_select'); + if (newflag == "" || newflag == "X") { // disable + if ( input ) { + input.disabled = true; + input.className = 'disabled'; + } + if ( select ) { + select.disabled = true; + select.className = 'hidden'; + } + } else if ( newflag == 'D' || newflag == 'F' || newflag == 'S' ) { + if ( input ) { + // enable text box, disable inventory select + input.disabled = false; + input.className = 'enabled'; + if ( select ) { + select.disabled = false; + select.className = 'hidden'; + } + } else if ( select ) { + // enable select + select.disabled = false; + select.className = 'enabled'; + if ( newflag == 'S' || select.getAttribute('should_be_multiple') ) { + select.multiple = true; + var defaults = select.getAttribute('default'); + if ( defaults ) { + defaults = defaults.split(','); + for (var i = 0; i < defaults.length; i++) { + for (j = 0; j < select.options.length; j++ ) { + if ( defaults[i] == select.options[j].value ) { + select.options[j].selected = true; + } + } + } + } + } else { + select.multiple = false; + } + } + } else if ( newflag == 'M' || newflag == 'A' || newflag == 'H' ) { + // these all require a class selection + if ( select ) { + select.disabled = false; + select.className = 'enabled'; + if ( input ) { + input.disabled = false; + input.className = 'hidden'; + } + } + } +} + +window.onload = function() { + var selects = document.getElementsByTagName('SELECT'); + for(i = 0; i < selects.length; i++) { + var obj = selects[i]; + if ( obj.multiple ) { + obj.setAttribute('should_be_multiple', true); + } + } + for(i = 0; i < selects.length; i++) { + var obj = selects[i]; + if ( obj.name.match(/_flag$/) ) { + flag_changed(obj); + } + } +}; + + + + -% $def_info = "($def_info)" if $def_info; -% $html .= -% qq!!. -% qq! !. -% qq! $def_info!. -% qq! !. -% qq!\n!; -% -% } #foreach my $field (@fields) { -% -% $part_svc->svcpart('') if $clone; #undone -% $html .= ""; -% -% $html .= include('/elements/progress-init.html', -% $layer, #form name -% [ qw(svc svcpart disabled preserve exportnum), -% @fields ], -% 'process/part_svc.cgi', -% $p.'browse/part_svc.cgi', -% $layer, -% ); -% $html .= '
'; -% -% #$html .= '
'; -% -% $html; -% -% }, -% ); -% -% +Service Part #<% $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %> + + + + + + +<& /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 %> <% include('/elements/footer.html') %> @@ -415,88 +196,43 @@ my $action = $part_svc->svcpart ? 'Edit' : 'Add'; my $hashref = $part_svc->hashref; # my $p_svcdb = $part_svc->svcdb || 'svc_acct'; -my %communigate_fields = ( - 'svc_acct' => { map { $_=>1 } - qw( file_quota file_maxnum file_maxsize - password_selfchange password_recover - ), - grep /^cgp_/, fields('svc_acct') - }, - 'svc_domain' => { map { $_=>1 } - qw( max_accounts trailer parent_svcnum ), - grep /^(cgp|acct_def)_/, fields('svc_domain') - }, - #'svc_forward' => { map { $_=>1 } qw( ) }, - #'svc_mailinglist' => { map { $_=>1 } qw( ) }, - #'svc_cert' => { map { $_=>1 } qw( ) }, -); - -my $svcdb_info = ' - - - - - - - - - - - - -
GenericAccessTelephony
-
    -
  • svc_acct: Accounts - anything with a username (mailbox, shell, RADIUS, etc.) -
  • svc_hardware: Equipment supplied to customers -
  • svc_external: Externally-tracked service -
-
-
    -
  • svc_dsl: DSL -
  • svc_broadband: Wireless broadband -
  • svc_dish: DISH Network -
-
-
    -
  • svc_phone: Customer phone number -
  • svc_pbx: Customer PBX -
-
-
- - - - - - - - -
HostingColocation
-
    -
  • svc_domain: Domain -
  • svc_cert: Certificate -
  • svc_forward: Mail forwarding -
  • svc_mailinglist: Mailing list -
  • svc_www: Virtual domain website -
-
-
    -
  • svc_port: Customer router/switch port -
-
- -'; -my $mod_info = ' -For the selected table, you can give fields default or fixed (unchangable) -values, or select an inventory class to manually or automatically fill in -that field. -'; +my @dbs = $hashref->{svcdb} + ? ( $hashref->{svcdb} ) + : FS::part_svc->svc_tables(); + +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' => 763, + #'height' => 400, + ); +} +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_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 + ) + } +);