diff options
author | ivan <ivan> | 2011-11-14 04:31:31 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-11-14 04:31:31 +0000 |
commit | 3db061f538c06804bd0a52b9ef8be3dc6b6db82e (patch) | |
tree | 7335808809768c4dcc6c8c85aebfa3ec365398ea /httemplate/edit | |
parent | 3892b13ea137969a2b4f880883960e58003cc1b3 (diff) |
rate tiers for vnes, RT#14903
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/elements/edit.html | 2 | ||||
-rw-r--r-- | httemplate/edit/process/rate_tier.html | 15 | ||||
-rw-r--r-- | httemplate/edit/rate_tier.html | 54 |
3 files changed, 70 insertions, 1 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 6db54fd48..4e896f239 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -549,7 +549,7 @@ Example: // only spawn if we're the last element... return if not - var field_regex = /(\d+)(_[a-z]+)?$/; + var field_regex = /(\d+)(_[a-z_]+)?$/; var match = field_regex.exec(what.name); if ( !match ) { alert(what.name + " didn't match for " + what); diff --git a/httemplate/edit/process/rate_tier.html b/httemplate/edit/process/rate_tier.html new file mode 100644 index 000000000..f29edbb50 --- /dev/null +++ b/httemplate/edit/process/rate_tier.html @@ -0,0 +1,15 @@ +<% include( 'elements/process.html', + 'table' => 'rate_tier', + 'viewall_dir' => 'browse', + 'process_o2m' => { + 'table' => 'rate_tier_detail', + 'fields' => [qw( min_quan min_charge )], + }, + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/rate_tier.html b/httemplate/edit/rate_tier.html new file mode 100644 index 000000000..f9df4b5ce --- /dev/null +++ b/httemplate/edit/rate_tier.html @@ -0,0 +1,54 @@ +<% include( 'elements/edit.html', + 'table' => 'rate_tier', + 'name_singular' => 'tiering plan', + 'fields' => [ + 'tiername', + #{ field=>'disabled', type=>'checkbox', value=>'Y' }, + { 'field' => 'tierdetailnum', + 'type' => 'rate_tier_detail', + 'colspan' => 2, + 'o2m_table' => 'rate_tier_detail', + 'm2_label' => 'Tier', + 'm2_error_callback' => $m2_error_callback, + }, + ], + 'labels' => { 'tiernum' => 'Plan #', + 'tiername' => 'Tiering plan', + 'tierdetailnum' => 'Tier', + }, + 'viewall_dir' => 'browse', + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $m2_error_callback = sub { + my($cgi, $object) = @_; + + #process_o2m fields in process/rate_tier.html + my @fields = qw( min_quan min_charge ); + my @gfields = ( '', map "_$_", @fields ); + + map { + if ( /^tierdetailnum(\d+)$/ ) { + my $num = $1; + if ( grep $cgi->param("tierdetailnum$num$_"), @gfields ) { + my $x = new FS::rate_tier_detail { + 'tierdetailnum' => scalar($cgi->param("tierdetailnum$num")), + map { $_ => scalar($cgi->param("tierdetailnum${num}_$_")) } + @fields, + }; + $x; + } else { + (); + } + } else { + (); + } + } + $cgi->param; +}; + +</%init> |