communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / FS / FS / inventory_item.pm
index 5312d95..3bba1cd 100644 (file)
@@ -2,10 +2,12 @@ package FS::inventory_item;
 
 use strict;
 use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( dbh qsearch qsearchs );
+use FS::cust_main_Mixin;
 use FS::inventory_class;
+use FS::cust_svc;
 
-@ISA = qw(FS::Record);
+@ISA = qw( FS::cust_main_Mixin FS::Record );
 
 =head1 NAME
 
@@ -105,20 +107,60 @@ sub check {
     $self->ut_numbern('itemnum')
     || $self->ut_foreign_key('classnum', 'inventory_class', 'classnum' )
     || $self->ut_text('item')
-    || $self->ut_numbern('svcnum')
+    || $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum' )
   ;
   return $error if $error;
 
   $self->SUPER::check;
 }
 
+=item cust_svc
+
+Returns the customer service associated with this inventory item, if the
+item has been used (see L<FS::cust_svc>).
+
+=cut
+
+sub cust_svc {
+  my $self = shift;
+  return '' unless $self->svcnum;
+  qsearchs( 'cust_svc', { 'svcnum' => $self->svcnum } );
+}
+
+=back
+
+=head1 SUBROUTINES
+
+=over 4
+
+=item process_batch_import
+
+=cut
+
+sub process_batch_import {
+  my $job = shift;
+
+  my $opt = { 'table'   => 'inventory_item',
+              #'params'  => [ 'itembatch', 'classnum', ],
+              'params'  => [ 'classnum', ],
+              'formats' => { 'default' => [ 'item' ] },
+              'default_csv' => 1,
+            };
+
+  FS::Record::process_batch_import( $job, $opt, @_ );
+
+}
+
 =back
 
 =head1 BUGS
 
+maybe batch_import should be a regular method in FS::inventory_class
+
 =head1 SEE ALSO
 
-L<FS::Record>, schema.html from the base documentation.
+L<inventory_class>, L<cust_svc>, L<FS::Record>, schema.html from the base
+documentation.
 
 =cut