Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / svc_phone.cgi
1 <& elements/svc_Common.html,
2      'table'            => 'svc_phone',
3      'fields'           => [],
4      'begin_callback'   => $begin_callback,
5      'svc_new_callback' => sub {
6        my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_;
7        $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg;
8      },
9 &>
10 <%init>
11
12 my $begin_callback = sub {
13   my( $cgi, $fields, $opt ) = @_;
14
15   my $bulk = $cgi->param('bulk') ? 1 : 0;
16
17   my $right = $bulk ? 'Bulk provision customer service'
18                     :      'Provision customer service';
19
20   die "access denied"
21     unless $FS::CurrentUser::CurrentUser->access_right($right);
22
23   my $conf = new FS::Conf;
24
25   push @$fields,
26               'countrycode',
27               { field    => 'phonenum',
28                 type     => 'select-did',
29                 label    => 'Phone number',
30                 multiple => $bulk,
31               },
32               { field     => 'sim_imsi',
33                 type      => 'text',
34                 size      => 15,
35                 maxlength => 15,
36               };
37
38   push @$fields, { field => 'domsvc',
39                    type  => 'select-svc-domain',
40                    label => 'Domain',
41                  }
42     if $conf->exists('svc_phone-domain');
43
44   push @$fields, { field => 'pbxsvc',
45                    type  => 'select-svc_pbx',
46                    label => 'PBX',
47                  };
48
49   if ( $bulk ) {
50
51     push @$fields, { field => 'bulk',
52                      type  => 'hidden',
53                      value => '1',
54                    };
55
56   } else {
57
58     push @$fields,
59               'sip_password',
60               'pin',
61               { field => 'phone_name',
62                 type  => 'text',
63                 maxlength => $conf->config('svc_phone-phone_name-max_length'),
64               },
65               'forwarddst',
66               'email',
67
68               { value   => 'E911 Information',
69                 type    => 'tablebreak-tr-title',
70                 colspan => 8,
71               },
72               { field => 'locationnum',
73                 type  => 'select-cust_location',
74                 label => 'E911 location',
75                 include_opt_callback => sub {
76                   my $svc_phone = shift;
77                   my $pkgnum =  $svc_phone->get('pkgnum')
78                              || $cgi->param('pkgnum')
79                              || $svc_phone->cust_svc->pkgnum; #hua?
80                                #cross agent location exposure?  sheesh
81                   my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
82                   my $cust_main = $cust_pkg ? $cust_pkg->cust_main : '';
83                   ( 'no_bold'   => 1,
84                     'cust_pkg'  => $cust_pkg,
85                     'cust_main' => $cust_main,
86                   );
87                 },
88               },
89               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
90     ;
91   }
92
93   if ( $conf->exists('svc_phone-lnp') && !$bulk ) {
94     push @$fields,
95             { value   => 'Number Portability',
96               type    => 'tablebreak-tr-title',
97                                 colspan => 8,
98             },
99             {   field => 'lnp_status',
100                 type => 'select-lnp_status',
101             },
102             'lnp_reject_reason',
103             {   field => 'portable',
104                 type => 'checkbox',
105             },
106             'lrn',
107             {   field => 'lnp_desired_due_date',
108                 type => 'input-date-field',
109             },
110             {   field => 'lnp_due_date',
111                 type => 'input-date-field',
112                 noinit => 1,
113             },
114             'lnp_other_provider',
115             'lnp_other_provider_account',
116     ;
117   }
118
119 };
120
121 </%init>