summaryrefslogtreecommitdiff
path: root/httemplate/edit/part_pkg.cgi
diff options
context:
space:
mode:
authorivan <ivan>2009-01-21 02:02:09 +0000
committerivan <ivan>2009-01-21 02:02:09 +0000
commit455556cc709f205cb63d42cfe941bb874f36c2f5 (patch)
tree7e6f8e522912efed9ba2e876dcdd6d9bd3111a4f /httemplate/edit/part_pkg.cgi
parente26229306dd63c4989352f082425267bec217100 (diff)
fix (hopefully last of the) customize package bogosity in 1.9, RT#4662
Diffstat (limited to 'httemplate/edit/part_pkg.cgi')
-rwxr-xr-xhttemplate/edit/part_pkg.cgi59
1 files changed, 36 insertions, 23 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index f79e759fa..6de0b3211 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -10,6 +10,7 @@
'new_hashref_callback' => $new_hashref_callback,
'new_object_callback' => $new_object_callback,
'new_callback' => $new_callback,
+ 'clone_callback' => $clone_callback,
'edit_callback' => $edit_callback,
'error_callback' => $error_callback,
@@ -193,8 +194,6 @@ my $taxproducts = $conf->exists('enable_taxproducts');
my @agent_type = ();
my %tax_override = ();
-my $clone_part_pkg = '';
-
my %taxproductnums = map { ($_->classnum => 1) }
qsearch('usage_class', { 'disabled' => '' });
@@ -227,7 +226,6 @@ my $error_callback = sub {
$tax_override{$_} = $cgi->param('tax_override_$_')
foreach(grep { /^tax_override_(\w+)$/ } $cgi->param);
$opt->{action} = 'Custom' if $cgi->param('clone');
- $clone_part_pkg= qsearchs('part_pkg', { 'pkgpart' => $cgi->param('clone') } );
$recur_disabled = $cgi->param('freq') ? 0 : 1;
@@ -255,21 +253,9 @@ my $new_hashref_callback = sub { { 'plan' => 'flat' }; };
my $new_object_callback = sub {
my( $cgi, $hashref, $fields, $opt ) = @_;
- my $part_pkg = '';
- if ( $cgi->param('clone') ) {
- $opt->{action} = 'Custom';
- $clone_part_pkg = qsearchs('part_pkg', { pkgpart=>$cgi->param('clone') } );
- $part_pkg = $clone_part_pkg->clone;
- $part_pkg->disabled('Y');
- %options = $clone_part_pkg->options;
- $part_pkg->set($_ => $options{$_})
- foreach (qw( setup_fee recur_fee ));
- $recur_disabled = $part_pkg->freq ? 0 : 1;
- } else {
- $part_pkg = FS::part_pkg->new( $hashref );
- $part_pkg->set($_ => '0')
- foreach (qw( setup_fee recur_fee ));
- }
+ my $part_pkg = FS::part_pkg->new( $hashref );
+ $part_pkg->set($_ => '0')
+ foreach (qw( setup_fee recur_fee ));
$part_pkg;
@@ -313,6 +299,26 @@ my $new_callback = sub {
};
+my $clone_callback = sub {
+ my( $cgi, $object, $fields, $opt ) = @_;
+
+ $opt->{action} = 'Custom';
+
+ #my $part_pkg = $clone_part_pkg->clone;
+ #this is all clone did anyway
+ $object->comment( '(CUSTOM) '. $object->comment )
+ unless $object->comment =~ /^\(CUSTOM\) /;
+
+ $object->disabled('Y');
+
+ %options = $object->options;
+
+ $object->set($_ => $options{$_})
+ foreach (qw( setup_fee recur_fee ));
+
+ $recur_disabled = $object->freq ? 0 : 1;
+};
+
my $m2_error_callback_maker = sub {
my $link_type = shift; #yay closures
return sub {
@@ -486,11 +492,18 @@ my $html_bottom = sub {
layer_callback => $layer_callback,
);
- include('/elements/selectlayers.html', %selectlayers, 'layers_only'=>1 ).
- '<SCRIPT TYPE="text/javascript">'.
- include('/elements/selectlayers.html', %selectlayers, 'js_only'=>1 ).
- "taxproduct_selectchanged(document.getElementById('taxproduct_select'));".
- '</SCRIPT>';
+ my $return =
+ include('/elements/selectlayers.html', %selectlayers, 'layers_only'=>1 ).
+ '<SCRIPT TYPE="text/javascript">'.
+ include('/elements/selectlayers.html', %selectlayers, 'js_only'=>1 );
+
+ $return .=
+ "taxproduct_selectchanged(document.getElementById('taxproduct_select'));\n"
+ if $taxproducts;
+
+ $return .= '</SCRIPT>';
+
+ $return;
};