<!DOCTYPE html>
<html lang="en">
  <head>
    <title>TESTING</title>
  </head>
  <body>
    <?php
      require './php/openLDBSVWS.php';
      require './php/submitIssue.php';
      require '/srv/php-keys/athena/gitea.php';

      echo cleanInput($_SERVER['QUERY_STRING']);

      date_default_timezone_set("Europe/London");
      $OpenLDBSVWS = new OpenLDBSVWS($ldbKey);
      $response = $OpenLDBSVWS->GetDepartureBoardByCRS(10,"BRI",date("H:i:s",time()),120,"","","","","True");
      $template["header"] = "
        <table>
          <thead>
            <tr>
              <th>ID</th>
              <th>Org.</th>
              <th>Dest.</th>
              <th>Plat.</th>
              <th>Sch</th>
              <th>Exp</th>
            </tr>
          </thead>
          <tbody>
        ";
      $template["row"] = "
            <tr>
              <td>{id}</td>
              <td>{org}</td>
              <td>{dest}</td>
              <td>{plat}</td>
              <td>{sch}</td>
              <td>{act}</td>
            </tr>
      ";
      $template["footer"] = "
          </tbody>
        </table>
      ";
      if (isset($response->GetBoardResult->trainServices->service))
      {
        print $template["header"];
        foreach($response->GetBoardResult->trainServices->service as $service)
        {
          $row = $template["row"];
          $destinations = array();

          $row = str_replace("{id}",$service->trainid,$row);
          $row = str_replace("{org}",$service->origin->location->tiploc,$row);
          $row = str_replace("{dest}",$service->destination->location->tiploc,$row);
          $row = str_replace("{plat}",$service->platform,$row);
          $row = str_replace("{sch}",$servoce->std,$row);
          $row = str_replace("{act}",$service->etd,$row);
          print $row;
        }
        print $template["footer"];
      }
    ?>
  </body>
</html>