allow custom packages to edit service quantities also
[freeside.git] / httemplate / edit / part_pkg.cgi
index bead141..8e7a6c5 100755 (executable)
@@ -1,5 +1,4 @@
-<!-- $Id: part_pkg.cgi,v 1.10 2002-02-10 02:16:47 ivan Exp $ -->
-
+<!-- mason kludge -->
 <%
 
 if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {
@@ -30,8 +29,10 @@ if ( $cgi->param('clone') ) {
 } elsif ( $query && $query =~ /^(\d+)$/ ) {
   $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
 } else {
-  $part_pkg ||= new FS::part_pkg {};
-  $part_pkg->plan('flat');
+  unless ( $part_pkg ) {
+    $part_pkg = new FS::part_pkg {};
+    $part_pkg->plan('flat');
+  }
 }
 unless ( $part_pkg->plan ) { #backwards-compat
   $part_pkg->plan('flat');
@@ -109,7 +110,9 @@ my $thead =  "\n\n". ntable('#cccccc', 2). <<END;
 <TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH><TH BGCOLOR="#dcdcdc">Service</TH></TR>
 END
 
-unless ( $cgi->param('clone') ) {
+#unless ( $cgi->param('clone') ) {
+#dunno why...
+unless ( 0 ) {
   #print <<END, $thead;
   print <<END, itable(), '<TR><TD VALIGN="top">', $thead;
 <BR><BR>Enter the quantity of each service this package includes.<BR><BR>
@@ -134,7 +137,9 @@ foreach my $part_svc ( @part_svc ) {
 
   push @fixups, "pkg_svc$svcpart";
 
-  unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) {
+  #unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) {
+  #dunno why...
+  unless ( 0 ) {
     print '<TR>'; # if $count == 0 ;
     print qq!<TD><INPUT TYPE="text" NAME="pkg_svc$svcpart" SIZE=4 MAXLENGTH=3 VALUE="!,
           $cgi->param("pkg_svc$svcpart") || $pkg_svc->quantity || 0,
@@ -152,7 +157,9 @@ foreach my $part_svc ( @part_svc ) {
   }
 }
 
-unless ( $cgi->param('clone') ) {
+#unless ( $cgi->param('clone') ) {
+#dunno why...
+unless ( 0 ) {
   print "</TR></TABLE></TD></TR></TABLE>";
   #print "</TR></TABLE>";
 }
@@ -212,7 +219,7 @@ tie my %plans, 'Tie::IxHash',
   },
 
   'flat_comission' => {
-    'name' => 'Flat rate with recurring comission per active package',
+    'name' => 'Flat rate with recurring comission per (any) active package',
     'fields' => {
       'setup_fee' => { 'name' => 'Setup fee for this package',
                        'default' => 0,
@@ -233,7 +240,7 @@ tie my %plans, 'Tie::IxHash',
   },
 
   'flat_comission_pkg' => {
-    'name' => 'Flat rate with recurring comission per active (selected) package',
+    'name' => 'Flat rate with recurring comission per (selected) active package',
     'fields' => {
       'setup_fee' => { 'name' => 'Setup fee for this package',
                        'default' => 0,
@@ -280,7 +287,7 @@ tie my %plans, 'Tie::IxHash',
     },
     'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_hours', 'recur_hourly_charge' ],
     'setup' => 'what.setup_fee.value',
-    'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_bkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
+    'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
   },
 
   'sesmon_minute' => {
@@ -301,7 +308,7 @@ tie my %plans, 'Tie::IxHash',
     },
     'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_min', 'recur_minly_charge' ],
     'setup' => 'what.setup_fee.value',
-    'recur' => '\'my $min = $cust_pkg->seconds_since($cust_bkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_flat.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'',
+    'recur' => '\'my $min = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_flat.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'',
 
   },
 
@@ -417,7 +424,7 @@ if ( $cgi->param('pkgnum') ) {
        <INPUT TYPE="text" NAME="<%= $field %>" VALUE="<%= exists($plandata{$field}) ? $plandata{$field} : $href->{$field}{'default'} %>" onChange="fchanged(this)">
   <% } elsif ( $href->{$field}{'type'} eq 'select_multiple' ) { %>
        <SELECT MULTIPLE NAME="<%= $field %>" onChange="fchanged(this)">
-       <% foreach $record ( qsearch( $href->{$field}{'select_table'}, $href->{$field}{'select_hash'} ) ) {
+       <% foreach my $record ( qsearch( $href->{$field}{'select_table'}, $href->{$field}{'select_hash'} ) ) {
           my $value = $record->getfield($href->{$field}{'select_key'}); %>
          <OPTION VALUE="<%= $value %>"<%= $plandata{$field} =~ /(^|, *)$value *(,|$)/ ? ' SELECTED' : '' %>><%= $record->getfield($href->{$field}{'select_label'}) %>
        <% } %>