svc_hardware: better error messages for bad hw_addr when not validating as a MAC...
[freeside.git] / FS / FS / svc_circuit.pm
index 1a42efa..9b781aa 100644 (file)
@@ -40,40 +40,68 @@ supported:
 
 =over 4
 
 
 =over 4
 
-=item svcnum - primary key; see also L<FS::cust_svc>
+=item svcnum
 
 
-=item typenum - circuit type (such as DS1, DS1-PRI, DS3, OC3, etc.); foreign
+primary key; see also L<FS::cust_svc>
+
+=item typenum
+
+circuit type (such as DS1, DS1-PRI, DS3, OC3, etc.); foreign
 key to L<FS::circuit_type>.
 
 key to L<FS::circuit_type>.
 
-=item providernum - circuit provider (telco); foreign key to 
+=item providernum
+
+circuit provider (telco); foreign key to 
 L<FS::circuit_provider>.
 
 L<FS::circuit_provider>.
 
-=item termnum - circuit termination type; foreign key to 
+=item termnum
+
+circuit termination type; foreign key to 
 L<FS::circuit_termination>
 
 L<FS::circuit_termination>
 
-=item circuit_id - circuit ID string defined by the provider
+=item circuit_id
+
+provider circuit ID string defined by the provider
+
+=item desired_due_date
 
 
-=item desired_due_date - the requested date for completion of the circuit
+the requested date for completion of the circuit
 order
 
 order
 
-=item due_date - the provider's committed date for completion of the circuit
+=item due_date
+
+the provider's committed date for completion of the circuit
 order
 
 order
 
-=item vendor_order_id - the provider's order number
+=item vendor_order_id
+
+the provider's order number
+
+=item vendor_qual_id
 
 
-=item vendor_qual_id - the qualification number, if a qualification was 
+the qualification number, if a qualification was 
 performed
 
 performed
 
-=item vendor_order_type -
+=item vendor_order_type
 
 
-=item vendor_order_status - the order status: ACCEPTED, PENDING, COMPLETED,
+=item vendor_order_status
+
+the order status: ACCEPTED, PENDING, COMPLETED,
 etc.
 
 etc.
 
-=item endpoint_ip_addr - the IP address of the endpoint equipment, if any. 
+=item endpoint_ip_addr
+
+the IP address of the endpoint equipment, if any. 
 This will be validated as an IP address but not assigned from managed address
 space or checked for uniqueness.
 
 This will be validated as an IP address but not assigned from managed address
 space or checked for uniqueness.
 
-=item endpoint_mac_addr - the MAC address of the endpoint.
+=item endpoint_mac_addr
+
+the MAC address of the endpoint.
+
+=item internal_circuit_id
+
+internal circuit ID string
 
 =back
 
 
 =back
 
