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'   => $svc_callback,
6      'svc_edit_callback'  => $svc_callback,
7      'svc_error_callback' => $svc_callback,
8 &>
9 <%init>
10 my $conf = new FS::Conf;
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   push @$fields,
24               'countrycode',
25               { field    => 'phonenum',
26                 type     => 'select-did',
27                 label    => 'Phone number',
28                 multiple => $bulk,
29               },
30               { field     => 'sim_imsi',
31                 type      => 'text',
32                 size      => 15,
33                 maxlength => 15,
34               };
35
36   push @$fields, { field => 'domsvc',
37                    type  => 'select-svc-domain',
38                    label => 'Domain',
39                  }
40     if $conf->exists('svc_phone-domain');
41
42   push @$fields, { field => 'pbxsvc',
43                    type  => 'select-svc_pbx',
44                    label => 'PBX',
45                  };
46
47   if ( $bulk ) {
48
49     push @$fields, { field => 'bulk',
50                      type  => 'hidden',
51                      value => '1',
52                    };
53
54   } else {
55
56     push @$fields,
57               'sip_password',
58               'pin',
59               { field => 'phone_name',
60                 type  => 'text',
61                 maxlength => $conf->config('svc_phone-phone_name-max_length'),
62               },
63               'forwarddst',
64               'email',
65
66               { value   => 'E911 Information',
67                 type    => 'tablebreak-tr-title',
68                 colspan => 8,
69               },
70               { field => 'locationnum',
71                 type  => 'select-cust_location',
72                 label => 'E911 location',
73                 include_opt_callback => sub {
74                   my $svc_phone = shift;
75                   my $pkgnum =  $svc_phone->get('pkgnum')
76                              || $cgi->param('pkgnum')
77                              || $svc_phone->cust_svc->pkgnum; #hua?
78                                #cross agent location exposure?  sheesh
79                   my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
80                   my $cust_main = $cust_pkg ? $cust_pkg->cust_main : '';
81                   ( 'no_bold'   => 1,
82                     'cust_pkg'  => $cust_pkg,
83                     'cust_main' => $cust_main,
84                   );
85                 },
86               },
87               { field   => 'e911_class',
88                 type    => 'select',
89                 options => [ keys(%{ FS::svc_phone->e911_classes }) ],
90                 labels  => FS::svc_phone->e911_classes,
91               },
92               { field   => 'e911_type',
93                 type    => 'select',
94                 options => [ keys(%{ FS::svc_phone->e911_types }) ],
95                 labels  => FS::svc_phone->e911_types,
96               },
97               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
98     ;
99   }
100
101   if ( $conf->exists('svc_phone-lnp') && !$bulk ) {
102     push @$fields,
103             { value   => 'Number Portability',
104               type    => 'tablebreak-tr-title',
105                                 colspan => 8,
106             },
107             {   field => 'lnp_status',
108                 type => 'select-lnp_status',
109             },
110             'lnp_reject_reason',
111             {   field => 'portable',
112                 type => 'checkbox',
113             },
114             'lrn',
115             {   field => 'lnp_desired_due_date',
116                 type => 'input-date-field',
117             },
118             {   field => 'lnp_due_date',
119                 type => 'input-date-field',
120                 noinit => 1,
121             },
122             'lnp_other_provider',
123             'lnp_other_provider_account',
124     ;
125   }
126
127   if ( ! $bulk ) {
128
129     push @$fields,
130            {
131              type    => 'tablebreak-tr-title',
132              value   => 'Carrier Information',
133              colspan => 8,
134            },
135            { field => 'sms_carrierid',
136              label => 'SMS Carrier',
137              type  => 'select-cdr_carrier',
138            },
139            'sms_account',
140            'max_simultaneous',
141     ;
142
143   }
144
145 }; # begin_callback
146
147 # svc_edit_callback / svc_new_callback
148 my $svc_callback = sub {
149   my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_;
150
151   push @$fields, {
152     field => 'circuit_svcnum',
153     type  => 'select-svc_circuit',
154     cust_pkg => $cust_pkg,
155     part_svc => $part_svc,
156   };
157
158   if ( $cust_pkg and not $svc_x->svcnum ) {
159     # new service, default to package location
160     $svc_x->set('locationnum', $cust_pkg->locationnum);
161   }
162
163   if ( not $conf->exists('showpasswords') and $svc_x->svcnum ) {
164     $svc_x->sip_password('*HIDDEN*');
165   }
166 };
167 </%init>