X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_pkg.cgi;h=3116b7b28f63d623e81ecdfdd4805eab9ca89d10;hb=3a02c437eadd9a39f7e56056ca987a4846650209;hp=e90dee26ccd462ac99bfc4001def7340d08d157b;hpb=753cda550c5e2fa3053224f92d8141975390610a;p=freeside.git diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index e90dee26c..3116b7b28 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,10 +1,12 @@ <% include( 'elements/process.html', #'debug' => 1, 'table' => 'part_pkg', + 'agent_virt' => 1, + 'agent_null_right' => \@agent_null_right, + 'redirect' => $redirect_callback, 'viewall_dir' => 'browse', 'viewall_ext' => 'cgi', 'edit_ext' => 'cgi', - #XXX usable with cloning? #'agent_null_right' => 'Edit global package definitions', 'precheck_callback' => $precheck_callback, 'args_callback' => $args_callback, 'process_m2m' => \@process_m2m, @@ -12,12 +14,21 @@ %> <%init> +my $customizing = ( ! $cgi->param('pkgpart') && $cgi->param('pkgnum') ); + my $curuser = $FS::CurrentUser::CurrentUser; +my $edit_global = 'Edit global package definitions'; +my $customize = 'Customize customer package'; + die "access denied" unless $curuser->access_right('Edit package definitions') - || $curuser->access_right('Edit global package definitions') - || ( ! $cgi->param('pkgpart') && $cgi->param('pkgnum') && $curuser->access_right('Customize customer package') ); + || $curuser->access_right($edit_global) + || ( $customizing && $curuser->access_right($customize) ); + +my @agent_null_right = ( $edit_global ); +push @agent_null_right, $customize if $customizing; + my $precheck_callback = sub { my( $cgi ) = @_; @@ -37,10 +48,11 @@ my $precheck_callback = sub { push @agents, $1 if $1; } return "At least one agent type must be specified." - unless( scalar(@agents) || - $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ || - !$cgi->param('pkgpart') && $conf->exists('agent-defaultpkg') - ); + unless scalar(@agents) + || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ ) + || ( !$cgi->param('pkgpart') && $conf->exists('agent-defaultpkg') ) + || $cgi->param('disabled') + || $cgi->param('agentnum'); return ''; @@ -83,6 +95,13 @@ my $args_callback = sub { } @options; + foreach ( split(',', $cgi->param('taxproductnums') ) ) { + my $value = $cgi->param("taxproductnum_$_"); + $error ||= "Illegal taxproductnum_$_: $value" + unless ( $value =~ /^\d*$/ ); + $options{"usage_taxproductnum_$_"} = $value; + } + $options{$_} = scalar( $cgi->param($_) ) for (qw( setup_fee recur_fee )); @@ -106,10 +125,24 @@ my $args_callback = sub { 'custnum_ref' => \$custnum; } + warn "args: ".join('/', @args). "\n"; + @args; }; +my $redirect_callback = sub { + #my( $cgi, $new ) = @_; + return '' unless $custnum; + my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/ + ? '' + : ';show=packages'; + #my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment + + #can we link back to the specific customized package? it would be nice... + popurl(3). "view/cust_main.cgi?custnum=$custnum$show;dummy="; +}; + #these should probably move to @args above and be processed by part_pkg.pm... $cgi->param('tax_override') =~ /^([\d,]+)$/; @@ -137,6 +170,22 @@ my @process_m2m = ( }, ); +foreach my $override_class ($cgi->param) { + next unless $override_class =~ /^tax_override_(\w+)$/; + my $class = $1; + + my (@tax_overrides) = (grep "$_", split (",", $1)) + if $cgi->param($override_class) =~ /^([\d,]+)$/; + + push @process_m2m, { + 'link_table' => 'part_pkg_taxoverride', + 'target_table' => 'tax_class', + 'hashref' => { 'usage_class' => $class }, + 'params' => [ @tax_overrides ], + }; + +} + my $conf = new FS::Conf; if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) {