diff options
author | levinse <levinse> | 2011-01-22 20:03:52 +0000 |
---|---|---|
committer | levinse <levinse> | 2011-01-22 20:03:52 +0000 |
commit | 61fbcfa109b5cc8e0eeff08fcd086164ee640904 (patch) | |
tree | 61aef90f3e015200f910665ed523fde42d2eccbe /FS | |
parent | 8f12b9fe1d7370c7307f183b0dff1e061c047ac5 (diff) |
populate MAC address from inventory for svc_phone devices, RT7794
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_device.pm | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 1e773a7e7..ce1cd4fae 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2810,7 +2810,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 49635841e..0f840a7bc 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; |