price plans web gui 1st pass, oh my
authorivan <ivan>
Mon, 15 Oct 2001 10:42:29 +0000 (10:42 +0000)
committerivan <ivan>
Mon, 15 Oct 2001 10:42:29 +0000 (10:42 +0000)
FS/FS/cust_main.pm
FS/FS/part_pkg.pm
README.1.4.0pre3-4
bin/fs-setup
httemplate/browse/part_pkg.cgi
httemplate/docs/config.html
httemplate/docs/schema.html
httemplate/docs/upgrade8.html
httemplate/edit/part_pkg.cgi
httemplate/edit/part_svc.cgi
httemplate/edit/process/part_pkg.cgi

index d5beca9..f99a15e 100644 (file)
@@ -216,10 +216,9 @@ otherwise returns false.
 
 CUST_PKG_HASHREF: If you pass a Tie::RefHash data structure to the insert
 method containing FS::cust_pkg and FS::svc_I<tablename> objects, all records
-are inserted atomicly, or the transaction is rolled back (this requries a 
-transactional database).  Passing an empty hash reference is equivalent to
-not supplying this parameter.  There should be a better explanation of this,
-but until then, here's an example:
+are inserted atomicly, or the transaction is rolled back.  Passing an empty
+hash reference is equivalent to not supplying this parameter.  There should be
+a better explanation of this, but until then, here's an example:
 
   use Tie::RefHash;
   tie %hash, 'Tie::RefHash'; #this part is important
@@ -233,7 +232,7 @@ INVOICING_LIST_ARYREF: If you pass an arrarref to the insert method, it will
 be set as the invoicing list (see L<"invoicing_list">).  Errors return as
 expected and rollback the entire transaction; it is not necessary to call 
 check_invoicing_list first.  The invoicing_list is set after the records in the
-CUST_PKG_HASHREF above are inserted, so it is now possible set set an
+CUST_PKG_HASHREF above are inserted, so it is now possible to set an
 invoicing_list destination to the newly-created svc_acct.  Here's an example:
 
   $cust_main->insert( {}, [ $email, 'POST' ] );
@@ -1216,9 +1215,9 @@ sub collect {
           }
 
           my @invoicing_list = grep { $_ ne 'POST' } $self->invoicing_list;
-          if ( $conf->exists('emailinvoiceonly') ) {
-            @invoicing_list = $self->default_invoicing_list
-              unless @invoicing_list;
+          if ( $conf->exists('emailinvoiceauto')
+               || ( $conf->exists('emailinvoiceonly') && ! @invoicing_list ) ) {
+            push @invoicing_list, $self->default_invoicing_list;
           }
           my $email = $invoicing_list[0];
 
@@ -1467,7 +1466,7 @@ sub apply_payments {
 
   }
 
-  # return 0; 
+  return $self->total_unapplied_payments;
 }
 
 =item total_credited
@@ -1559,15 +1558,17 @@ sub invoicing_list {
     } else {
       @cust_main_invoice = ();
     }
