<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/header.php');
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . '/Auth/nav.php');
?>

<div class="container">
  <div class="card bg-light mb-3">
    <div class="card-header">
      <div class="row">
        <div class="col-sm-12">
          <h2 class="text-center">TOM - <?php echo $tom->getClientCompany($_GET['id']); ?></h2>
        </div>
      </div>
      <div class="row">
        <div class="form-group col-sm-1">
        </div>
        <div class="form-group col-sm-11">
          <div class="fortschritt_rahmen">
            <p style="float:left"><?php echo $amountQuests; ?></p>
            <p style="float:right"><?php echo $amountUncompletedQuestions; ?></p>
            <p><?php echo $completedPercent; ?>%</p>
            <span style="width:<?php echo $completedPercent; ?>%"></span>
          </div>
        </div>
      </div>
      <form name="jump" action="<?php echo$_SERVER['PHP_SELF']; ?>" method="get">
      <div class="row">
        <div class="form-group col-sm-1">
          <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
        </div>
        <div class="form-group col-sm-7">
          <select name="frage_id" id="frage_id" class="form-control" onchange="jump.submit()" required>
            <option value="">Bitte auswählen</option>
            <?php
            foreach ($rowsDropdownThemenblock as $rowDD) {
              echo '<option value="' . $rowDD["Tom_frage_id"] . '">' . showHtmlEntities($rowDD["TB_Name"].' - FrageID '.$rowDD["Tom_frage_id"]) . '</option>';
            }
            ?>
          </select>
        </div>
        <div class="form-group col-sm-4">
          <p class="text-right">
            <a href="print-l.php?id=<?php echo $_GET['id']; ?>" target="_blank"><button type="button" class="btn btn-info">Bericht QF <i class="far fa-file-pdf fa-rotate-90"></i></button></a>
            <a href="print.php?id=<?php echo $_GET['id']; ?>" target="_blank"><button type="button" class="btn btn-info">Bericht HF<i class="far fa-file-pdf"></i></button></a>
          </p>
        </div>
      </div>
      </form>
    </div>
    <form name="edit" action="<?php echo$_SERVER['PHP_SELF']; ?>" method="post">
    <div class="card-body">
      <div class="row">
        <div class="col-sm-12">
          <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
          <input type="hidden" name="kunden_id" value="<?php echo $_GET['id'] ;?>">
          <input type="hidden" name="frage_id" value="<?php echo $_GET['frage_id']; ?>">
          <input type="hidden" name="site" value="<?php echo$_SERVER['PHP_SELF']; ?>?id=<?php echo $_GET['id']; ?>&frage_id=<?php echo $_GET['frage_id']; ?>">
          <input type="hidden" name="themenblock_id" value="<?php echo $row['themenblock_id']; ?>">
          <h3 style="background: <?php echo $tom->getStatusColor($row['status']); ?>">
            &nbsp; 
            <font color="<?php echo $tom->getStatusTextColor($row['status']); ?>">Frage ID: <?php echo $row['frage_id']; ?> | Themenblock: <?php echo showHtmlEntities($tom->getThemenblockName($row['themenblock_id'])); ?> Frage Nr: <?php echo $row['themenfrage_id']; ?></font>
          </h3>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-8 form-group">
          &nbsp;
          <p><span class="badge badge-secondary" style="font-size:20px;"><?php echo $_GET['frage_id']; ?></span>
            <?php
            if ($previousQuestShow    == "") {
              echo '';
            } else {
            ?>
            <a href="edit.php?id=<?php echo $_GET['id']; ?>&frage_id=<?php echo $previousQuestShow; ?>&tom=TOM"><button type="button" class="btn btn-success">Zurück</button></a>
            <?php
            }
            ?>
            <a href="edit.php?id=<?php echo $_GET['id']; ?>&frage_id=<?php echo $nextQuestShow; ?>&tom=TOM"><button type="button" class="btn btn-success">Weiter</button></a>
          </p>
        </div>
        <div class="col-sm-4 form-group">
          &nbsp;
          <p class="text-right"><a href="delete.php?id=<?php echo $_GET['id']; ?>&tom_id=<?php echo $row['id']; ?>" onClick="return secquest(this);"><button type="button" class="btn btn-danger"><i class="fas fa-trash"></i></button></a></p>
        </div>
      </div>
      <p>&nbsp;</p>
      <div class="row">
        <div class="col-sm-12 form-group">
          <label for="frage">Frage/ Maßnahme:</label>
          <textarea name="frage" id="frage" class="form-control" rows="5"><?php echo showHtmlEntities($row['frage']); ?></textarea>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-12 form-group">
          <label for="bemerkung_begruendung">Bemerkung Begründung:</label>
          <textarea name="bemerkung_begruendung" id="bemerkung_begruendung" class="form-control" rows="5"><?php echo showHtmlEntities($row['bemerkung_begruendung']); ?></textarea>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-12 form-group">
          <label for="empfehlung">Frage/ Maßnahme:</label>
          <textarea name="empfehlung" id="empfehlung" class="form-control" rows="5"><?php echo showHtmlEntities($row['empfehlung']); ?></textarea>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-4 form-group">
          <label for="status">Status</label>
          <select name="status" id="status" class="form-control" required>
            <?php
            foreach ($rowsDropdownStatus as $key => $value) {
              echo '<option value="' . $value . '"';
              if ($row['status']                 == $value) {
                echo ' selected';
              }
              echo '>' . $value . ' - ' . $key . '</option>';
            }
            ?>
          </select>
        </div>
        <div class="col-sm-8 form-group">
          <p>&nbsp;</p>
          <p class="text-right"><input type="submit" name="submit_tom" class="btn btn-warning" value="Änderungen der Frage <?php echo $_GET['frage_id']; ?> speichern"></p>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-12 form-group">
          &nbsp;
          <span class="badge badge-secondary" style="font-size:20px;"><?php echo $_GET['frage_id']; ?></span>
          <?php
            if ($previousQuestShow    == "") {
              echo '';
            } else {
            ?>
            <a href="edit.php?id=<?php echo $_GET['id']; ?>&frage_id=<?php echo $previousQuestShow; ?>&tom=TOM"><button type="button" class="btn btn-success">Zurück</button></a>
            <?php
            }
          ?>
          <a href="edit.php?id=<?php echo $_GET['id']; ?>&frage_id=<?php echo $nextQuestShow; ?>&tom=TOM"><button type="button" class="btn btn-success">Weiter</button></a>
        </div>
      </div>
    </div>
    </form>
  </div>
</div>

<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/footer.php');
?>
<script>
function secquest(Formular)
{
  if(confirm("Vorlage löschen?")) {
    return true;
  } else {
    return false;
  }
}
</script>
</body>
</html>
