[freeside-commits] branch FREESIDE_4_BRANCH updated. 849eff8453b945e99c00b00682a846dccbbb5519
Mark Wells
mark at 420.am
Thu Apr 28 20:23:27 PDT 2016
The branch, FREESIDE_4_BRANCH has been updated
via 849eff8453b945e99c00b00682a846dccbbb5519 (commit)
from 769398e8bddf874129a9f4be54337742de55f5a0 (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 849eff8453b945e99c00b00682a846dccbbb5519
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 b4db082..93659f9 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -316,6 +316,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 bc679e5..4e112c0 100644
--- a/httemplate/edit/elements/part_svc_column.html
+++ b/httemplate/edit/elements/part_svc_column.html
@@ -132,7 +132,10 @@ my %communigate_fields = (
% } 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 42cd895..3a0dc5b 100644
--- a/httemplate/elements/select.html
+++ b/httemplate/elements/select.html
@@ -21,6 +21,7 @@
disabled => 0,
onchange => 'do_something()',
js_only => 0, # disables the whole thing
+ element_etc => '', # anything else to put in the <select> tag
&>
</%doc>
@@ -35,6 +36,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 | 2 +
4 files changed, 80 insertions(+), 1 deletion(-)
create mode 100644 httemplate/elements/select-svc.html
More information about the freeside-commits
mailing list