4.x style
[freeside.git] / httemplate / edit / part_device.html
1 <% include( 'elements/edit.html',
2                  'name'   => 'Phone device type',
3                  'table'  => 'part_device',
4                  'labels' => { 
5                                'devicepart' => 'Part number',
6                                'devicename' => 'Device name',
7                                'inventory_classnum' => 'Inventory class',
8                                'title'      => 'External name',
9                              },
10                  'fields' => \@fields,
11                  'viewall_dir' => 'browse',
12                  'html_bottom' => $html_bottom_sub,
13            )
14 %>
15 <%init>
16
17 die "access denied"
18   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
19
20 my $extra_sql =
21   join( ' OR ', map { "exporttype = '$_'" }
22                 keys %{FS::part_export::export_info('part_device')}
23       );
24 $extra_sql = $extra_sql ? " WHERE ( $extra_sql ) " : " WHERE 0 = 1 ";
25
26 my @inventory_classnums;
27 push @inventory_classnums, '';
28 my %inventory_classnum_labels;
29 $inventory_classnum_labels{''} = '';
30 my @inventory_classes = qsearch('inventory_class', {} );
31 foreach my $inventory_class ( @inventory_classes ) {
32     push @inventory_classnums, $inventory_class->classnum;
33     $inventory_classnum_labels{$inventory_class->classnum} = $inventory_class->classname;
34 }
35                         
36 my @fields;
37 push @fields, 'devicename',
38               'title',
39               { field => 'inventory_classnum', 
40                 type => 'select',
41                 options => \@inventory_classnums,
42                 labels => \%inventory_classnum_labels,
43               };
44
45 my $html_bottom_sub = sub {
46   my $part_device = shift;
47
48   '<BR>'.
49   '<FONT SIZE="+1">Exports</FONT><BR>'.
50
51   '<TABLE BGCOLOR="#cccccc" WIDTH=100%>'.
52   '<TR><TD>'.
53   include( '/elements/checkboxes-table.html',
54              'source_obj'    => $part_device,
55              'link_table'    => 'export_device',
56              'target_table'  => 'part_export',
57              'extra_sql'     => $extra_sql,
58              'name_callback' => sub { my $o = shift;
59                                       $o->exporttype. ' to '. $o->machine;
60                                     },
61          ).
62   '</TD></TR></TABLE>';
63
64 };
65
66 </%init>
67