diff options
author | Mark Wells <mark@freeside.biz> | 2014-12-23 21:01:03 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-12-24 10:58:41 -0800 |
commit | fcb43580b83129097a2abf53104ca29f3185d44b (patch) | |
tree | 5300e33e7b25d7a7c8b41f87dbe081a97b4b8eef /httemplate/edit | |
parent | 403bd5f61004717ecfecf8c5211141939e3b7176 (diff) |
Thinktel VoIP provisioning, #32084
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/elements/export_svc.html | 84 | ||||
-rw-r--r-- | httemplate/edit/elements/part_svc_column.html | 40 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 3 |
3 files changed, 95 insertions, 32 deletions
diff --git a/httemplate/edit/elements/export_svc.html b/httemplate/edit/elements/export_svc.html new file mode 100644 index 000000000..5962ae7f8 --- /dev/null +++ b/httemplate/edit/elements/export_svc.html @@ -0,0 +1,84 @@ +<%args> +$part_svc +$svcdb +$clone => undef +</%args> +<%init> + +my $svcpart = $clone || $part_svc->svcpart; # may be undef + +# get a list of applicable part_exports +my @part_export; +my $export_info = FS::part_export::export_info($svcdb); +foreach ( keys %{ $export_info } ) { + push @part_export, qsearch('part_export', { exporttype => $_ }); +} +# and a hash of which ones are already assigned to this part_svc +my %export_svc; +if ( $svcpart ) { + %export_svc = map { $_->exportnum => $_ } + qsearch('export_svc', { svcpart => $svcpart }); +} + +my $count = 0; +my $columns = 3; + +</%init> +<script type="text/javascript"> +function toggle_selectrole() { + var selectrole = document.getElementById( this.name + '_selectrole' ); + if ( selectrole ) { + selectrole.style.visibility = (this.checked) ? '' : 'hidden'; + } +} +<&| /elements/onload.js &> + var boxes = document.getElementsByClassName('checkbox_export'); + for ( var i = 0; i < boxes.length; i++ ) { + boxes[i].onchange = toggle_selectrole; + toggle_selectrole.apply(boxes[i]); + } +</&> +</script> +<& /elements/table.html &> + <TR><TH COLSPAN=<% $columns %>>Exports</TH></TR> + <TR> +% # exports +% foreach my $part_export (@part_export) { +% my $exportnum = $part_export->exportnum; + <TD> + <INPUT CLASS="checkbox_export" + TYPE="checkbox" \ + NAME="exportnum<% $exportnum %>" \ + VALUE=1 \ + <% $export_svc{$exportnum} ? 'CHECKED' : '' %>> + <% $part_export->label_html %> +% if ( $part_export->info->{roles} ) { +% my $role_info = $part_export->info->{roles}; +% my @role_names = keys %$role_info; +% my %role_labels = map { %_ => $role_info->{$_}->{label} } @role_names; +% my $curr_role = $export_svc{$exportnum} ? $export_svc{$exportnum}->role +% : ''; + <SPAN CLASS="selectrole" ID="exportnum<%$exportnum%>_selectrole"> + as: + <& /elements/select.html, + 'field' => "exportnum${exportnum}_role", + 'options' => \@role_names, + 'labels' => \%role_labels, + 'curr_value' => $curr_role, + 'empty_label' => 'select', + &> + </SPAN> +% # XXX should lock out roles that don't apply to the selected svcdb, +% # but that's a pain in the ass +% } + </SELECT> + </SPAN> + </TD> +% $count++; +% if ( $count % $columns == 0 ) { + </TR> + <TR> +% } +% } + </TR> +</TABLE><BR><BR> diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index 6dcb602fe..53cda859e 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -64,26 +64,11 @@ my %communigate_fields = ( </%once> <INPUT TYPE="hidden" NAME="svcdb" VALUE="<% $svcdb %>"> <BR><BR> -<& /elements/table.html &> - <TR><TH COLSPAN=<% $columns %>>Exports</TH></TR> - <TR> -% # exports -% foreach my $part_export (@part_export) { - <TD> - <INPUT TYPE="checkbox" \ - NAME="exportnum<% $part_export->exportnum %>" \ - VALUE=1 \ - <% $has_export_svc{$part_export->exportnum} ? 'CHECKED' : '' %>> - <% $part_export->label_html %> - </TD> -% $count++; -% if ( $count % $columns == 0 ) { - </TR> - <TR> -% } -% } - </TR> -</TABLE><BR><BR> +%# include export selection +<& export_svc.html, + part_svc => $part_svc, + svcdb => $svcdb +&> For the selected table, you can give fields default or fixed (unchangeable) values, or select an inventory class to manually or automatically fill in that field. @@ -285,27 +270,18 @@ that field. <%init> my $svcdb = shift; my %opt = @_; -my $columns = 3; my $count = 0; my $communigate = 0; my $conf = FS::Conf->new; my $part_svc = $opt{'part_svc'} || FS::part_svc->new; -my @part_export; -my $export_info = FS::part_export::export_info($svcdb); -foreach (keys %{ $export_info }) { - push @part_export, qsearch('part_export', { exporttype => $_ }); +# see if there are communigate exports configured +if ( exists $communigate_fields{$svcdb} ) { + $communigate = FS::part_export->count("exporttype like 'communigate%'"); } -$communigate = scalar(grep {$_->exporttype =~ /^communigate/} @part_export); my $svcpart = $opt{'clone'} || $part_svc->svcpart; -my %has_export_svc; -if ( $svcpart ) { - foreach (qsearch('export_svc', { svcpart => $svcpart })) { - $has_export_svc{$_->exportnum} = 1; - } -} my @fields; if ( defined( dbdef->table($svcdb) ) ) { # when is it ever not defined? diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 2ec024269..47b020c5a 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -31,6 +31,9 @@ font-size: smaller; font-style: italic; } +.selectrole { + font-size: small +} </STYLE> <SCRIPT TYPE="text/javascript"> function fixup_submit(layer) { |