X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_pkg.cgi;h=2c3808fe1a05d11d1204827969a7cbcabcffd88a;hb=cf8f8aafc5595b31f24a7b0d06289c830d123cb8;hp=546e0711326a87a6b61684803aba4bdf1c942aaf;hpb=5fc8c5edf574ab024d4646914b6432d458e2ffbd;p=freeside.git diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 546e07113..2c3808fe1 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; + $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'); } 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 {}; @@ -93,7 +97,12 @@ Package information - + + Promotional code + + + + Disable new orders @@ -110,42 +119,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} ) %> -%> +<% } %> @@ -168,23 +166,29 @@ unless ( 0 ) { END } + +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 %pkg_svc = map { $_->svcpart => $_ } $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"; @@ -201,7 +205,9 @@ foreach my $part_svc ( @part_svc ) { print '>'; } print qq!!, $part_svc->getfield('svc'), ""; + qq!">!, $part_svc->getfield('svc'), ''; + print ' (DISABLED)' if $part_svc->disabled =~ /^Y/i; + print ''; # print "$thead" if ++$count == int(scalar(@part_svc) / 2); $count+=1; foreach ( 1 .. $columns-1 ) { @@ -230,7 +236,8 @@ print ''; 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 +263,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 +303,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'} )