stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / edit / svc_Common.html
index 6393f9e..5949a4d 100644 (file)
@@ -1,5 +1,14 @@
+<% include('elements/svc_Common.html',
+             'table'        => $table,
+            'post_url'     => popurl(1). "process/svc_Common.html",
+             %opt,
+         )
+%>
 <%init>
 
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
 # false laziness w/view/svc_Common.html
 
 $cgi->param('svcdb') =~ /^(svc_\w+)$/ or die "unparsable svcdb";
@@ -11,6 +20,7 @@ if ( UNIVERSAL::can("FS::$table", 'table_info') ) {
   $opt{'name'}   = "FS::$table"->table_info->{'name'};
 
   my $fields = "FS::$table"->table_info->{'fields'};
+
   my %labels = map { $_ => ( ref($fields->{$_})
                                ? $fields->{$_}{'label'}
                               : $fields->{$_}
@@ -19,12 +29,17 @@ if ( UNIVERSAL::can("FS::$table", 'table_info') ) {
                keys %$fields;
   $opt{'labels'} = \%labels;
 
+  #transform FS::svc_* table_info's structure into one edit.html likes
+  delete $fields->{svcnum};
+  $opt{'fields'} = [ map { ref $fields->{$_}
+                             ? { field => $_,
+                                 %{ $fields->{$_} }
+                               }
+                             : $_
+                          } keys %$fields
+                   ];
+
+
 }
 
 </%init>
-<% include('elements/svc_Common.html',
-             'table'        => $table,
-            'post_url'     => popurl(1). "process/svc_Common.html",
-            %opt,
-         )
-%>