Option to ignore old CDRs, RT#81480
[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               { field => 'forward_svcnum',
64                 type  => 'select-svc_phone-forward',
65               },
66               'forwarddst',
67               'email',
68
69               { value   => 'E911 Information',
70                 type    => 'tablebreak-tr-title',
71                 colspan => 8,
72               },
73               { field => 'locationnum',
74                 type  => 'select-cust_location',
75                 label => 'E911 location',
76                 include_opt_callback => sub {
77                   my $svc_phone = shift;
78                   my $pkgnum =  $svc_phone->get('pkgnum')
79                              || $cgi->param('pkgnum')
80                              || $svc_phone->cust_svc->pkgnum; #hua?
81                                #cross agent location exposure?  sheesh
82                   my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
83                   my $cust_main = $cust_pkg ? $cust_pkg->cust_main : '';
84                   ( 'no_bold'   => 1,
85                     'cust_pkg'  => $cust_pkg,
86                     'cust_main' => $cust_main,
87                   );
88                 },
89               },
90               { field   => 'e911_class',
91                 type    => 'select',
92                 options => [ keys(%{ FS::svc_phone->e911_classes }) ],
93                 labels  => FS::svc_phone->e911_classes,
94               },
95               { field   => 'e911_type',
96                 type    => 'select',
97                 options => [ keys(%{ FS::svc_phone->e911_types }) ],
98                 labels  => FS::svc_phone->e911_types,
99               },
100               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
101     ;
102   }
103
104   if ( $conf->exists('svc_phone-lnp') && !$bulk ) {
105     push @$fields,
106             { value   => 'Number Portability',
107               type    => 'tablebreak-tr-title',
108                                 colspan => 8,
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 => 'sip_server',
136              type  => 'select-sip_server',
137            },
138            { field => 'sms_carrierid',
139              label => 'SMS Carrier',
140              type  => 'select-cdr_carrier',
141            },
142            'sms_account',
143            'max_simultaneous',
144     ;
145
146   }
147
148 }; # begin_callback
149
150 # svc_edit_callback / svc_new_callback
151 my $svc_callback = sub {
152   my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_;
153
154   push @$fields, {
155     field => 'circuit_svcnum',
156     type  => 'select-svc_circuit',
157     cust_pkg => $cust_pkg,
158     part_svc => $part_svc,
159   };
160
161   if ( $cust_pkg and not $svc_x->svcnum ) {
162     # new service, default to package location
163     $svc_x->set('locationnum', $cust_pkg->locationnum);
164   }
165
166   if ( not $conf->exists('showpasswords') and $svc_x->svcnum ) {
167     $svc_x->sip_password('*HIDDEN*');
168   }
169 };
170 </%init>