This commit was generated by cvs2svn to compensate for changes in r6255,
[freeside.git] / httemplate / edit / process / part_export.cgi
1 %if ( $error ) {
2 %  $cgi->param('error', $error );
3 <% $cgi->redirect(popurl(2). "part_export.cgi?". $cgi->query_string ) %>
4 %} else {
5 <% $cgi->redirect(popurl(3). "browse/part_export.cgi") %>
6 %}
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
11
12 my $exportnum = $cgi->param('exportnum');
13
14 my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum;
15
16 #fixup options
17 #warn join('-', split(',',$cgi->param('options')));
18 my %options = map {
19   my $value = $cgi->param($_);
20   $value =~ s/\r\n/\n/g; #browsers? (textarea)
21   $_ => $value;
22 } split(',', $cgi->param('options'));
23
24 my $new = new FS::part_export ( {
25   map {
26     $_, scalar($cgi->param($_));
27   } fields('part_export')
28 } );
29
30 my $error;
31 if ( $exportnum ) {
32   #warn $old;
33   #warn $exportnum;
34   #warn $new->machine;
35   $error = $new->replace($old,\%options);
36 } else {
37   $error = $new->insert(\%options);
38 #  $exportnum = $new->exportnum;
39 }
40
41 </%init>