backport select_list changes from 1.5 so the fix for #118 works in 1.4 branch too
[freeside.git] / httemplate / edit / part_svc.cgi
index 683bf9e..ce8c463 100755 (executable)
@@ -67,6 +67,7 @@ blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
 <%
 #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',
@@ -87,7 +88,11 @@ my %defs = (
     'quota'     => '',
     '_password' => 'Password',
     'gid'       => 'GID (when blank, defaults to UID)',
-    'shell'     => 'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
+    'shell'     => {
+                     desc =>'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
+                     type =>'select',
+                     select_list => [ $conf->config('shells') ],
+                   },
     'finger'    => 'GECOS',
     'domsvc'    => {
                      desc =>'svcnum from svc_domain',
@@ -204,12 +209,20 @@ my %defs = (
           if ( $def->{type} eq 'select' ) {
             $html .= qq!<SELECT NAME="${layer}__${field}">!;
             $html .= '<OPTION> </OPTION>' unless $value;
-            foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
-              my $rvalue = $record->getfield($def->{select_key});
-              $html .= qq!<OPTION VALUE="$rvalue"!.
-                       ( $rvalue==$value ? ' SELECTED>' : '>' ).
-                       $record->getfield($def->{select_label}). '</OPTION>';
-            }
+            if ( $def->{select_table} ) {
+              foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
+                my $rvalue = $record->getfield($def->{select_key});
+                $html .= qq!<OPTION VALUE="$rvalue"!.
+                         ( $rvalue==$value ? ' SELECTED>' : '>' ).
+                         $record->getfield($def->{select_label}). '</OPTION>';
+              } #next $record
+            } else { # select_list
+              foreach my $item ( @{$def->{select_list}} ) {
+                $html .= qq!<OPTION VALUE="$item"!.
+                         ( $item eq $value ? ' SELECTED>' : '>' ).
+                         $item. '</OPTION>';
+              } #next $item
+            } #endif
             $html .= '</SELECT>';
           } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
             $html .= FS::svc_acct::radius_usergroup_selector(