X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Felements%2Fsvc_devices.html;h=c9f5eda781a3107cf4c9ae8914429a6e274fe80f;hp=d71c82f07d0dc5185b67097a31cdd57f54d37f2f;hb=f3ac48703be75c0e2aec161487057eafeb8fc74f;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924
diff --git a/httemplate/view/elements/svc_devices.html b/httemplate/view/elements/svc_devices.html
index d71c82f07..c9f5eda78 100644
--- a/httemplate/view/elements/svc_devices.html
+++ b/httemplate/view/elements/svc_devices.html
@@ -12,91 +12,89 @@
)
%doc>
-<% $devices %>
+%if ( @devices || $num_part_device || $table eq 'dsl_device' ) {
+% my $svcnum = $svc_x->svcnum;
+
+ Devices
+ (Add device)
+
+
+% if ( @devices ) {
+
+
+
+ <& /elements/table-grid.html &>
+
+% if ( $table ne 'dsl_device' ) { # ( $table eq 'phone_device' || $table eq 'cable_device' || $table eq 'pbx_device' ) {
+ Type |
+% }
+ MAC Addr |
+ |
+ |
+
+
+% my $bgcolor1 = '#eeeeee';
+% my $bgcolor2 = '#ffffff';
+% my $bgcolor = '';
+%
+% foreach my $device ( @devices ) {
+%
+% if ( $bgcolor eq $bgcolor1 ) {
+% $bgcolor = $bgcolor2;
+% } else {
+% $bgcolor = $bgcolor1;
+% }
+%
+% my $td = qq();
+%
+% my $devicenum = $device->devicenum;
+% my $export_links = '';
+% $export_links = join( ' ', @{ $device->export_links } )
+% if $device->can('export_links');
+
+ |
+% #$devices->can('part_device')
+% if ( $table eq 'phone_device' || $svc_x->isa('FS::device_Common') ) {
+ <% $td %><% $device->part_device->devicename |h %>
+% }
+ <% $td %><% $device->mac_addr_pretty %>
+ <% $td %><% $export_links %>
+ <% $td %>(
+% unless ( $opt{'no_edit'} ) {
+ edit |
+% }
+ delete
+ )
+
+% }
+
+
+
+% }
+
+%}
<%init>
- my %opt = @_;
- my $table = $opt{'table'}; #part_device, dsl_device
- my $svc_x = $opt{'svc_x'};
-
- my $devices = '';
-
- my $num_part_device = 0;
- if ( $table eq 'phone_device' ) {
- my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device")
- #WHERE disabled = '' OR disabled IS NULL;");
- or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- $num_part_device = $sth->fetchrow_arrayref->[0];
+my %opt = @_;
+my $table = $opt{'table'}; #part_device, dsl_device
+my $svc_x = $opt{'svc_x'};
+
+my $num_part_device = 0;
+if ( $table ne 'dsl_device' ) { # ( $table eq 'phone_device' || $table eq 'cable_device' || $table eq 'pbx_device' ) {
+ my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device")
+ #WHERE disabled = '' OR disabled IS NULL;");
+ or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ $num_part_device = $sth->fetchrow_arrayref->[0];
}
- my @devices = $svc_x->$table();
-
- #should move the below to proper mason code above instead of making $devices
- if ( @devices || $num_part_device || $table eq 'dsl_device' ) {
- my $svcnum = $svc_x->svcnum;
- $devices .=
- qq[Devices (Add device)
];
- if ( @devices ) {
-
- $devices .= qq!
-
- !;
-
-
- $devices .=
- include('/elements/table-grid.html').
- '';
-
- $devices .=
- 'Type | '
- if $table eq 'phone_device';
-
- $devices .=
- 'MAC Addr | '.
- ' | '.
- ' | '.
- '
';
- my $bgcolor1 = '#eeeeee';
- my $bgcolor2 = '#ffffff';
- my $bgcolor = '';
-
- foreach my $device ( @devices ) {
-
- if ( $bgcolor eq $bgcolor1 ) {
- $bgcolor = $bgcolor2;
- } else {
- $bgcolor = $bgcolor1;
- }
- my $td = qq();
-
- my $devicenum = $device->devicenum;
- my $export_links = join( ' ', @{ $device->export_links } )
- if $device->can('export_links');
-
- $devices .= ' | ';
- $devices .= $td. $device->part_device->devicename. ''
- if $table eq 'phone_device'; #$devices->can('part_device');
-
- $devices .= $td. $device->mac_addr. ''.
- $td. $export_links. ''.
- "$td( ";
-
- $devices .= qq(edit | )
- unless $opt{'no_edit'};
-
- $devices .= qq(delete).
- ' )'.
- '
';
- }
- $devices .= '
';
- }
- $devices .= '
';
- }
+my @devices = $svc_x->isa('FS::device_Common') ? $svc_x->device_objects()
+ : $table ? $svc_x->$table()
+ : ();
%init>