@@ -95,56 +123,57 @@ sub table_info {
               disabled_inventory => 1, disable_select => 1 );
 
   tie my %fields, 'Tie::IxHash', (
               disabled_inventory => 1, disable_select => 1 );
 
   tie my %fields, 'Tie::IxHash', (
-    'svcnum'            => 'Service',
-    'providernum'       => {
+    'svcnum'              => 'Service',
+    'providernum'         => {
                               label         => 'Provider',
                               type          => 'select',
                               select_table  => 'circuit_provider',
                               select_key    => 'providernum',
                               select_label  => 'provider',
                               disable_inventory => 1,
                               label         => 'Provider',
                               type          => 'select',
                               select_table  => 'circuit_provider',
                               select_key    => 'providernum',
                               select_label  => 'provider',
                               disable_inventory => 1,
-                           },
-    'typenum'           => {
+                             },
+    'typenum'             => {
                               label         => 'Circuit type',
                               type          => 'select',
                               select_table  => 'circuit_type',
                               select_key    => 'typenum',
                               select_label  => 'typename',
                               disable_inventory => 1,
                               label         => 'Circuit type',
                               type          => 'select',
                               select_table  => 'circuit_type',
                               select_key    => 'typenum',
                               select_label  => 'typename',
                               disable_inventory => 1,
-                           },
-    'termnum'           => {
+                             },
+    'termnum'             => {
                               label         => 'Termination type',
                               type          => 'select',
                               select_table  => 'circuit_termination',
                               select_key    => 'termnum',
                               select_label  => 'termination',
                               disable_inventory => 1,
                               label         => 'Termination type',
                               type          => 'select',
                               select_table  => 'circuit_termination',
                               select_key    => 'termnum',
                               select_label  => 'termination',
                               disable_inventory => 1,
-                           },
-    'circuit_id'        => { label => 'Circuit ID', %dis },
-    'desired_due_date'  => { label => 'Desired due date',
+                             },
+    'circuit_id'          => { label => 'Provider Circuit ID', %dis },
+    'desired_due_date'    => { label => 'Desired due date',
                              %dis
                              %dis
-                           },
-    'due_date'          => { label => 'Due date',
+                             },
+    'due_date'            => { label => 'Due date',
                              %dis
                              %dis
-                           },
-    'vendor_order_id'   => { label => 'Vendor order ID', %dis },
-    'vendor_qual_id'    => { label => 'Vendor qualification ID', %dis },
-    'vendor_order_type' => {
+                             },
+    'vendor_order_id'     => { label => 'Vendor order ID', %dis },
+    'vendor_qual_id'      => { label => 'Vendor qualification ID', %dis },
+    'vendor_order_type'   => {
                               label => 'Vendor order type',
                               disable_inventory => 1
                               label => 'Vendor order type',
                               disable_inventory => 1
-                           }, # should be a select?
+                             }, # should be a select?
     'vendor_order_status' => {
                               label => 'Vendor order status',
                               disable_inventory => 1
                              }, # should also be a select?
     'vendor_order_status' => {
                               label => 'Vendor order status',
                               disable_inventory => 1
                              }, # should also be a select?
-    'endpoint_ip_addr'  => {
+    'endpoint_ip_addr'    => {
                               label => 'Endpoint IP address',
                               label => 'Endpoint IP address',
-                           },
-    'endpoint_mac_addr' => {
+                             },
+    'endpoint_mac_addr'   => {
                               label => 'Endpoint MAC address',
                               type => 'input-mac_addr',
                               disable_inventory => 1,
                               label => 'Endpoint MAC address',
                               type => 'input-mac_addr',
                               disable_inventory => 1,
-                           },
+                             },
+    'internal_circuit_id' => { label => 'Internal Circuit ID', %dis },
   );
   return {
     'name'              => 'Circuit',
   );
   return {
     'name'              => 'Circuit',
@@ -198,6 +227,7 @@ sub check {
     || $self->ut_textn('vendor_order_status')
     || $self->ut_ipn('endpoint_ip_addr')
     || $self->ut_textn('endpoint_mac_addr')
     || $self->ut_textn('vendor_order_status')
     || $self->ut_ipn('endpoint_ip_addr')
     || $self->ut_textn('endpoint_mac_addr')
+    || $self->ut_textn('internal_circuit_id')
   ;
 
   # no canonical values yet for vendor_order_status or _type
   ;
 
   # no canonical values yet for vendor_order_status or _type
@@ -221,9 +251,9 @@ sub label {
 sub search_sql {
   my ($class, $string) = @_;
   my @where = ();
 sub search_sql {
   my ($class, $string) = @_;
   my @where = ();
-  push @where, 'LOWER(svc_circuit.circuit_id) = ' . dbh->quote($string);
-  push @where, 'LOWER(circuit_provider.provider) = ' . dbh->quote($string);
-  push @where, 'LOWER(circuit_type.typename) = ' . dbh->quote($string);
+  push @where, 'LOWER(svc_circuit.circuit_id) = LOWER(' . dbh->quote($string) . ')';
+  push @where, 'LOWER(circuit_provider.provider) = LOWER(' . dbh->quote($string) . ')';
+  push @where, 'LOWER(circuit_type.typename) = LOWER(' . dbh->quote($string) . ')';
   '(' . join(' OR ', @where) . ')';
 }
 
   '(' . join(' OR ', @where) . ')';
 }
 
@@ -232,6 +262,17 @@ sub search_sql_addl_from {
   'LEFT JOIN circuit_type USING ( typenum )';
 }
 
   'LEFT JOIN circuit_type USING ( typenum )';
 }
 
+sub _upgrade_data {
+
+  require FS::Misc::FixIPFormat;
+  FS::Misc::FixIPFormat::fix_bad_addresses_in_table(
+      'svc_circuit', 'svcnum', 'endpoint_ip_addr',
+  );
+
+  '';
+
+}
+
 =back
 
 =head1 SEE ALSO
 =back
 
 =head1 SEE ALSO
@@ -241,4 +282,3 @@ L<FS::Record>
 =cut
 
 1;
 =cut
 
 1;
-