X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_pkg.cgi;h=61e4086be4def8094a1418c1baeefac02f670363;hp=546e0711326a87a6b61684803aba4bdf1c942aaf;hb=c1bb4ddb71147d0571bd301a6d8c452fdf0e1bc9;hpb=5fc8c5edf574ab024d4646914b6432d458e2ffbd diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 546e07113..61e4086be 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,4 +1,3 @@ - <% if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { @@ -13,21 +12,26 @@ if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { } my ($query) = $cgi->keywords; -my $action = ''; + my $part_pkg = ''; if ( $cgi->param('error') ) { $part_pkg = new FS::part_pkg ( { map { $_, scalar($cgi->param($_)) } fields('part_pkg') } ); } + +my $action = ''; +my $clone_part_pkg = ''; +my $pkgpart = ''; if ( $cgi->param('clone') ) { - $action='Custom Pricing'; - my $old_part_pkg = - qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); - $part_pkg ||= $old_part_pkg->clone; - $part_pkg->disabled('Y'); + $pkgpart = $cgi->param('clone'); + $action = 'Custom Pricing'; + $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); + $part_pkg ||= $clone_part_pkg->clone; + $part_pkg->disabled('Y'); #isn't sticky on errors } elsif ( $query && $query =~ /^(\d+)$/ ) { $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); + $pkgpart = $part_pkg->pkgpart; } else { unless ( $part_pkg ) { $part_pkg = new FS::part_pkg {}; @@ -44,7 +48,7 @@ my $hashref = $part_pkg->hashref; %> -<%= header("$action Package Definition", menubar( +<%= include("/elements/header.html","$action Package Definition", menubar( 'Main Menu' => popurl(2), 'View all packages' => popurl(2). 'browse/part_pkg.cgi', )) %> @@ -55,21 +59,8 @@ my $hashref = $part_pkg->hashref; Error: <%= $cgi->param('error') %> <% } %> -<% #print '
'; %> - -<% -#if ( $cgi->param('clone') ) { -# print qq!!; -#} -#if ( $cgi->param('pkgnum') ) { -# print qq!!; -#} -# -#print qq!!, -%> - <%= itable('',8,1) %> Package information @@ -93,7 +84,12 @@ Package information - + + Promotional code + + + + Disable new orders @@ -110,42 +106,31 @@ Tax information Setup fee tax exempt -<% - -print '{setuptax} eq "Y"; -print '>'; + {setuptax} eq 'Y' ? ' CHECKED' : '' %>> + + + + Recurring fee tax exempt + + {recurtax} eq 'Y' ? ' CHECKED' : '' %>> + + -print < -Recurring fee tax exempt -END +<% my $conf = new FS::Conf; %> +<% if ( $conf->exists('enable_taxclasses') ) { %> -print '{recurtax} eq "Y"; -print '>'; + + Tax class + + <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> + + -print ''; +<% } else { %> -my $conf = new FS::Conf; -#false laziness w/ view/cust_main.cgi quick order -if ( $conf->exists('enable_taxclasses') ) { - print 'Tax class'; -} else { - print - ''; -} + <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %> -%> +<% } %> @@ -159,78 +144,83 @@ $thead .= 'Primary' if dbdef->table('pkg_svc')->column('primary_svc'); $thead .= 'Service'; -#unless ( $cgi->param('clone') ) { -#dunno why... -unless ( 0 ) { - #print <', $thead; +%> + +<%= itable('', 4, 1) %>

Services included -END +<%= $thead %> + +<% + +my $where = "WHERE disabled IS NULL OR disabled = ''"; +if ( $pkgpart ) { + $where .= " OR 0 < ( SELECT quantity FROM pkg_svc + WHERE pkg_svc.svcpart = part_svc.svcpart + AND pkgpart = $pkgpart + )"; } +my @part_svc = qsearch('part_svc', {}, '', $where); +my $q_part_pkg = $clone_part_pkg || $part_pkg; +my %pkg_svc = map { $_->svcpart => $_ } $q_part_pkg->pkg_svc; my @fixups = (); my $count = 0; my $columns = 3; -my @part_svc = qsearch( 'part_svc', { 'disabled' => '' } ); foreach my $part_svc ( @part_svc ) { my $svcpart = $part_svc->svcpart; - my $pkgpart = $cgi->param('clone') || $part_pkg->pkgpart; - my $pkg_svc = $pkgpart && qsearchs( 'pkg_svc', { - 'pkgpart' => $pkgpart, - 'svcpart' => $svcpart, - } ) || new FS::pkg_svc ( { - 'pkgpart' => $pkgpart, - 'svcpart' => $svcpart, - 'quantity' => 0, - 'primary_svc' => '', - }); - #? #next unless $pkg_svc; + my $pkg_svc = $pkg_svc{$svcpart} + || new FS::pkg_svc ( { + 'pkgpart' => $pkgpart, + 'svcpart' => $svcpart, + 'quantity' => 0, + 'primary_svc' => '', + } ); push @fixups, "pkg_svc$svcpart"; - #unless ( defined ($cgi->param('clone')) && $cgi->param('clone') ) { - #dunno why... - unless ( 0 ) { - print ''; # if $count == 0 ; - print qq!quantity || 0, - qq!">!; - if ( dbdef->table('pkg_svc')->column('primary_svc') ) { - print qq!primary_svc =~ /^Y/i; - print '>'; - } - print qq!!, $part_svc->getfield('svc'), ""; -# print "$thead" if ++$count == int(scalar(@part_svc) / 2); - $count+=1; - foreach ( 1 .. $columns-1 ) { - print "$thead" - if $count == int( $_ * scalar(@part_svc) / $columns ); - } - } else { - print qq!quantity || 0, qq!">\n!; - } -} +%> -#unless ( $cgi->param('clone') ) { -#dunno why... -unless ( 0 ) { - print ""; - #print ""; -} + + + quantity || 0 %>"> + + + + primary_svc =~ /^Y/i ? ' CHECKED' : '' %>> + -foreach my $f ( qw( clone pkgnum ) ) { - print qq!'; -} -print ''; + + <%= $part_svc->svc %> <%= $part_svc->disabled =~ /^Y/i ? ' (DISABLED' : '' %> + + + + <% $count++; + foreach ( 1 .. $columns-1 ) { + if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { + %> + <%= $thead %> + + <% } + } + %> + +<% } %> + + + +<% foreach my $f ( qw( clone pkgnum ) ) { %> + +<% } %> + + +<% # prolly should be in database tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() }; my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } - split("\n", $part_pkg->plandata ); + 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; @@ -256,7 +246,9 @@ my $widget = new HTML::Widgets::SelectLayers( 'options' => \%options, 'form_name' => 'dummy', 'form_action' => 'process/part_pkg.cgi', - 'form_text' => [ qw(pkg comment clone pkgnum pkgpart), @fixups ], + '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, @@ -294,8 +286,17 @@ my $widget = new HTML::Widgets::SelectLayers( ? $plandata{$field} : $href->{$field}{'default'} ). qq!" onChange="fchanged(this)">!; - } elsif ( $href->{$field}{'type'} eq 'select_multiple' ) { - $html .= qq!'; + } elsif ( $href->{$field}{'type'} =~ /^select/ ) { + $html .= '{$field}{'type'} eq 'select_multiple'; + $html .= qq! NAME="$field" onChange="fchanged(this)">!; foreach my $record ( qsearch( $href->{$field}{'select_table'}, $href->{$field}{'select_hash'} )