1 package FS::part_device;
4 use base qw( FS::Record FS::m2m_Common );
5 use FS::Record qw( qsearch qsearchs );
11 FS::part_device - Object methods for part_device records
17 $record = new FS::part_device \%hash;
18 $record = new FS::part_device { 'column' => 'value' };
20 $error = $record->insert;
22 $error = $new_record->replace($old_record);
24 $error = $record->delete;
26 $error = $record->check;
30 An FS::part_device object represents a phone device definition. FS::part_device
31 inherits from FS::Record. The following fields are currently supported:
41 device name (used in Freeside)
43 =item inventory_classnum
45 L<FS::inventory_class> used to track inventory of these devices.
49 external device name (for export)
59 Creates a new record. To add the record to the database, see L<"insert">.
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to. You can ask the object for a copy with the I<hash> method.
66 # the new method can be inherited from FS::Record, if a table method is defined
68 sub table { 'part_device'; }
72 Adds this record to the database. If there is an error, returns the error,
73 otherwise returns false.
77 # the insert method can be inherited from FS::Record
81 Delete this record from the database.
85 # the delete method can be inherited from FS::Record
87 =item replace OLD_RECORD
89 Replaces the OLD_RECORD with this one in the database. If there is an error,
90 returns the error, otherwise returns false.
94 # the replace method can be inherited from FS::Record
98 Checks all fields to make sure this is a valid record. If there is
99 an error, returns the error, otherwise returns false. Called by the insert
104 # the check method should currently be supplied - FS::Record contains some
105 # data checking routines
111 $self->ut_numbern('devicepart')
112 || $self->ut_text('devicename')
113 || $self->ut_foreign_keyn('inventory_classnum', 'inventory_class', 'classnum')
114 || $self->ut_textn('title')
116 return $error if $error;
123 Returns a list of all exports (see L<FS::part_export>) for this device.
129 map { qsearchs( 'part_export', { 'exportnum' => $_->exportnum } ) }
130 qsearch( 'export_device', { 'devicepart' => $self->devicepart } );
133 =item inventory_class
135 Returns the inventory class (see L<FS::inventory_class>) for this device,
140 sub inventory_class {
142 return '' unless $self->inventory_classnum;
143 qsearchs('inventory_class', { 'classnum' => $self->inventory_classnum });
146 sub process_batch_import {
149 my $opt = { 'table' => 'part_device',
151 'formats' => { 'default' => [ 'devicename' ] },
155 FS::Record::process_batch_import( $job, $opt, @_ );
165 L<FS::Record>, schema.html from the base documentation.