summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-01-25 22:17:14 +0000
committerivan <ivan>2010-01-25 22:17:14 +0000
commit9ad4f8407cc106ef5815e65bce2ee873cd0896c2 (patch)
treed4b8c2ab3df5369cb3aa5b64dc8774ec71c7933c /httemplate
parent667cee1c0b352573f80663eae5be2de8ad8a93de (diff)
linking DIDs and users to PBXes, RT#7051
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/elements/edit.html8
-rw-r--r--httemplate/edit/elements/svc_Common.html10
-rwxr-xr-xhttemplate/edit/part_svc.cgi10
-rwxr-xr-xhttemplate/edit/svc_acct.cgi9
-rw-r--r--httemplate/edit/svc_phone.cgi5
-rw-r--r--httemplate/elements/select-svc_pbx.html57
-rw-r--r--httemplate/elements/tr-select-svc_pbx.html60
-rwxr-xr-xhttemplate/view/svc_acct.cgi7
-rw-r--r--httemplate/view/svc_phone.cgi2
9 files changed, 166 insertions, 2 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 43b7afe11..4fe32c15d 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -40,6 +40,10 @@ Example:
'disabled' => 0,
'onchange' => 'javascript_function',
+ 'include_opt_callback' => sub { #my $ = @_;
+ ( 'option' => 'value', );
+ },
+
'm2name_table' => 'table_name',
'm2name_namecol' => 'name_column',
#OR#
@@ -294,6 +298,10 @@ Example:
% $include_common{'colspan'} = $f->{colspan} if $f->{colspan};
% }
%
+% if ( $f->{include_opt_callback} ) {
+% %include_common = ( %include_common, &{ $f->{include_opt_callback} } );
+% }
+%
% my $layer_prefix_on = '';
%
% my $include_sub = sub {
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html
index ef04bd04a..31d4739bf 100644
--- a/httemplate/edit/elements/svc_Common.html
+++ b/httemplate/edit/elements/svc_Common.html
@@ -54,6 +54,7 @@
'field_callback' => sub {
my ($cgi, $object, $f) = @_;
+
my $columndef = $part_svc->part_svc_column($f->{'field'});
my $flag = $columndef->columnflag;
if ( $flag eq 'F' ) {
@@ -62,6 +63,15 @@
: 'hidden';
$f->{'value'} = $columndef->columnvalue;
}
+
+ if ( $f->{'type'} eq 'select-svc_pbx' ) {
+ $f->{'include_opt_callback'} =
+ sub { ( 'pkgnum' => $pkgnum,
+ 'svcpart' => $svcpart,
+ );
+ };
+ }
+
},
'html_init' => sub {
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index 20bc27780..d74e0f20d 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -289,6 +289,14 @@ that field.
% } #endif
% $html .= '</SELECT>';
%
+% } elsif ( $def->{type} eq 'select-svc_pbx.html' ) {
+%
+% $html .= include('/elements/select-svc_pbx.html',
+% 'element_name' => "${layer}__${field}",
+% 'element_etc' => $disabled,
+% 'multiple' => ($flag eq 'S'),
+% );
+%
% } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
%
% #XXX disable the RADIUS usergroup selector? ugh it sure does need
@@ -304,7 +312,7 @@ that field.
%
% } else {
%
-% $html .= '<font color="#ff0000">unknown type'. $def->{type};
+% $html .= '<font color="#ff0000">unknown type '. $def->{type};
%
% }
%
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index afbd002c1..2845c8301 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -122,7 +122,14 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
</TD>
</TR>
% }
-%
+
+<% include('/elements/tr-select-svc_pbx.html',
+ 'curr_value' => $svc_acct->pbxsvc,
+ 'part_svc' => $part_svc,
+ 'cust_pkg' => $cust_pkg,
+ )
+%>
+
%#pop
%my $popnum = $svc_acct->popnum || 0;
%if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi
index d7629ab6f..55ee890f4 100644
--- a/httemplate/edit/svc_phone.cgi
+++ b/httemplate/edit/svc_phone.cgi
@@ -6,6 +6,10 @@
type => 'select-did',
label => 'Phone number',
},
+ { field => 'pbxsvc',
+ type => 'select-svc_pbx',
+ label => 'PBX',
+ },
'sip_password',
'pin',
'phone_name',
@@ -16,6 +20,7 @@
'sip_password' => 'SIP password',
'pin' => 'Voicemail PIN',
'phone_name' => 'Name',
+ 'pbxsvc' => 'PBX',
},
)
%>
diff --git a/httemplate/elements/select-svc_pbx.html b/httemplate/elements/select-svc_pbx.html
new file mode 100644
index 000000000..19bce96ca
--- /dev/null
+++ b/httemplate/elements/select-svc_pbx.html
@@ -0,0 +1,57 @@
+<SELECT <% $opt{'multiple'} ? 'MULTIPLE' : 'SIZE=1' %>
+ NAME = "<% $opt{'element_name'} || $opt{'field'} || 'pbxsvc' %>"
+ <% $opt{'element_etc'} %>
+>
+
+% unless ( $opt{'multiple'} || $opt{'disable_empty'} ) {
+ <OPTION VALUE=""><% $opt{'empty_label'} || '' %>
+% }
+
+% foreach my $svcnum (
+% sort { $svc_pbx{$a} cmp $svc_pbx{$b} }
+% keys %svc_pbx
+% ) {
+% my $svc_pbx = $svc_pbx{$svcnum};
+% my $selected = ($svcnum == $pbxsvc) ? ' SELECTED' : '';
+
+ <OPTION VALUE="<% $svcnum %>" <% $selected %>><% $svc_pbx{$svcnum} %>
+
+% }
+
+</SELECT>
+<%init>
+
+# false laziness w/select-svc_acct-domain.html
+
+my %opt = @_;
+
+my $pbxsvc = $opt{'curr_value'};
+my $part_svc = $opt{'part_svc'}
+ || qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} });
+my $svcpart = $part_svc ? $part_svc->svcpart : '';
+
+#optional
+my $cust_pkg = $opt{'cust_pkg'};
+$cust_pkg ||= qsearchs('cust_pkg', { 'pkgnum' => $opt{'pkgnum'} })
+ if $opt{'pkgnum'};
+
+my $pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';
+
+my %svc_pbx = ();
+
+if ( $pbxsvc ) {
+ my $svc_pbx = qsearchs('svc_pbx', { 'svcnum' => $pbxsvc } );
+ if ( $svc_pbx ) {
+ $svc_pbx{$svc_pbx->svcnum} = $svc_pbx;
+ } else {
+ warn "unknown svc_pbx.svcnum for svc_acct.pbxsvc: $pbxsvc";
+ }
+}
+
+%svc_pbx = (
+ %svc_pbx,
+ FS::svc_Common->pbx_select_hash( 'svcpart' => $svcpart,
+ 'pkgnum' => $pkgnum,
+ )
+);
+</%init>
diff --git a/httemplate/elements/tr-select-svc_pbx.html b/httemplate/elements/tr-select-svc_pbx.html
new file mode 100644
index 000000000..b02bd65c3
--- /dev/null
+++ b/httemplate/elements/tr-select-svc_pbx.html
@@ -0,0 +1,60 @@
+%if ( $columnflag eq 'F' || !keys(%svc_pbx) ) {
+ <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'pbxsvc' %>" VALUE="<% $pbxsvc %>">
+% } else {
+
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || 'PBX' %></TD>
+ <TD>
+ <% include('/elements/select-svc_pbx.html',
+ 'curr_value' => $pbxsvc,
+ 'part_svc' => $part_svc,
+ 'cust_pkg' => $cust_pkg,
+ )
+ %>
+ </TD>
+ </TR>
+% }
+<%init>
+
+# false laziness w/tr-select-svc_acct-domain.html
+
+my %opt = @_;
+
+my $pbxsvc = $opt{'curr_value'};
+
+#required
+my $part_svc = $opt{'part_svc'}
+ || qsearchs('part_svc', { 'svcpart' => $opt{'svcpart'} });
+my $svcpart =
+ $part_svc ? $part_svc->svcpart : '';
+my $columnflag =
+ $part_svc ? $part_svc->part_svc_column('pbxsvc')->columnflag : '';
+
+#optional
+my $cust_pkg = $opt{'cust_pkg'};
+$cust_pkg ||= qsearchs('cust_pkg', { 'pkgnum' => $opt{'pkgnum'} })
+ if $opt{'pkgnum'};
+
+# false laziness w/select-svc_pbx.html
+
+my $pkgnum = $cust_pkg ? $cust_pkg->pkgnum : '';
+
+my %svc_pbx = ();
+
+if ( $pbxsvc ) {
+ my $svc_pbx = qsearchs('svc_pbx', { 'svcnum' => $pbxsvc } );
+ if ( $svc_pbx ) {
+ $svc_pbx{$svc_pbx->svcnum} = $svc_pbx;
+ } else {
+ warn "unknown svc_pbx.svcnum for svc_acct.pbxsvc: $pbxsvc";
+ }
+}
+
+%svc_pbx = (
+ %svc_pbx,
+ FS::svc_Common->pbx_select_hash( 'svcpart' => $svcpart,
+ 'pkgnum' => $pkgnum,
+ )
+);
+
+</%init>
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index 44a2aa611..7e94df16d 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -157,6 +157,13 @@ Service #<B><% $svcnum %></B>
<TD BGCOLOR="#ffffff"><% $domain %></TD>
</TR>
+% if ( $svc_acct->pbxsvc ) {
+ <TR>
+ <TD ALIGN="right">PBX</TD>
+ <TD BGCOLOR="#ffffff"><% $svc_acct->pbx_title %></TD>
+ </TR>
+%}
+
<TR>
<TD ALIGN="right">Password</TD>
<TD BGCOLOR="#ffffff">
diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi
index c5fce62d9..59ee2d516 100644
--- a/httemplate/view/svc_phone.cgi
+++ b/httemplate/view/svc_phone.cgi
@@ -3,6 +3,7 @@
'fields' => [qw(
countrycode
phonenum
+ pbx_title
sip_password
pin
phone_name
@@ -10,6 +11,7 @@
'labels' => {
'countrycode' => 'Country code',
'phonenum' => 'Phone number',
+ 'pbx_title' => 'PBX',
'sip_password' => 'SIP password',
'pin' => 'PIN',
'phone_name' => 'Name',