communigate (phase 2): rules. RT#7514
[freeside.git] / httemplate / edit / svc_phone.cgi
1 <% include( 'elements/svc_Common.html',
2                'table'    => 'svc_phone',
3                'fields'   => \@fields,
4                'labels'   => {
5                                'svcnum'       => 'Service',
6                                'countrycode'  => 'Country code',
7                                'phonenum'     => 'Phone number',
8                                'domsvc'       => 'Domain',
9                                'sip_password' => 'SIP password',
10                                'pin'          => 'Voicemail PIN',
11                                'phone_name'   => 'Name',
12                                'pbxsvc'       => 'PBX',
13                                'locationnum'  => 'E911 location',
14                              },
15                'svc_new_callback' => sub {
16                  my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_;
17                  $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg;
18                },
19            )
20 %>
21 <%init>
22
23 die "access denied"
24   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
25
26 my $conf = new FS::Conf;
27
28 my @fields = ( 'countrycode',
29                { field => 'phonenum',
30                  type  => 'select-did',
31                  label => 'Phone number',
32                },
33              );
34
35 push @fields, { field => 'domsvc',
36                 type  => 'select-svc-domain',
37                 label => 'Domain',
38               }
39   if $conf->exists('svc_phone-domain');
40
41 push @fields, { field => 'pbxsvc',
42                 type  => 'select-svc_pbx',
43                 label => 'PBX',
44               },
45               'sip_password',
46               'pin',
47               { field => 'phone_name',
48                 type  => 'text',
49                 maxlength => $conf->config('svc_phone-phone_name-max_length'),
50               },
51
52               { value   => 'E911 Information',
53                 type    => 'tablebreak-tr-title',
54                 colspan => 7,
55               },
56               { field => 'locationnum',
57                 type  => 'select-cust_location',
58                 label => 'E911 location',
59                 include_opt_callback => sub {
60                   my $svc_phone = shift;
61                   my $pkgnum =  $svc_phone->get('pkgnum')
62                              || $cgi->param('pkgnum')
63                              || $svc_phone->cust_svc->pkgnum; #hua?
64                                #cross agent location exposure?  sheesh
65                   my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
66                   my $cust_main = $cust_pkg ? $cust_pkg->cust_main : '';
67                   ( 'no_bold'   => 1,
68                     'cust_pkg'  => $cust_pkg,
69                     'cust_main' => $cust_main,
70                   );
71                 },
72               },
73               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
74 ;
75
76
77 </%init>