summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-01-19 02:29:23 -0800
committerIvan Kohler <ivan@freeside.biz>2015-01-19 02:29:23 -0800
commit8e2372530191ae32938786363885aa4b540e29c7 (patch)
treebce80235cfbaa36dacbcb6cd4879dc1263a9595c /FS
parent9837c59915b41af2b7f4d348083a70fa549e10b1 (diff)
import package definitions, RT#32639
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Record.pm11
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/part_pkg/Import.pm76
-rw-r--r--FS/bin/freeside-queued2
4 files changed, 88 insertions, 2 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 991c56ede..f8282c031 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -1809,6 +1809,7 @@ sub process_batch_import {
#?
default_csv => $opt->{default_csv},
postinsert_callback => $opt->{postinsert_callback},
+ insert_args_callback => $opt->{insert_args_callback},
);
if ( $opt->{'batch_namecol'} ) {
@@ -1895,6 +1896,9 @@ sub batch_import {
my $preinsert_callback = '';
$preinsert_callback = $param->{'preinsert_callback'}
if $param->{'preinsert_callback'};
+ my $insert_args_callback = '';
+ $insert_args_callback = $param->{'insert_args_callback'}
+ if $param->{'insert_args_callback'};
if ( $param->{'format'} ) {
@@ -2204,7 +2208,12 @@ sub batch_import {
next if exists $param->{skiprow} && $param->{skiprow};
}
- my $error = $record->insert;
+ my @insert_args = ();
+ if ( $insert_args_callback ) {
+ @insert_args = &{$insert_args_callback}($record, $param);
+ }
+
+ my $error = $record->insert(@insert_args);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 8d33f92cf..f51b5762d 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3052,6 +3052,7 @@ sub tables_hashref {
'part_pkg' => {
'columns' => [
'pkgpart', 'serial', '', '', '', '',
+ 'pkgpartbatch', 'varchar', 'NULL', $char_d, '', '',
'pkg', 'varchar', '', $char_d, '', '',
'comment', 'varchar', 'NULL', 2*$char_d, '', '',
'promo_code', 'varchar', 'NULL', $char_d, '', '',
diff --git a/FS/FS/part_pkg/Import.pm b/FS/FS/part_pkg/Import.pm
new file mode 100644
index 000000000..9e9044e7f
--- /dev/null
+++ b/FS/FS/part_pkg/Import.pm
@@ -0,0 +1,76 @@
+package FS::part_pkg::Import;
+
+use strict;
+use FS::Record;
+use FS::part_pkg;
+
+=head1 NAME
+
+FS::part_pkg::Import - Batch customer importing
+
+=head1 SYNOPSIS
+
+ use FS::part_pkg::Import;
+
+ #ajax helper
+ use FS::UI::Web::JSRPC;
+ my $server =
+ new FS::UI::Web::JSRPC 'FS::part_pkg::Import::process_batch_import', $cgi;
+ print $server->process;
+
+=head1 DESCRIPTION
+
+Batch package definition importing.
+
+=head1 SUBROUTINES
+
+=item process_batch_import
+
+Load a batch import as a queued JSRPC job
+
+=cut
+
+sub process_batch_import {
+ my $job = shift;
+
+ my $opt = { 'table' => 'part_pkg',
+ 'params' => [qw( agentnum pkgpartbatch )],
+ 'formats' => { 'default' => [
+ 'agent_pkgpartid',
+ 'pkg',
+ 'comment',
+ 'freq',
+ 'plan',
+ 'setup_fee',
+ 'recur_fee',
+ 'setup_cost',
+ 'recur_cost',
+ 'classnum',
+ 'taxclass',
+ ],
+ },
+ 'insert_args_callback' => sub {
+ my $part_pkg = shift;
+ ( 'options' => { 'setup_fee' => $part_pkg->get('setup_fee'),
+ 'recur_fee' => $part_pkg->get('recur_fee'),
+ },
+ );
+ },
+ #'default_csv' => 1,
+ };
+
+ FS::Record::process_batch_import( $job, $opt, @_ );
+
+}
+
+=head1 BUGS
+
+Not enough documentation.
+
+=head1 SEE ALSO
+
+L<FS::cust_main>, L<FS::part_pkg>
+
+=cut
+
+1;
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 70d853483..7c4cf1b64 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -196,7 +196,7 @@ while (1) {
dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
#auto-use classes...
- if ( $ljob->job =~ /(FS::(part_export|cust_main|cust_pkg|Cron)::\w+)::/
+ if ( $ljob->job =~ /(FS::(part_export|cust_main|cust_pkg|part_pkg|Cron)::\w+)::/
|| $ljob->job =~ /(FS::\w+)::/
)
{