5 include( 'elements/svc_devices.html',
7 'svc_x' => $svc_phone, #or $svc_dsl
8 'table' => 'phone_device', #or dsl_device
11 'no_edit' => 0, #set true to turn off edit link
15 %if ( @devices || $num_part_device || $table eq 'dsl_device' ) {
16 % my $svcnum = $svc_x->svcnum;
18 <FONT CLASS="fsinnerbox-title">Devices</FONT>
19 (<A HREF="<%$p%>edit/<%$table%>.html?svcnum=<%$svcnum%>">Add device</A>)
25 function areyousure(href) {
26 if (confirm("Are you sure you want to delete this device?") == true)
27 window.location.href = href;
31 <& /elements/table-grid.html &>
33 % if ( $table ne 'dsl_device' ) { # ( $table eq 'phone_device' || $table eq 'cable_device' || $table eq 'pbx_device' ) {
34 <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
36 <TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH>
37 <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
38 <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
41 % my $bgcolor1 = '#eeeeee';
42 % my $bgcolor2 = '#ffffff';
45 % foreach my $device ( @devices ) {
47 % if ( $bgcolor eq $bgcolor1 ) {
48 % $bgcolor = $bgcolor2;
50 % $bgcolor = $bgcolor1;
53 % my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">);
55 % my $devicenum = $device->devicenum;
56 % my $export_links = '';
57 % $export_links = join( '<BR>', @{ $device->export_links } )
58 % if $device->can('export_links');
61 % #$devices->can('part_device')
62 % if ( $table eq 'phone_device' || $svc_x->isa('FS::device_Common') ) {
63 <% $td %><% $device->part_device->devicename |h %></TD>
65 <% $td %><% $device->mac_addr_pretty %>
66 % my $vendor = Net::MAC::Vendor::lookup($device->mac_addr_formatted('U',':'));
67 (<% $vendor ? $vendor->[0] : '' %>)
69 <% $td %><% $export_links %></TD>
71 % unless ( $opt{'no_edit'} ) {
72 <A HREF="<%$p%>edit/<%$table%>.html?<%$devicenum%>">edit</A> |
74 <A HREF="javascript:areyousure('<%$p%>misc/delete-<%$table%>.html?<%$devicenum%>')">delete</A>
87 my $table = $opt{'table'}; #part_device, dsl_device
88 my $svc_x = $opt{'svc_x'};
90 my $num_part_device = 0;
91 if ( $table ne 'dsl_device' ) { # ( $table eq 'phone_device' || $table eq 'cable_device' || $table eq 'pbx_device' ) {
92 my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device")
93 #WHERE disabled = '' OR disabled IS NULL;");
95 $sth->execute or die $sth->errstr;
96 $num_part_device = $sth->fetchrow_arrayref->[0];
99 my @devices = $svc_x->isa('FS::device_Common') ? $svc_x->device_objects()
100 : $table ? $svc_x->$table()