<& /htmlheader &>

<& modelheader &>
<h2>Linking and Orbit Determination Efficiency<br>
Field <% $fieldId %><br>
MJD <% $f->epoch %><br>
</b>
<% mopslib_mjd2localtimestr($f->epoch, $config->{site}->{gmt_offset_hours}) %>

<h3>Derivations</h3>
<table border=1 cellspacing=0 cellpadding=2 width=75%>
<tr>
<th class="darkheader"> Event ID </th>
<th class="darkheader"> Timestamp </th>
<th class="darkheader"> Derived<br>Object Name </th>
<th class="darkheader"> SSM<br>Object Name </th>
<th class="darkheader"> Current<br>Classification </th>
<th class="darkheader"> Orbit </th>
<th class="darkheader"> Resid<br>(arcsec) </th>
<th class="darkheader"> Details </th>
</tr>

% foreach $h (sort { 
%    ($a->classification cmp $b->classification) || 
%    ($a->orbitCode cmp $b->orbitCode)
% } @{$goo}) {

<tr>

% my $name;
% if ($h->derivedobjectId) {
%    my $do = modcdo_retrieve($inst, derivedobjectId => $h->derivedobjectId);
%    my $orb = modco_retrieve($inst, orbitId => $h->orbitId);
%    $name = modcs_ssmId2objectName($inst, $h->ssmId); # $h->ssmId unreliable still
    <td align="center"> <% $h->eventId %> </td>
    <td align="center"> <% $h->eventTime %> </td>
    <td align="center"> <% $do->objectName %> </td>
% if ($h->ssmId) {
    <td align="center"> <a href="ssmhist.html?ssmId=<% $h->ssmId %>"><% $name %></a> </td>
% } else {
    <td align="center"> N/A </td>
% }
    <td align="center"> <% $MOPS_EFF_DESCS{$h->classification} %> </td>
    <td align="center"> OK </td>
    <td align="center"> <% sprintf "%.3f", $orb->residual %> </td>
    <td align="center"> <a href="dohist.html?derivedobjectId=<% $do->derivedobjectId %>">History</a></td>
% } else {
%    $name = modcs_ssmId2objectName($inst, $h->ssmId);
    <td align="center"> <% $h->eventId %> </td>
    <td align="center"> <% $h->eventTime %> </td>
    <td align="center"> - </td>
    <td align="center"> <a href="ssmhist.html?ssmId=<% $h->ssmId %>"><% $name %></a> </td>
    <td align="center"> <% $MOPS_EFF_DESCS{$h->classification} %> </td>
%    if ($h->orbitId) {
%      my $orb = modco_retrieve($inst, orbitId => $h->orbitId);
    <td align="center"> Fail DIFF </td>
    <td align="center"> <% sprintf "%.3f", $orb->residual %> </td>
%    } else {
    <td align="center"> <% $h->orbitCode eq 'I' ? 'Fail IOD' : 'Unlinked' %> </td>
    <td align="center"> N/A </td>
%    }
    <td align="center"> <a href="ufdohist.html?eventId=<% $h->eventId %>">Details</a> </td>
% }
</tr>
% } # foreach
</table>

<& /htmlfooter &>

<%args>
$fieldId
</%args>

<%init>
my $h;
my $inst = $m->notes('INST');
my $config = $inst->getConfig();
use PS::MOPS::Constants qw(:all);
use PS::MOPS::Lib qw(:all);
use PS::MOPS::DC::DerivedObject;
use PS::MOPS::DC::History::Derivation;
use PS::MOPS::DC::SSM;
use PS::MOPS::DC::Orbit;
use PS::MOPS::DC::Field;
my $goo = modchd_retrieve($inst, fieldId => $fieldId);
my $f = modcf_retrieve($inst, fieldId => $fieldId);
</%init>
