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