add enable_edit flag so serials and key codes can be edited locally
[freeside.git] / FS / FS / part_export / artera_turbo.pm
index c2de4d9..68910ed 100644 (file)
@@ -25,6 +25,9 @@ tie my %options, 'Tie::IxHash',
   'debug'      => { 'label' => 'Enable debug logging',
                     'type'  => 'checkbox',
                   },
+  'enable_edit' => { 'label' => 'Enable local editing of Artera serial numbers and key codes (note that the changes will NOT be exported to Artera)',
+                     'type'  => 'checkbox',
+                   },
 ;
 
 %info = (
@@ -101,7 +104,7 @@ sub _export_insert {
   if ( $result->{'id'} == 1 ) {
     my $new = new FS::svc_external { $svc_external->hash };
     $new->id(sprintf('%010d', $result->{'ASN'}));
-    $new->title(sprintf('%010d', $result->{'AKC'}));
+    $new->title(sprintf('%010x', hex($result->{'AKC'}) ));
     $new->replace($svc_external);
   } else {
     $result->{'message'} || 'No response from Artera';
@@ -110,6 +113,7 @@ sub _export_insert {
 
 sub _export_replace {
   my( $self, $new, $old ) = (shift, shift, shift);
+  return '' if $self->option('enable_edit');
   return "can't change serial number with Artera"
     if $old->id != $new->id && $old->id;
   return "can't change key code with Artera"
@@ -132,7 +136,7 @@ sub _export_unsuspend {
   $self->queue_statusChange(15, $svc_external);
 }
 
-sub queue_StatusChange {
+sub queue_statusChange {
   my( $self, $status, $svc_external ) = @_;
 
   my $queue = new FS::queue {
@@ -165,7 +169,7 @@ sub statusChange {
 
   my $result = $artera->statusChange(
     'asn'      => sprintf('%010d', $id),
-    'akc'      => sprintf('%010d', $title),
+    'akc'      => sprintf('%010x', hex($title)),
     'statusid' => $status,
   );