show imported region and rate #s, RT#83146
[freeside.git] / httemplate / edit / svc_phone.cgi
index 2c19d2c..ef5cec6 100644 (file)
@@ -1,42 +1,68 @@
-<% include( 'elements/svc_Common.html',
-               'table'    => 'svc_phone',
-               'fields'   => \@fields,
-               'svc_new_callback' => sub {
-                 my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_;
-                 $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg;
-               },
-           )
-%>
+<& elements/svc_Common.html,
+     'table'            => 'svc_phone',
+     'fields'           => [],
+     'begin_callback'   => $begin_callback,
+     'svc_new_callback'   => $svc_callback,
+     'svc_edit_callback'  => $svc_callback,
+     'svc_error_callback' => $svc_callback,
+&>
 <%init>
+my $conf = new FS::Conf;
 
-die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+my $begin_callback = sub {
+  my( $cgi, $fields, $opt ) = @_;
 
-my $conf = new FS::Conf;
+  my $bulk = $cgi->param('bulk') ? 1 : 0;
+
+  my $right = $bulk ? 'Bulk provision customer service'
+                    :      'Provision customer service';
 
-my @fields = ( 'countrycode',
-               { field => 'phonenum',
-                 type  => 'select-did',
-                 label => 'Phone number',
-               },
-             );
-
-push @fields, { field => 'domsvc',
-                type  => 'select-svc-domain',
-                label => 'Domain',
-              }
-  if $conf->exists('svc_phone-domain');
-
-push @fields, { field => 'pbxsvc',
-                type  => 'select-svc_pbx',
-                label => 'PBX',
+  die "access denied"
+    unless $FS::CurrentUser::CurrentUser->access_right($right);
+
+  push @$fields,
+              'countrycode',
+              { field    => 'phonenum',
+                type     => 'select-did',
+                label    => 'Phone number',
+                multiple => $bulk,
               },
+              { field     => 'sim_imsi',
+                type      => 'text',
+                size      => 15,
+                maxlength => 15,
+              };
+
+  push @$fields, { field => 'domsvc',
+                   type  => 'select-svc-domain',
+                   label => 'Domain',
+                 }
+    if $conf->exists('svc_phone-domain');
+
+  push @$fields, { field => 'pbxsvc',
+                   type  => 'select-svc_pbx',
+                   label => 'PBX',
+                 };
+
+  if ( $bulk ) {
+
+    push @$fields, { field => 'bulk',
+                     type  => 'hidden',
+                     value => '1',
+                   };
+
+  } else {
+
+    push @$fields,
               'sip_password',
               'pin',
               { field => 'phone_name',
                 type  => 'text',
                 maxlength => $conf->config('svc_phone-phone_name-max_length'),
               },
+              { field => 'forward_svcnum',
+                type  => 'select-svc_phone-forward',
+              },
              'forwarddst',
              'email',
 
@@ -61,18 +87,26 @@ push @fields, { field => 'pbxsvc',
                   );
                 },
               },
+              { field   => 'e911_class',
+                type    => 'select',
+                options => [ keys(%{ FS::svc_phone->e911_classes }) ],
+                labels  => FS::svc_phone->e911_classes,
+              },
+              { field   => 'e911_type',
+                type    => 'select',
+                options => [ keys(%{ FS::svc_phone->e911_types }) ],
+                labels  => FS::svc_phone->e911_types,
+              },
               { field => 'custnum', type=> 'hidden' }, #for new cust_locations
-;
+    ;
+  }
 
-if ( $conf->exists('svc_phone-lnp') ) {
-    push @fields,
+  if ( $conf->exists('svc_phone-lnp') && !$bulk ) {
+    push @$fields,
             { value   => 'Number Portability',
              type    => 'tablebreak-tr-title',
                                colspan => 8,
             },
-           {   field => 'lnp_status',
-               type => 'select-lnp_status',
-           },
            'lnp_reject_reason',
            {   field => 'portable',
                type => 'checkbox',
@@ -87,7 +121,50 @@ if ( $conf->exists('svc_phone-lnp') ) {
            },
             'lnp_other_provider',
             'lnp_other_provider_account',
-;
-}
+    ;
+  }
+
+  if ( ! $bulk ) {
+
+    push @$fields,
+           {
+             type    => 'tablebreak-tr-title',
+             value   => 'Carrier Information',
+             colspan => 8,
+           },
+           { field => 'sip_server',
+             type  => 'select-sip_server',
+           },
+           { field => 'sms_carrierid',
+             label => 'SMS Carrier',
+             type  => 'select-cdr_carrier',
+           },
+           'sms_account',
+           'max_simultaneous',
+    ;
+
+  }
+
+}; # begin_callback
+
+# svc_edit_callback / svc_new_callback
+my $svc_callback = sub {
+  my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_;
+
+  push @$fields, {
+    field => 'circuit_svcnum',
+    type  => 'select-svc_circuit',
+    cust_pkg => $cust_pkg,
+    part_svc => $part_svc,
+  };
+
+  if ( $cust_pkg and not $svc_x->svcnum ) {
+    # new service, default to package location
+    $svc_x->set('locationnum', $cust_pkg->locationnum);
+  }
 
+  if ( not $conf->exists('showpasswords') and $svc_x->svcnum ) {
+    $svc_x->sip_password('*HIDDEN*');
+  }
+};
 </%init>