<%doc>

Cable management stuff...

</%doc>
%
%
<%args>
$id               => undef;
$start_id         => undef;
$end_id           => undef;
$cable_sort       => undef;
$edit             => undef;
$page_type        => undef;
$submit_site      => undef;
$backbone_srch    => undef;
$backbone_id_srch => undef;
$site_srch        => undef;
</%args>
%
%
<%flags>

</%flags>
%
%
<%attr>
title   => 'Cable Plant' 
section => 'Plant'
</%attr>
%
%
<%init>
my $DEBUG         = 0;
my $MAX_SELECTION = 500;
my %cssitem       = (0 => "formtablec1", 1 => "formtablec2");
my $o             = undef;
my $name;

$end_id   = 0 if ($end_id == -1);
$start_id = 0 if ($start_id == -1);

if ($id) {
   $o = Site->retrieve($id);
   $name = $o->name;
} else {
   $name = "Search";
}

$backbone_srch = "%" . $backbone_srch . "%" if ($backbone_srch);
$site_srch = "%" . $site_srch . "%" if ($site_srch);

# For table building modules:
my (@field_headers, @cell_data, @headers, @rows);
</%init>

<div id="sectiondetail">

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

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

    if (!$ui->form_to_db(%ARGS)) {
        $m->comp("error.mhtml", $ui->error());
	}
    
    # Do this to 'flush' the values associated with the object
    # before redisplaying
    $o = undef;
    if ($id) {
        $o = Site->retrieve($id);
        $name = $o->name;
    }
}  
# end insertion/update code
# -----------------------------------------------------------------------------
</%perl>     

%if ($o) {
  <div class="containeroutside">
    <div class="containerheadleftoutside">
      <% ucfirst(lc($page_type)) %> for Site: <a href="view.html?table=Site&id=<% $id %>"><% $o->name %></a>&nbsp;&nbsp; 
    </div>
    <div class="containerheadrightoutside">
      <a href="cable_plant.html?id=<% $id %>&page_type=<% $page_type %>&cable_sort=<% $cable_sort %>">[refresh]</a>
    </div>
    <div class="containerbodyoutside">
%}

%     if ($edit) {
        <form name="netdotform" action="cable_plant.html" method="POST">
	  <input type="hidden" name="id" value="<% $id %>">
	  <input type="hidden" name="start_id" value="<% $start_id %>">
	  <input type="hidden" name="end_id" value="<% $end_id %>">
	  <input type="hidden" name="backbone_srch" value="<% $backbone_srch %>">
	  <input type="hidden" name="backbone_id_srch" value="<% $backbone_id_srch %>">
	  <input type="hidden" name="circuit_srch" value="<% $ARGS{circuit_srch} %>">
	  <input type="hidden" name="site_srch" value="<% $site_srch %>">
	  <input type="hidden" name="page_type" value="<% $page_type %>">
	  <input type="hidden" name="_action" value="<% $id ? "UPDATE" : "NEW" %>">
%     }

%     if (uc($page_type) eq "HORIZONTAL") {
%       $m->abort() if (!defined($o));

        <& cable_plant_horizontal.mhtml, o => $o, id => $id, MAX_SELECTION => $MAX_SELECTION, 
               page_type => $page_type, cable_sort => $cable_sort, edit => $edit &>

%     } elsif (uc($page_type) eq "BACKBONE") {

        <& cable_plant_backbone.mhtml, o => $o, MAX_SELECTION => $MAX_SELECTION, start_id => $start_id,
               end_id => $end_id, page_type => $page_type, submit_site => $submit_site,
               backbone_srch => $backbone_srch, backbone_id_srch => $backbone_id_srch,
               edit => $edit, site_srch => $site_srch, cable_sort => $cable_sort &>

%     } elsif (uc($page_type) eq "CLOSETS") {
%       $m->abort() if (!defined($o) && !exists($ARGS{closet_srch}));

        <& cable_plant_closet.mhtml, o => $o, MAX_SELECTION => $MAX_SELECTION, closet_srch => $ARGS{closet_srch},
               edit => $edit, id => $id, page_type => $page_type, cable_sort => $cable_sort &>

%     } elsif (uc($page_type) eq "STRANDS") {
%       $m->abort() if (!defined($backbone_id_srch));

        <& cable_plant_strand.mhtml, o => $o, id => $id, MAX_SELECTION => $MAX_SELECTION, 
			   page_type => $page_type, backbone_id_srch => $backbone_id_srch,
               edit => $edit, cable_sort => $cable_sort &>

%     } else {
%       $m->comp("/generic/error.mhtml", error => "Unknown page type \"$page_type\"");
%     }

%     if ($edit) {	 
        </form>
%     }

%     if ($o) {
    </div> <!-- close containerbodyoutside -->
  </div> <!-- close containerbody -->
%     }

</div> <!-- close sectiondetail -->
