<%doc>

Cable management stuff...

</%doc>

<%args>
$id             => undef
$strand_sort    => undef
$edit           => undef
$edit_list      => undef
$__edit_list    => undef
$_action        => undef
$number_strands => undef
$fiber_type     => undef
$range1         => undef
$range2         => undef
$splice_bb_end  => undef
$splice_action  => undef
$strand_range   => undef
$start_closet   => undef
$user           => $ui->get_current_user($r)
</%args>

<%attr>
title   => 'Backbone Cable' 
section => 'Plant'
</%attr>

<%init>
my $DEBUG = 0;
my %cssitem = (0 => "formtablec1", 1 => "formtablec2");
my $editBackbone = 0;
my $editStrand = 0;
my ($o, $start_site, $end_site);
my ($start_site_id, $end_site_id) = (0, 0);

if ( $id && $id ne "NEW" ) {
    $o = BackboneCable->retrieve($id);
    
    if ( $o->start_closet->room->floor && $o->start_closet->room->floor->site ){
	$start_site = $o->start_closet->room->floor->site;
    }
    if ( $o->end_closet->room->floor && $o->end_closet->room->floor->site ){
	$end_site = $o->end_closet->room->floor->site;
    }
    
    $start_site_id = $start_site->id if ($start_site);
    $end_site_id = $end_site->id if ($end_site);
}

$editBackbone = 1 if ($id eq "NEW" || $edit eq "cableinfo");
$editStrand   = 1 if ($edit eq "strandinfo");

# For table building modules:
my (@field_headers, @cell_data, @headers, @rows);
my $manager = $ui->get_permission_manager($r);
</%init>

<%perl>
print "<pre>", Dumper(%ARGS), "</pre><br>" if $DEBUG;

# code for inserting/updating
# -----------------------------------------------------------------------------
if (defined($_action) && ($_action eq "UPDATE" || $_action eq "STRAND_UPDATE")) {
    print "inserting/updating, ARGS is  <pre>", Dumper(%ARGS), "</pre><br>" if $DEBUG;

    my %update_info;
    unless ( %update_info = $ui->form_to_db(%ARGS) ) {
        $m->comp("../generic/error.mhtml", error => $ui->error);
    }

    # Ignore id changes for anything but BackboneCable.
    # (i.e., we do not care about CableStrand id update).

    if (exists $update_info{BackboneCable}{id} ) {
        $id = (keys %{$update_info{BackboneCable}{id}})[0];
    }

    print "update info is <pre>", Dumper(%update_info), "</pre><br>" if $DEBUG;
    
    # Do this to 'flush' the values associated with the object
    # before redisplaying
    $o = undef;
    if ($id && $id ne "NEW") {
        $o = BackboneCable->retrieve($id);
	if ( $o->start_closet->room->floor && $o->start_closet->room->floor->site ){
	    $start_site = $o->start_closet->room->floor->site;
	}

	if ( $o->end_closet->room->floor && $o->end_closet->room->floor->site ){
	    $end_site = $o->end_closet->room->floor->site;
	}
        $start_site_id = $start_site->id if ($start_site);
        $end_site_id = $end_site->id if ($end_site);
        
        $editBackbone = 0;
        $editStrand = 0;
    }
}

# Edit range
elsif ( defined($_action) && $_action eq "EDIT_RANGE" ){
    $m->comp("../generic/error.mhtml", error => "Strand Range not specified.") 
	if (!$strand_range);
    
    my ($start, $end) = split(/\-/o, $strand_range);
    $m->comp("../generic/error.mhtml", error => "Invalid Range: $strand_range.") 
	unless ($start && $end);
    
    my %args = (start=>$start, end=>$end);
    foreach my $key ( qw/fiber_type status/ ){
	$args{$key} = $ARGS{$key} if ( exists $ARGS{$key} && $ARGS{$key} ne "null" );
    }
    eval {
	$o->update_range(%args);
    };
    if ( my $e = $@ ){
	$m->comp("../generic/error.mhtml", error=>"$e");
    }
}

# insert N number of strands...
elsif ( defined($_action) && $_action eq "ADD_STRANDS" ){
    eval{
	$o->insert_strands($number_strands, $fiber_type);
    };
    if ( my $e = $@ ){
	$m->comp("../generic/error.mhtml", error=>"$e");
    }
}

