[freeside-commits] freeside/FS/FS Schema.pm, 1.147, 1.148 part_device.pm, NONE, 1.1 phone_device.pm, NONE, 1.1 Mason.pm, 1.10, 1.11 svc_phone.pm, 1.18, 1.19
Ivan,,,
ivan at wavetail.420.am
Mon Jun 29 18:42:57 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv27146/FS/FS
Modified Files:
Schema.pm Mason.pm svc_phone.pm
Added Files:
part_device.pm phone_device.pm
Log Message:
phone devices (for netsapiens integration), RT#5226
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- Schema.pm 29 Jun 2009 13:53:23 -0000 1.147
+++ Schema.pm 30 Jun 2009 01:42:55 -0000 1.148
@@ -2306,6 +2306,29 @@
'index' => [ [ 'countrycode', 'phonenum' ] ],
},
+ 'phone_device' => {
+ 'columns' => [
+ 'devicenum', 'serial', '', '', '', '',
+ 'devicepart', 'int', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'mac_addr', 'varchar', 'NULL', 12, '', '',
+ ],
+ 'primary_key' => 'devicenum',
+ 'unique' => [ [ 'mac_addr' ], ],
+ 'index' => [ [ 'devicepart' ], [ 'svcnum' ], ],
+ },
+
+ 'part_device' => {
+ 'columns' => [
+ 'devicepart', 'serial', '', '', '', '',
+ 'devicename', 'varchar', '', $char_d, '', '',
+ #'classnum', #tie to an inventory class?
+ ],
+ 'primary_key' => 'devicepart',
+ 'unique' => [ [ 'devicename' ] ], #?
+ 'index' => [],
+ },
+
'phone_avail' => {
'columns' => [
'availnum', 'serial', '', '', '', '',
Index: svc_phone.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_phone.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- svc_phone.pm 10 May 2009 00:45:33 -0000 1.18
+++ svc_phone.pm 30 Jun 2009 01:42:55 -0000 1.19
@@ -7,6 +7,7 @@
use FS::Msgcat qw(gettext);
use FS::svc_Common;
use FS::part_svc;
+use FS::phone_device;
@ISA = qw( FS::svc_Common );
@@ -326,6 +327,17 @@
();
}
+=item phone_device
+
+Returns any FS::phone_device records associated with this service.
+
+=cut
+
+sub phone_device {
+ my $self = shift;
+ qsearch('phone_device', { 'svcnum' => $self->svcnum } );
+}
+
=back
=head1 BUGS
--- NEW FILE: phone_device.pm ---
package FS::phone_device;
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearchs ); # qsearch );
use FS::part_device;
use FS::svc_phone;
=head1 NAME
FS::phone_device - Object methods for phone_device records
=head1 SYNOPSIS
use FS::phone_device;
$record = new FS::phone_device \%hash;
$record = new FS::phone_device { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::phone_device object represents a specific customer phone device, such as
a SIP phone or ATA. FS::phone_device inherits from FS::Record. The following
fields are currently supported:
=over 4
=item devicenum
primary key
=item devicepart
devicepart
=item svcnum
svcnum
=item mac_addr
mac_addr
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'phone_device'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $mac = $self->mac_addr;
$mac =~ s/\s+//g;
$mac =~ s/://g;
$self->mac_addr($mac);
my $error =
$self->ut_numbern('devicenum')
|| $self->ut_foreign_key('devicepart', 'part_device', 'devicepart')
|| $self->ut_foreign_key('svcnum', 'svc_phone', 'svcnum' ) #cust_svc?
|| $self->ut_hexn('mac_addr')
;
return $error if $error;
$self->SUPER::check;
}
=item part_device
Returns the device type record (see L<FS::part_device>) associated with this
customer device.
=cut
sub part_device {
my $self = shift;
qsearchs( 'part_device', { 'devicepart' => $self->devicepart } );
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
Index: Mason.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Mason.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Mason.pm 22 Jun 2009 22:55:05 -0000 1.10
+++ Mason.pm 30 Jun 2009 01:42:55 -0000 1.11
@@ -174,6 +174,8 @@
use FS::access_right;
use FS::AccessRight;
use FS::svc_phone;
+ use FS::phone_device;
+ use FS::part_device;
use FS::reason_type;
use FS::reason;
use FS::cust_main_note;
--- NEW FILE: part_device.pm ---
package FS::part_device;
use strict;
use base qw( FS::Record );
use FS::Record; # qw( qsearch qsearchs );
=head1 NAME
FS::part_device - Object methods for part_device records
=head1 SYNOPSIS
use FS::part_device;
$record = new FS::part_device \%hash;
$record = new FS::part_device { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::part_device object represents a phone device definition. FS::part_device
inherits from FS::Record. The following fields are currently supported:
=over 4
=item devicepart
primary key
=item devicename
devicename
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'part_device'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $error =
$self->ut_numbern('devicepart')
|| $self->ut_text('devicename')
;
return $error if $error;
$self->SUPER::check;
}
sub process_batch_import {
my $job = shift;
my $opt = { 'table' => 'part_device',
'params' => [],
'formats' => { 'default' => [ 'devicename' ] },
'default_csv' => 1,
};
FS::Record::process_batch_import( $job, $opt, @_ );
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
More information about the freeside-commits
mailing list