diff options
author | ivan <ivan> | 2004-10-20 08:08:41 +0000 |
---|---|---|
committer | ivan <ivan> | 2004-10-20 08:08:41 +0000 |
commit | 787275a5f36e80bf26e2cf592592acc3e3f179db (patch) | |
tree | 301daa3c8531ce30c6a09c0dc8a54e9481b05bb1 /bin/artera.import | |
parent | eaf44792a30d0e879e5ab12682d0cd07faa77380 (diff) |
adding artera import
Diffstat (limited to 'bin/artera.import')
-rw-r--r-- | bin/artera.import | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/artera.import b/bin/artera.import new file mode 100644 index 000000000..f7def1bbe --- /dev/null +++ b/bin/artera.import @@ -0,0 +1,67 @@ +#!/usr/bin/perl -w + +use strict; + +use Text::CSV_XS; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearchs); +use FS::svc_external; +use FS::svc_domain; +use FS::svc_acct; + +$FS::svc_Common::noexport_hack = 1; + +my $svcpart = 30; + +my $user = shift + or die 'Usage:\n\n artera.import user <artera_active_orders.csv'; +adminsuidsetup $user; + +## + +my $csv = new Text::CSV_XS; + +my $header = scalar(<>); + +my( $num, $linked ) = ( 0, 0 ); + +while (<>) { + my $status = $csv->parse($_) + or die $csv->error_input; + my($serial, $keycode, $name, $ordernum, $email) = $csv->fields(); + #warn join(" - ", $serial, $keycode, $name, $ordernum, $email ). "\n"; + + $email =~ /^([^@]+)\@([^@]+)$/ + or die $email; + my($username, $domain) = ( $1, $2 ); + my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } ); + my $cust_svc = ''; + if ( $svc_domain ) { + my $svc_acct = qsearchs('svc_acct', { + 'username' => $username, + 'domsvc' => $svc_domain->svcnum, + } ); + $cust_svc = $svc_acct->cust_svc + if $svc_acct; + #} else { + # warn "can't find domain $domain\n"; + } + + my $svc_external = new FS::svc_external { + 'svcpart' => $svcpart, + 'pkgnum' => ( $cust_svc ? $cust_svc->pkgnum : '' ), + 'id' => $serial, + 'title' => $keycode, + }; + #my $error = $svc_external->check; + my $error = $svc_external->insert; + die $error if $error; + + $num++; + $linked++ if $cust_svc; + #print "$num imported, $linked linked\n"; + +} + +print "$num imported, $linked linked\n"; + |