# splice cables by a range of strands
elsif (defined($_action) && $_action eq "SPLICE_RANGE") {
    $m->comp("../generic/error.mhtml", error => "range1, range2, or backbone not specified.") 
	if (!$range1 || !$range2 || !$splice_bb_end);

    my ($start_low, $start_high) = split(/\-/o, $range1);
    my ($end_low, $end_high) = split(/\-/o, $range2);
    my $bb_end = BackboneCable->retrieve($splice_bb_end);

    if (($start_high - $start_low) != $end_high - $end_low) {
        $m->comp("../generic/error.mhtml", error => "Mismatch between ranges.");
    }

    # build up arrays of strands we care about.
    my (@start_strands, @end_strands);
    for (my $i = $start_low; $i <= $start_high; ++$i) {
        push(@start_strands, CableStrand->search(cable=>$id, number=>$i));
    }

    for (my $i = $end_low; $i <= $end_high; ++$i) {
        push(@end_strands, CableStrand->search(cable=>$bb_end->id, number=>$i));
    }

    if ( scalar(@start_strands) != scalar(@end_strands) ){
        $m->comp("../generic/error.mhtml", error => "Mismatch between start strand and end strand length.");
    }

    # first delete all splices associated with our starting strands
    foreach my $strand ( @start_strands ){
	eval {
	    $strand->delete_splices;
	};
	$m->comp("../generic/error.mhtml", error=>"$@") if $@;
    }
    
    if ( $splice_action eq 'add' ){
	# and now lets add our splices...
	for (my $i = 0, my $len = scalar(@start_strands); $i < $len; ++$i) {
	    Splice->insert({strand1=>$start_strands[$i], strand2=>$end_strands[$i]});
	}
    }
}


# special case for updating splices
# -----------------------------------------------------------------------------
if (defined($_action) && $_action eq "STRAND_UPDATE") {
    my @splices = ("__splice1_", "__splice2_");
    my @strands = ();

    # user can by either be operating on a subset of strands...
    if ($__edit_list) {
        foreach my $l (split(/,/o, $__edit_list)) {
            push(@strands, CableStrand->retrieve($l));
        }
    }
    # ...or all strands for this cable.
    else {
        @strands = $o->strands;
    }

    
    # first delete all splices for these strands
    foreach my $strand ( @strands ){
	eval {
	    $strand->delete_splices;
	};
	$m->comp("../generic/error.mhtml", error=>"$@") if ( $@ );
    }
    # then work through the post data and recreate splices as needed.
    foreach my $strand ( @strands ) {
        foreach my $sp ( @splices ) {
            next if (!defined($ARGS{$sp . $strand->id}) || $ARGS{$sp . $strand->id} eq "");
	    my $strand2 = CableStrand->retrieve($ARGS{$sp . $strand->id});
	    eval {
		Splice->insert({strand1=>$strand, strand2=>$strand2});
	    };
	    $m->comp("../generic/error.mhtml", error=>"$@") if $@;
        }
    }
}

# end insertion/update code
# -----------------------------------------------------------------------------
</%perl>

<script language="JavaScript">
<!--
/* suggestName()
 *
 * Suggests a backbone cable name. This typically takes on the format:
 * <startsite>/<endsite>-<number>
 * Not sure if there is a better way to generate this name than post off
 * to a new window.
 *
 * TODO: This should probably have better duplicate checking.
*/
function suggestName()
{
    var start = document.netdotform.BackboneCable__<% $id %>__start_closet.value;
    var end = document.netdotform.BackboneCable__<% $id %>__end_closet.value;

    if (!start || !end)
    {
        alert("Please specify both a start and end closet.");
        return;
    }

    var url = "suggest_backbonename.html?start=";
    url += start + "&end=" + end;
    url += "&name=" + "BackboneCable__<% $id %>__name";

    var wind = window.open(url, "tmp", "width=1,height=1");
    wind.blur();
}
-->
</script>

% # interface...
% # ---------------------------------------------------------------------------
<!-- Header Table -->
<div class="containeroutside">
<div class="containerheadoutside">
% if (defined($o)) {
        Start:
        <% $start_site ? "<a href=\"cable_plant.html?start_id=" . $start_site->id . "&page_type=BACKBONE\">" . $start_site->name . "</a>" 
                         : "<i>undefined</i>" %>
        &nbsp;&nbsp;
        End:
        <% $end_site ? "<a href=\"cable_plant.html?start_id=" . $end_site->id . "&page_type=BACKBONE\">" . $end_site->name . "</a>"
                         : "<i>undefined</i>" %>
%}
</div>

