<?php $render('header', ['loggedUser'=>$loggedUser, 'title'=>$titlePage]); ?>
<?=$render('sidebar', [
  'loggedUser'=>$loggedUser, 
  'pageActive'=>$pageActive,
  'permissions'=>$permissions
]);?>

<!-- Content System -->
<div class="content-wrapper">
  <div class="pages">
    <h3>Adicionar Permissão</h3>
    <div class="permissions">
      <!-- Message -->

      <?php if(!empty($error)): ?>
        <div class="alert <?=$error['alertType'];?>" role="alert">
          <?php echo $error['msg']; ?>
        </div>
      <?php endif; ?>

      <!-- /Message -->
      <form method="POST" action="<?=$base; ?>/savegroup" id="form_validator">

        <div class="form-group">
          <label for="permissions">Nome do Grupo</label>
          <input type="text" class="form-control" id="permissions" name="name" data-rules="required">
        </div>

        <div class="form-group">
          <label>Permissões do Grupo</label><br/>
          <?php foreach($permissionsList as $p): ?>
            <div class="form-control">
              <input type="checkbox" name="permissions[]" value="<?= $p['id']; ?>" id="p_<?= $p['id']; ?>" />
              <label for="p_<?= $p['id']; ?>"><?= $p['nick_name']; ?></label>
            </div>
          <?php endforeach; ?>
        </div>

        <div class="form-group">
          <input type="submit" value="Salvar" class="btn btn-success">
          <a href="<?=$base; ?>/permissions" class="btn btn-info">Voltar</a>
        </div>
      </form>
    </div>
  </div>  		
</div>
<script type="text/javascript" src="<?=$base?>/assets/js/permissions.js"></script>
<!-- /.content-system -->

<?=$render('footer');?>