[freeside-commits] branch FREESIDE_3_BRANCH updated. 96d6a93b8cbc7fbe2eb7a0877c4108111c96d3e3
Ivan
ivan at 420.am
Sat Jan 18 19:13:18 PST 2014
The branch, FREESIDE_3_BRANCH has been updated
via 96d6a93b8cbc7fbe2eb7a0877c4108111c96d3e3 (commit)
from 01bdc344d07af3be10b7486d177c0a515da68b66 (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 96d6a93b8cbc7fbe2eb7a0877c4108111c96d3e3
Author: Ivan Kohler <ivan at freeside.biz>
Date: Sat Jan 18 19:13:16 2014 -0800
FS/FS/pbx_extension.pm
diff --git a/FS/FS.pm b/FS/FS.pm
index d655500..e450492 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -202,6 +202,8 @@ L<FS::svc_external> - Externally tracked service class.
L<FS::svc_pbx> - PBX service class
+L<FS::pbx_extension> - PBX extension class
+
L<FS::svc_cert> - Certificate service class
L<FS::svc_dish> - Dish network service class
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5b4ba07..2871c21 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3996,6 +3996,25 @@ sub tables_hashref {
'index' => [ [ 'id' ] ],
},
+ 'pbx_extension' => {
+ 'columns' => [
+ 'extensionnum', 'serial', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'extension', 'varchar', '', $char_d, '', '',
+ 'pin', 'varchar', 'NULL', $char_d, '', '',
+ 'sip_password', 'varchar', 'NULL', $char_d, '', '',
+ 'phone_name', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'extensionnum',
+ 'unique' => [ [ 'svcnum', 'extension' ] ],
+ 'index' => [ [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_pbx',
+ },
+ ],
+ },
+
'svc_mailinglist' => { #svc_group?
'columns' => [
'svcnum', 'int', '', '', '', '',
diff --git a/FS/FS/svc_pbx.pm b/FS/FS/svc_pbx.pm
index 7c228f8..7899621 100644
--- a/FS/FS/svc_pbx.pm
+++ b/FS/FS/svc_pbx.pm
@@ -1,5 +1,5 @@
package FS::svc_pbx;
-use base qw( FS::svc_External_Common );
+use base qw( FS::o2m_Common FS::svc_External_Common );
use strict;
use Tie::IxHash;
diff --git a/FS/t/pbx_extension.t b/FS/t/pbx_extension.t
new file mode 100644
index 0000000..796c9aa
--- /dev/null
+++ b/FS/t/pbx_extension.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::pbx_extension;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/edit/process/svc_pbx.html b/httemplate/edit/process/svc_pbx.html
new file mode 100644
index 0000000..15023a4
--- /dev/null
+++ b/httemplate/edit/process/svc_pbx.html
@@ -0,0 +1,13 @@
+<& elements/svc_Common.html,
+ table => 'svc_pbx',
+ edit_ext => 'html',
+ process_o2m => { table => 'pbx_extension',
+ fields => [qw( extension pin sip_password phone_name )],
+ },
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+</%init>
diff --git a/httemplate/edit/svc_pbx.html b/httemplate/edit/svc_pbx.html
new file mode 100644
index 0000000..d973bf5
--- /dev/null
+++ b/httemplate/edit/svc_pbx.html
@@ -0,0 +1,52 @@
+<& elements/svc_Common.html,
+ 'table' => 'svc_pbx',
+
+ 'end_callback' => sub {
+ my( $cgi, $svc_pbx, $fields, $opt ) = @_;
+ $opt->{labels}{extensionnum} = ' ';
+ push @$fields,
+ { type => 'tablebreak-tr-title',
+ value => 'Extensions',
+ },
+ {
+ field => 'extensionnum',
+ type => 'pbx_extension',
+ o2m_table => 'pbx_extension',
+ m2_label => ' ',
+ m2_error_callback => $m2_error_callback,
+ },
+ ;
+
+ },
+
+&>
+<%init>
+
+my $m2_error_callback = sub {
+ my($cgi, $object) = @_;
+
+ #process_o2m fields in process/svc_pbx.html
+ my @fields = qw( extension pin sip_password phone_name );
+ my @gfields = ( '', map "_$_", @fields );
+
+ map {
+ if ( /^extensionnum(\d+)$/ ) {
+ my $num = $1;
+ if ( grep $cgi->param("extensionnum$num$_"), @gfields ) {
+ my $x = new FS::pbx_extension {
+ 'extensionnum' => scalar($cgi->param("extensionnum$num")),
+ map { $_ => scalar($cgi->param("extensionnum${num}_$_")) } @fields,
+ };
+ $x;
+ } else {
+ ();
+ }
+ } else {
+ ();
+ }
+ }
+ $cgi->param;
+};
+
+
+</%init>
diff --git a/httemplate/elements/pbx_extension.html b/httemplate/elements/pbx_extension.html
new file mode 100644
index 0000000..62a1f51
--- /dev/null
+++ b/httemplate/elements/pbx_extension.html
@@ -0,0 +1,113 @@
+% unless ( $opt{'js_only'} ) {
+
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
+
+ <TABLE STYLE="display:inline">
+ <TR>
+
+% ###
+% # extension
+% ###
+ <TD>
+ <INPUT
+ TYPE = "text"
+ NAME = "<%$name%>_extension"
+ ID = "<%$id%>_extension"
+ VALUE = "<% scalar($cgi->param($name.'_extension'))
+ || $pbx_extension->extension
+ %>"
+ SIZE = 5
+ MAXLENGTH = 6
+ <% $onchange %>
+ >
+ <BR>
+ <FONT SIZE="-1">Extension</FONT>
+ </TD>
+
+% ###
+% # pin
+% ###
+ <TD>
+ <INPUT
+ TYPE = "text"
+ NAME = "<%$name%>_pin"
+ ID = "<%$id%>_pin"
+ VALUE = "<% scalar($cgi->param($name.'_pin'))
+ || $pbx_extension->pin
+ %>"
+ SIZE = 7
+ MAXLENGTH = 6
+ <% $onchange %>
+ >
+ <BR>
+ <FONT SIZE="-1">PIN</FONT>
+ </TD>
+
+% ###
+% # sip_password
+% ###
+ <TD>
+ <INPUT
+ TYPE = "text"
+ NAME = "<%$name%>_sip_password"
+ ID = "<%$id%>_sip_password"
+ VALUE = "<% scalar($cgi->param($name.'_sip_password'))
+ || $pbx_extension->sip_password
+ %>"
+ SIZE = <% $passwordmax == 80 ? 20 : $passwordmax + 2 %>
+ MAXLENGTH = <% $passwordmax + 2 %>
+ <% $onchange %>
+ >
+ <BR>
+ <FONT SIZE="-1">SIP Password</FONT>
+ </TD>
+
+% ###
+% # phone_name
+% ###
+ <TD>
+ <INPUT
+ TYPE = "text"
+ NAME = "<%$name%>_phone_name"
+ ID = "<%$id%>_phone_name"
+ VALUE = "<% scalar($cgi->param($name.'_phone_name'))
+ || $pbx_extension->phone_name
+ %>"
+ SIZE = 20
+ MAXLENGTH = 80
+ <% $onchange %>
+ >
+ <BR>
+ <FONT SIZE="-1">Name</FONT>
+ </TD>
+
+ </TR>
+ </TABLE>
+
+% }
+<%init>
+
+my( %opt ) = @_;
+
+my $conf = new FS::Conf;
+my $passwordmax = $conf->config('sip_passwordmax') || 80;
+
+my $name = $opt{'element_name'} || $opt{'field'} || 'extensionnum';
+my $id = $opt{'id'} || 'extensionnum';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $onchange = '';
+if ( $opt{'onchange'} ) {
+ $onchange = $opt{'onchange'};
+ $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
+ $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
+ #callbacks should act the same
+ $onchange = 'onChange="'. $onchange. '"';
+}
+
+my $pbx_extension = $curr_value
+ ? qsearchs('pbx_extension', { 'extensionnum' => $curr_value } )
+ : new FS::pbx_extension {};
+
+</%init>
diff --git a/httemplate/elements/tr-pbx_extension.html b/httemplate/elements/tr-pbx_extension.html
new file mode 100644
index 0000000..a9d640d
--- /dev/null
+++ b/httemplate/elements/tr-pbx_extension.html
@@ -0,0 +1,24 @@
+% unless ( $opt{'js_only'} ) {
+
+ <% include('tr-td-label.html', %opt) %>
+ <TD <% $cell_style %>>
+
+% }
+%
+ <% include( '/elements/pbx_extension.html', %opt ) %>
+%
+% unless ( $opt{'js_only'} ) {
+
+ </TD>
+ </TR>
+
+% }
+<%init>
+
+my( %opt ) = @_;
+
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'label'} ||= 'Extension';
+
+</%init>
diff --git a/httemplate/view/svc_pbx.cgi b/httemplate/view/svc_pbx.cgi
index ff0d285..9b18dc3 100644
--- a/httemplate/view/svc_pbx.cgi
+++ b/httemplate/view/svc_pbx.cgi
@@ -1,6 +1,6 @@
<% include('elements/svc_Common.html',
'table' => 'svc_pbx',
- 'edit_url' => $p."edit/svc_Common.html?svcdb=svc_pbx;svcnum=",
+ 'edit_url' => $p.'edit/svc_pbx.html?',
'labels' => \%labels,
'html_foot' => $html_foot,
)
@@ -19,6 +19,48 @@ my $html_foot = sub {
my $svc_pbx = shift;
##
+ # Extensions
+ ##
+
+ my @pbx_extension = sort { $a->extension cmp $b->extension }
+ $svc_pbx->pbx_extension;
+
+ my $extensions = '';
+ if ( @pbx_extension ) {
+
+ $extensions .= '<FONT CLASS="fsinnerbox-title">Extensions</FONT>'.
+ include('/elements/table-grid.html');
+ my $bgcolor1 = '#eeeeee';
+ my $bgcolor2 = '#ffffff';
+ my $bgcolor = '';
+
+ #$extensions .= '
+ # <TR>
+ # <TH CLASS="grid" BGCOLOR="#cccccc">Ext</TH>
+ # <TH CLASS="grid" BGCOLOR="#cccccc">Name</TH>
+ # </TR>
+ #';
+
+ foreach my $pbx_extension ( @pbx_extension ) {
+ if ( $bgcolor eq $bgcolor1 ) {
+ $bgcolor = $bgcolor2;
+ } else {
+ $bgcolor = $bgcolor1;
+ }
+
+ $extensions .= qq(
+ <TR>
+ <TD CLASS="grid" BGCOLOR="$bgcolor">). $pbx_extension->extension. qq(
+ <TD CLASS="grid" BGCOLOR="$bgcolor">). $pbx_extension->phone_name. qq(
+ </TR>
+ );
+
+ }
+
+ $extensions .= '</TABLE><BR>';
+ }
+
+ ##
# CDR links
##
@@ -29,7 +71,7 @@ my $html_foot = sub {
#matching as per package def cdr_svc_method
my $cust_pkg = $svc_pbx->cust_svc->cust_pkg;
- return '' unless $cust_pkg;
+ return $extensions unless $cust_pkg;
my @voip_pkgs =
grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
@@ -43,7 +85,7 @@ my $html_foot = sub {
my $cdr_svc_method = ( $voip_pkg && $voip_pkg->option('cdr_svc_method') )
|| 'svc_phone.phonenum';
- return '' unless $cdr_svc_method =~ /^svc_pbx\.(.*)$/;
+ return $extensions unless $cdr_svc_method =~ /^svc_pbx\.(.*)$/;
my $field = $1;
my $search;
@@ -55,7 +97,7 @@ my $html_foot = sub {
$search = 'svcnum='. $svc_pbx->svcnum;
} else {
warn "unknown cdr_svc_method svc_pbx.$field";
- return '';
+ return $extensions
}
my @links = map {
@@ -67,6 +109,7 @@ my $html_foot = sub {
# concatenate & return
###
+ $extensions.
join(' | ', @links ). '<BR>';
};
-----------------------------------------------------------------------
Summary of changes:
FS/FS.pm | 2 +
FS/FS/Schema.pm | 19 +++++
FS/FS/svc_pbx.pm | 2 +-
FS/t/{AccessRight.t => pbx_extension.t} | 2 +-
httemplate/edit/process/svc_pbx.html | 13 ++++
httemplate/edit/svc_pbx.html | 52 +++++++++++++
httemplate/elements/pbx_extension.html | 113 +++++++++++++++++++++++++++++
httemplate/elements/tr-pbx_extension.html | 24 ++++++
httemplate/view/svc_pbx.cgi | 51 ++++++++++++-
9 files changed, 272 insertions(+), 6 deletions(-)
copy FS/t/{AccessRight.t => pbx_extension.t} (81%)
create mode 100644 httemplate/edit/process/svc_pbx.html
create mode 100644 httemplate/edit/svc_pbx.html
create mode 100644 httemplate/elements/pbx_extension.html
create mode 100644 httemplate/elements/tr-pbx_extension.html
More information about the freeside-commits
mailing list