<!-- Begin Backbone Cable Table -->
<div class="containerbodyoutside">
  <div class="container">
    <form name="netdotform" action="cable_backbone.html" method="POST">
      <input type="hidden" name="_action" value="UPDATE">
	<div class="containerheadleft">
	  Backbone Cable
	</div>
	<div class="containerheadright">
%         if ($editBackbone) {
	    <input type="button" name="cancel_button" value="cancel" onClick="history.go(-1);" /> 
	    &nbsp;&nbsp; 
	    <input name="submit" value="save" type="submit" />
%         } else {
              <a href="cable_backbone.html?id=<% $id %>">[refresh]</a> 
%             if ( $manager && $manager->can($user, 'edit', $o) ){
	          <a href="cable_backbone.html?id=<% $id %>&edit=cableinfo">[edit]</a> 
%             }
%             if ( $manager && $manager->can($user, 'delete', $o) ){
	          <a href="delete.html?table=BackboneCable&id=<% $id %>">[delete]</a>
%             }
%         }
	</div>
	<div class="containerbody">

	  <!-- Table for two column layout -->
	  <table width="100%"  class="formtablebg">
	    <tr>
	      <!-- Left sub table -->
	      <td width="50%">
<%perl>
    (@field_headers, @cell_data) = ();
    my @fields = ('start_closet','end_closet','type');
    my %args = (o=>$o, table=>"BackboneCable", edit=>$editBackbone, fields=>\@fields, 
		       field_headers=>\@field_headers, cell_data=>\@cell_data);
    if ( my $sc = Closet->retrieve($start_closet) ){
	$args{default} = [$sc, undef, undef];
    }
    $ui->add_to_fields(%args);
</%perl>
    
		<& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data &>
              </td>

	      <!-- Right sub table -->  
	      <td width="50%">
<%perl>
    (@field_headers, @cell_data) = ();

    my %tmp = $ui->form_field(object=>$o, table=>"BackboneCable", column=>"name", edit=>$editBackbone);
    my $name_tmp = $tmp{value};
    if ($editBackbone) {                
	$name_tmp .= '&nbsp;&nbsp;&nbsp;<input type="button" name="suggest_name"'
	    . 'value="Suggest Name" onClick="suggestName();" />';
    }
    push( @field_headers, $tmp{label} );
    push( @cell_data, $name_tmp );

    $ui->add_to_fields(o=>$o, table=>"BackboneCable", edit=>$editBackbone, fields=>['owner', 'installdate', 'length'],
		       field_headers=>\@field_headers, cell_data=>\@cell_data);


    if ( $id eq 'NEW' ){
        push( @field_headers, "Number of Strands:" );
        push( @cell_data, '<input type="text" name="BackboneCable__NEW__numstrands">' );
    }

</%perl>

		<& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data &>
              </td>
	    </tr>
	  </table>

<%perl> 
{
    my %tmp;
    %tmp = $ui->form_field(object=>$o, table=>"BackboneCable", column=>"info", edit=>$editBackbone, 
			   htmlExtra=>'rows="3" cols="80"');
    print '<div class="containerseparator">'.$tmp{label}.'</div>';
    print $tmp{value};         
} 
</%perl>
	</div>
      </form>
    </div>
  </div>
<!-- End Backbone Cable Table -->


<!-- Begin Cable Strands Table -->
<%perl>
my @backbones = ();
if ($editStrand) {
    # we need to grab all backbones for start and end sites of this strand.
    foreach my $closet (($start_site->closets, $end_site->closets)) {
        map { push (@backbones, $_) } (BackboneCable->search(start_closet=>$closet),
                                       BackboneCable->search(end_closet=>$closet));
    }
}
</%perl>

