<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/header.php');
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . '/Auth/nav.php');
?>
<form name="create" action="<?php echo$_SERVER['PHP_SELF']; ?>" method="POST">
<div class="container">
  <div class="card border-primary mb-3">
    <div class="card-header">
      <h1>Neue TOM - Textvorlage</h1>
      <input type="hidden" name="site" value="<?php echo $site; ?>">
    </div>
    <div class="card-body">
      <div class="row">
        <div class="form-group col-sm-2">
          <label for="themenblock_id">Themenblock</label>
        </div>
        <div class="form-group col-sm-7">
          <select name="themenblock_id" id="themenblock_id" class="form-control" required onChange="getUsedId()">
            <option value="">Bitte auswählen</option>
            <?php
            foreach ($rowsDropdownThemenblock as $rowDD) {
              echo '<option value="' . $rowDD["themenblock_id"] . '">' . showHtmlEntities($rowDD["themenblock"]) . '</option>';
            }
            ?>
          </select>
        </div>
        
      </div>
      <div class="row">
        <div class="form-group col-sm-2">
          <label for="themenfrage_id">Themenfrage ID</label>
        </div>
        <div class="form-group col-sm-7">
          <input type="text" name="themenfrage_id" id="themenfrage_id" class="form-control" required>
        </div>
        <div class="form-group col-sm-3">
          <div id="output_id"></div>
        </div>
      </div>
      <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"></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"></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"></textarea>
        </div>
      </div>
    </div>
  </div>
  <?php 
    include ($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/forms/footer.create.php');
  ?>
</div>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/footer.php');
?>
<script>

function getUsedId() {
  var themenblock_id = document.create.themenblock_id.value;
  
  $("#output_id").load("get-used-id.php?id=" + themenblock_id);
}
</script>
</body>
</html>

