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')
56 if ( $cgi->param('svc_machine') eq 'Y' ) {
57 $new->machine('_SVC_MACHINE');
58 $new->part_export_machine_textarea( $cgi->param('part_export_machine') );
59 $new->default_machine_name( $cgi->param('default_machine_name') );
67 $error = $new->replace($old,\%options);
69 $error = $new->insert(\%options);
70 # $exportnum = $new->exportnum;
73 my $info = FS::part_export::export_info()->{$new->exporttype};
75 my @nasnums = map { /^nasnum(\d+)$/ ? $1 : () } keys %{ $cgi->Vars };
76 $error ||= $new->process_m2m(
77 link_table => 'export_nas',
78 target_table => 'nas',