From f96adaf19c0097ef8c9d6f29a5541b75381cc05d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 12 Mar 2002 15:33:22 +0000 Subject: abstract stupid HTML layer trick out to HTML::Widgets::SelectLayers --- httemplate/edit/part_pkg.cgi | 256 ++++++++++++++++--------------------------- httemplate/edit/part_svc.cgi | 225 ++++++++++++------------------------- 2 files changed, 167 insertions(+), 314 deletions(-) (limited to 'httemplate/edit') diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 8e7a6c5cf..d3213dd46 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -42,24 +42,12 @@ unless ( $part_pkg->plan ) { #backwards-compat $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; my $hashref = $part_pkg->hashref; -%> - - - -<% print header("$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', -), ' onLoad="visualize()"'); +)); +#), ' onLoad="visualize()"'); print qq!Error: !, $cgi->param('error'), "" @@ -164,8 +152,12 @@ unless ( 0 ) { #print ""; } +foreach my $f ( qw( clone pkgnum ) ) { + print qq!'; +} +print ''; + # prolly should be in database -use Tie::IxHash; tie my %plans, 'Tie::IxHash', 'flat' => { 'name' => 'Flat rate', @@ -314,159 +306,99 @@ tie my %plans, 'Tie::IxHash', ; -%> - - -
-Price plan - - - -<% my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } +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"; -%> - - -
- - - - - - - -<% foreach my $f ( @fixups ) { %> - -<% } %> -<% -if ( $cgi->param('clone') ) { - print qq!!; -} -if ( $cgi->param('pkgnum') ) { - print qq!!; -} -%> +tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans; + +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 freq clone pkgnum pkgpart), @fixups ], + 'form_checkbox' => [ qw(setuptax recurtax disabled) ], + 'fixup_callback' => sub { + #my $ = @_; + my $html = ''; + for my $p ( keys %plans ) { + $html .= "if ( what.plan.value == \"$p\" ) { + what.setup.value = $plans{$p}->{setup} ; + what.recur.value = $plans{$p}->{recur} ; + }\n"; + } + $html; + }, + 'layer_callback' => sub { + my $layer = shift; + my $html = qq!!. + ntable("#cccccc",2); + my $href = $plans{$layer}->{'fields'}; + foreach my $field ( exists($plans{$layer}->{'fieldorder'}) + ? @{$plans{$layer}->{'fieldorder'}} + : keys %{ $href } + ) { + + $html .= ''. $href->{$field}{'name'}. ''; + + if ( ! exists($href->{$field}{'type'}) ) { + $html .= qq!!; + } elsif ( $href->{$field}{'type'} eq 'select_multiple' ) { + $html .= qq!'; + } - -<%= ntable("#cccccc",2) %> + $html .= ''; + } + $html .= ''; + + $html .= ''. + '

'; + + $html .= ''; + + $html .= '

don\'t edit this unless you know what you\'re doing '. + ''. + ntable("#cccccc",2). + ''. + 'Setup expression
'. + ''. + '

'. + 'Recurring espression
'. + ''. + '
'. + ''. + ''; + + $html; -<% my $href = $plans{$layer}->{'fields'}; - foreach my $field ( exists($plans{$layer}->{'fieldorder'}) - ? @{$plans{$layer}->{'fieldorder'}} - : keys %{ $href } - ) { -%> - <%= $href->{$field}{'name'} %> - - <% if ( ! exists($href->{$field}{'type'}) ) { %> - - <% } elsif ( $href->{$field}{'type'} eq 'select_multiple' ) { %> - - <% } %> - -<% } %> - - - -

+ }, +); -<% -print qq!!; %> -

don't edit this unless you know what you're doing <%= ntable("#cccccc",2) %> -Setup expression

-Recurring espression
- - - -
- - - -<% } %> - - +
+Price plan <%= $widget->html %> diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 57ab3985e..3292a9b9b 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -15,25 +15,16 @@ } my $action = $part_svc->svcpart ? 'Edit' : 'Add'; my $hashref = $part_svc->hashref; - my $p_svcdb = $part_svc->svcdb || 'svc_acct'; +# my $p_svcdb = $part_svc->svcdb || 'svc_acct'; -%> - + #" onLoad=\"visualize()\"" +%> <%= header("$action Service Definition", menubar( 'Main Menu' => $p, 'View all service definitions' => "${p}browse/part_svc.cgi" ), - " onLoad=\"visualize()\"" ) %> @@ -47,6 +38,7 @@ function visualize(what) {

Service
Disable new orders {disabled} eq 'Y' ? ' CHECKED' : '' %>>
+
Services are items you offer to your customers.