-
-<% foreach my $f ( qw( clone pkgnum ) ) { %>
- <INPUT TYPE="hidden" NAME="<%= $f %>" VALUE="<%= $cgi->param($f) %>">
-<% } %>
-<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<%= $part_pkg->pkgpart %>">
-
-<%
-
-# prolly should be in database
-tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() };
-
-my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
- split("\n", ($clone_part_pkg||$part_pkg)->plandata );
-#warn join("\n", map { "$_: $plandata{$_}" } keys %plandata ). "\n";
-
-tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans;
-
-my @form_select = ();
-if ( $conf->exists('enable_taxclasses') ) {
- push @form_select, 'taxclass';
-} else {
- push @fixups, 'taxclass'; #hidden
-}
-
-my @form_radio = ();
-if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
- push @form_radio, 'pkg_svc_primary';
-}
-
-tie my %freq, 'Tie::IxHash', %FS::part_pkg::freq;
-if ( $part_pkg->dbdef_table->column('freq')->type =~ /(int)/i ) {
- delete $freq{$_} foreach grep { ! /^\d+$/ } keys %freq;
-}
-
-my $widget = new HTML::Widgets::SelectLayers(
- 'selected_layer' => $part_pkg->plan,
- 'options' => \%options,
- 'form_name' => 'dummy',
- 'form_action' => 'process/part_pkg.cgi',
- 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart),
- @fixups
- ],
- 'form_checkbox' => [ qw(setuptax recurtax disabled) ],
- 'form_radio' => \@form_radio,
- 'form_select' => \@form_select,
- 'layer_callback' => sub {
- my $layer = shift;
- my $html = qq!<INPUT TYPE="hidden" NAME="plan" VALUE="$layer">!.
- ntable("#cccccc",2);
- $html .= '
- <TR>
- <TD ALIGN="right">Recurring fee frequency </TD>
- <TD><SELECT NAME="freq">
- ';
-
- my @freq = keys %freq;
- @freq = grep { /^\d+$/ } @freq
- if exists($plans{$layer}->{'freq'}) && $plans{$layer}->{'freq'} eq 'm';
- foreach my $freq ( @freq ) {
- $html .= qq(<OPTION VALUE="$freq");
- $html .= ' SELECTED' if $freq eq $part_pkg->freq;
- $html .= ">$freq{$freq}";
- }
- $html .= '</SELECT></TD></TR>';
-
- my $href = $plans{$layer}->{'fields'};
- foreach my $field ( exists($plans{$layer}->{'fieldorder'})
- ? @{$plans{$layer}->{'fieldorder'}}
- : keys %{ $href }
- ) {
-
- $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>';
-
- if ( ! exists($href->{$field}{'type'}) ) {
- $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!.
- ( exists($plandata{$field})
- ? $plandata{$field}
- : $href->{$field}{'default'} ).
- qq!" onChange="fchanged(this)">!;
- } elsif ( $href->{$field}{'type'} eq 'checkbox' ) {
- $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !.
- ( exists($plandata{$field}) && $plandata{$field}
- ? ' CHECKED'
- : ''
- ). '>';
- } elsif ( $href->{$field}{'type'} =~ /^select/ ) {
- $html .= '<SELECT';
- $html .= ' MULTIPLE'
- if $href->{$field}{'type'} eq 'select_multiple';
- $html .= qq! NAME="$field" onChange="fchanged(this)">!;
- foreach my $record (
- qsearch( $href->{$field}{'select_table'},
- $href->{$field}{'select_hash'} )
- ) {
- my $value = $record->getfield($href->{$field}{'select_key'});
- $html .= qq!<OPTION VALUE="$value"!.
- ( $plandata{$field} =~ /(^|, *)$value *(,|$)/
- ? ' SELECTED'
- : '' ).
- '>'. $record->getfield($href->{$field}{'select_label'})
- }
- $html .= '</SELECT>';
- }
-
- $html .= '</TD></TR>';
- }
- $html .= '</TABLE>';
-
- $html .= '<INPUT TYPE="hidden" NAME="plandata" VALUE="'.
- join(',', keys %{ $href } ). '">'.
- '<BR><BR>';
-
- $html .= '<INPUT TYPE="submit" VALUE="'.
- ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ).
- '" onClick="fchanged(this)">';
-
- $html;
-
- },
-);
-
-%>
-
-<BR><BR>Price plan <%= $widget->html %>
+% foreach my $f ( qw( clone pkgnum ) ) {
+
+ <INPUT TYPE="hidden" NAME="<% $f %>" VALUE="<% $cgi->param($f) %>">
+% }
+
+<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
+%
+%
+%# prolly should be in database
+%tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() };
+%
+%my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
+% split("\n", ($clone_part_pkg||$part_pkg)->plandata );
+%#warn join("\n", map { "$_: $plandata{$_}" } keys %plandata ). "\n";
+%
+%tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans;
+%
+%#my @form_select = ('classnum');
+%#if ( $conf->exists('enable_taxclasses') ) {
+%# push @form_select, 'taxclass';
+%#} else {
+%# push @fixups, 'taxclass'; #hidden
+%#}
+%my @form_elements = ( 'classnum', 'taxclass' );
+%
+%my @form_radio = ();
+%if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
+% push @form_radio, 'pkg_svc_primary';
+%}
+%
+%tie my %freq, 'Tie::IxHash', %{FS::part_pkg->freqs_href()};
+%if ( $part_pkg->dbdef_table->column('freq')->type =~ /(int)/i ) {
+% delete $freq{$_} foreach grep { ! /^\d+$/ } keys %freq;
+%}
+%
+%my $widget = new HTML::Widgets::SelectLayers(
+% 'selected_layer' => $part_pkg->plan,
+% 'options' => \%options,
+% 'form_name' => 'dummy',
+% 'form_action' => 'process/part_pkg.cgi',
+% 'form_elements' => \@form_elements,
+% 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart),
+% @fixups
+% ],
+% 'form_checkbox' => [ qw(setuptax recurtax disabled) ],
+% 'form_radio' => \@form_radio,
+% 'layer_callback' => sub {
+% my $layer = shift;
+% my $html = qq!<INPUT TYPE="hidden" NAME="plan" VALUE="$layer">!.
+% ntable("#cccccc",2);
+% $html .= '
+% <TR>
+% <TD ALIGN="right">Recurring fee frequency </TD>
+% <TD><SELECT NAME="freq">
+% ';
+%
+% my @freq = keys %freq;
+% @freq = grep { /^\d+$/ } @freq
+% if exists($plans{$layer}->{'freq'}) && $plans{$layer}->{'freq'} eq 'm';
+% foreach my $freq ( @freq ) {
+% $html .= qq(<OPTION VALUE="$freq");
+% $html .= ' SELECTED' if $freq eq $part_pkg->freq;
+% $html .= ">$freq{$freq}";
+% }
+% $html .= '</SELECT></TD></TR>';
+%
+% my $href = $plans{$layer}->{'fields'};
+% foreach my $field ( exists($plans{$layer}->{'fieldorder'})
+% ? @{$plans{$layer}->{'fieldorder'}}
+% : keys %{ $href }
+% ) {
+%
+% $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>';
+%
+% if ( ! exists($href->{$field}{'type'}) ) {
+% $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!.
+% ( exists($plandata{$field})
+% ? $plandata{$field}
+% : $href->{$field}{'default'} ).
+% qq!" onChange="fchanged(this)">!;
+% } elsif ( $href->{$field}{'type'} eq 'checkbox' ) {
+% $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !.
+% ( exists($plandata{$field}) && $plandata{$field}
+% ? ' CHECKED'
+% : ''
+% ). '>';
+% } elsif ( $href->{$field}{'type'} =~ /^select/ ) {
+% $html .= '<SELECT';
+% $html .= ' MULTIPLE'
+% if $href->{$field}{'type'} eq 'select_multiple';
+% $html .= qq! NAME="$field" onChange="fchanged(this)">!;
+%
+% if ( $href->{$field}{'select_table'} ) {
+% foreach my $record (
+% qsearch( $href->{$field}{'select_table'},
+% $href->{$field}{'select_hash'} )
+% ) {
+% my $value = $record->getfield($href->{$field}{'select_key'});
+% $html .= qq!<OPTION VALUE="$value"!.
+% ( $plandata{$field} =~ /(^|, *)$value *(,|$)/
+% ? ' SELECTED'
+% : ''
+% ).
+% '>'. $record->getfield($href->{$field}{'select_label'});
+% }
+% } elsif ( $href->{$field}{'select_options'} ) {
+% foreach my $key ( keys %{ $href->{$field}{'select_options'} } ) {
+% my $value = $href->{$field}{'select_options'}{$key};
+% $html .= qq!<OPTION VALUE="$key"!.
+% ( $plandata{$field} =~ /(^|, *)$value *(,|$)/
+% ? ' SELECTED'
+% : ''
+% ).
+% '>'. $value;
+% }
+%
+% } else {
+% $html .= '<font color="#ff0000">warning: '.
+% "don't know how to retreive options for $field select field".
+% '</font>';
+% }
+% $html .= '</SELECT>';
+% }
+%
+% $html .= '</TD></TR>';
+% }
+% $html .= '</TABLE>';
+%
+% $html .= '<INPUT TYPE="hidden" NAME="plandata" VALUE="'.
+% join(',', keys %{ $href } ). '">'.
+% '<BR><BR>';
+%
+% $html .= '<INPUT TYPE="submit" VALUE="'.
+% ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ).
+% '" onClick="fchanged(this)">';
+%
+% $html;
+%
+% },
+%);
+%
+%
+
+
+<BR><BR>Price plan <% $widget->html %>