summaryrefslogtreecommitdiff
path: root/httemplate/edit/part_device.html
blob: 75e6b0aa5dfc9fe770908832e9370ced611b6db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<% include( 'elements/edit.html',
                 'name'   => 'Phone device type',
                 'table'  => 'part_device',
                 'labels' => { 
                               'devicepart' => 'Part number',
                               'devicename' => 'Device name',
			       'inventory_classnum' => 'Inventory class',
                               'title'      => 'External name',
                             },
		 'fields' => \@fields,
                 'viewall_dir' => 'browse',
                 'html_bottom' => $html_bottom_sub,
           )
%>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

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',
              'title',
	      { 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>';

};

</%init>