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
19 my $table = $opt{'table'}; #part_device, dsl_device
20 my $svc_x = $opt{'svc_x'};
24 my $num_part_device = 0;
25 if ( $table eq 'phone_device' ) {
26 my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device")
27 #WHERE disabled = '' OR disabled IS NULL;");
29 $sth->execute or die $sth->errstr;
30 $num_part_device = $sth->fetchrow_arrayref->[0];
33 my @devices = $svc_x->$table();
35 #should move the below to proper mason code above instead of making $devices
36 if ( @devices || $num_part_device || $table eq 'dsl_device' ) {
37 my $svcnum = $svc_x->svcnum;
39 qq[Devices (<A HREF="${p}edit/$table.html?svcnum=$svcnum">Add device</A>)<BR>];
44 function areyousure(href) {
45 if (confirm("Are you sure you want to delete this device?") == true)
46 window.location.href = href;
53 include('/elements/table-grid.html').
57 '<TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>'
58 if $table eq 'phone_device';
61 '<TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH>'.
62 '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'.
63 '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'.
65 my $bgcolor1 = '#eeeeee';
66 my $bgcolor2 = '#ffffff';
69 foreach my $device ( @devices ) {
71 if ( $bgcolor eq $bgcolor1 ) {
76 my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">);
78 my $devicenum = $device->devicenum;
79 my $export_links = join( '<BR>', @{ $device->export_links } )
80 if $device->can('export_links');
83 $devices .= $td. $device->part_device->devicename. '</TD>'
84 if $table eq 'phone_device'; #$devices->can('part_device');
86 $devices .= $td. $device->mac_addr. '</TD>'.
87 $td. $export_links. '</TD>'.
90 $devices .= qq(<A HREF="${p}edit/$table.html?$devicenum">edit</A> | )
91 unless $opt{'no_edit'};
93 $devices .= qq(<A HREF="javascript:areyousure('${p}misc/delete-$table.html?$devicenum')">delete</A>).
97 $devices .= '</TABLE><BR>';