[freeside-commits] branch FREESIDE_3_BRANCH updated. 58dca90a87df3a8de108c3f92f6f3017da734d96
Mark Wells
mark at 420.am
Thu Apr 28 20:23:23 PDT 2016
The branch, FREESIDE_3_BRANCH has been updated
via 58dca90a87df3a8de108c3f92f6f3017da734d96 (commit)
from 06b3cebdee3d838cf25d51b5bd5668b47fec7a4e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 58dca90a87df3a8de108c3f92f6f3017da734d96
Author: Mark Wells <mark at freeside.biz>
Date: Thu Apr 28 20:19:49 2016 -0700
more convenient selection of domain in svc_acct definition, #40962
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 8e5859e..74ddcd5 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -337,6 +337,7 @@ sub table_info {
'domsvc' => {
label => 'Domain',
type => 'select',
+ select_svc => 1,
select_table => 'svc_domain',
select_key => 'svcnum',
select_label => 'domain',
diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html
index d950032..d2aa14e 100644
--- a/httemplate/edit/elements/part_svc_column.html
+++ b/httemplate/edit/elements/part_svc_column.html
@@ -133,7 +133,10 @@ that field.
% } elsif ( $def->{'type'} eq 'select' ) {
%
% if ( $def->{'select_table'} ) {
- <& /elements/select-table.html,
+% # set the 'select_svc' flag to enable two-step selection of services
+% my $comp = '/elements/select-table.html';
+% $comp = '/elements/select-svc.html' if $def->{'select_svc'};
+ <& $comp,
'field' => $name,
'id' => $name.'_select',
'table' => $def->{'select_table'},
diff --git a/httemplate/elements/select-svc.html b/httemplate/elements/select-svc.html
new file mode 100644
index 0000000..b439a28
--- /dev/null
+++ b/httemplate/elements/select-svc.html
@@ -0,0 +1,73 @@
+<%init>
+my %opt = @_;
+my $svcdb = $opt{table};
+my $field = $opt{field} || 'svcnum';
+my $id = $opt{id} || $opt{field};
+my $curr_value = [ split(',', $opt{curr_value} || '') ];
+my $label = $opt{name_col} || 'label';
+
+# cut-down, jquerified version of select-tiered
+# XXX do we need to agent-virt this? edit/part_svc is Configuration-access.
+my @part_svc = qsearch('part_svc', {
+ disabled => '',
+ svcdb => $svcdb
+});
+my %labels; # service labels, of some kind
+my %values; # svcnums
+my (@all_l, @all_v);
+foreach my $part_svc (@part_svc) {
+ my (@l, @v);
+ foreach my $svc_x (qsearch({
+ 'table' => 'cust_svc',
+ 'addl_from' => " JOIN $svcdb USING (svcnum)",
+ 'select' => "$svcdb.*, cust_svc.svcpart",
+ 'hashref' => { 'svcpart' => $part_svc->svcpart },
+ }))
+ {
+ push @l, $svc_x->$label;
+ push @all_l, $svc_x->$label;
+ push @v, $svc_x->svcnum;
+ push @all_v, $svc_x->svcnum;
+ }
+ $labels{ $part_svc->svcpart } = \@l;
+ $values{ $part_svc->svcpart } = \@v;
+}
+$labels{ '' } = \@all_l;
+$values{ '' } = \@all_v;
+
+</%init>
+<& /elements/select-table.html,
+ 'table' => 'part_svc',
+ 'records' => \@part_svc,
+ 'id' => $id.'_svcpart',
+ 'name_col' => 'svc',
+ 'empty_label' => 'any',
+ 'curr_value' => '',
+ 'field' => $id.'_svcpart', # avoid confusion with any other field
+&>
+<BR>
+<& /elements/select.html,
+ %opt,
+ 'field' => $field,
+ 'id' => $id,
+&>
+<script>
+$().ready(function() {
+ var labels = <% encode_json(\%labels) %>;
+ var values = <% encode_json(\%values) %>;
+ var select_svcpart = $('#<% $id.'_svcpart' %>');
+ var select_svcnum = $('#<% $id %>');
+ var onchange_svcpart = function() {
+ var l = labels[ this.value ];
+ var v = values[ this.value ];
+ select_svcnum.empty();
+ for (var i = 0; i < v.length; i++) {
+ var opt = $('<option />').val(v[i]).text(l[i]);
+ select_svcnum.append(opt);
+ }
+ };
+ select_svcpart.on('change', onchange_svcpart);
+ select_svcpart.change();
+ select_svcnum.val(<% encode_json($curr_value) %>);
+});
+</script>
diff --git a/httemplate/elements/select.html b/httemplate/elements/select.html
index 4492681..59010c1 100644
--- a/httemplate/elements/select.html
+++ b/httemplate/elements/select.html
@@ -9,6 +9,7 @@
<% $style %>
<% $opt{disabled} %>
<% $onchange %>
+ <% $opt{'element_etc'} %>
>
% if ( $opt{options} ) {
-----------------------------------------------------------------------
Summary of changes:
FS/FS/svc_acct.pm | 1 +
httemplate/edit/elements/part_svc_column.html | 5 +-
httemplate/elements/select-svc.html | 73 +++++++++++++++++++++++++
httemplate/elements/select.html | 1 +
4 files changed, 79 insertions(+), 1 deletion(-)
create mode 100644 httemplate/elements/select-svc.html
More information about the freeside-commits
mailing list