finishing e911/svc_phone location, RT#7047
[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               'phone_name',
48
49               { value   => 'E911 Information',
50                 type    => 'tablebreak-tr-title',
51                 colspan => 7,
52               },
53               { field => 'locationnum',
54                 type  => 'select-cust_location',
55                 label => 'E911 location',
56                 include_opt_callback => sub {
57                   my $svc_phone = shift;
58                   my $pkgnum =  $svc_phone->get('pkgnum')
59                              || $cgi->param('pkgnum')
60                              || $svc_phone->cust_svc->pkgnum; #hua?
61                                #cross agent location exposure?  sheesh
62                   my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
63                   my $cust_main = $cust_pkg ? $cust_pkg->cust_main : '';
64                   ( 'no_bold'   => 1,
65                     'cust_pkg'  => $cust_pkg,
66                     'cust_main' => $cust_main,
67                   );
68                 },
69               },
70               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
71 ;
72
73
74 </%init>