add cust_event.no_action flag for events that conditionally execute, #36741
[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             {   field => 'lnp_status',
111                 type => 'select-lnp_status',
112             },
113             'lnp_reject_reason',
114             {   field => 'portable',
115                 type => 'checkbox',
116             },
117             'lrn',
118             {   field => 'lnp_desired_due_date',
119                 type => 'input-date-field',
120             },
121             {   field => 'lnp_due_date',
122                 type => 'input-date-field',
123                 noinit => 1,
124             },
125             'lnp_other_provider',
126             'lnp_other_provider_account',
127     ;
128   }
129
130   if ( ! $bulk ) {
131
132     push @$fields,
133            {
134              type    => 'tablebreak-tr-title',
135              value   => 'Carrier Information',
136              colspan => 8,
137            },
138            { field => 'sip_server',
139              type  => 'select-sip_server',
140            },
141            { field => 'sms_carrierid',
142              label => 'SMS Carrier',
143              type  => 'select-cdr_carrier',
144            },
145            'sms_account',
146            'max_simultaneous',
147     ;
148
149   }
150
151 }; # begin_callback
152
153 # svc_edit_callback / svc_new_callback
154 my $svc_callback = sub {
155   my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_;
156
157   push @$fields, {
158     field => 'circuit_svcnum',
159     type  => 'select-svc_circuit',
160     cust_pkg => $cust_pkg,
161     part_svc => $part_svc,
162   };
163
164   if ( $cust_pkg and not $svc_x->svcnum ) {
165     # new service, default to package location
166     $svc_x->set('locationnum', $cust_pkg->locationnum);
167   }
168
169   if ( not $conf->exists('showpasswords') and $svc_x->svcnum ) {
170     $svc_x->sip_password('*HIDDEN*');
171   }
172 };
173 </%init>