<%doc> Circuit Interface <%args> $id => undef $edit => undef $strand_sort => undef $search => undef $_action => undef $sequence_list => undef $add_interfaces => undef $new_interface => undef $add_strands => undef $user => $ui->get_current_user($r) <%attr> title => 'Circuit' <%init> my $DEBUG = 0; print "
", Dumper(%ARGS), "

" if $DEBUG; my $o = Circuit->retrieve($id) if ($id && $id ne "NEW"); my $manager = $ui->get_permission_manager($r); my @list; if ( $_action ){ if ( $_action eq "SEARCH" ) { if ( length($search) ){ $search = Netdot->rem_lt_sp($search); unless ( @list = Circuit->search_by_keyword($search) ){ print "

No results"; $m->abort; } my $num = scalar(@list); if ( $num == 1 ){ # Don't offer list. Just display this circuit $o = $list[0]; $id = $o->id; $search = undef; } }else{ # Show all @list = Circuit->retrieve_all(); } }elsif( $_action eq "ADD_STRANDS" && $sequence_list ){ my @sequences; if ( ref($sequence_list) eq "ARRAY" ) { @sequences = @{$sequence_list}; }else { push(@sequences, $sequence_list); } if ( scalar @sequences ){ foreach my $seq ( @sequences ){ my @strands = split(/,/o, $seq); foreach my $strandid ( @strands ){ my $strand = CableStrand->retrieve($strandid); $strand->update({circuit_id=>$o}); } } }else{ $m->comp("/generic/error.mhtml", error=>"Empty sequence list"); } }elsif( $_action eq "UPDATE_SEQUENCES" ){ foreach my $key ( keys(%ARGS) ) { next if ($key !~ /^__unassign_(\d+)/o); my @strands = split(/,/o, $ARGS{"__sequence_" . $1}); foreach my $strandid ( @strands ){ eval { my $strand = CableStrand->retrieve($strandid); $strand->update({circuit_id=>""}); }; if ( my $e = $@ ){ $m->comp("/generic/error.mhtml", error=>"Problem updating strand: $e"); } } } }elsif( $_action eq "ADD_INTERFACE" ){ if ( $new_interface && $new_interface !~ /\D/o){ eval { my $i = Interface->retrieve($new_interface); $i->update({circuit=>$o}); }; if ( my $e = $@ ){ $m->comp("/generic/error.mhtml", error=>"Problem updating interface: $e"); } }else{ $m->comp("/generic/error.mhtml", error=>"No interface selected, or invalid value"); } }elsif( $_action eq "UPDATE_INTERFACES" ){ my @ints; foreach my $key ( keys %ARGS ){ my $id; if ( $key =~ /^_un_interface_(\d+)$/og ){ $id = $1; }else{ next; } eval { my $i = Interface->retrieve($id); $i->update({circuit=>''}); }; if ( my $e = $@ ){ $m->comp("/generic/error.mhtml", error=>"Problem unassigning interface: $e"); } } } } % if ( defined $search && @list ){

<% scalar(@list) %> results for <% $search %>
<& /generic/sortresults.mhtml, object => \@list, view => "row", page => "circuit.html", withdelete => 1, withedit => 1 &>
% }elsif ( $o ){
% if ( $o->linkid ){ Circuit for Site Link: <% $o->linkid->name %> % }else{ Circuit ID: <% $o->cid %> % }
Circuit
[refresh] % if ( $manager && $manager->can($user, 'access_admin_section', 'circuit:new') ){ [new] % } % if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % if ( $manager && $manager->can($user, 'delete', $o) ){ [delete] % } [text]
<& /generic/form.mhtml, table=>"Circuit", id=>$o->id, edit=>$edit &>
%# Interfaces <& circuit_interfaces.mhtml, interfaces=>[$o->interfaces], id=>$id, add=>$add_interfaces &> %# Strand Sequences

<& display_sequence.mhtml, strands=>[$o->strands], id=>$id, add=>$add_strands, table_view=>1 &>

%# Contacts % my $cl; % if ( $o->vendor && int($cl = $o->vendor->contactlist) && $cl->contacts ){

<& /generic/contactlist.mhtml, id=>$cl->id, edit=>0, show_buttons=>0 &>
% }
%}