[freeside-commits] branch FREESIDE_3_BRANCH updated. c2b9c73711f245627492595320e18d3d986d61a6

Christopher Burger burgerc at freeside.biz
Tue Jun 19 11:49:39 PDT 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  c2b9c73711f245627492595320e18d3d986d61a6 (commit)
       via  b11b95320dcb860212129de464d6349e4ac6da5e (commit)
      from  77ffd5cb8c802e43cad458e859ef9c035d3b39f0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c2b9c73711f245627492595320e18d3d986d61a6
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Jun 19 14:48:58 2018 -0400

    RT# 77498 - fixed getting filename in  V3

diff --git a/FS/FS/contact/Import.pm b/FS/FS/contact/Import.pm
index 26bdcfa6e..7a71349bc 100644
--- a/FS/FS/contact/Import.pm
+++ b/FS/FS/contact/Import.pm
@@ -2,6 +2,8 @@ package FS::contact::Import;
 
 use strict;
 use vars qw( $DEBUG ); #$conf );
+use Storable qw(thaw);
+use MIME::Base64;
 use Data::Dumper;
 use FS::Misc::DateTime qw( parse_datetime );
 use FS::Record qw( qsearchs );
@@ -49,7 +51,8 @@ Load a batch import as a queued JSRPC job
 
 sub process_batch_import {
   my $job = shift;
-  my $param = shift;
+  #my $param = shift;
+  my $param = thaw(decode_base64(shift));
   warn Dumper($param) if $DEBUG;
   
   my $files = $param->{'uploaded_files'}

commit b11b95320dcb860212129de464d6349e4ac6da5e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Sep 18 09:35:02 2017 -0400

    RT# 77498 - Customer Import now uses contact/Import.pm rather than contact_import.pm
    
    Conflicts:
            FS/FS/contact_import.pm

diff --git a/FS/FS.pm b/FS/FS.pm
index 9ee5fc944..e1d65f9e7 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -67,6 +67,8 @@ L<FS::cust_main::Search> - Customer searching
 
 L<FS::cust_main::Import> - Batch customer importing
 
+L<FS::contact::Import> - Batch contact importing
+
 =head2 Database record classes
 
 L<FS::Record> - Database record base class
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 8a381a509..4db3cdfd1 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -12,6 +12,7 @@ use FS::contact_class;
 use FS::cust_location;
 use FS::contact_phone;
 use FS::contact_email;
+use FS::contact::Import;
 use FS::queue;
 use FS::cust_pkg;
 use FS::phone_type; #for cgi_contact_fields
diff --git a/FS/FS/contact_import.pm b/FS/FS/contact_import.pm
deleted file mode 100644
index 599132bc7..000000000
--- a/FS/FS/contact_import.pm
+++ /dev/null
@@ -1,164 +0,0 @@
-package FS::contact_import;
-
-use strict;
-use vars qw( $DEBUG ); #$conf );
-use Storable qw(thaw);
-use Data::Dumper;
-use MIME::Base64;
-use FS::Misc::DateTime qw( parse_datetime );
-use FS::Record qw( qsearchs );
-use FS::contact;
-use FS::cust_main;
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::contact_import - Batch contact importing
-
-=head1 SYNOPSIS
-
-  use FS::contact_import;
-
-  #import
-  FS::contact_import::batch_import( {
-    file      => $file,      #filename
-    type      => $type,      #csv or xls
-    format    => $format,    #default
-    agentnum  => $agentnum,
-    job       => $job,       #optional job queue job, for progressbar updates
-    pkgbatch  => $pkgbatch,  #optional batch unique identifier
-  } );
-  die $error if $error;
-
-  #ajax helper
-  use FS::UI::Web::JSRPC;
-  my $server =
-    new FS::UI::Web::JSRPC 'FS::contact_import::process_batch_import', $cgi;
-  print $server->process;
-
-=head1 DESCRIPTION
-
-Batch contact 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 $param = shift;
-  my $param = thaw(decode_base64(shift));
-  warn Dumper($param) if $DEBUG;
-  
-  my $files = $param->{'uploaded_files'}
-    or die "No files provided.\n";
-
-  my (%files) = map { /^(\w+):([\.\w]+)$/ ? ($1,$2):() } split /,/, $files;
-
-  my $dir = '%%%FREESIDE_CACHE%%%/cache.'. $FS::UID::datasrc. '/';
-
-  my $file = $dir. $files{'file'};
-
-  my $type;
-  if ( $file =~ /\.(\w+)$/i ) {
-    $type = lc($1);
-  } else {
-    #or error out???
-    warn "can't parse file type from filename $file; defaulting to CSV";
-    $type = 'csv';
-  }
-
-  my $error =
-    FS::contact_import::batch_import( {
-      job      => $job,
-      file     => $file,
-      type     => $type,
-      agentnum => $param->{'agentnum'},
-      'format' => $param->{'format'},
-    } );
-
-  unlink $file;
-
-  die "$error\n" if $error;
-
-}
-
-=item batch_import
-
-=cut
-
-my %formatfields = (
-  'default'      => [ qw( custnum last first title comment selfservice_access emailaddress phonetypenum1 phonetypenum3 phonetypenum2 ) ],
-);
-
-sub _formatfields {
-  \%formatfields;
-}
-
-## not tested but maybe allow 2nd format to attach location in the future
-my %import_options = (
-  'table'         => 'contact',
-
-  '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});
-      }
-
-      my $error = $cust_location->find_or_insert; # this avoids duplicates
-      return "error creating location: $error" if $error;
-      $record->set('locationnum', $cust_location->locationnum);
-    }
-    '';
-  },
-
-);
-
-sub _import_options {
-  \%import_options;
-}
-
-sub batch_import {
-  my $opt = shift;
-
-  my $iopt = _import_options;
-  $opt->{$_} = $iopt->{$_} foreach keys %$iopt;
-
-  my $format = delete $opt->{'format'};
-
-  my $formatfields = _formatfields();
-    die "unknown format $format" unless $formatfields->{$format};
-
-  my @fields;
-  foreach my $field ( @{ $formatfields->{$format} } ) {
-    push @fields, $field;
-  }
-
-  $opt->{'fields'} = \@fields;
-
-  FS::Record::batch_import( $opt );
-
-}
-
-=head1 BUGS
-
-Not enough documentation.
-
-=head1 SEE ALSO
-
-L<FS::contact>
-
-=cut
-
-1;
\ No newline at end of file
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 93835936a..d16282ffd 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -513,6 +513,7 @@ t/class_Common.t
 FS/category_Common.pm
 t/category_Common.t
 FS/contact.pm
