summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2011-01-07 23:13:58 +0000
committerlevinse <levinse>2011-01-07 23:13:58 +0000
commit8ae589024036a94bb71da0e05f645b00697e271f (patch)
treee29950ca6c4942b2bba4958289fcc702eb74ccad /FS
parent29c296af24c09dc904f6fad51edbf3c5f2f085d3 (diff)
opensips provisioning, RT10993
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/part_export/phone_sqlopensips.pm92
-rw-r--r--FS/FS/svc_phone.pm8
3 files changed, 101 insertions, 0 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 52f4d8f07..26252a7c0 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2973,6 +2973,7 @@ sub tables_hashref {
'pbxsvc', 'int', 'NULL', '', '', '',
'domsvc', 'int', 'NULL', '', '', '',
'locationnum', 'int', 'NULL', '', '', '',
+ 'route', 'varchar', 'NULL', $char_d, '', '',
'lnp_status', 'varchar', 'NULL', $char_d, '', '',
'portable', 'char', 'NULL', 1, '', '',
'lrn', 'char', 'NULL', 10, '', '',
diff --git a/FS/FS/part_export/phone_sqlopensips.pm b/FS/FS/part_export/phone_sqlopensips.pm
new file mode 100644
index 000000000..8a3d3a17b
--- /dev/null
+++ b/FS/FS/part_export/phone_sqlopensips.pm
@@ -0,0 +1,92 @@
+package FS::part_export::phone_sqlopensips;
+
+use vars qw(@ISA @EXPORT_OK %info %options);
+use Exporter;
+use Tie::IxHash;
+use FS::Record qw( dbh qsearch qsearchs );
+use FS::part_export;
+use FS::svc_phone;
+use FS::export_svc;
+
+@ISA = qw(FS::part_export);
+
+tie %options, 'Tie::IxHash',
+ 'datasrc' => { label=>'DBI data source ' },
+ 'username' => { label=>'Database username' },
+ 'password' => { label=>'Database password' },
+;
+
+%info = (
+ 'svc' => 'svc_phone',
+ 'desc' => 'Export DIDs to OpenSIPs dr_rules table',
+ 'options' => \%options,
+ 'notes' => 'Export DIDs to OpenSIPs dr_rules table',
+);
+
+sub rebless { shift; }
+
+sub _export_insert {
+ my($self, $svc_x) = (shift, shift);
+ my $dbh = $self->opensips_connect;
+ my $sth = $dbh->prepare("insert into dr_rules ".
+ "( groupid, prefix, timerec, routeid, gwlist, description ) ".
+ " values ( ?, ?, ?, ?, ?, ? )") or die $dbh->errstr;
+ $sth->execute('0',$svc_x->phonenum,'',$svc_x->route,'',
+ $svc_x->phone_name) or die $sth->errstr;
+ $dbh->disconnect;
+ '';
+}
+
+sub opensips_connect {
+ my $self = shift;
+ DBI->connect($self->option('datasrc'),$self->option('username'),
+ $self->option('password')) or die $DBI::errstr;
+}
+
+sub _export_replace {
+ my( $self, $new, $old ) = (shift, shift, shift);
+ my @update = ();
+ my @paramvalues = ();
+
+ if($old->route ne $new->route){
+ push @update, 'routeid = ?';
+ push @paramvalues, $new->route;
+ }
+
+ if($old->phone_name ne $new->phone_name) {
+ push @update, 'description = ?';
+ push @paramvalues, $new->phone_name;
+ }
+
+ if(scalar(@update)) {
+ my $update_str = join(' and ',@update);
+ my $dbh = $self->opensips_connect;
+ my $sth = $dbh->prepare("update dr_rules set $update_str " .
+ " where prefix = ? ") or die $dbh->errstr;
+ push @paramvalues, $old->phonenum;
+ $sth->execute(@paramvalues) or die $sth->errstr;
+ $dbh->disconnect;
+ }
+ '';
+}
+
+sub _export_suspend {
+ my( $self, $svc_phone ) = (shift, shift);
+ '';
+}
+
+sub _export_unsuspend {
+ my( $self, $svc_phone ) = (shift, shift);
+ '';
+}
+
+sub _export_delete {
+ my( $self, $svc_x ) = (shift, shift);
+ my $dbh = $self->opensips_connect;
+ my $sth = $dbh->prepare("delete from dr_rules where prefix = ?")
+ or die $dbh->errstr;
+ $sth->execute($svc_x->phonenum) or die $sth->errstr;
+ $dbh->disconnect;
+ '';
+}
+
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index 56f3f3c2e..0b001d706 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -79,6 +79,10 @@ Voicemail PIN
Optional svcnum from svc_pbx
+=item route
+
+Route id/number
+
=item lnp_status
LNP Status (can be null, native, portedin, portingin, portin-reject,
@@ -163,6 +167,9 @@ sub table_info {
disable_inventory => 1,
disable_select => 1,
},
+ 'route' => { label => 'Route',
+ %dis2,
+ },
'lnp_status' => { label => 'LNP Status',
type => 'select-lnp_status.html',
%dis2,
@@ -456,6 +463,7 @@ sub check {
|| $self->ut_foreign_keyn('pbxsvc', 'svc_pbx', 'svcnum' )
|| $self->ut_foreign_keyn('domsvc', 'svc_domain', 'svcnum' )
|| $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
+ || $self->ut_textn('route')
|| $self->ut_numbern('lrn')
|| $self->ut_numbern('lnp_desired_due_date')
|| $self->ut_numbern('lnp_due_date')