+my $extra_sql =
+ join( ' OR ', map { "exporttype = '$_'" }
+ keys %{FS::part_export::export_info('part_device')}
+ );
+$extra_sql = $extra_sql ? " WHERE ( $extra_sql ) " : " WHERE 0 = 1 ";
+
+my @inventory_classnums;
+push @inventory_classnums, '';
+my %inventory_classnum_labels;
+$inventory_classnum_labels{''} = '';
+my @inventory_classes = qsearch('inventory_class', {} );
+foreach my $inventory_class ( @inventory_classes ) {
+ push @inventory_classnums, $inventory_class->classnum;
+ $inventory_classnum_labels{$inventory_class->classnum} = $inventory_class->classname;
+}
+
+my @fields;
+push @fields, 'devicename',
+ { field => 'inventory_classnum',
+ type => 'select',
+ options => \@inventory_classnums,
+ labels => \%inventory_classnum_labels,
+ };
+
+my $html_bottom_sub = sub {
+ my $part_device = shift;
+
+ '<BR>'.
+ '<FONT SIZE="+1">Exports</FONT><BR>'.
+
+ '<TABLE BGCOLOR="#cccccc" WIDTH=100%>'.
+ '<TR><TD>'.
+ include( '/elements/checkboxes-table.html',
+ 'source_obj' => $part_device,
+ 'link_table' => 'export_device',
+ 'target_table' => 'part_export',
+ 'extra_sql' => $extra_sql,
+ 'name_callback' => sub { my $o = shift;
+ $o->exporttype. ' to '. $o->machine;
+ },
+ ).
+ '</TD></TR></TABLE>';
+
+};
+