X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_pkg.cgi;h=ec001cb0c7f10abe3131fd62dcf85c5788483c5e;hb=edb7652d50dcbabc4ec066a78ae8f65a4a7b5d24;hp=77822d7e0844857183ba004967b8714e81ec1378;hpb=e498bae00f6ae8a8f83dd6e4983f662e54eb9362;p=freeside.git diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 77822d7e0..ec001cb0c 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -1,68 +1,9 @@ -% -% -%if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { -% $cgi->param('clone', $1); -%} else { -% $cgi->param('clone', ''); -%} -%if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { -% $cgi->param('pkgnum', $1); -%} else { -% $cgi->param('pkgnum', ''); -%} -% -%my ($query) = $cgi->keywords; -% -%my $part_pkg = ''; -%my @agent_type = (); -%if ( $cgi->param('error') ) { -% $part_pkg = new FS::part_pkg ( { -% map { $_, scalar($cgi->param($_)) } fields('part_pkg') -% } ); -% (@agent_type) = $cgi->param('agent_type'); -%} -% -%my $action = ''; -%my $clone_part_pkg = ''; -%my $pkgpart = ''; -%if ( $cgi->param('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'); #isn't sticky on errors -%} elsif ( $query && $query =~ /^(\d+)$/ ) { -% (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1}) -% unless $part_pkg; -% $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); -% $pkgpart = $part_pkg->pkgpart; -%} else { -% unless ( $part_pkg ) { -% $part_pkg = new FS::part_pkg {}; -% $part_pkg->plan('flat'); -% } -%} -%unless ( $part_pkg->plan ) { #backwards-compat -% $part_pkg->plan('flat'); -% $part_pkg->plandata("setup_fee=". $part_pkg->setup. "\n". -% "recur_fee=". $part_pkg->recur. "\n"); -%} -%$action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; -%my $hashref = $part_pkg->hashref; -% -% - - -<% include("/elements/header.html","$action Package Definition", menubar( - 'Main Menu' => popurl(2), +<% include('/elements/header.html', "$action Package Definition", menubar( 'View all packages' => popurl(2). 'browse/part_pkg.cgi', )) %> % #), ' onLoad="visualize()"'); -% if ( $cgi->param('error') ) { - - Error: <% $cgi->param('error') %> -% } +<% include('/elements/error.html') %>
@@ -89,7 +30,10 @@ Package information - <% include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %> + <% include( '/elements/tr-select-pkg_class.html', + 'curr_value' => $part_pkg->classnum, + ) + %> Promotional code @@ -122,7 +66,6 @@ Tax information -% my $conf = new FS::Conf; % if ( $conf->exists('enable_taxclasses') ) { @@ -159,34 +102,42 @@ Line-item revenue recognition -%#Reseller information # after 1.7.2 -%#<% ntable("#cccccc", 2) %> -%# -%# <% 'Agent Types' %> -%# -%# <% include( '/elements/select-table.html', -%# 'element_name' => 'agent_type', -%# 'table' => 'agent_type', -%# 'name_col' => 'atype', -%# 'value' => \@agent_type, -%# 'empty_label' => '(none)', -%# 'element_etc' => 'multiple size="10"', -%# ) -%# %> -%# -%# -%# +% if ( $cgi->param('clone') ) { + + + +% } elsif ( scalar(@all_agent_types) == 1) { + + + +% } else { + + Reseller information + <% ntable("#cccccc", 2) %> + + <% 'Agent Types' %> + + <% include( '/elements/select-table.html', + 'element_name' => 'agent_type', + 'table' => 'agent_type', + 'name_col' => 'atype', + 'value' => \@agent_type, + 'multiple' => '1', + 'element_etc' => 'size="10"', + ) + %> + + + + +% } + -% -% -%my $thead = "\n\n". ntable('#cccccc', 2). -% 'Quan.'; -%$thead .= 'Primary' -% if dbdef->table('pkg_svc')->column('primary_svc'); -%$thead .= 'Service'; -% -% +%my $thead = "\n\n". ntable('#cccccc', 2). +% 'Quan.'. +% 'Primary'. +% 'Service';

Services included <% itable('', 4, 1) %> @@ -216,15 +167,28 @@ Line-item revenue recognition % 'quantity' => 0, % 'primary_svc' => '', % } ); +% if ( $cgi->param('error') ) { +% my $primary_svc = ( $pkg_svc->primary_svc =~ /^Y/i ); +% my $pkg_svc_primary = scalar($cgi->param('pkg_svc_primary')); +% $pkg_svc->primary_svc('') +% if $primary_svc && $pkg_svc_primary != $svcpart; +% $pkg_svc->primary_svc('Y') +% if ! $primary_svc && $pkg_svc_primary == $svcpart; +% } % % push @fixups, "pkg_svc$svcpart"; % -% +% my $quan = 0; +% if ( $cgi->param("pkg_svc$svcpart") =~ /^\s*(\d+)\s*$/ ) { +% $quan = $1; +% } elsif ( $pkg_svc->quantity ) { +% $quan = $pkg_svc->quantity; +% } - quantity || 0 %>"> + @@ -248,10 +212,9 @@ Line-item revenue recognition -% foreach my $f ( qw( clone pkgnum ) ) { - - -% } +% foreach my $f ( qw( clone pkgnum ) ) { #safe, these were untained in %init + +% } % @@ -271,20 +234,16 @@ Line-item revenue recognition %#} else { %# push @fixups, 'taxclass'; #hidden %#} -%my @form_elements = ( 'classnum', 'taxclass' ); -%# copying non-existant elements is probably harmless, but after 1.7.2 -%#my @form_elements = ( 'classnum', 'taxclass', 'agent_type' ); +%my @form_elements = ( 'classnum', 'taxclass', 'agent_type' ); % -%my @form_radio = (); -%if ( dbdef->table('pkg_svc')->column('primary_svc') ) { -% push @form_radio, 'pkg_svc_primary'; -%} +%my @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; %} % +%#this should be replaced by /elements/selectlayers.html %my $widget = new HTML::Widgets::SelectLayers( % 'selected_layer' => $part_pkg->plan, % 'options' => \%options, @@ -292,7 +251,7 @@ Line-item revenue recognition % 'form_action' => 'process/part_pkg.cgi', % 'form_elements' => \@form_elements, % 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), -% qw(pay_weight credit_weight), +% qw(pay_weight credit_weight), #keys(%weight), % @fixups, % ], % 'form_checkbox' => [ qw(setuptax recurtax disabled) ], @@ -325,12 +284,14 @@ Line-item revenue recognition % % $html .= ''. $href->{$field}{'name'}. ''; % +% my $format = sub { shift }; +% $format = $href->{$field}{'format'} if exists($href->{$field}{'format'}); % if ( ! exists($href->{$field}{'type'}) ) { % $html .= qq!!; #after 1.7.2 +% qq!" onChange="fchanged(this)">!; % } elsif ( $href->{$field}{'type'} eq 'checkbox' ) { % $html .= qq!{$field}{'type'} eq 'select_multiple'; -% $html .= qq! NAME="$field" onChange="fchanged(this)">!; # after 1.7.2 +% $html .= qq! NAME="$field" onChange="fchanged(this)">!; % % if ( $href->{$field}{'select_table'} ) { % foreach my $record ( @@ -384,8 +345,11 @@ Line-item revenue recognition % '

'; % % $html .= ''; #after 1.7.2 +% ( $action eq 'Custom' +% ? 'Customize package' +% : ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ) +% ). +% '" onClick="fchanged(this)">'; % % $html; % @@ -396,5 +360,70 @@ Line-item revenue recognition

Price plan <% $widget->html %> - - + +<% include('/elements/footer.html') %> +<%init> + +if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) { + $cgi->param('clone', $1); +} else { + $cgi->param('clone', ''); +} +if ( $cgi->param('pkgnum') && $cgi->param('pkgnum') =~ /^(\d+)$/ ) { + $cgi->param('pkgnum', $1); +} else { + $cgi->param('pkgnum', ''); +} + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Edit package definitions') + || $curuser->access_right('Edit global package definitions') + || ( $cgi->param('pkgnum') && $curuser->access_right('Customize customer package') ); + +my ($query) = $cgi->keywords; + +my $conf = new FS::Conf; +my $part_pkg = ''; +my @agent_type = (); +my @all_agent_types = map {$_->typenum} qsearch('agent_type',{}); +if ( $cgi->param('error') ) { + $part_pkg = new FS::part_pkg ( { + map { $_, scalar($cgi->param($_)) } fields('part_pkg') + } ); + (@agent_type) = $cgi->param('agent_type'); +} + +my $action = ''; +my $clone_part_pkg = ''; +my $pkgpart = ''; +if ( $cgi->param('clone') ) { + $pkgpart = $cgi->param('clone'); + #$action = 'Custom Pricing'; + $action = 'Custom'; + $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } ); + $part_pkg ||= $clone_part_pkg->clone; + $part_pkg->disabled('Y') unless $cgi->param('error'); +} elsif ( $query && $query =~ /^(\d+)$/ ) { + (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1}) + unless $part_pkg; + $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); + $pkgpart = $part_pkg->pkgpart; +} else { + unless ( $part_pkg ) { + $part_pkg = new FS::part_pkg {}; + $part_pkg->plan('flat'); + @agent_type = @all_agent_types if $conf->exists('agent_defaultpkg'); + + } +} +unless ( $part_pkg->plan ) { #backwards-compat + $part_pkg->plan('flat'); + $part_pkg->plandata("setup_fee=". $part_pkg->setup. "\n". + "recur_fee=". $part_pkg->recur. "\n"); +} +$action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; +my $hashref = $part_pkg->hashref; + +