summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2011-01-22 20:03:50 +0000
committerlevinse <levinse>2011-01-22 20:03:50 +0000
commite87a701dd25a5d20218924057aa0d38def2eefc1 (patch)
treecff56e9aa5bccc7f75f93b98d4e778edb2c79d2d /FS/FS
parent0259db6a5f67fa8837c18bbaed3e424cccf7a3e0 (diff)
populate MAC address from inventory for svc_phone devices, RT7794
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Schema.pm2
-rw-r--r--FS/FS/part_device.pm15
2 files changed, 16 insertions, 1 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index fe5f96a..71403b4 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3012,7 +3012,7 @@ sub tables_hashref {
'columns' => [
'devicepart', 'serial', '', '', '', '',
'devicename', 'varchar', '', $char_d, '', '',
- #'classnum', #tie to an inventory class?
+ 'inventory_classnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'devicepart',
'unique' => [ [ 'devicename' ] ], #?
diff --git a/FS/FS/part_device.pm b/FS/FS/part_device.pm
index 4963584..0f840a7 100644
--- a/FS/FS/part_device.pm
+++ b/FS/FS/part_device.pm
@@ -40,6 +40,7 @@ primary key
devicename
+=item inventory_classnum
=back
@@ -103,6 +104,7 @@ sub check {
my $error =
$self->ut_numbern('devicepart')
|| $self->ut_text('devicename')
+ || $self->ut_foreign_keyn('inventory_classnum', 'inventory_class', 'classnum')
;
return $error if $error;
@@ -121,6 +123,19 @@ sub part_export {
qsearch( 'export_device', { 'devicepart' => $self->devicepart } );
}
+=item inventory_class
+
+Returns the inventory class (see L<FS::inventory_class>) for this device,
+if any.
+
+=cut
+
+sub inventory_class {
+ my $self = shift;
+ return '' unless $self->inventory_classnum;
+ qsearchs('inventory_class', { 'classnum' => $self->inventory_classnum });
+}
+
sub process_batch_import {
my $job = shift;