<html>
<head>
  <!--
  results.result value lookup table
  results.result |   old UI        | new UI
            0    | submitted       | pending
            1    | running         | running
            2    | failed          | suspended
            3    | compliant       | completed
            4    | critical issue  | abandoned
            5    | mild issue      | unused
            6    | imprvmnt chance | unused
            7    | cancel          | cancel
            8    | cancelled       | cancelled
            9    | error           | error
            >10  | % done          | % done
  -->
  <meta http-equiv="refresh" content="30">
  <link rel="stylesheet" type="text/css" href="CSS/styles.css">
  <style>
    .zebra tr:nth-child(even){background:#EDEDED};
  </style>
  <script>
    function echoprid(i){
      alert('saved to portal with id = '+i);
    }
    function showres(str){
      var el = document.getElementsByClassName('reports');
      for (var i=0;i<el.length; i++){el[i].style.display = "none";}
      document.getElementById(str).style.display = "block";
    }
    function save_to_portal(){
      alert("results saved to portal");
    }
  </script>
</head>
<body style="background-color:white;">
<!-- ######## -->
<!--  HEADER  -->
<!-- ######## -->
<?php include "Pages/header.php"; ?>
<?php
  $rid = array(); $result = array(); $pname = array(); $pid = array(); $ename = array(); $mname = array();
  $resB = mysqli_query($con,"	SELECT results.id,results.result,results.name,results.preset,estates.name,models.name
							  FROM results
								INNER JOIN models  ON results.model = models.id
								INNER JOIN estates ON models.estate = estates.id
								WHERE estates.owners LIKE '%,{$user_id},%'
								ORDER BY results.id;");
  while($rowB = mysqli_fetch_array($resB)){
    array_push($rid,$rowB[0]);
    array_push($result,$rowB[1]);
    array_push($pname,$rowB[2]);
    array_push($pid,$rowB[3]);
    array_push($ename,$rowB[4]);
    array_push($mname,$rowB[5]);
  }
?>

<!-- ########### -->
<!--  MAIN PAGE  -->
<!-- ########### -->
<div id="col-container">
  <div id="left-bigcol">
    <table class="zebra" width="100%">

      <tr class="Xlarge-text grey-text"> <td>Job ID</td> <td>Requests</td> <td>Status</td> <td>Actions</td></tr>
      <tr></tr>
      <tr> <td><hr></td> <td><hr></td> <td><hr></td> <td><hr></td> </tr>
      <?php
        $i = 0;
        foreach($rid as $r){
          $str1 = "error";
          $str2 = "error";
          $str3 = "";
          $str1 = get_res_string1($result[$i]);
          $str2 = get_res_string2($con,$result[$i],$r);
		      echo("
          <tr class='grey-text large-text' onclick='showres(\"report{$i}\")'>
            <td>{$rid[$i]}:</td>
            <td>{$ename[$i]}: {$mname[$i]}: <a href='Pages/viewModelInputs.php?rid={$rid[$i]}' class='grey-text'>{$pname[$i]}</a>");
            if ($result[$i]=='0') {              
              $str3 = get_res_string3($con,$result[$i],$r);
              echo ": {$str3}";}
            echo("</td>
            <td>{$str1}</td>
            <td>{$str2}</td>
          </tr>");
          $i++;
        }
      ?>
    </table>
  </div>
</div>
<?php mysqli_close($con);?>

<!-- ######## -->
<!--  FOOTER  -->
<!-- ######## -->
<?php footer:?>
<div id="footer">
  <hr>
  <?php include "Pages/footer.php";?>
</div>
</body>
</html>






<!--  -->
