import rt 2.0.14
[freeside.git] / httemplate / edit / process / part_export.cgi
1 <%
2
3 my $exportnum = $cgi->param('exportnum');
4
5 my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum;
6
7 #fixup options
8 #warn join('-', split(',',$cgi->param('options')));
9 my %options = map {
10   my $value = $cgi->param($_);
11   $value =~ s/\r\n/\n/g; #browsers? (textarea)
12   $_ => $value;
13 } split(',', $cgi->param('options'));
14
15 my $new = new FS::part_export ( {
16   map {
17     $_, scalar($cgi->param($_));
18   } fields('part_export')
19 } );
20
21 my $error;
22 if ( $exportnum ) {
23   #warn $old;
24   #warn $exportnum;
25   #warn $new->machine;
26   $error = $new->replace($old,\%options);
27 } else {
28   $error = $new->insert(\%options);
29 #  $exportnum = $new->exportnum;
30 }
31
32 if ( $error ) {
33   $cgi->param('error', $error );
34   print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string );
35 } else {
36   print $cgi->redirect(popurl(3). "browse/part_export.cgi");
37 }
38
39 %>