summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-03-26 23:33:09 -0700
committerMark Wells <mark@freeside.biz>2012-03-26 23:33:19 -0700
commit77977d04ed407c3a44877a83b475a3800a581361 (patch)
tree670bd4566df4d8ab6ed43e6804c311d9f25b211b /httemplate
parent9b4209f91ad9e3c4cef7deebfb0180f6faf1d0dc (diff)
historical package definition feature, part 1, #16824
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_pkg.cgi21
-rwxr-xr-xhttemplate/edit/part_pkg.cgi28
2 files changed, 47 insertions, 2 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 766806044..4ca78d718 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -45,6 +45,7 @@ my $select = '*';
my $orderby = 'pkgpart';
my %hash = ();
my $extra_count = '';
+my $family_pkgpart;
if ( $cgi->param('active') ) {
$orderby = 'num_active DESC';
@@ -77,6 +78,16 @@ if ( $cgi->param('missing_recur_fee') ) {
)";
}
+if ( $cgi->param('family') =~ /^(\d+)$/ ) {
+ $family_pkgpart = $1;
+ push @where, "family_pkgpart = $1";
+ # Hiding disabled or one-time charges and limiting by classnum aren't
+ # very useful in this mode, so all links should still refer back to the
+ # non-family-limited display.
+ $cgi->param('showdisabled', 1);
+ $cgi->delete('family');
+}
+
push @where, FS::part_pkg->curuser_pkgs_sql
unless $acl_edit_global;
@@ -209,6 +220,16 @@ push @fields, sub {
$part_pkg->part_pkg_discount;
[
+ ( !$family_pkgpart &&
+ $part_pkg->pkgpart == $part_pkg->family_pkgpart ? () : [
+ {
+ 'align'=> 'center',
+ 'colspan' => 2,
+ 'size' => '-1',
+ 'data' => '<b>Show all versions</b>',
+ 'link' => $p.'browse/part_pkg.cgi?family='.$part_pkg->family_pkgpart,
+ }
+ ] ),
[
{ data =>$plan,
align=>'center',
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index e5edcdedc..cd0731370 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -24,6 +24,8 @@
'error_callback' => $error_callback,
'field_callback' => $field_callback,
+ 'onsubmit' => 'confirm_submit',
+
'labels' => {
'pkgpart' => 'Package Definition',
'pkg' => 'Package (customer-visible)',
@@ -66,6 +68,8 @@
},
{ field=>'custom', type=>'hidden' },
+ { field=>'family_pkgpart', type=>'hidden' },
+ { field=>'successor', type=>'hidden' },
{ type => 'columnstart' },
@@ -593,7 +597,7 @@ my $javascript = <<'END';
}
- function aux_planchanged(what) {
+ function aux_planchanged(what) { //?
alert('called!');
var plan = what.options[what.selectedIndex].value;
@@ -609,9 +613,29 @@ my $javascript = <<'END';
}
- </SCRIPT>
END
+my $warning =
+ 'Changing the setup or recurring fee will create a new package definition. '.
+ 'Continue?';
+
+if ( $conf->exists('part_pkg-lineage') ) {
+ $javascript .= "
+ function confirm_submit(f) {
+
+ var fields = Array('setup_fee','recur_fee');
+ for(var i=0; i < fields.length; i++) {
+ if ( f[fields[i]].value != f[fields[i]].defaultValue ) {
+ return confirm('$warning');
+ }
+ }
+ return true;
+ }
+";
+}
+
+$javascript .= '</SCRIPT>';
+
tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() };
tie my %plan_labels, 'Tie::IxHash',