' if $DEBUG;
my $table = 'Interface';
# Check if user can access this page
# We don't want average users seeing this page, its only for admins and operators.
my $manager = $ui->get_permission_manager($r);
unless ( $manager && $manager->can($user, "access_section", 'interface.html') ){
$m->comp('/generic/error.mhtml', error=>"You don't have permission to access this page");
}
my $o = Interface->retrieve($id);
my $dbh = Netdot::Model->db_Main();
my $fdb_tstamps;
my %linksfrom = Interface->meta_data->get_links_from;
%init>
% }elsif( $i eq 'fwt_entries' ){
<%perl>
my $sth1 = $dbh->prepare("SELECT ft.tstamp
FROM interface i, fwtable ft, fwtableentry fte
WHERE fte.interface=i.id
AND fte.fwtable=ft.id
AND i.id=?
GROUP BY ft.tstamp
ORDER BY ft.tstamp DESC");
%perl>
% $sth1->execute($id);
% $fdb_tstamps = $sth1->fetchall_arrayref();
% my $fdb_count = scalar(@$fdb_tstamps);
% my @headers = ("Timestamp");
% my @rows;
% if ( $fdb_count ){
FWT entries
% foreach my $row (@$fdb_tstamps){
% my ($tstamp) = @$row;
% push @rows, ["$tstamp"];
% }
% $m->comp('/generic/data_table.mhtml', field_headers=>\@headers, data=>\@rows);
% }
% }elsif( $i eq 'arp_entries' ){
<%perl>
my $sth2 = $dbh->prepare("SELECT arp.tstamp
FROM interface i, arpcache arp, arpcacheentry arpe
WHERE arpe.interface=i.id
AND arpe.arpcache=arp.id
AND i.id=?
GROUP BY arp.tstamp
ORDER BY arp.tstamp DESC");
%perl>
% $sth2->execute($id);
% my $arp_tstamps = $sth2->fetchall_arrayref();
% my $arp_count = scalar(@$arp_tstamps);
% my @headers = ("Timestamp");
% my @rows = ();
% if ( $arp_count ){
ARP entries
% foreach my $row (@$arp_tstamps){
% my ($tstamp) = @$row;
% push @rows, ["$tstamp"];
% }
% $m->comp('/generic/data_table.mhtml', field_headers=>\@headers, data=>\@rows);
% }
% }else{
% # Table that points to us
% my $j = (keys %{ $linksfrom{$i} })[0];
%
% # Column in the other table that points to this table
% my $ffield = $linksfrom{$i}{$j};
%
% # Determine if the has_many method returns ordered data from the db
% my $ffattrs = $j->meta_data->get_column($ffield)->links_to_attrs();
% my $ffield_order = $ffattrs->{order_by} if ( defined $ffattrs && exists $ffattrs->{order_by} );
%
% my @robjs = $o->$i;
% my $dtbl = $j;
% my $ctbl = $j;
%
% my %args = ( table=>$dtbl, object=>\@robjs );
% my $num = scalar(@robjs);
% my $title = $i;
% $title .= " ($num)" if $num;
<% $title %>
% if ( $edit eq $i ){
% }else{
% if ( $num ){
[edit]
% }
[add]
% }
% if ( $edit eq $i ){
% $args{withedit} = 1;
% }else{
% # If data came ordered from the db, tell sortresults not to bother sorting
% $args{sort} = 0 if ( $ffield_order );
% }
% if ( $num ) {
% $args{return_args} = "?table=$table&id=$id&view=$view";
% $m->comp('/generic/sortresults.mhtml', %args);
% }