X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_device.pm;h=ac987400a7ac237db886cdbfced1168742a11d31;hp=79a534ae7a5bc0dbf1e6840521040417a331d68a;hb=389b6f1116c3309c2ee57a6c295ed1a793503095;hpb=665067cef48a5516e0bfb2dd79d99b8495e25ee5 diff --git a/FS/FS/part_device.pm b/FS/FS/part_device.pm index 79a534ae7..ac987400a 100644 --- a/FS/FS/part_device.pm +++ b/FS/FS/part_device.pm @@ -1,8 +1,10 @@ package FS::part_device; use strict; -use base qw( FS::Record ); -use FS::Record; # qw( qsearch qsearchs ); +use base qw( FS::Record FS::m2m_Common ); +use FS::Record qw( qsearch qsearchs ); +use FS::part_export; +use FS::export_device; =head1 NAME @@ -36,8 +38,15 @@ primary key =item devicename -devicename +device name (used in Freeside) +=item inventory_classnum + +L used to track inventory of these devices. + +=item title + +external device name (for export) =back @@ -101,12 +110,39 @@ sub check { my $error = $self->ut_numbern('devicepart') || $self->ut_text('devicename') + || $self->ut_foreign_keyn('inventory_classnum', 'inventory_class', 'classnum') + || $self->ut_textn('title') ; return $error if $error; $self->SUPER::check; } +=item part_export + +Returns a list of all exports (see L) for this device. + +=cut + +sub part_export { + my $self = shift; + map { qsearchs( 'part_export', { 'exportnum' => $_->exportnum } ) } + qsearch( 'export_device', { 'devicepart' => $self->devicepart } ); +} + +=item inventory_class + +Returns the inventory class (see L) 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;