[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.153, 1.154
Ivan,,,
ivan at wavetail.420.am
Thu Oct 6 13:44:20 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv25965/FS/FS/ClientAPI
Modified Files:
MyAccount.pm
Log Message:
add dsl_device to track mac addresses, RT#13656
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -w -d -r1.153 -r1.154
--- MyAccount.pm 6 Oct 2011 03:31:50 -0000 1.153
+++ MyAccount.pm 6 Oct 2011 20:44:18 -0000 1.154
@@ -25,6 +25,8 @@
use FS::svc_domain;
use FS::svc_phone;
use FS::svc_external;
+use FS::svc_dsl;
+use FS::dsl_device;
use FS::part_svc;
use FS::cust_main;
use FS::cust_bill;
@@ -1403,6 +1405,82 @@
}
+sub _customer_svc_x {
+ my($custnum, $svcnum, $table) = @_;
+
+ $custnum =~ /^(\d+)$/ or die "illegal custnum";
+ my $search = " AND custnum = $1";
+ #$search .= " AND agentnum = ". $session->{'agentnum'} if $context eq 'agent';
+
+ qsearchs( {
+ 'table' => ($table || 'svc_acct'),
+ 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) '.
+ 'LEFT JOIN cust_pkg USING ( pkgnum ) ',#.
+ #'LEFT JOIN cust_main USING ( custnum ) ',
+ 'hashref' => { 'svcnum' => $svcnum, },
+ 'extra_sql' => $search, #important
+ } );
+
+}
+
+sub list_dsl_devices {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $svc_dsl = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_dsl' )
+ or return { 'error' => "Service not found" };
+
+ return {
+ 'devices' => [ map {
+ +{ 'mac_addr' => $_->mac_addr };
+ } $svc_dsl->dsl_device
+ ],
+ };
+
+}
+
+sub add_dsl_device {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $svc_dsl = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_dsl' )
+ or return { 'error' => "Service not found" };
+
+ return { 'error' => 'No MAC address supplied' }
+ unless length($p->{'mac_addr'});
+
+ my $dsl_device = new FS::dsl_device { 'svcnum' => $svc_dsl->svcnum,
+ 'mac_addr' => scalar($p->{'mac_addr'}),
+ };
+ my $error = $dsl_device->insert;
+ return { 'error' => $error };
+
+}
+
+sub delete_dsl_device {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $svc_dsl = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_dsl' )
+ or return { 'error' => "Service not found" };
+
+ my $dsl_device = qsearchs('dsl_device', { 'svcnum' => $svc_dsl->svcnum,
+ 'mac_addr' => scalar($p->{'mac_addr'}),
+ }
+ )
+ or return { 'error' => 'Unknown MAC address: '. $p->{'mac_addr'} };
+
+ my $error = $dsl_device->delete;
+ return { 'error' => $error };
+
+}
+
sub port_graph {
my $p = shift;
_usage_details( \&_port_graph, $p,
More information about the freeside-commits
mailing list