34eb699bf1eff1a5724fb1ade5c2a5ff5685f3ab
[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 { $_=>$cgi->param($_) } split(',',$cgi->param('options'));
10
11 my $new = new FS::part_export ( {
12   map {
13     $_, scalar($cgi->param($_));
14   } fields('part_export')
15 } );
16
17 my $error;
18 if ( $exportnum ) {
19   warn $old;
20   warn $exportnum;
21   warn $new->machine;
22   $error = $new->replace($old,\%options);
23 } else {
24   $error = $new->insert(\%options);
25 #  $exportnum = $new->exportnum;
26 }
27
28 if ( $error ) {
29   $cgi->param('error', $error );
30   print $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string );
31 } else {
32   print $cgi->redirect(popurl(3). "browse/part_export.cgi");
33 }
34
35 %>