<?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">
      <?php
      include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/headline.php');
      ?>
    </div>

    <div class="card-body">
      <table width="100%">
        <thead>
          <tr>
            <th height="40" width="50">Nr.</th>
            <th>Benutzername</th>
            <th>Vorname</th>
            <th>Nachname</th>
            <th>Rolle</th>
            <th></th>
            <th></th>
            <th></th>
          </tr>
        </thead>

        <tbody>
        <?php
        $counter                = 1;
        foreach ($rows as $row) {
          if($tdColor                             == constant("TD_FIRST_COLOR")) {
            $tdColor                              = constant("TD_SECOND_COLOR");
          } else {
            $tdColor                              = constant("TD_FIRST_COLOR");
          }
        ?>
          <tr bgcolor="<?php echo $tdColor; ?>">
            <td height="40"><span class="badge"><?php echo $counter; ?></span></td>
            
            <td><?php echo showHtmlEntities($row['username']); ?></td>
            <td><?php echo showHtmlEntities($row['first_name']); ?></td>
            <td><?php echo showHtmlEntities($row['last_name']); ?></td>
            <td><?php echo $user->getUserRoleName($row['role']); ?></td>

            <td width="40">
              <a href="change-pw.php?id=<?php echo $row['uuid']; ?>">
                <strong><font color="#2E64FE" size="+1">
                  <span class="fas fa-key" data-toggle="tooltip" data-placement="left" title="Passwort ändern">&nbsp;</span>
                </font></strong>
              </a>
            </td>

            <td width="40">
              <a href="edit.php?id=<?php echo $row['uuid']; ?>">
                <strong><font color="#F2AE43" size="+1">
                  <span class="fas fa-user-edit" data-toggle="tooltip" data-placement="left" title="Benutzerdaten ändern">&nbsp;</span>
                </font></strong>
              </a>
            </td>


            <?php
            if ($_GET['status']         == 0) {
            ?>
            <td width="40">
              <a href="change-status.php?id=<?php echo $row['uuid']; ?>&status=<?php echo $_GET['status']; ?>">
                <strong><font color="#FF0000" size="+1">
                  <span class="fas fa-lock" data-toggle="tooltip" data-placement="left" title="Benutzer <?php echo showHtmlEntities($row['username']); ?> sperren">&nbsp;</span>
                </font></strong>
              </a>
            </td>
            <?php
            } else {
            ?>
            <td width="40">
              <a href="change-status.php?id=<?php echo $row['uuid']; ?>&status=<?php echo $_GET['status']; ?>">
                <strong><font color="#088A29" size="+1">
                  <i class="fas fa-unlock" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Benutzer <?php echo showHtmlEntities($row['username']); ?> aktivieren">&nbsp;</i>
                </font></strong>
              </a>
            </td>
            <?php
            }
            ?>
          </tr>
        <?php
          $counter++;
        }
        ?>
      </table>
    </div>
  </div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
include($_SERVER['DOCUMENT_ROOT'] . HOME_DIR . TEMPLATE_DIR . '/footer.php');
?>

</body>
</html>


