<?php

function sensors($sensor_row)
{
   $return_string = '';

   for($i = 6; $i <= (count($sensor_row) / 2) - 1; $i++) // Dividing count by two as returning both the column name and its index
   {
      if($sensor_row[$i] != null) {
         list($sensor, $status) = explode('|', $sensor_row[$i]);


         if($status == 'blocked') {
            $return_string .= '<b>' . $sensor . '</b> ';
         } else {
            $return_string .= $sensor . ' ';
         }
      }
   }


   return trim($return_string);
}

?>
<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>Flight Processing Status/Order</title>
   <link rel="stylesheet" type="text/css" href="../style/default.css"/>
   <link rel="stylesheet" type="text/css" href="../style/order.css"/>
</head>
<body>

<div id="arsf_header">
   <a href="/">
      <img src="../images/banner.jpg">
   </a>
</div>
<div id="nerclogo">
   <a href="http://www.nerc.ac.uk/">
      <img src="/images/nerc_logo.png" width="86" height="60" border="0" alt="NERC Homepage" title="NERC Homepage">
   </a>
</div>
<div id="content">
   <h1>Processing Order</h1>

   <p>This page gives the provisional order in which ARSF-DAN will process the data for each project (2009 data onwards). As standard we choose the order in which to process data first by project alpha grading and second by date flown, but we may make exceptions to this - names in italics have been moved from where they would be in the standard order. Please note that this order is subject to change without notice. If your project is not on this page, or it is but not all the sensors you expect are listed, then it is probably being processed, see the relevant project ticket for more information. If we are processing several flight days from the same project code close together in time then we may wait until processing for all flight days has been completed before dispatching data - please contact us if you would like us not to do this. </p>

   <p>Sensors in <em>italic</em> have had their priorities increased, and sensors in
      <b>bold</b> have had their progress blocked for some reason. Please check the
      <a href="../progress/progress.php">progress page</a> for more details on blocked sensors.

   <h2>Primary sensors</h2>

   <p>This list is for sensors specifically requested in the ARSF application (i.e. required for the science case). If a sensor was not requested but was flown anyway, it will still be processed after all primary sensors have been processed.</p>

   <table>
      <thead>
      <tr>
         <td>
            Project code
         </td>
         <td>
            Flight day/year
         </td>
         <td>
            Site name
         </td>
         <td>
            Sensors
         </td>
         <td>
            Priority
         </td>
         <td>
            Ticket
         </td>
      </tr>
      </thead>
      <tbody>
      <?php
      $rowString = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href='http://arsf-dan.nerc.ac.uk/trac/ticket/%s'>%s</a></td></tr>";
      foreach($order_page_data['primary'] as $ps) {
         echo sprintf($rowString, $ps['project_code'], $ps['flight_date'], $ps['area'], sensors($ps), $ps['priority'], $ps['primary_ticket'], $ps['primary_ticket']);
      }
      ?>
      </tbody>
   </table>

   <hr>
   <h2>Secondary sensors</h2>
   <table>
      <thead>
      <tr>
         <td>
            Project code
         </td>
         <td>
            Flight day/year
         </td>
         <td>
            Site name
         </td>
         <td>
            Sensors
         </td>
         <td>
            Priority
         </td>
         <td>
            Ticket
         </td>
      </tr>
      </thead>
      <tbody>
      <?php
      $rowString = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href='http://arsf-dan.nerc.ac.uk/trac/ticket/%s'>%s</a></td></tr>";
      foreach($order_page_data['secondary'] as $ps) {
         echo sprintf($rowString, $ps['project_code'], $ps['flight_date'], $ps['area'], sensors($ps), $ps['priority'], $ps['primary_ticket'], $ps['primary_ticket']);
      }
      ?>
      </tbody>
   </table>

   <p>This list is for sensors flown but not specifically requested in the ARSF application (i.e. not required for the science case). If a sensor was not requested but was flown anyway, it will still be processed after all primary sensors have been processed.</p>

   <hr>
   <h2>Delivery checking</h2>

   <p>This list shows projects for which processing has been completed and they are awaiting final QC checking prior to delivery to the PI. When the project is removed from this list it is being checked and should be ready for dispatch shortly, unless problems are found during final QC. Note that because some sensors are processed separately for each flight, the fact that a project is on this list means only that at least one category of sensor has completed processing, not necessarily all that were flown.</p>
   <table>
      <thead>
      <tr>
         <td>
            Project code
         </td>
         <td>
            Flight day/year
         </td>
         <td>
            Site name
         </td>
         <td>
            Sensors
         </td>
         <td>
            Priority
         </td>
         <td>
            Ticket
         </td>
      </tr>
      </thead>
      <tbody>
      <?php
      $rowString = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href='http://arsf-dan.nerc.ac.uk/trac/ticket/%s'>%s</a></td></tr>";
      foreach($order_page_data['delivery'] as $ps) {
         echo sprintf($rowString, $ps['project_code'], $ps['flight_date'], $ps['area'], sensors($ps), $ps['priority'], $ps['primary_ticket'], $ps['primary_ticket']);
      }
      ?>
      </tbody>
   </table>
   <hr/>
</div>
</body>
</html>

