diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-03-06 16:32:44 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-03-06 16:32:44 -0800 |
commit | 978862f11a10e6a0a8b6010d22be3f15bf7ea8f5 (patch) | |
tree | f5989189d632f4fcab4084b22bfa0448944792fa /httemplate/view | |
parent | 0704f3f641deb525399521368f1e6ba9ff5b71cd (diff) |
cleanup phone devices, RT#21623
Diffstat (limited to 'httemplate/view')
-rw-r--r-- | httemplate/view/elements/svc_devices.html | 159 |
1 files changed, 77 insertions, 82 deletions
diff --git a/httemplate/view/elements/svc_devices.html b/httemplate/view/elements/svc_devices.html index d71c82f07..38c6d0919 100644 --- a/httemplate/view/elements/svc_devices.html +++ b/httemplate/view/elements/svc_devices.html @@ -12,91 +12,86 @@ ) </%doc> -<% $devices %> +%if ( @devices || $num_part_device || $table eq 'dsl_device' ) { +% my $svcnum = $svc_x->svcnum; + + Devices + (<A HREF="<%$p%>edit/<%$table%>.html?svcnum=<%$svcnum%>">Add device</A>) + <BR> + +% if ( @devices ) { + + <SCRIPT> + function areyousure(href) { + if (confirm("Are you sure you want to delete this device?") == true) + window.location.href = href; + } + </SCRIPT> + + <& /elements/table-grid.html &> + <TR> +% if ( $table eq 'phone_device' ) { + <TH CLASS="grid" BGCOLOR="#cccccc">Type</TH> +% } + <TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH> + <TH CLASS="grid" BGCOLOR="#cccccc"></TH> + <TH CLASS="grid" BGCOLOR="#cccccc"></TH> + </TR> + +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; +% +% foreach my $device ( @devices ) { +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } +% +% my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">); +% +% my $devicenum = $device->devicenum; +% my $export_links = ''; +% $export_links = join( '<BR>', @{ $device->export_links } ) +% if $device->can('export_links'); + + <TR> +% if ( $table eq 'phone_device' ) { #$devices->can('part_device') + <% $td %><% $device->part_device->devicename |h %></TD> +% } + <% $td %><% $device->mac_addr %></TD> + <% $td %><% $export_links %></TD> + <% $td %>( +% unless ( $opt{'no_edit'} ) { + <A HREF="<%$p%>edit/<%$table%>.html?<%$devicenum%>">edit</A> | +% } + <A HREF="javascript:areyousure('<%$p%>misc/delete-<%$table%>.html?<%$devicenum%>')">delete</A> + )</TD> + </TR> +% } + </TABLE> + <BR> + +% } + <BR> +%} <%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 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 @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 (<A HREF="${p}edit/$table.html?svcnum=$svcnum">Add device</A>)<BR>]; - if ( @devices ) { - - $devices .= qq! - <SCRIPT> - function areyousure(href) { - if (confirm("Are you sure you want to delete this device?") == true) - window.location.href = href; - } - </SCRIPT> - !; - - - $devices .= - include('/elements/table-grid.html'). - '<TR>'; - - $devices .= - '<TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>' - if $table eq 'phone_device'; - - $devices .= - '<TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH>'. - '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'. - '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'. - '</TR>'; - my $bgcolor1 = '#eeeeee'; - my $bgcolor2 = '#ffffff'; - my $bgcolor = ''; - - foreach my $device ( @devices ) { - - if ( $bgcolor eq $bgcolor1 ) { - $bgcolor = $bgcolor2; - } else { - $bgcolor = $bgcolor1; - } - my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">); - - my $devicenum = $device->devicenum; - my $export_links = join( '<BR>', @{ $device->export_links } ) - if $device->can('export_links'); - - $devices .= '<TR>'; - $devices .= $td. $device->part_device->devicename. '</TD>' - if $table eq 'phone_device'; #$devices->can('part_device'); - - $devices .= $td. $device->mac_addr. '</TD>'. - $td. $export_links. '</TD>'. - "$td( "; - - $devices .= qq(<A HREF="${p}edit/$table.html?$devicenum">edit</A> | ) - unless $opt{'no_edit'}; - - $devices .= qq(<A HREF="javascript:areyousure('${p}misc/delete-$table.html?$devicenum')">delete</A>). - ' )</TD>'. - '</TR>'; - } - $devices .= '</TABLE><BR>'; - } - $devices .= '<BR>'; - } +my @devices = $svc_x->$table(); </%init> |