2 % $cgi->param('error', $error );
3 <% $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string ) %>
5 <% $cgi->redirect(popurl(3). "browse/part_export.cgi") %>
10 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
12 my $exportnum = $cgi->param('exportnum');
14 my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum;
16 my %vars = $cgi->Vars;
18 #warn join('-', split(',',$cgi->param('options')));
20 my $value = $vars{$_};
21 $value =~ s/\0/ /g; # deal with multivalued options
22 $value =~ s/\r\n/\n/g; #browsers? (textarea)
24 } split(',', $cgi->param('options'));
26 # deal with multiline options
27 # %vars should never contain incomplete rows, but just in case it does,
28 # we make a list of all the row indices that contain values, and
29 # then write a line in each option for each row, even if it's empty.
30 # This ensures that all values with the same row index line up.
32 foreach my $option (split(',', $cgi->param('multi_options'))) {
33 $optionrows{$option} = {};
34 my %values; # bear with me
36 /^$option(\d+)/ or next;
37 $optionrows{$option}{$1} = $vars{$option.$1};
38 $optionrows{_ALL_}{$1} = 1 if length($vars{$option.$1});
41 foreach my $option (split(',', $cgi->param('multi_options'))) {
43 foreach my $row (sort keys %{$optionrows{_ALL_}}) {
44 $value .= ($optionrows{$option}{$row} || '') . "\n";
47 $options{$option} = $value;
50 my $new = new FS::part_export ( {
52 $_, scalar($cgi->param($_));
53 } fields('part_export')
61 $error = $new->replace($old,\%options);
63 $error = $new->insert(\%options);
64 # $exportnum = $new->exportnum;
67 my $info = FS::part_export::export_info()->{$new->exporttype};
69 my @nasnums = map { /^nasnum(\d+)$/ ? $1 : () } keys %{ $cgi->Vars };
70 $error ||= $new->process_m2m(
71 link_table => 'export_nas',
72 target_table => 'nas',