<!DOCTYPE html>
<html>
  <head>
    <?php
    include './page-blocks/headers.php';
    include_once './php/version.php';
    ?>
    <title>Athena - Report Issue</title>
  </head>

  <body>

   <?php

   // Imports the functions needed to validate and submit data
   require './php/submitIssue.php';

   // Set initial values
   $title = $detail = "";
   $ua_str = $_SERVER["HTTP_USER_AGENT"];

   // If the page has been POSTed to then run this:
   if ($_SERVER["REQUEST_METHOD"] == "POST" ) {
     $title = cleanInput($_POST["subject"]);
     $detail = cleanInput($_POST["detail"]);

     // Prepare $detail to POST
     $body = "Athena Version: " . $athenaVersion . "\n\n" . "User Agent: " . $ua_str . "\n\n Server PHP Version: " . PHP_VERSION . "\n\nUser Comments:\n" . $detail;

     // Call POST function
     sendInput($title,$body);

     // Redirect to submit-done.php
     echo "<script>setTimeout(function(){window.location.href = '/submit-done.php';}, 10);</script>";
   };
   ?>

    <!-- Popup Menu -->
    <?php require "./page-blocks/nav-menu.php";?>

    <!-- Main Content Begins -->
    <?php require "./page-blocks/title-image.php";?>

    <h1>Please help us fix your issue</h1>

      <p>Give as much detail as possible so we can try to fix the problem.</p>

      <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
        <span class="form-info">Subject:</span>
        <br>
        <input class="form-text-small" type="text" name="subject" placeholder="Subject" value="<?php echo $title;?>">
        <br>
        <br>
        <span class="form-info">Details:</span>
        <br>
        <textarea class="form-text-large" placeholder="Please give as much detail here as possible" name="detail"><?php echo $detail;?></textarea>
        <br>
        <br>
        <input class="actionbutton" type="submit">
        <br>
        <div class="text-description">
          <p>
            On submission of this form, your browsers User Agent string will be
            collected alongside the information you provide above and will be
            posted to the <a class="inlinelink" href="https://git.fjla.uk/fred.boniface/athena.fb-infra.uk/issues?q=&state=open">
            issue tracker</a>.
          </p>
          <br>
          <br>
          <span class="form-info">
            Your user agent is:
          </span>
          <br>
          <?php echo $ua_str; ?>
        </div>
      </form>


    <!-- Footer -->
      <?php include "./page-blocks/footer.php" ?>
  </body>

</html>