+FS/contact/Import.pm
 t/contact.t
 FS/contact_phone.pm
 t/contact_phone.t
diff --git a/Makefile b/Makefile
index 4e6ffa322..e12b03f9f 100644
--- a/Makefile
+++ b/Makefile
@@ -235,7 +235,7 @@ perl-modules:
 	" blib/lib/FS/part_export/*.pm;\
 	perl -p -i -e "\
 	  s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
-	" blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
+	" blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm blib/lib/FS/contact/*.pm;\
 	perl -p -i -e "\
 	  s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
 	" blib/lib/FS/Daemon/*.pm;\
diff --git a/httemplate/misc/process/contact-import.cgi b/httemplate/misc/process/contact-import.cgi
index cbdcad455..108ee93e9 100644
--- a/httemplate/misc/process/contact-import.cgi
+++ b/httemplate/misc/process/contact-import.cgi
@@ -5,6 +5,6 @@ die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Import');
 
 my $server =
-  new FS::UI::Web::JSRPC 'FS::contact_import::process_batch_import', $cgi;
+  new FS::UI::Web::JSRPC 'FS::contact::Import::process_batch_import', $cgi;
 
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS.pm                                   |   2 +
 FS/FS/contact.pm                           |   1 +
 FS/FS/contact/Import.pm                    |   5 +-
 FS/FS/contact_import.pm                    | 164 -----------------------------
 FS/MANIFEST                                |   1 +
 Makefile                                   |   2 +-
 httemplate/misc/process/contact-import.cgi |   2 +-
 7 files changed, 10 insertions(+), 167 deletions(-)
 delete mode 100644 FS/FS/contact_import.pm




More information about the freeside-commits mailing list