diff options
author | Mark Wells <mark@freeside.biz> | 2014-04-04 18:56:48 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-04-07 14:11:47 -0700 |
commit | c8d94e67465c81cbdef6e85f6fe303cc3a403e63 (patch) | |
tree | 35380122b6301b875f4b012343e0091f0401a193 | |
parent | 9a51fd5542ee9979bea99a39c83d63e221e59155 (diff) |
cust_pkg import format with location, #28082
-rw-r--r-- | FS/FS/Schema.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_pkg/Import.pm | 23 | ||||
-rw-r--r-- | httemplate/misc/cust_pkg-import.html | 38 |
4 files changed, 62 insertions, 3 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 60860b056..30da415b7 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1865,7 +1865,7 @@ sub tables_hashref { 'manual_flag', 'char', 'NULL', 1, '', '', 'no_auto', 'char', 'NULL', 1, '', '', 'quantity', 'int', 'NULL', '', '', '', - 'agent_pkgid', 'int', 'NULL', '', '', '', + 'agent_pkgid', 'varchar', 'NULL', $char_d, '', '', 'waive_setup', 'char', 'NULL', 1, '', '', 'recur_show_zero', 'char', 'NULL', 1, '', '', 'setup_show_zero', 'char', 'NULL', 1, '', '', diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 60d42cfea..82cb479cf 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -654,7 +654,7 @@ sub check { || $self->ut_numbern('dundate') || $self->ut_enum('no_auto', [ '', 'Y' ]) || $self->ut_enum('waive_setup', [ '', 'Y' ]) - || $self->ut_numbern('agent_pkgid') + || $self->ut_textn('agent_pkgid') || $self->ut_enum('recur_show_zero', [ '', 'Y', 'N', ]) || $self->ut_enum('setup_show_zero', [ '', 'Y', 'N', ]) || $self->ut_foreign_keyn('main_pkgnum', 'cust_pkg', 'pkgnum') diff --git a/FS/FS/cust_pkg/Import.pm b/FS/FS/cust_pkg/Import.pm index fe69f82fd..694d8147f 100644 --- a/FS/FS/cust_pkg/Import.pm +++ b/FS/FS/cust_pkg/Import.pm @@ -106,6 +106,7 @@ my %formatfields = ( 'svc_acct' => [qw( username _password domsvc )], 'svc_phone' => [qw( countrycode phonenum sip_password pin )], 'svc_external' => [qw( id title )], + 'location' => [qw( address1 address2 city state zip country )], ); sub _formatfields { @@ -115,11 +116,31 @@ sub _formatfields { my %import_options = ( 'table' => 'cust_pkg', + 'preinsert_callback' => sub { + my($record, $param) = @_; + my @location_params = grep /^location\./, keys %$param; + if (@location_params) { + my $cust_location = FS::cust_location->new({ + 'custnum' => $record->custnum, + }); + foreach my $p (@location_params) { + $p =~ /^location.(\w+)$/; + $cust_location->set($1, $param->{$p}); + } + +warn Dumper $cust_location; # XXX + my $error = $cust_location->find_or_insert; # this avoids duplicates + return "error creating location: $error" if $error; + $record->set('locationnum', $cust_location->locationnum); + } + ''; + }, + 'postinsert_callback' => sub { my( $record, $param ) = @_; my $formatfields = _formatfields; - foreach my $svc_x ( grep { $_ ne 'default' } keys %$formatfields ) { + foreach my $svc_x ( grep /^svc/, keys %$formatfields ) { my $ff = $formatfields->{$svc_x}; diff --git a/httemplate/misc/cust_pkg-import.html b/httemplate/misc/cust_pkg-import.html index f86d317b9..94e7dd926 100644 --- a/httemplate/misc/cust_pkg-import.html +++ b/httemplate/misc/cust_pkg-import.html @@ -36,6 +36,9 @@ Import a file containing package records. <OPTION VALUE="svc_phone-agent_custid">Phone service with agent_custid <OPTION VALUE="svc_external">External service <OPTION VALUE="svc_external-agent_custid">External service with agent_custid + <OPTION VALUE="location">Location + <OPTION VALUE="location-agent_custid">Location with agent_custid + <OPTION VALUE="location-agent_custid-agent_pkgid">Location with agent_custid and agent_pkgid </SELECT> </TD> </TR> @@ -88,6 +91,27 @@ Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. <b>External service with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, id, title</i> <BR><BR> +<b>Location</b> format has the following field order: <i>custnum<%$req%>, +pkgpart<%$req%>, discountnum, +start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, +address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%> +</i> +<BR><BR> + +<b>Location with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, +pkgpart<%$req%>, discountnum, +start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, +address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%> +</i> +<BR><BR> + +<b>Location with agent_custid and agent_pkgid</b> format has the following field order: <i>agent_custid<%$req%>, agent_pkgid, +pkgpart<%$req%>, discountnum, +start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, +address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%> +</i> +<BR><BR> + <%$req%> Required fields <BR><BR> @@ -99,6 +123,8 @@ Field information: <li><i>agent_custid</i>: This specifies an existing customer record by agent_custid. + <li><i>agent_pkgid</i>: This specifies an existing customer record by agent_custid. + <li><i>pkgpart</i>: Package definition. Configuration -> Packages -> Package definitions <li><i>discountnum</i>: Optional discount. Configuration -> Packages -> Discounts @@ -129,6 +155,18 @@ Field information: <li><i>title</i>: External service identifier, text + <li><i>address1</i>: Service address, number and street, text + + <li><i>address2</i>: Service address, suite/unit/building identifier, text + + <li><i>city</i>: Service address, name of city, text + + <li><i>state</i>: Service address, state/province, abbreviated + + <li><i>zip</i>: Service address, postal code + + <li><i>country</i>: Service address, country, 2-letter code + </ul> <BR> |