5 <% include('/elements/header.html','Import successful') %>
6 <% include('/elements/footer.html') %>
11 unless $FS::CurrentUser::CurrentUser->access_right('Import');
13 my $cfh = $cgi->upload('codefile');
14 my $zfh = $cgi->upload('plus4file');
15 my $tfh = $cgi->upload('txmatrix');
16 my $dfh = $cgi->upload('detail');
20 my $oldAutoCommit = $FS::UID::AutoCommit;
21 local $FS::UID::AutoCommit = 0;
26 my ($cifh, $cdfh, $zifh, $zdfh, $tifh, $tdfh);
29 $cifh = new File::Temp( TEMPLATE => 'code.insert.XXXXXXXX',
30 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
31 ) or die "can't open temp file: $!\n";
33 $cdfh = new File::Temp( TEMPLATE => 'code.insert.XXXXXXXX',
34 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
35 ) or die "can't open temp file: $!\n";
39 $fh = $cifh if $_ =~ /"I"\s*$/;
40 $fh = $cdfh if $_ =~ /"D"\s*$/;
41 die "bad input line: $_" unless $fh;
48 $error = 'No code file';
51 $error ||= FS::tax_class::batch_import( {
53 'format' => scalar($cgi->param('format')),
59 $zifh = new File::Temp( TEMPLATE => 'plus4.insert.XXXXXXXX',
60 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
61 ) or die "can't open temp file: $!\n";
63 $zdfh = new File::Temp( TEMPLATE => 'plus4.insert.XXXXXXXX',
64 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
65 ) or die "can't open temp file: $!\n";
69 $fh = $zifh if $_ =~ /"I"\s*$/;
70 $fh = $zdfh if $_ =~ /"D"\s*$/;
71 die "bad input line: $_" unless $fh;
78 $error = 'No plus4 file';
81 $error ||= FS::cust_tax_location::batch_import( {
83 'format' => scalar($cgi->param('format')),
88 $tifh = new File::Temp( TEMPLATE => 'txmatrix.insert.XXXXXXXX',
89 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
90 ) or die "can't open temp file: $!\n";
92 $tdfh = new File::Temp( TEMPLATE => 'txmatrix.insert.XXXXXXXX',
93 DIR => $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc,
94 ) or die "can't open temp file: $!\n";
98 $fh = $tifh if $_ =~ /"I"\s*$/;
99 $fh = $tdfh if $_ =~ /"D"\s*$/;
100 die "bad input line: $_" unless $fh;
107 $error = 'No tax matrix file';
110 $error ||= FS::part_pkg_taxrate::batch_import( {
112 'format' => scalar($cgi->param('format')),
114 close $tifh if $tifh;
116 $error ||= defined($dfh)
117 ? FS::tax_rate::batch_update( {
119 'format' => scalar($cgi->param('format')),
121 : 'No tax detail file';
123 $error ||= FS::part_pkg_taxrate::batch_import( {
125 'format' => scalar($cgi->param('format')),
127 close $tdfh if $tdfh;
129 $error ||= FS::cust_tax_location::batch_import( {
131 'format' => scalar($cgi->param('format')),
133 close $zdfh if $zdfh;
135 $error ||= FS::tax_class::batch_import( {
137 'format' => scalar($cgi->param('format')),
139 close $cdfh if $cdfh;
142 $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
144 $dbh->commit or die $dbh->errstr if $oldAutoCommit;