<%doc> #Example: include( 'elements/svc_devices.html', #required 'svc_x' => $svc_phone, #or $svc_dsl 'table' => 'phone_device', #or dsl_device #optional 'no_edit' => 0, #set true to turn off edit link ) %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 %> % my $vendor = Net::MAC::Vendor::lookup($device->mac_addr_formatted('U',':')); (<% $vendor ? $vendor->[0] : '' %>) <% $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 $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->isa('FS::device_Common') ? $svc_x->device_objects() : $table ? $svc_x->$table() : ();