<?php 
include "navegacao.php";
echo '<div id="main" class="w3-container" style="margin-left:300px;margin-top:118px">';
echo '  <div class="w3-container w3-section w3-padding-large w3-card-4 w3-light-grey">';
echo '      <h1>' . utf8_encode($nome) . '</h1>';
echo '  </div>';
if ($id > 0) {
    echo '<div class="w3-row-padding w3-margin-top">';
    echo '  <div class="w3-container w3-section w3-padding-large w3-card-4 w3-light-grey">';
    echo '      <br>';
    echo '      <div class="w3-justify">' . $registroImg['img_audiodescricao'] . '</div>';
    echo '      <br>';
    echo '      <img src="./img/' . $registroImg['img_nome_original'] . '" style="width:45%" alt="' . $registroImg['img_nome'] . '">';
    echo '      <br><br>';
    echo '      <strong>Categoria:</strong> ' . BuscaDado('cat_nome', 'categoria', 'cat_codigo = ' . $registroImg['cat_codigo']);
    $sqlTag = "SELECT it.`tag_codigo`,\n                              t.`tag_descricao`,\n                              t.`tag_cont`\n                       FROM `imagem_tag` as it \n                           INNER JOIN `tag` as t\n                               ON t.`tag_codigo` = it.`tag_codigo`\n                       WHERE it.`img_codigo` = " . $registroImg['img_codigo'] . "\n                       ORDER BY t.`tag_cont` DESC";
    $queryTag = $mysqli->query($sqlTag);
    if (mysqli_num_rows($queryTag) > 0) {
        echo '      <br>';
        echo '      <strong>Palavras-chave:</strong> ';
        while ($registroTag = $queryTag->fetch_assoc()) {
            echo '<a href="./tag.php?id=' . $registroTag['tag_codigo'] . '"><span class="w3-tag w3-green w3-margin-4">' . $registroTag['tag_descricao'] . '';
            echo '</span></a> ';
        }
    }
    echo '      <br><br>';
    echo '  </div>';
    echo '</div>';
    $queryImg->free();
}
    echo '<table class="w3-table w3-striped w3-border">';
    echo '    <thead>';
    echo '    <tr class="w3-green">';
    echo '      <th>Nome</th>';
    echo '      <th>Data/Hora</th>';
    echo '      <th>Categoria</th>';
    echo '      <th>Usuário</th>';
    echo '      <th WIDTH="75">Revisar</th>';
    echo '    </tr>';
    echo '    </thead>';
    while ($registroRev = $queryRev->fetch_assoc()) {
        echo '<tr>';
        echo '  <td>' . utf8_encode($registroRev['img_nome']) . '</td>';
        echo '  <td>' . date('d/m/Y', strtotime($registroRev['img_data'])) . ' - ' . $registroRev['img_hora'] . '</td>';
        echo '  <td>' . BuscaDado('cat_nome', 'categoria', 'cat_codigo = ' . $registroRev['cat_codigo']) . '</td>';
        echo '  <td>' . BuscaDado('usu_nome', 'usuario', 'usu_codigo = ' . $registroRev['usu_codigo']) . '</td>';
        echo '  <td WIDTH="75">';
        echo '      <form id="revisar_imagem" action="revisar_imagem.php" method="post">';
        echo '          <input id="imagem" name="imagem" type="hidden" value="' . $registroRev['img_codigo'] . '"/>';
        echo '          <button id="solicitar" type="submit" class="w3-btn w3-green"><i class="fi-page-edit"></i></button>';
        echo '      </form>';
        echo '  </td>';
        echo '</tr>';
    }
    echo '</table>';
} else {
    echo "<a>Nenhuma imagem para revisar</a>";
}
?>
        <br>
        <?php