summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-10-16 10:15:01 +0000
committerivan <ivan>2004-10-16 10:15:01 +0000
commitdbc6a01ed6a3b4373b01bf985ca735386dd047d4 (patch)
treed3e30bf7d503540d4698f28bcaca7014745c5706
parentbb60bac36854bcd609563dd4b1500bfcdc1449ec (diff)
add artera turbo export
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/part_export/artera_turbo.pm143
-rw-r--r--FS/FS/svc_external.pm2
-rwxr-xr-xFS/bin/freeside-setup2
-rw-r--r--README.1.5.0pre63
-rw-r--r--httemplate/docs/upgrade10.html2
6 files changed, 156 insertions, 3 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index bd3ff3e..c8fd7cd 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1291,6 +1291,13 @@ httemplate/docs/config.html
'select_enum' => [ 'none', 'username', 'username@domain' ],
},
+ {
+ 'key' => 'svc_external-skip_manual',
+ 'section' => 'UI',
+ 'description' => 'When provisioning svc_external services, skip manual entry of id and title fields in the UI. Usually used in conjunction with an export that populates these fields (i.e. artera_turbo).',
+ 'type' => 'checkbox',
+ },
+
);
1;
diff --git a/FS/FS/part_export/artera_turbo.pm b/FS/FS/part_export/artera_turbo.pm
new file mode 100644
index 0000000..60cafc3
--- /dev/null
+++ b/FS/FS/part_export/artera_turbo.pm
@@ -0,0 +1,143 @@
+package FS::part_export::artera_turbo;
+
+use vars qw(@ISA %info);
+use Tie::IxHash;
+use FS::Record qw(qsearch);
+use FS::part_export;
+use FS::cust_svc;
+use FS::svc_external;
+
+@ISA = qw(FS::part_export);
+
+tie my %options, 'Tie::IxHash',
+ 'rid' => { 'label' => 'Reseller ID (RID)' },
+ 'username' => { 'label' => 'Reseller username', },
+ 'password' => { 'label' => 'Reseller password', },
+ 'pid' => { 'label' => 'Artera Product ID', },
+ 'priceid' => { 'label' => 'Artera Price ID', },
+ 'agent_aid' => { 'label' => 'Export agentnum values to Artera AID',
+ 'type' => 'checkbox',
+ },
+ 'production' => { 'label' => 'Production mode (leave unchecked for staging)',
+ 'type' => 'checkbox',
+ },
+;
+
+%info = (
+ 'svc' => 'svc_external',
+ #'svc' => [qw( svc_acct svc_forward )],
+ 'desc' =>
+ 'Real-time export to Artera Turbo Reseller API',
+ 'options' => \%options,
+ #'nodomain' => 'Y',
+ 'notes' => <<'END'
+Real-time export to <a href="http://www.arteraturbo.com/">Artera Turbo</a>
+Reseller API. Requires installation of
+<a href="http://search.cpan.org/dist/Net-Artera">Net::Artera</a>
+from CPAN.
+END
+);
+
+sub rebless { shift; }
+
+sub _new_Artera {
+ my $self = shift;
+
+ my $artera = new Net::Artera (
+ map { $_ => $self->option($_) }
+ qw( rid username password production )
+ );
+}
+
+
+sub _export_insert {
+ my($self, $svc_external) = (shift, shift);
+
+ # want the ASN (serial) and AKC (key code) right away
+
+ eval "use Net::Artera;";
+ return $@ if $@;
+
+ my $artera = $self->_new_Artera;
+
+ my $cust_pkg = $svc_external->cust_svc->cust_pkg;
+ my $part_pkg = $cust_pkg->part_pkg;
+ my @svc_acct = grep { $_->table eq 'svc_acct' }
+ map { $_->svc_x }
+ sort { my $svcpart = $part_pkg->svcpart('svc_acct');
+ ($b->svcpart==$svcpart) cmp ($a->svcpart==$svcpart); }
+ qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum } );
+ my $email = scalar(@svc_acct) ? $svc_acct[0]->email : '';
+
+ my $cust_main = $cust_pkg->cust_main;
+
+ my $result = $artera->newOrder(
+ 'pid' => $self->option('pid'),
+ 'priceid' => $self->option('priceid'),
+ 'email' => $email,
+ 'cname' => $cust_main->name,
+ 'ref' => $svc_external->svcnum,
+ 'aid' => ( $self->option('agent_aid') ? $cust_main->agentnum : '' ),
+ 'add1' => $cust_main->address1,
+ 'add2' => $cust_main->address2,
+ 'add3' => $cust_main->city,
+ 'add4' => $cust_main->state,
+ 'zip' => $cust_main->zip,
+ 'cid' => $cust_main->country,
+ 'phone' => $cust_main->daytime || $cust_main->night,
+ 'fax' => $cust_main->fax,
+ );
+
+ if ( $result->{'id'} == 1 ) {
+ my $new = new FS::svc_external { $svc_external->hash };
+ $new->id($result->{'ASN'});
+ $new->title($result->{'AKC'});
+ $new->replace($svc_external);
+ } else {
+ $result->{'message'} || 'No response from Artera';
+ }
+}
+
+sub _export_replace {
+ my( $self, $new, $old ) = (shift, shift, shift);
+ #except the first time, hehe..
+ #return "can't change serial number with Artera"
+ # if $old->id != $new->id;
+ #return "can't change key code with Artera"
+ # if $old->title ne $new->title;
+ '';
+}
+
+sub _export_delete {
+ my( $self, $svc_external ) = (shift, shift);
+ $self->StatusChange(17, $svc_external);
+}
+
+sub _export_suspend {
+ my( $self, $svc_external ) = (shift, shift);
+ $self->StatusChange(16, $svc_external);
+}
+
+sub _export_unsuspend {
+ my( $self, $svc_external ) = (shift, shift);
+ $self->StatusChange(15, $svc_external);
+}
+
+sub StatusChange {
+ my( $self, $status, $svc_external ) = @_;
+
+ my $artera = $self->_new_Artera;
+
+ my $result = $artera->StatusChange(
+ 'asn' => sprintf('%010d', $svc_external->id),
+ 'akc' => $svc_external->title,
+ 'statusid' => $status,
+ );
+
+ $result->{'id'} == 1
+ ? ''
+ : $result->{'message'};
+}
+
+1;
+
diff --git a/FS/FS/svc_external.pm b/FS/FS/svc_external.pm
index b97e12b..79eec97 100644
--- a/FS/FS/svc_external.pm
+++ b/FS/FS/svc_external.pm
@@ -158,7 +158,7 @@ sub check {
my $error =
$self->ut_numbern('svcnum')
- || $self->ut_number('id')
+ || $self->ut_numbern('id')
|| $self->ut_textn('title')
;
diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
index 386c4c7..5de71a9 100755
--- a/FS/bin/freeside-setup
+++ b/FS/bin/freeside-setup
@@ -1127,7 +1127,7 @@ sub tables_hash_hack {
'svc_external' => {
'columns' => [
'svcnum', 'int', '', '',
- 'id', 'int', '', '',
+ 'id', 'int', 'NULL', '',
'title', 'varchar', 'NULL', $char_d,
],
'primary_key' => 'svcnum',
diff --git a/README.1.5.0pre6 b/README.1.5.0pre6
index bd5e39b..9fcfd2e 100644
--- a/README.1.5.0pre6
+++ b/README.1.5.0pre6
@@ -25,6 +25,9 @@ CREATE TABLE cust_pay_void (
);
CREATE INDEX cust_pay_void1 ON cust_pay_void(custnum);
+alter table svc_external alter column id drop not null;
+alter table h_svc_external alter column id drop not null;
+
dbdef-create username
create-history-tables username cust_pay_refund cust_pay_void
dbdef-create username
diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html
index 8922d19..6a11324 100644
--- a/httemplate/docs/upgrade10.html
+++ b/httemplate/docs/upgrade10.html
@@ -80,7 +80,7 @@ CREATE INDEX acct_snarf1 ON acct_snarf ( svcnum );
CREATE TABLE svc_external (
svcnum int NOT NULL,
- id int NOT NULL,
+ id int,
title varchar(80),
PRIMARY KEY (svcnum)
);