- should finish off the part_svc -> part_export s/one-to-many/many-to-many/
[freeside.git] / httemplate / edit / process / part_svc.cgi
index 31ab134..859670b 100755 (executable)
@@ -33,6 +33,29 @@ if ( $error ) {
   $cgi->param('error', $error);
   print $cgi->redirect(popurl(2). "part_svc.cgi?". $cgi->query_string );
 } else {
+
+  #false laziness w/ edit/process/agent_type.cgi
+  foreach my $part_export (qsearch('part_export',{})) {
+    my $exportnum = $part_export->exportnum;
+    my $export_svc = qsearchs('export_svc', {
+      'exportnum' => $part_export->exportnum,
+      'svcpart'   => $new->svcpart,
+    } );
+    if ( $export_svc && ! $cgi->param("exportnum". $part_export->exportnum) ) {
+      $error = $export_svc->delete;
+      die $error if $error;
+    } elsif ( $cgi->param("exportnum". $part_export->exportnum)
+              && ! $export_svc ) {
+      $export_svc = new FS::export_svc ( {
+        'exportnum' => $part_export->exportnum,
+        'svcpart'   => $new->svcpart,
+      } );
+      $error = $export_svc->insert;
+      die $error if $error;
+    }
+
+  }
+
   print $cgi->redirect(popurl(3)."browse/part_svc.cgi");
 }