pod
[freeside.git] / httemplate / edit / svc_Common.html
1 <% include('elements/svc_Common.html',
2              'table'        => $table,
3              'post_url'     => popurl(1). "process/svc_Common.html",
4              %opt,
5           )
6 %>
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
11
12 # false laziness w/view/svc_Common.html
13
14 $cgi->param('svcdb') =~ /^(svc_\w+)$/ or die "unparsable svcdb";
15 my $table = $1;
16 require "FS/$table.pm";
17
18 my %opt;
19 if ( UNIVERSAL::can("FS::$table", 'table_info') ) {
20   $opt{'name'}   = "FS::$table"->table_info->{'name'};
21
22   my $fields = "FS::$table"->table_info->{'fields'};
23
24   my %labels = map { $_ => ( ref($fields->{$_})
25                                ? $fields->{$_}{'label'}
26                                : $fields->{$_}
27                            );
28                    }
29                keys %$fields;
30   $opt{'labels'} = \%labels;
31
32   #transform FS::svc_* table_info's structure into one edit.html likes
33   delete $fields->{svcnum};
34   $opt{'fields'} = [ map { ref $fields->{$_}
35                              ? { field => $_,
36                                  %{ $fields->{$_} }
37                                }
38                              : $_
39                           } keys %$fields
40                    ];
41
42
43 }
44
45 </%init>