% if (defined($o)) {
<script language="JavaScript">
<!--
/* Code to allow user to edit specific rows in table. Added to increase
 * usability and performance. XXX: need to test w/ IE.
*/
var editable = new Array(); // array of selected items to edit.
function editCheck(field)
{
    if (!field)
        return;

    var id = field.name.substr(field.name.indexOf("_") + 1);

    if (field.checked)
    {
        editable.push(id);
    }

    else
    {
        for (var i = 0; i < editable.length; ++i)
            if (editable[i] == id)
                editable[i] = null;
    }
}

function editSelected(id)
{
    var url = "cable_backbone.html?id=" + id + "&edit=strandinfo&edit_list=" + editable.join(",") + "#cable_strand";
    location.href = url;
    return true;
}
-->
</script>

<div class="container">
<A NAME="cable_strand"></A>
     <form name="cable_strand_form" action="cable_backbone.html" method="POST">
     <input type="hidden" name="id" value="<% $id %>">
     <input type="hidden" name="_action" value="STRAND_UPDATE">
%    if ( $editStrand && $edit_list ) {
     <input type="hidden" name="__edit_list" value="<% $edit_list %>">
%    }
% my $strand_count = scalar $o->strands;
<div class="containerheadleft">
	Cable Strands (<% $strand_count %>)
</div>
<div class="containerheadright">
%	 if ($editStrand) {	 
            <input type="button" name="cancel_st_button" value="cancel" onClick="history.go(-1);" /> 
	    &nbsp;&nbsp; 
	    <input name="submit" value="save" type="submit" />
%	 }else {
%             if ( $manager && $manager->can($user, 'access_admin_section', 'cable_backbone:new') ){
                  <a href="cable_strand.html?id=NEW&backbone_id=<% $o->id %>">[new]</a>
%             }
%             if ( $manager && $manager->can($user, 'edit', $o) ){
                  <a href="#" onClick="editSelected(<% $id %>);">[edit]</a>
%             }
%             if ( $manager && $manager->can($user, 'edit', $o) ){
                  <a href="cable_backbone.html?id=<% $id %>&edit=strandinfo#cable_strand">[edit all]</a>
%             }
           
%	 }
</div>

<div class="containerbody">
    <%perl>
    my @strands;
    if ( $edit_list ) {
        # if the user has selected specific rows, only display those selected.
        foreach my $l (split(/,/o, $edit_list)) {
            push(@strands, CableStrand->retrieve($l));
        }
    } else {
	@strands = $o->strands;
    }
    </%perl>

%   if (scalar(@strands)) {

	<!--  Set up headers -->
	<%perl>
	(@headers, @rows) = ();

	@headers = ( 
		     '<a href="cable_backbone.html?id=' . $id . '&strand_sort=name#cable_strand">Name</a>',
		     '<a href="cable_backbone.html?id=' . $id . '&strand_sort=type#cable_strand">Type</a>',
		     '<a href="cable_backbone.html?id=' . $id . '&strand_sort=status#cable_strand">Status</a>',
	             'Spliced With',
		     );

	if (!$editStrand) {        
	    push( @headers, 'Part of Sequence' );
	    push(@headers, '<a href="cable_backbone.html?id=' . $id . '&strand_sort=circuit#cable_strand">Circuit</a>');
            if ( $manager && $manager->can($user, 'edit', $o) ){
	        push( @headers, '<B>Edit?</B>' );
	    }
	}
	</%perl>

	<%perl>
	my @sorted_strands;
	if ($strand_sort eq "name" || !$strand_sort) {
	    # sort by name
	    # -----------------------------------------------------------
	    @sorted_strands = sort { (split(/\./o, $a->name, 2))[1] <=> (split(/\./o, $b->name, 2))[1] } @strands;
	} elsif ($strand_sort eq "status") {
	    # sort by status
	    # -----------------------------------------------------------
	    @sorted_strands = sort { uc($a->status->name) cmp uc($b->status->name) } @strands;
	} elsif ($strand_sort eq "type") {
	    # sort by type
	    # -----------------------------------------------------------
	    @sorted_strands = sort { uc($a->fiber_type->name) cmp uc($b->fiber_type->name) } @strands;
	} elsif ($strand_sort eq "circuit") {
	    # sort by circuit
	    # -----------------------------------------------------------
	    @sorted_strands = sort { uc($a->circuit_id->cid) cmp uc($b->circuit_id->cid) } @strands;
	}
	</%perl>

        <!--  Set up content/rows -->
	<%perl>
	foreach my $st (@sorted_strands) {
	    my @row = ();
	    push( @row, 
		  &{sub{
		      my $ac = "";
		      if ($editStrand) {
			  $ac .= '<input type="checkbox" name="' . "CableStrand__" . $st->id . "__delete" . '">[del]';
			  my %tmp = $ui->form_field(object=>$st, column=>"name", edit=>$editStrand);            
			  $ac .= $tmp{value};
		      } else {
			  $ac .= '<a href="cable_strand.html?id=' . $st->id . '">' . $st->name . '</a>';
		      }
		      $ac;
		  }} );

	    my %tmp = $ui->form_field(object=>$st, column=>"fiber_type", edit=>$editStrand);
	    push( @row, $tmp{value} );

	    %tmp = $ui->form_field(object=>$st, column=>"status", edit=>$editStrand);
	    push( @row, $tmp{value} );

	    push( @row, 
		  &{sub{
		      my $ac = "";
		      if (!$editStrand) {
			  my %seen;
			  my @spliced_with;
			  foreach my $splice ( $st->splices ){
			      my @strands = ($splice->strand1, $splice->strand2);
			      foreach my $sstrand ( @strands ){
				  if ( ($sstrand->id == $st->id) || $seen{$sstrand->id} ){
				      next;
				  }
				  $seen{$sstrand->id} = 1;
				  push @spliced_with, '<a href="cable_strand.html?id=' . $sstrand->id . '">'
				      . $sstrand->name . '</a>';
			      }
			  }
			  $ac = join ", ", @spliced_with;
		      } else {
			  $ac .= <<'HERE';
			  <script language="JavaScript">
			  <!--
			  function lookupStrands(bb_id, field_name, form_name)
			  {
			      if (!bb_id)
			      {
				  alert("You must select a backbone.");
			      }
			      var url = "strand_backbone_list_query.html?bb_id=";
			      url += bb_id + "&field_name=" + field_name;
			      url += "&form_name=" + form_name;
			      var wind = window.open(url, "tmp", "width=1,height=1");
			      wind.blur();
			  }
			  -->
			  </script>
HERE
                          $ac .= '<SELECT NAME="backbone_list_srch1_' 
			  . $st->id . '" onChange="lookupStrands(this.value, \'__splice1_' 
			  . $st->id . '\', \'cable_strand_form\');">';
			  $ac .= '<OPTION VALUE="">Lookup by Backbone</OPTION>';

			  my @splices = $st->splices;
			  my %stored = ();
			  foreach my $bb (sort { $a->name cmp $b->name } @backbones)
			  {
			      next if ($bb->id == int($st->cable) || exists($stored{$bb}));
			      $stored{$bb} = 1;
			      $ac .= sprintf("<OPTION VALUE=\"%s\">%s</OPTION>\n", $bb->id, $bb->name);
			  }

			  $ac .= '</SELECT> &nbsp; ';
			  $ac .= '<select name="__splice1_' . $st->id . '">';
			  $ac .= '<option value="">-- Make your selection --</option>';
			  if (scalar(@splices)) {
			      $ac .= '<option value="' . $splices[0]->strand2->id . '" SELECTED>' 
				  . $splices[0]->strand2->name . '</option>';
			  }
			  $ac .= '<option value="">[null]</option>';
			  $ac .= '</select>';
			  $ac .= '<br>';

			  $ac .= '<SELECT NAME="backbone_list_srch2_' . $st->id 
			      . '" onChange="lookupStrands(this.value, \'__splice2_' . $st->id 
			      . '\', \'cable_strand_form\');">';
			  $ac .= '<OPTION VALUE="">Lookup by Backbone</OPTION>';


			  %stored = ();
			  foreach my $bb (sort { $a->name cmp $b->name } @backbones)
			  {
			      next if ($bb->id == int($st->cable) || exists($stored{$bb}));
			      $stored{$bb} = 1;
			      $ac .= sprintf("<OPTION VALUE=\"%s\">%s</OPTION>\n", $bb->id, $bb->name);
			  }

			  $ac .= '</SELECT> &nbsp; ';
			  $ac .= '<select name="__splice2_' . $st->id . '">';
			  $ac .= '<option value="">-- Make your selection --</option>';
			  if (scalar(@splices) == 2) {
			      $ac .= '<option value="' . $splices[1]->strand2->id . '" SELECTED>' 
				  . $splices[1]->strand2->name . '</option>';
			  }
			  $ac .= '<option value="">[null]</option>';
			  $ac .= '</select>';
		      }
		      $ac;
		  }} );

	    if (!$editStrand) {        
		push( @row, $m->scomp('display_sequence.mhtml', strands=>[$st]) );

		%tmp = $ui->form_field(object=>$st, column=>"circuit_id", edit=>0, linkPage=>"circuit.html");
		push( @row, $tmp{value} );
		
		if ( $manager && $manager->can($user, 'edit', $o) ){
		    push( @row, '<input type="checkbox" name="edit_' . $st->id . '" onChange="editCheck(this);">' );
		}
	    }
	    push( @rows, \@row );
	} # foreach
	</%perl>

%       # Print the Cable Strands table
	<& /generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows &>

%   }	# if scalar strands

    </form>
</div>	<!-- containerbody -->
</div>  <!-- container -->
<!-- End Cable Strands Table -->

% if ( $manager && $manager->can($user, 'edit', $o) ){

<!-- Edit Strand Range  -->
%  if ($edit ne "strandinfo") {
  <div class="container">
    
    <div class="containerhead">
       Edit Strand Range
    </div>

    <div class="containerbody">
      <form action="cable_backbone.html" method="POST">
	<input type="hidden" name="id" value="<% $id %>" />
	<input type="hidden" name="_action" value="EDIT_RANGE" />
	Range (i.e. 1-12)&nbsp; <input type="text" name="strand_range" value="" size="5" />
      Type:
	<select name="fiber_type">
	  <option value="null" selected>Select Type</option>
	  <option value="1">Multimode</option>
	  <option value="2">Singlemode</option>
        </select>
      Status:
	<select name="status">
        <option value="null" selected>Select Status</option>
%       foreach my $st ( StrandStatus->retrieve_all() ){
            <option value="<% $st %>"><% $st->name %></option>
%       }
        </select>
	&nbsp;<input type="submit" name="edit_range" value="Save" />&nbsp;
      </form>
    </div>
  </div>

%  }
% }

% if ( $manager && $manager->can($user, 'edit', $o) ){
<!-- Manually Add Strands  -->
%  if ($edit ne "strandinfo") {
  <div class="container">
    
    <div class="containerhead">
      Manually Add Strands
    </div>

    <div class="containerbody">
      <form action="cable_backbone.html" method="POST">
	<input type="hidden" name="id" value="<% $id %>" />
	<input type="hidden" name="_action" value="ADD_STRANDS" />
	Add <input type="text" name="number_strands" value="0" size="3" /> strands of type 
	<select name="fiber_type">
	  <option value="1">Multimode</option>
	  <option value="2">Singlemode</option>
        </select>
	&nbsp;<input type="submit" name="strand_add" value="Go" />&nbsp;
      </form>
    </div>
  </div>

  <!-- Manually Add Splice Range -->
  <%perl>
  my @bbones;
  foreach my $closet (($start_site->closets, $end_site->closets)) {
      map { push (@bbones, $_) if ($_->id != $id && $_->strands) } 
      (BackboneCable->search(start_closet=>$closet),
       BackboneCable->search(end_closet=>$closet));
  }
  </%perl>
% if ( $o->strands && @bbones ){
  <div class="container">
    <div class="containerhead">
      Splice/Unsplice Strand Range
    </div>
    
    <div class="containerbody">
      <form action="cable_backbone.html" method="POST">
	<input type="hidden" name="id" value="<% $id %>" />
	<input type="hidden" name="_action" value="SPLICE_RANGE" />
	<SELECT NAME="splice_action">
	  <OPTION VALUE="add">Splice</OPTION>
	  <OPTION VALUE="delete">Unsplice</OPTION>
	</SELECT>
	Strands (i.e. 1-12)
	<input type="text" name="range1" value="" size="4">&nbsp;from this backbone, and strands &nbsp;
	<input type="text" name="range2" value="" size="4">&nbsp;from 
	<SELECT NAME="splice_bb_end">
	  <OPTION VALUE="">Backbone...</OPTION>
	  <%perl>
	  my %stored = ();
          foreach my $bb (sort { $a->name cmp $b->name } @bbones) {
	      next if ( exists($stored{$bb}) );
	      $stored{$bb} = 1;
	      printf("<OPTION VALUE=\"%s\">%s, %s</OPTION>\n", $bb->id, $bb->name, $bb->end_closet->get_label());
	  }
	  </%perl>
	</SELECT>
	&nbsp;<input type="submit" name="splice_update" value="Go">
      </form>
    </div>
  </div>
%   }
%  }	# if edit ne strandinfo
% }     # if manager
%}	# if defined (about 300 lines up !)
</div>  <!-- containerheadoutside -->
</div>  <!-- containeroutside -->
<!-- End Header Table  (starts about line 200 !)-->
