<?php
require_once 'header.php';
require_once 'inc/funcionalidade.php';
require_once 'erpc_funcionalidades_toolbar.php';


//include 'toolbar.php';
?>

<div class="block">
  <div class="header">
    <h2>Funcionalidade - Lista</h2>
  </div>
  <div class="content">
    <?php
    //echo '<pre>' . var_export($_SESSION, true) . '</pre>';
    displayMessagesAndErrors();
    ?>
    <p><a href="erpc_funcionalidades_add.php" class="btn btn-default btn-clean"><span class="fa fa-plus"></span> Adicionar Novo</a></p>
    <div class="table-responsive">
      <table class="table table-bordered table-striped table-responsible code-sortable" data-order-by="0">
        <thead>
          <tr>
            <!--<th width="3%"><input type="checkbox" class="checkall" /></th>-->
            <th width="10%">ID</th>
            <th width="70%">Nome</th>
            <th width="10%">Ativo ?</th>
            <th width="05%" class="no-sort">Editar</th>
            <th width="05%" class="no-sort">Remover</th>
          </tr>
        </thead>
        <tbody>
          <?php
          $lista = funcionalidade_getAll();
          foreach($lista as $item) {
            $idUrl = urlencode(base64_encode($item['id']));
            ?>
          <tr>
            <td><?= htmlentities($item['id'], ENT_NOQUOTES, 'utf-8'); ?></td>
            <td><?= htmlentities($item['ds_funcionalidade'], ENT_NOQUOTES, 'utf-8'); ?></td>
              <?
              $f_st_ativo = $item['st_ativo'];
              if($f_st_ativo=="1"){
                $f_st_ativo = "Sim";
              } else{
                $f_st_ativo = "Não";
              }
              echo "<td>$f_st_ativo&nbsp;</td>";
              ?>

            <td class='text-center'>
              <a href="erpc_funcionalidades_edit.php?id=<?= $idUrl; ?>"><i class="glyphicon glyphicon-pencil" title='Editar'><span class="sr-only">Editar</span></i></a>
            </td>
            <td class='text-center'>
              <a href="erpc_funcionalidades_remove.php?id=<?= $idUrl; ?>"><i class="glyphicon glyphicon-remove" title='Remover'><span class="sr-only">Remover</span></i></a>
            </td>
          </tr>
            <?php
          }
          ?>
        </tbody>
      </table>
    </div> <!-- table-responsive -->
  </div> <!-- content -->
</div> <!-- block -->

<?php include 'footer.php'; ?>
