bundle bill linked packages into top line total when desired #5724
authorjeff <jeff>
Mon, 20 Jul 2009 14:26:12 +0000 (14:26 +0000)
committerjeff <jeff>
Mon, 20 Jul 2009 14:26:12 +0000 (14:26 +0000)
13 files changed:
FS/FS/Schema.pm
FS/FS/cust_bill.pm
FS/FS/cust_bill_pkg.pm
FS/FS/cust_main.pm
FS/FS/part_pkg.pm
FS/FS/part_pkg_link.pm
httemplate/edit/elements/edit.html
httemplate/edit/part_pkg.cgi
httemplate/edit/process/part_pkg.cgi
httemplate/elements/checkbox.html [new file with mode: 0644]
httemplate/elements/tr-checkbox.html
httemplate/elements/tr-justtitle.html
httemplate/elements/tr-title.html

index 8b53184..419e9ac 100644 (file)
@@ -518,6 +518,7 @@ sub tables_hashref {
         'quantity',             'int', 'NULL',      '', '', '',
         'unitsetup',           @money_typen,            '', '', 
         'unitrecur',           @money_typen,            '', '', 
+        'hidden',              'char', 'NULL',       1, '', '',
       ],
       'primary_key' => 'billpkgnum',
       'unique' => [],
@@ -1240,15 +1241,18 @@ sub tables_hashref {
 
     'part_pkg_link' => {
       'columns' => [
-        'pkglinknum',  'serial',  '',      '', '', '',
-        'src_pkgpart', 'int',     '',      '', '', '',
-        'dst_pkgpart', 'int',     '',      '', '', '', 
-        'link_type',   'varchar', '', $char_d, '', '',
+        'pkglinknum',  'serial',   '',      '', '', '',
+        'src_pkgpart', 'int',      '',      '', '', '',
+        'dst_pkgpart', 'int',      '',      '', '', '', 
+        'link_type',   'varchar',  '', $char_d, '', '',
+        'hidden',      'char', 'NULL',       1, '', '',
       ],
       'primary_key' => 'pkglinknum',
-      'unique' => [ [ 'src_pkgpart', 'dst_pkgpart', 'link_type' ] ],
+      'unique' => [ [ 'src_pkgpart', 'dst_pkgpart', 'link_type', 'hidden' ] ],
       'index'  => [ [ 'src_pkgpart' ] ],
     },
+    # XXX somewhat borked unique: we don't really want a hidden and unhidden
+    # it turns out we'd prefer to use svc, bill, and invisibill (or something)
 
     'part_pkg_taxclass' => {
       'columns' => [
index 17b88c5..ac02808 100644 (file)
@@ -2793,8 +2793,19 @@ sub _items_cust_bill_pkg {
   my $section = $opt{section}->{description} if $opt{section};
 
   my @b = ();
+  my ($s, $r, $u) = ( undef, undef, undef );
   foreach my $cust_bill_pkg ( @$cust_bill_pkg )
   {
+
+    foreach ( $s, $r, $u ) {
+      if ( $_ && !$cust_bill_pkg->hidden ) {
+        $_->{amount}      = sprintf( "%.2f", $_->{amount} ),
+        $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
+        push @b, { %$_ };
+        $_ = undef;
+      }
+    }
+
     foreach my $display ( grep { defined($section)
                                  ? $_->section eq $section
                                  : 1
@@ -2826,18 +2837,25 @@ sub _items_cust_bill_pkg {
           my @d = ();
           push @d, map &{$escape_function}($_),
                        $cust_pkg->h_labels_short($self->_date)
-            unless $cust_pkg->part_pkg->hide_svc_detail;
+            unless $cust_pkg->part_pkg->hide_svc_detail
+                || $cust_bill_pkg->hidden;
           push @d, $cust_bill_pkg->details(%details_opt)
             if $cust_bill_pkg->recur == 0;
 
-          push @b, {
-            description     => $description,
-            #pkgpart         => $part_pkg->pkgpart,
-            pkgnum          => $cust_bill_pkg->pkgnum,
-            amount          => sprintf("%.2f", $cust_bill_pkg->setup),
-            unit_amount     => sprintf("%.2f", $cust_bill_pkg->unitsetup),
-            quantity        => $cust_bill_pkg->quantity,
-            ext_description => \@d,
+          if ( $cust_bill_pkg->hidden ) {
+            $s->{amount}      += $cust_bill_pkg->setup;
+            $s->{unit_amount} += $cust_bill_pkg->unitsetup;
+            push @{ $s->{ext_description} }, @d;
+          } else {
+            $s = {
+              description     => $description,
+              #pkgpart         => $part_pkg->pkgpart,
+              pkgnum          => $cust_bill_pkg->pkgnum,
+              amount          => $cust_bill_pkg->setup,
+              unit_amount     => $cust_bill_pkg->unitsetup,
+              quantity        => $cust_bill_pkg->quantity,
+              ext_description => \@d,
+            };
           };
 
         }
@@ -2869,6 +2887,7 @@ sub _items_cust_bill_pkg {
                                                  #$cust_bill_pkg->sdate)
             unless $cust_pkg->part_pkg->hide_svc_detail
                 || $cust_bill_pkg->itemdesc
+                || $cust_bill_pkg->hidden
                 || $is_summary;
 
           push @d, $cust_bill_pkg->details(%details_opt)
@@ -2883,17 +2902,45 @@ sub _items_cust_bill_pkg {
             $amount = $cust_bill_pkg->usage;
           }
   
-          push @b, {
-            description     => $description,
-            #pkgpart         => $part_pkg->pkgpart,
-            pkgnum          => $cust_bill_pkg->pkgnum,
-            amount          => sprintf("%.2f", $amount),
-            unit_amount     => sprintf("%.2f", $cust_bill_pkg->unitrecur),
-            quantity        => $cust_bill_pkg->quantity,
-            ext_description => \@d,
-          } unless ( $type eq 'U' && ! $amount );
+          if ( !$type || $type eq 'R' ) {
+
+            if ( $cust_bill_pkg->hidden ) {
+              $r->{amount}      += $amount;
+              $r->{unit_amount} += $cust_bill_pkg->unitrecur;
+              push @{ $r->{ext_description} }, @d;
+            } else {
+              $r = {
+                description     => $description,
+                #pkgpart         => $part_pkg->pkgpart,
+                pkgnum          => $cust_bill_pkg->pkgnum,
+                amount          => $amount,
+                unit_amount     => $cust_bill_pkg->unitrecur,
+                quantity        => $cust_bill_pkg->quantity,
+                ext_description => \@d,
+              };
+            }
+
+          } elsif ( $amount ) {  # && $type eq 'U'
+
+            if ( $cust_bill_pkg->hidden ) {
+              $u->{amount}      += $amount;
+              $u->{unit_amount} += $cust_bill_pkg->unitrecur;
+              push @{ $u->{ext_description} }, @d;
+            } else {
+              $u = {
+                description     => $description,
+                #pkgpart         => $part_pkg->pkgpart,
+                pkgnum          => $cust_bill_pkg->pkgnum,
+                amount          => $amount,
+                unit_amount     => $cust_bill_pkg->unitrecur,
+                quantity        => $cust_bill_pkg->quantity,
+                ext_description => \@d,
+              };
+            }
 
-        }
+          }
+
+        } # recurring or usage with recurring charge
 
       } else { #pkgnum tax or one-shot line item (??)
 
@@ -2918,6 +2965,14 @@ sub _items_cust_bill_pkg {
 
   }
 
+  foreach ( $s, $r, $u ) {
+    if ( $_ ) {
+      $_->{amount}      = sprintf( "%.2f", $_->{amount} ),
+      $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
+      push @b, { %$_ };
+    }
+  }
+
   @b;
 
 }
index fbc67c5..abf0218 100644 (file)
@@ -63,6 +63,8 @@ supported:
 
 =item unitrecur - If not set, defaults to recur
 
+=item hidden - If set to Y, indicates data should not appear as separate line item on invoice
+
 =back
 
 sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">.  Also
@@ -236,6 +238,7 @@ sub check {
       || $self->ut_numbern('edate')
       || $self->ut_textn('itemdesc')
       || $self->ut_textn('itemcomment')
+      || $self->ut_enum('hidden', [ '', 'Y' ])
   ;
   return $error if $error;
 
index 2957579..9d41c4b 100644 (file)
@@ -2535,6 +2535,7 @@ sub bill {
                             'recur'               => \$total_recur,
                             'tax_matrix'          => \%taxlisthash,
                             'time'                => $time,
+                            'real_pkgpart'        => $real_pkgpart,
                             'options'             => \%options,
                           );
       if ($error) {
@@ -2566,6 +2567,7 @@ sub bill {
 
     } elsif ( $postal_pkg ) {
 
+      my $real_pkgpart = $postal_pkg->pkgpart;
       foreach my $part_pkg ( $postal_pkg->part_pkg->self_and_bill_linked ) {
         my %postal_options = %options;
         delete $postal_options{cancel};
@@ -2578,6 +2580,7 @@ sub bill {
                               'recur'               => \$total_recur,
                               'tax_matrix'          => \%taxlisthash,
                               'time'                => $time,
+                              'real_pkgpart'        => $real_pkgpart,
                               'options'             => \%postal_options,
                             );
         if ($error) {
@@ -2790,7 +2793,7 @@ sub _make_lines {
   my (%options) = %{$params{options}};
 
   my $dbh = dbh;
-  my $real_pkgpart = $cust_pkg->pkgpart;
+  my $real_pkgpart = $params{real_pkgpart};
   my %hash = $cust_pkg->hash;
   my $old_cust_pkg = new FS::cust_pkg \%hash;
 
@@ -2958,6 +2961,7 @@ sub _make_lines {
         'unitrecur' => $unitrecur,
         'quantity'  => $cust_pkg->quantity,
         'details'   => \@details,
+        'hidden'    => $part_pkg->hidden,
       };
 
       if ( $part_pkg->option('recur_temporality', 1) eq 'preceding' ) {
@@ -2981,7 +2985,7 @@ sub _make_lines {
       ###
 
       my $error = 
-        $self->_handle_taxes($part_pkg, $taxlisthash, $cust_bill_pkg, $cust_pkg, $options{invoice_time});
+        $self->_handle_taxes($part_pkg, $taxlisthash, $cust_bill_pkg, $cust_pkg, $options{invoice_time}, $real_pkgpart);
       return $error if $error;
 
       push @$cust_bill_pkgs, $cust_bill_pkg;
@@ -3001,6 +3005,7 @@ sub _handle_taxes {
   my $cust_bill_pkg = shift;
   my $cust_pkg = shift;
   my $invoice_time = shift;
+  my $real_pkgpart = shift;
 
   my %cust_bill_pkg = ();
   my %taxes = ();
@@ -3091,20 +3096,29 @@ sub _handle_taxes {
   }
  
   my @display = ();
-  if ( $conf->exists('separate_usage') ) {
+  if ( $conf->exists('separate_usage') || $cust_bill_pkg->hidden ) {
+
+    my $temp_pkg = new FS::cust_pkg { pkgpart => $real_pkgpart };
+    my %hash = $cust_bill_pkg->hidden  # maybe for all bill linked?
+               ? (  'section' => $temp_pkg->part_pkg->categoryname )
+               : ();
+
     my $section = $cust_pkg->part_pkg->option('usage_section', 'Hush!');
     my $summary = $cust_pkg->part_pkg->option('summarize_usage', 'Hush!');
-    push @display, new FS::cust_bill_pkg_display { type    => 'S' };
-    push @display, new FS::cust_bill_pkg_display { type    => 'R' };
-    push @display, new FS::cust_bill_pkg_display { type    => 'U',
-                                                   section => $section
-                                                 };
+    push @display, new FS::cust_bill_pkg_display { type => 'S', %hash };
+    push @display, new FS::cust_bill_pkg_display { type => 'R', %hash };
+
     if ($section && $summary) {
-      $display[2]->post_total('Y');
       push @display, new FS::cust_bill_pkg_display { type    => 'U',
                                                      summary => 'Y',
-                                                   }
+                                                     %hash,
+                                                   };
+      $hash{post_total} = 'Y';
     }
+
+    $hash{section} = $section if $conf->exists('separate_usage');
+    push @display, new FS::cust_bill_pkg_display { type => 'U', %hash };
+
   }
   $cust_bill_pkg->set('display', \@display);
 
index ba80475..3ee9e7f 100644 (file)
@@ -917,10 +917,12 @@ sub svc_part_pkg_link {
 
 sub _part_pkg_link {
   my( $self, $type ) = @_;
-  qsearch('part_pkg_link', { 'src_pkgpart' => $self->pkgpart,
-                             'link_type'   => $type,
-                           }
-         );
+  qsearch({ table    => 'part_pkg_link',
+            hashref  => { 'src_pkgpart' => $self->pkgpart,
+                          'link_type'   => $type,
+                        },
+            order_by => "ORDER BY hidden",
+         });
 }
 
 sub self_and_bill_linked {
@@ -928,12 +930,18 @@ sub self_and_bill_linked {
 }
 
 sub _self_and_linked {
-  my( $self, $type ) = @_;
+  my( $self, $type, $hidden ) = @_;
+  $hidden ||= '';
+
+  my @result = ();
+  foreach ( ( $self, map { $_->dst_pkg->_self_and_linked($type, $_->hidden) }
+                     $self->_part_pkg_link($type) ) )
+  {
+    $_->hidden($hidden) if $hidden;
+    push @result, $_;
+  }
 
-  ( $self,
-    map { $_->dst_pkg->_self_and_linked($type) }
-        $self->_part_pkg_link($type)
-  );
+  (@result);
 }
 
 =item part_pkg_taxoverride [ CLASS ]
index f517360..fb7a8d3 100644 (file)
@@ -51,6 +51,11 @@ Destination package (see L<FS::part_pkg>)
 Link type - currently, "bill" (source package bills a line item from target
 package), or "svc" (source package includes services from target package).
 
+=item hidden
+
+Flag indicating that this subpackage should be felt, but not seen as an invoice
+line item when set to 'Y'
+
 =back
 
 =head1 METHODS
@@ -114,7 +119,8 @@ sub check {
     $self->ut_numbern('pkglinknum')
     || $self->ut_foreign_key('src_pkgpart', 'part_pkg', 'pkgpart')
     || $self->ut_foreign_key('dst_pkgpart', 'part_pkg', 'pkgpart')
-    || $self->ut_text('link_type', [ 'bill', 'svc' ] )
+    || $self->ut_enum('link_type', [ 'bill', 'svc' ] )
+    || $self->ut_enum('hidden', [ '', 'Y' ] )
   ;
   return $error if $error;
 
index 4a6079a..23d4db3 100644 (file)
@@ -289,7 +289,8 @@ Example:
 %     foreach grep exists($f->{$_}), qw( hashref agent_virt agent_null_right );
 %
 %   if ( $type eq 'tablebreak-tr-title' ) {
-%     $include_common{'table_id'} = 'TableNumber'. $tablenum++
+%     $include_common{'table_id'} = 'TableNumber'. $tablenum++;
+%     $include_common{'colspan'} = $f->{colspan} if $f->{colspan};
 %   }
 %
 %   my $layer_prefix_on = '';
@@ -317,6 +318,27 @@ Example:
 %     @include;
 %   };
 %
+%   my $column_sub = sub {
+%     my %opt = @_;
+%
+%     my $column   = delete($opt{field});
+%     my $fieldnum = delete($opt{fieldnum});
+%     my $include  = delete($opt{type}) || 'text';
+%     $include = "input-$include" if $include =~ /^(text|money|percentage)$/;
+%
+%     ( "/elements/$include.html",
+%         'field'        => $field.'__'.$column.$fieldnum,
+%         'id'           => $field.'__'.$column.$fieldnum,
+%         'layer_prefix' => $field.'__'.$column.$fieldnum.".",
+%         ( $fieldnum
+%             ? ('cell_style' => 'border-top:1px solid black')
+%             : ()
+%         ),
+%         'cgi' => $cgi,
+%         %opt,
+%     );
+%   };
+%
 %   unless ( $type =~ /^column/ ) {
 %     $g_row = 1 if $type eq 'tablebreak-tr-title';
 %     $g_row++;
@@ -382,8 +404,35 @@ Example:
 %         'layer_values' => $layer_values,
 %         'cell_style'   => ( $fieldnum ? 'border-top:1px solid black' : '' ),
 %       );
+%       $existing[0] =~ s(^/elements/tr-)(/elements/);
+%       my @label = @existing;
+%       $label[0] = '/elements/tr-td-label.html';
 
+        <% include( @label ) %>
+        <TD>
         <% include( @existing ) %>
+        </TD>
+
+%       if ( $f->{'m2_fields'} ) {
+%         foreach my $c ( @{ $f->{'m2_fields'} } ) {
+%           my $column = $c->{field};
+%           my @column = &{ $column_sub }( %$c,
+%                                          'fieldnum' => $fieldnum,
+%                                          'curr_value' => $name_obj->$column()
+%                                        );
+
+            <TD id='<% $field %>__<% $column %>_label<% $fieldnum %>'
+                style='text-align:right;vertical-align:top;
+                       border-top:1px solid black;padding-top:5px;'>
+              <% $c->{'label'} || '' %>
+            </TD>
+            <TD style='border-top:1px solid black;padding-top:3px;'>
+              <% include( @column ) %>
+            </TD>
+%         }
+%       }
+
+        </TR>
 
 %       $fieldnum++;
 %       $g_row++;
@@ -409,9 +458,40 @@ Example:
 %     'onchange'   => $onchange,
 %     ( $fieldnum ? ('cell_style' => 'border-top:1px solid black') : () ),
 %   );
+%
+%   if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) {
+%     $include[0] =~ s(^/elements/tr-)(/elements/);
+%     my @label = @include;
+%     $label[0] = '/elements/tr-td-label.html';
+
+      <% include( @label ) %>
+      <TD>
+      <% include( @include ) %>
+      </TD>
+
+%     if ( $f->{'m2_fields'} ) {
+%       foreach my $c ( @{ $f->{'m2_fields'} } ) {
+%         my $column = $c->{field};
+%         my @column = &{ $column_sub }( %$c, 'fieldnum' => $fieldnum );
+
+          <TD id='<% $field %>__<% $column %>_label<% $fieldnum %>'
+              style='text-align:right;vertical-align:top;
+                     border-top:1px solid black;padding-top:5px;'>
+            <% $c->{'label'} || '' %>
+          </TD>
+          <TD style='border-top:1px solid black;padding-top:3px;'>
+            <% include( @column ) %>
+          </TD>
+%       }
+%     }
 
-    <% include( @include ) %>
+      </TR>
 
+%   } else {
+
+      <% include( @include ) %>
+
+%   }
 %   if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) {
 
       <SCRIPT TYPE="text/javascript">
@@ -499,6 +579,39 @@ Example:
 
           row.appendChild(widget_cell);
 
+%         if ( $f->{'m2_fields'} ) {
+%           foreach my $c ( @{ $f->{'m2_fields'} } ) {
+%             my $column = $c->{field};
+%             my @column = &{ $column_sub }(%$c, 'fieldnum' => 'MAGIC_NUMBER');
+
+              var column =  <% include(@column, html_only=>1) |js_string %>;
+              column  = column.replace(  magic_regex, <%$field%>_fieldnum );
+
+              var column_label = document.createElement('TD');
+              column_label.id =
+                '<% $field %>__<% $column %>_label' + <%$field%>_fieldnum;
+
+              column_label.style.textAlign = "right";
+              column_label.style.verticalAlign = "top";
+              column_label.style.borderTop = "1px solid black";
+              column_label.style.paddingTop = "5px";
+
+              column_label.innerHTML = '<% $c->{'label'} || '' %>';
+
+              row.appendChild(column_label);
+          
+              var column_widget = document.createElement('TD');
+
+              column_widget.style.borderTop = "1px solid black";
+              column_widget.style.paddingTop = "3px";
+
+              column_widget.innerHTML = column;
+
+              row.appendChild(column_widget);
+
+%           }
+%         }
+
 %         if ( $f->{'m2_new_js'} ) {
             // take out items selected in previous dropdowns
             var new_element = document.getElementById("<%$field%>" + <%$field%>_fieldnum );
index a78aa87..690e884 100755 (executable)
                             },
 
 
-                            { 'type'  => 'tablebreak-tr-title',
-                              'value' => 'Pricing add-ons',
+                            { 'type'    => 'tablebreak-tr-title',
+                              'value'   => 'Pricing add-ons',
+                              'colspan' => 4,
                             },
                             { 'field'      => 'bill_dst_pkgpart',
                               'type'       => 'select-part_pkg',
                               'm2m_dstcol' => 'dst_pkgpart',
                               'm2_error_callback' =>
                                 &{$m2_error_callback_maker}('bill'),
+                              'm2_fields' => [ { 'field' => 'hidden',
+                                                 'type'  => 'checkbox',
+                                                 'value' => 'Y',
+                                                 'curr_value' => '',
+                                                 'label' => 'Bundle',
+                                               },
+                                             ],
                             },
 
                             { type  => 'tablebreak-tr-title',
@@ -385,16 +393,26 @@ my $m2_error_callback_maker = sub {
   my $link_type = shift; #yay closures
   return sub {
     my( $cgi, $object ) = @_;
-      map  {
-             new FS::part_pkg_link {
-               'link_type'   => $link_type,
-               'src_pkgpart' => $object->pkgpart,
-               'dst_pkgpart' => $_,
-             };
-           }
-      grep $_,
-      map  $cgi->param($_),
-      grep /^${link_type}_dst_pkgpart(\d+)$/, $cgi->param;
+    my $num;
+    map {
+
+          if ( /^${link_type}_dst_pkgpart(\d+)$/ &&
+               ( my $dst = $cgi->param("${link_type}_dst_pkgpart$1") ) )
+          {
+
+            my $hidden = $cgi->param("${link_type}_dst_pkgpart__hidden$1")
+                         || '';
+            new FS::part_pkg_link {
+              'link_type'   => $link_type,
+              'src_pkgpart' => $object->pkgpart,
+              'dst_pkgpart' => $dst,
+              'hidden'      => $hidden,
+            };
+          } else {
+            ();
+          }
+        }
+    $cgi->param;
   };
 };
 
index 107d459..7229f30 100755 (executable)
@@ -163,16 +163,28 @@ my @process_m2m = (
     'target_table' => 'part_pkg',
     'base_field'   => 'src_pkgpart',
     'target_field' => 'dst_pkgpart',
-    'hashref'      => { 'link_type' => 'bill' },
-    'params'       => [ map $cgi->param($_), grep /^bill_dst_pkgpart/, $cgi->param ],
-  },
-  { 'link_table'   => 'part_pkg_link',
-    'target_table' => 'part_pkg',
-    'base_field'   => 'src_pkgpart',
-    'target_field' => 'dst_pkgpart',
-    'hashref'      => { 'link_type' => 'svc' },
-    'params'       => [ map $cgi->param($_), grep /^svc_dst_pkgpart/, $cgi->param ],
+    'hashref'      => { 'link_type' => 'svc', 'hidden' => '' },
+    'params'       => [ map $cgi->param($_),
+                        grep /^svc_dst_pkgpart/, $cgi->param
+                      ],
   },
+  map { 
+    my $hidden = $_;
+    { 'link_table'   => 'part_pkg_link',
+      'target_table' => 'part_pkg',
+      'base_field'   => 'src_pkgpart',
+      'target_field' => 'dst_pkgpart',
+      'hashref'      => { 'link_type' => 'bill', 'hidden' => $hidden },
+      'params'       => [ map { $cgi->param($_) }
+                          grep { my $param = "bill_dst_pkgpart__hidden";
+                                 my $digit = '';
+                                 (($digit) = /^bill_dst_pkgpart(\d+)/ ) &&
+                                 $cgi->param("$param$digit") eq $hidden;
+                               }
+                          $cgi->param
+                        ],
+    },
+  } ( '', 'Y' ),
 );
 
 foreach my $override_class ($cgi->param) {
diff --git a/httemplate/elements/checkbox.html b/httemplate/elements/checkbox.html
new file mode 100644 (file)
index 0000000..5176070
--- /dev/null
@@ -0,0 +1,19 @@
+<% $opt{'prefix'} %><INPUT TYPE  = "checkbox"
+                           NAME  = "<% $opt{field} %>"
+                           ID    = "<% $opt{id} %>"
+                           VALUE = "<% $opt{value} %>"
+                           <% $opt{curr_value} eq $opt{value}
+                                ? ' CHECKED'
+                                : ''
+                           %>
+                           <% $onchange %>
+                    ><% $opt{'postfix'} %>
+<%init>
+
+my %opt = @_;
+
+my $onchange = $opt{'onchange'}
+                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
+                 : '';
+
+</%init>
index 2e6d1f1..c3cf92d 100644 (file)
@@ -1,13 +1,7 @@
 <% include('tr-td-label.html', @_ ) %>
 
   <TD <% $style %>>
-    <INPUT TYPE  = "checkbox"
-           NAME  = "<% $opt{field} %>"
-           ID    = "<% $opt{id} %>"
-           VALUE = "<% $opt{value} %>"
-           <% $opt{curr_value} eq $opt{value} ? ' CHECKED' : '' %>
-           <% $onchange %>
-    >
+    <% include('checkbox.html', @_) %>
   </TD>
 
 </TR>
index 7839a8c..8c14d34 100644 (file)
@@ -1,5 +1,5 @@
 <TR>
-  <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left">
+  <TH BGCOLOR="#e8e8e8" COLSPAN=<% $opt{colspan} || 2 %> ALIGN="left">
     <FONT SIZE="+1"><% $opt{value} %></FONT>
   </TH>
 </TR>
index 8517737..f2d269e 100644 (file)
@@ -1,5 +1,10 @@
 <TR>
-  <TD BGCOLOR="#e8e8e8" COLSPAN=2>&nbsp;</TD>
+  <TD BGCOLOR="#e8e8e8" COLSPAN=<% $opt{colspan} || 2 %>>&nbsp;</TD>
 </TR>
 
 <% include('tr-justtitle.html', @_) %>
+<%init>
+
+my %opt = @_;
+
+</%init>