+    my %seen = map { $_->address => 1 } @cust_main_invoice;
     foreach my $address ( @{$arrayref} ) {
-      unless ( grep { $address eq $_->address } @cust_main_invoice ) {
-        my $cust_main_invoice = new FS::cust_main_invoice ( {
-          'custnum' => $self->custnum,
-          'dest'    => $address,
-        } );
-        my $error = $cust_main_invoice->insert;
-        warn $error if $error;
-      } 
+      #unless ( grep { $address eq $_->address } @cust_main_invoice ) {
+      next if exists $seen{$address} && $seen{$address};
+      $seen{$address} = 1;
+      my $cust_main_invoice = new FS::cust_main_invoice ( {
+        'custnum' => $self->custnum,
+        'dest'    => $address,
+      } );
+      my $error = $cust_main_invoice->insert;
+      warn $error if $error;
     }
   }
   if ( $self->custnum ) {
@@ -1603,6 +1604,8 @@ sub check_invoicing_list {
 
 =item default_invoicing_list
 
+Returns the email addresses of any 
+
 =cut
 
 sub default_invoicing_list {
@@ -1647,6 +1650,40 @@ sub referral_cust_main {
   @cust_main;
 }
 
+=item referral_cust_pkg [ DEPTH ]
+
+Like referral_cust_main, except returns a flat list of all unsuspended packages
+for each customer.  The number of items in this list may be useful for
+comission calculations (perhaps after a grep).
+
+=cut
+
+sub referral_cust_pkg {
+  my $self = shift;
+  my $depth = @_ ? shift : 1;
+
+  map { $_->unsuspended_pkgs }
+    grep { $_->unsuspended_pkgs }
+      $self->referral_cust_main($depth);
+}
+
+=item credit AMOUNT, REASON
+
+Applies a credit to this customer.  If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+sub credit {
+  my( $self, $amount, $reason ) = @_;
+  my $cust_credit = new FS::cust_credit {
+    'custnum' => $self->custnum,
+    'amount'  => $amount,
+    'reason'  => $reason,
+  };
+  $cust_credit->insert;
+}
+
 =back
 
 =head1 SUBROUTINES
@@ -1788,7 +1825,7 @@ sub append_fuzzyfiles {
 
 =head1 VERSION
 
-$Id: cust_main.pm,v 1.39 2001-10-09 23:10:16 ivan Exp $
+$Id: cust_main.pm,v 1.40 2001-10-15 10:42:28 ivan Exp $
 
 =head1 BUGS
 
index d262a04..d84b9c5 100644 (file)
@@ -46,11 +46,15 @@ inherits from FS::Record.  The following fields are currently supported:
 
 =item comment - Text name of this billing item definition (non-customer-viewable)
 
-=item setup - Setup fee
+=item setup - Setup fee expression
 
 =item freq - Frequency of recurring fee
 
-=item recur - Recurring fee
+=item recur - Recurring fee expression
+
+=item plan - Price plan
+
+=item plandata - Price plan data
 
 =back
 
@@ -128,6 +132,8 @@ sub check {
     || $self->ut_anything('setup')
     || $self->ut_number('freq')
     || $self->ut_anything('recur')
+    || $self->ut_alphan('plan')
+    || $self->ut_anything('plandata')
   ;
 }
 
@@ -166,7 +172,7 @@ sub svcpart {
 
 =head1 VERSION
 
-$Id: part_pkg.pm,v 1.2 1999-08-20 08:27:06 ivan Exp $
+$Id: part_pkg.pm,v 1.3 2001-10-15 10:42:28 ivan Exp $
 
 =head1 BUGS
 
index 102b578..49ca5a4 100644 (file)
@@ -14,6 +14,8 @@ CREATE INDEX part_pop_local1 ON part_pop_local ( npa, nxx );
 ALTER TABLE cust_pkg ADD manual_flag char(1) NULL;
 ALTER TABLE cust_pay_batch ADD paybatchnum integer;
 CREATE UNIQUE INDEX cust_pay_batch_pkey ON cust_pay_batch ( paybatchnum );
+ALTER TABLE part_pkg ADD plan varchar NULL;
+ALTER TABLE part_pkg ADD plandata varchar NULL;
 
 Run bin/dbdef-create
 
index edfc5ff..96ec2b7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.61 2001-10-09 23:10:17 ivan Exp $
+# $Id: fs-setup,v 1.62 2001-10-15 10:42:28 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -73,7 +73,7 @@ my($char_d) = 80; #default maxlength for text fields
 
 #my(@date_type)  = ( 'timestamp', '', ''     );
 my(@date_type)  = ( 'int', 'NULL', ''     );
-my(@perl_type) = ( 'varchar', 'NULL', 255  ); 
+my(@perl_type) = ( 'varchar', 'NULL', ''  ); 
 my @money_type = ( 'decimal',   '', '10,2' );
 
 ###
@@ -540,6 +540,8 @@ sub tables_hash_hack {
         'setup',      @perl_type,
         'freq',       'int', '', '',  #billing frequency (months)
         'recur',      @perl_type,
+        'plan',       'varchar', 'NULL', '',
+        'plandata',   'varchar', 'NULL', '',
       ],
       'primary_key' => 'pkgpart',
       'unique' => [ [] ],
index 1538a71..e20ba24 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: part_pkg.cgi,v 1.4 2001-09-04 14:44:06 ivan Exp $ -->
+#<!-- $Id: part_pkg.cgi,v 1.5 2001-10-15 10:42:28 ivan Exp $ -->
 
 use strict;
 use vars qw( $cgi $p $part_pkg );
@@ -27,9 +27,9 @@ print $cgi->header( '-expires' => 'now' ), header("Package Definition Listing",m
       <TR>
         <TH COLSPAN=2>Package</TH>
         <TH>Comment</TH>
-        <TH><FONT SIZE=-1>Setup Fee</FONT></TH>
         <TH><FONT SIZE=-1>Freq.</FONT></TH>
-        <TH><FONT SIZE=-1>Recur. Fee</FONT></TH>
+        <TH><FONT SIZE=-1>Plan</FONT></TH>
+        <TH><FONT SIZE=-1>Data</FONT></TH>
         <TH>Service</TH>
         <TH><FONT SIZE=-1>Quan.</FONT></TH>
       </TR>
@@ -42,6 +42,16 @@ foreach $part_pkg ( sort {
   my(@pkg_svc)=grep $_->getfield('quantity'),
     qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} });
   my($rowspan)=scalar(@pkg_svc);
+  my $plandata;
+  if ( $hashref->{plan} ) {
+    $plandata = $hashref->{plandata};
+    $plandata =~ s/^(\w+)=/$1&nbsp;/mg;
+    $plandata =~ s/\n/<BR>/g;
+  } else {
+    $hashref->{plan} = "(legacy)";
+    $plandata = "Setup&nbsp;". $hashref->{setup}.
+                "<BR>Recur&nbsp;". $hashref->{recur};
+  }
   print <<END;
       <TR>
         <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">
@@ -49,9 +59,9 @@ foreach $part_pkg ( sort {
         </A></TD>
         <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">$hashref->{pkg}</A></TD>
         <TD ROWSPAN=$rowspan>$hashref->{comment}</TD>
-        <TD ROWSPAN=$rowspan>$hashref->{setup}</TD>
         <TD ROWSPAN=$rowspan>$hashref->{freq}</TD>
-        <TD ROWSPAN=$rowspan>$hashref->{recur}</TD>
+        <TD ROWSPAN=$rowspan>$hashref->{plan}</TD>
+        <TD ROWSPAN=$rowspan>$plandata</TD>
 END
 
   my($pkg_svc);
index 63f6bab..3c6fe02 100644 (file)
@@ -53,7 +53,8 @@ All further configuration files and directories are located in
   <li><a name="disable_customer_referrals">disable_customer_referrals</a> - The existance of this file will disable new customer-to-customer referrals in the web interface.
   <li><a name="domain"><font color="#ff0000">domain</font></a> - Your domain name.
   <li><a name="editreferrals">editreferrals</a> - The existance of this file will allow you to change the referral of existing customers.
-  <li><a name="emailinvoiceonly">emailinvoiceonly</a>
+  <li><a name="emailinvoiceonly">emailinvoiceonly</a> - Disables postal mail invoices.
+  <li><a name="emailinvoiceauto">emailinvoiceauto</a> - Automatically adds new accounts to the email invoice list upon customer creation.
   <li><a name="erpcdmachines">erpcdmachines</a> - Your ERPCD authenticaion machines, one per line.  This enables export of `/usr/annex/acp_passwd' and `/usr/annex/acp_dialup'.
   <li><a name="hidecancelledpackages">hidecancelledpackages</a> - The existance of this file will prevent cancelled packages from showing up in listings (though they will still be in the database)
   <li><a name="hidecancelledcustomers">hidecancelledcustomers</a> - The existance of this file will prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)
index d831c59..88b4cb2 100644 (file)
         <li>pkgpart - primary key
         <li>pkg - package name
         <li>comment - non-customer visable package comment
-        <li>setup - setup fee
+        <li>setup - setup fee expression
         <li>freq - recurring frequency (months)
-        <li>recur - recurring fee
+        <li>recur - recurring fee expression
+        <li>plan - price plan
+        <li>plandata - additional price plan data
       </ul>
     <li><a name="part_referral" href="man/FS/part_referral.html">part_referral</a> - Referral listing
       <ul>
index 79eb6da..c317e88 100644 (file)
@@ -135,6 +135,8 @@ ALTER TABLE cust_pay ADD custnum integer;
 ALTER TABLE cust_pay_batch ADD paybatchnum integer;
 ALTER TABLE cust_refund ADD custnum integer;
 ALTER TABLE cust_pkg ADD manual_flag char(1) NULL;
+ALTER TABLE part_pkg ADD plan varchar NULL;
+ALTER TABLE part_pkg ADD plandata varchar NULL;
 CREATE INDEX cust_main3 ON cust_main ( referral_custnum );
 CREATE INDEX cust_credit_bill1 ON cust_credit_bill ( crednum );
 CREATE INDEX cust_credit_bill2 ON cust_credit_bill ( invnum );
@@ -223,7 +225,7 @@ CREATE TABLE cust_pay_temp (
 INSERT INTO cust_pay_temp SELECT * from cust_pay;
 DROP TABLE cust_pay;
 ALTER TABLE cust_pay_temp RENAME TO cust_pay;
-CREATE UNIQUE INDEX cust_pay1 ON cust_pay paynum;
+CREATE UNIQUE INDEX cust_pay1 ON cust_pay (paynum);
 CREATE TABLE cust_refund_temp (
   refundnum int primary key,
   custnum int not null,
@@ -238,7 +240,7 @@ CREATE TABLE cust_refund_temp (
 INSERT INTO cust_refund_temp SELECT * from cust_refund;
 DROP TABLE cust_refund;
 ALTER TABLE cust_refund_temp RENAME TO cust_refund;
-CREATE UNIQUE INDEX cust_refund1 ON cust_refund refundnum;
+CREATE UNIQUE INDEX cust_refund1 ON cust_refund (refundnum);
 </pre></font>
 </td><td>
 <font size=-1><pre>
index b7707f3..a4123e1 100755 (executable)
@@ -1,23 +1,7 @@
-<!-- $Id: part_pkg.cgi,v 1.3 2001-10-11 17:44:33 ivan Exp $ -->
-
-<% my $plan = 'flat'; %>
-
-<SCRIPT>
-function visualize(what) {
-  if (document.getElementById) {
-    document.getElementById('d<%= $plan %>').style.visibility = "visible";
-  } else {
-    document.l<%= $plan %>.visibility = "visible";
-  }
-}
-</SCRIPT>
+<!-- $Id: part_pkg.cgi,v 1.4 2001-10-15 10:42:29 ivan Exp $ -->
 
 <%
 
-$cgi = new CGI;
-
-&cgisuidsetup($cgi);
-
 if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
   $cgi->param('clone', $1);
 } else {
@@ -44,16 +28,36 @@ if ( $cgi->param('clone') ) {
   $part_pkg ||= $old_part_pkg->clone;
 } elsif ( $query && $query =~ /^(\d+)$/ ) {
   $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
+  unless ( $part_pkg->plan ) {
+    $part_pkg->plan('flat');
+    $part_pkg->plandata("setup=". $part_pkg->setup. "\n".
+                        "recur=". $part_pkg->recur. "\n");
+  }
 } else {
   $part_pkg ||= new FS::part_pkg {};
+  $part_pkg->plan('flat');
 }
 $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add';
 my $hashref = $part_pkg->hashref;
 
+%>
+
+<SCRIPT>
+function visualize(what) {
+  if (document.getElementById) {
+    document.getElementById('d<%= $part_pkg->plan %>').style.visibility = "visible";
+  } else {
+    document.l<%= $part_pkg->plan %>.visibility = "visible";
+  }
+}
+</SCRIPT>
+
+<% 
+
 print header("$action Package Definition", menubar(
   'Main Menu' => popurl(2),
   'View all packages' => popurl(2). 'browse/part_pkg.cgi',
-));
+), ' onLoad="visualize()"');
 
 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
       "</FONT>"
@@ -136,8 +140,12 @@ my %plans = (
   'flat' => {
     'name' => 'Flat rate',
     'fields' => {
-      'setup_fee' => { 'name' => 'Setup fee for this package' },
-      'recur_fee' => { 'name' => 'Recurring fee for this package' },
+      'setup_fee' => { 'name' => 'Setup fee for this package',
+                       'default' => 0,
+                     },
+      'recur_fee' => { 'name' => 'Recurring fee for this package',
+                       'default' => 0,
+                      },
     },
     'setup' => 'what.setup_fee.value',
     'recur' => 'what.recur_fee.value',
@@ -146,13 +154,21 @@ my %plans = (
   'flat_comission' => {
     'name' => 'Flat rate with recurring referral comission as credit',
     'fields' => {
-      'setup_fee' => { 'name' => 'Setup fee for this package' },
-      'recur_fee' => { 'name' => 'Recurring fee for this package' },
-      'comission_amount' => { 'name' => 'Comission amount' },
-      'comission_depth' => { 'name' => 'Number of layers' },
+      'setup_fee' => { 'name' => 'Setup fee for this package',
+                       'default' => 0,
+                     },
+      'recur_fee' => { 'name' => 'Recurring fee for this package',
+                       'default' => 0,
+                     },
+      'comission_amount' => { 'name' => 'Comission amount',
+                              'default' => 0,
+                            },
+      'comission_depth'  => { 'name' => 'Number of layers',
+                              'default' => 1,
+                            },
     },
     'setup' => 'what.setup_fee.value',
-    'recur' => '\'$cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ) ; \' + what.recur_fee.value + \';\'',
+    'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
   },
 
 );
@@ -160,8 +176,7 @@ my %plans = (
 %>
 
 <SCRIPT>
-var svcdb = null;
-var something = null;
+var layer = null;
 
 function changed(what) {
   layer = what.options[what.selectedIndex].value;
@@ -185,9 +200,10 @@ function changed(what) {
 
 </SCRIPT>
 <BR>
-Price plan <SELECT NAME="plan" SIZE=1 onChange="changed(this)">
+Price plan <SELECT NAME="plan" SIZE=1 onChange="changed(this);">
+<OPTION>
 <% foreach my $layer (keys %plans ) { %>
-<OPTION VALUE="<%= $layer %>"<%= ' SELECTED'x($layer eq $plan) %>><%= $plans{$layer}->{'name'} %>
+<OPTION VALUE="<%= $layer %>"<%= ' SELECTED'x($layer eq $part_pkg->plan) %>><%= $plans{$layer}->{'name'} %>
 <% } %>
 </SELECT></FORM>
 
@@ -197,6 +213,7 @@ function fchanged(what) {
 }
 
 function fixup(what) {
+alert(what);
 <% foreach my $f ( qw( pkg comment freq ), @fixups ) { %>
   what.<%= $f %>.value = document.dummy.<%= $f %>.value;
 <% } %>
@@ -210,7 +227,9 @@ function fixup(what) {
 }
 </SCRIPT>
 
-<% #foreach my $layer ( 'konq_kludge', keys %plans ) { 
+<% my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
+                    split("\n", $part_pkg->plandata );
+   #foreach my $layer ( 'konq_kludge', keys %plans ) { 
    foreach my $layer ( 'konq_kludge', keys %plans ) {
      my $visibility = "hidden";
 %>
@@ -224,9 +243,9 @@ if (document.getElementById) {
 </SCRIPT>
 
 <FORM NAME="<%= $layer %>" ACTION="process/part_pkg.cgi" METHOD=POST onSubmit="fixup(this)">
-<INPUT TYPE="hidden" NAME="plan" VALUE="<%= $plan %>">
+<INPUT TYPE="hidden" NAME="plan" VALUE="<%= $part_pkg->plan %>">
 <INPUT TYPE="hidden" NAME="pkg" VALUE="<%= $hashref->{pkg} %>">
-<INPUT TYPE="hidden" NAME="comment" VALUE="$<%= hashref->{comment} %>">
+<INPUT TYPE="hidden" NAME="comment" VALUE="$<%= $hashref->{comment} %>">
 <INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>">
 <% foreach my $f ( @fixups ) { %>
 <INPUT TYPE="hidden" NAME="<%= $f %>" VALUE="">
@@ -245,12 +264,13 @@ print qq!<INPUT TYPE="hidden" NAME="pkgpart" VALUE="$hashref->{pkgpart}">!,
 <% my $href = $plans{$layer}->{'fields'};
    foreach my $field ( keys %{ $href } ) { %>
 <%= $href->{$field}{'name'} %>: 
-<INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= $ref->{$field}{'default'} %>" onChange="fchanged(this)"><BR>
+<INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= exists($plandata{$field}) ? $plandata{$field} : $href->{$field}{'default'} %>" onChange="fchanged(this)"><BR>
 <% } %>
+<INPUT TYPE="hidden" NAME="plandata" VALUE="<%= join(',', keys %{ $href } ) %>">
 
-<FONT SIZE="-2">
-Setup expression                    <INPUT TYPE="text" NAME="setup" SIZE="100%" VALUE="<%= $hashref->{setup} %>"><BR>
-Recurring espression                <INPUT TYPE="text" NAME="recur" SIZE="100%" VALUE="<%= $hashref->{recur} %>"><BR>
+<FONT SIZE="1">
+Setup expression<BR><INPUT TYPE="text" NAME="setup" SIZE="160" VALUE="<%= $hashref->{setup} %>" onLoad="fchanged(this)"><BR>
+Recurring espression<BR><INPUT TYPE="text" NAME="recur" SIZE="160" VALUE="<%= $hashref->{recur} %>" onLoad="fchanged(this)"><BR>
 </FONT>
 
 <%
@@ -273,9 +293,9 @@ if (document.getElementById) {
 
 <TAG onLoad="
     if (document.getElementById) {
-      document.getElementById('d<%= $plan %>').style.visibility = 'visible';
+      document.getElementById('d<%= $part_pkg->plan %>').style.visibility = 'visible';
     } else {
-      document.l<%= $plan %>.visibility = 'visible';
+      document.l<%= $part_pkg->plan %>.visibility = 'visible';
     }
 ">
   </BODY>
index 7797230..2977856 100755 (executable)
@@ -1,4 +1,4 @@
-<!-- $Id: part_svc.cgi,v 1.11 2001-09-11 19:16:41 ivan Exp $ -->
+<!-- $Id: part_svc.cgi,v 1.12 2001-10-15 10:42:29 ivan Exp $ -->
 <% 
    my $part_svc;
    if ( $cgi->param('error') ) { #error
@@ -65,7 +65,6 @@ blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
 <BR><BR>
 <SCRIPT>
 var svcdb = null;
-var something = null;
 function changed(what) {
   svcdb = what.options[what.selectedIndex].value;
 <% foreach my $svcdb ( qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ) ) { %>
index 5850599..6cfaa12 100755 (executable)
@@ -1,5 +1,5 @@
 <%
-#<!-- $Id: part_pkg.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ -->
+#<!-- $Id: part_pkg.cgi,v 1.3 2001-10-15 10:42:29 ivan Exp $ -->
 
 use strict;
 use vars qw( $cgi $pkgpart $old $new $part_svc $error $dbh );
@@ -19,6 +19,13 @@ $pkgpart = $cgi->param('pkgpart');
 
 $old = qsearchs('part_pkg',{'pkgpart'=>$pkgpart}) if $pkgpart;
 
+#fixup plandata
+my $plandata = $cgi->param('plandata');
+my @plandata = split(',', $plandata);
+$cgi->param('plandata', 
+  join('', map { "$_=". $cgi->param($_). "\n" } @plandata )
+);
+
 $new = new FS::part_pkg ( {
   map {
     $_, scalar($cgi->param($_));