<?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="row">
    <div class="col-sm-8">
      <h3>Dokumente - <br>Firma <?php echo $doc->getClientCompany($_GET['id']); ?></h3>
    </div>
    <div class="col-sm-4">
      <p class="text-right"><a href="create.php?id=<?php echo $_GET['id']; ?>"><button type="button" class="btn btn-success">Neues Dokument <i class="fa fa-plus" aria-hidden="true"></i></button></a></p>
    </div>
  </div>
  
  <table class="table table-striped">
    <thead>
      <tr>
        <th>Nr</th>
        <th>Typ</th>
        <th>Dokument</th>
        <th>Datum Upload</th>
        <th></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <?php
      $replaceArray                 = array('/var/www/web22/html/dsb/_docs/', '../../_docs/', '../../_docs/');
      foreach ($rows as $row) {
        
      ?>
      <tr>
        <td><?php echo $row['id']; ?></td>
        <td><?php echo $doc->getDocType($row['doc_type']); ?></td>
        <td>
          <a href="<?php echo str_replace('/var/www/web22/html/dsb/_docs/', '../../_docs/', $row['path_to_doc']); ?>" target="_blank"><?php echo showHtmlEntities($row['description']); ?><br>
          <font size="-1"><?php echo str_replace($replaceArray, "", $row['path_to_doc']); ?></font></a>
        </td>
        <td><?php echo makeLOCALDATE($row['reg_datetime'], "DE"); ?></td>
        <td><a href="edit.php?id=<?php echo $_GET['id']; ?>&doc_uuid=<?php echo $row['uuid']; ?>"><button type="button" class="btn btn-warning"><i class="fas fa-edit"></i></button></td>
        <td><a href="delete.php?id=<?php echo $_GET['id']; ?>&doc_uuid=<?php echo $row['uuid']; ?>" onClick="return secquest(this);"><button type="button" class="btn btn-danger"><i class="fas fa-trash"></i></button></a></td>
      </tr>
      <?php
      }
      ?>
    </tbody>
  </table>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/footer.php');
?>
<script>
function secquest(Formular)
{
  if(confirm("Dokument löschen?")) {
    return true;
  } else {
    return false;
  }
}
</script>
</body>
</html>
