diff options
author | Mark Wells <mark@freeside.biz> | 2014-12-30 16:04:48 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-12-30 16:04:48 -0800 |
commit | f041c3f6e17bdacf8ad6b0da87342ef84e7db404 (patch) | |
tree | f80115a8f5dacff6395ee26fd91ded929ac1a613 /FS | |
parent | 63e6a91136d87591d57a7f4e006dbfb41906a02c (diff) |
import deployment zone census block list, #32625
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Record.pm | 10 | ||||
-rw-r--r-- | FS/FS/deploy_zone.pm | 51 |
2 files changed, 56 insertions, 5 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 9fa8296..10b1cf6 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1711,7 +1711,7 @@ Table name (required). =item params -Listref of field names for static fields. They will be given values from the +Arrayref of field names for static fields. They will be given values from the PARAMS hashref and passed as a "params" hashref to batch_import. =item formats @@ -1760,10 +1760,10 @@ format_types). =back -PARAMS is a base64-encoded Storable string containing the POSTed data as -a hash ref. It normally contains at least one field, "uploaded files", -generated by /elements/file-upload.html and containing the list of uploaded -files. Currently only supports a single file named "file". +PARAMS is a hashref (or base64-encoded Storable hashref) containing the +POSTed data. It must contain the field "uploaded files", generated by +/elements/file-upload.html and containing the list of uploaded files. +Currently only supports a single file named "file". =cut diff --git a/FS/FS/deploy_zone.pm b/FS/FS/deploy_zone.pm index 6142b91..38dd7dc 100644 --- a/FS/FS/deploy_zone.pm +++ b/FS/FS/deploy_zone.pm @@ -3,6 +3,8 @@ package FS::deploy_zone; use strict; use base qw( FS::o2m_Common FS::Record ); use FS::Record qw( qsearch qsearchs dbh ); +use Storable qw(thaw); +use MIME::Base64; =head1 NAME @@ -265,6 +267,55 @@ sub deploy_zone_vertex { }); } +=back + +=head2 SUBROUTINES + +=over 4 + +=item process_batch_import JOB, PARAMS + +=cut + +sub process_batch_import { + eval { + use FS::deploy_zone_block; + use FS::deploy_zone_vertex; + }; + my $job = shift; + my $param = shift; + if (!ref($param)) { + $param = thaw(decode_base64($param)); + } + + # even if creating a new zone, the deploy_zone object should already + # be inserted by this point + my $zonenum = $param->{zonenum} + or die "zonenum required"; + my $zone = FS::deploy_zone->by_key($zonenum) + or die "deploy_zone #$zonenum not found"; + my $opt; + if ( $zone->zonetype eq 'B' ) { + $opt = { 'table' => 'deploy_zone_block', + 'params' => [ 'zonenum', 'censusyear' ], + 'formats' => { 'plain' => [ 'censusblock' ] }, + 'default_csv' => 1, + }; + $job->update_statustext('1,Inserting census blocks'); + } elsif ( $zone->zonetype eq 'P' ) { + $opt = { 'table' => 'deploy_zone_vertex', + 'params' => [ 'zonenum' ], + 'formats' => { 'plain' => [ 'latitude', 'longitude' ] }, + 'default_csv' => 1, + }; + } else { + die "don't know how to import to zonetype ".$zone->zonetype; + } + + FS::Record::process_batch_import( $job, $opt, $param ); + +} + =head1 BUGS =head1 SEE ALSO |