<?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 Usuário</h3>
    <div class="users">
      <!-- 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;?>/saveuser" id="form_validator">

        <div class="form-row">
          <div class="form-group col-md-2">
            <label for="inputStatus">Status</label>
            <input type="text" readonly class="form-control" name="status" value="Ativo">
          </div>

          <div class="form-group col-md-2" id="validade_email">
            <label for="inputEmail">Email (*)</label>
            <input type="email" class="form-control" id="inputEmail" name="email" data-rules="required" placeholder="email@dominio.com.br" value="<?= (!empty($form))?$form['email']:''; ?>">
          </div>

          <div class="form-group col-md-2" id="validate_password">
            <label for="inputPassword">Senha (*)</label>
            <input type="password" class="form-control" id="inputPassword" name="password" data-rules="required|min=6" placeholder="********" value="<?= (!empty($form))?$form["password"]:''; ?>">
          </div>

          <div class="form-group col-md-2">
            <label for="inputType">Tipo</label>
            <select class="form-control" name="user_group">
              <?php foreach($groupsList as $item): ?>
                <option value="<?= $item['id']; ?>"><?= $item['name']; ?></option>
              <?php endforeach ?>
            </select>
          </div>
        </div>

        <div class="form-row">
          <div class="form-group col-md-2" id="validate_name">
            <label for="inputName">Nome (*)</label>
            <input type="text" class="form-control" id="inputName" data-rules="required" name="name" placeholder="Fulano Da Silva" value="<?= (!empty($form))?$form["name"]:''; ?>">
          </div>

          <div class="form-group col-md-2" id="validate_cpf">
            <label for="inputcpf">CPF</label>
            <input type="text" class="form-control" id="inputcpf" name="cpf" data-rules="cpf" placeholder="000.000.000-00" value="<?= (!empty($form))?$form["cpf"]:''; ?>">
          </div>

          <div class="form-group col-md-2" id="validate_birth_date">
            <label for="inputBirtDate">Dt Nasc</label>
            <input type="text" class="form-control" id="inputBirtDate" name="birth_date" placeholder="00/00/0000" value="<?= (!empty($form))?$form["birth_date"]:''; ?>">
          </div> 

          <div class="form-group col-md-2">
            <label for="inputPhone">Fone</label>
            <input type="text" class="form-control" id="inputPhone" name="phone" data-rules="phonecel" placeholder="(00) 00000-0000" value="<?= (!empty($form))?$form["phone"]:''; ?>">
          </div> 
        </div>

        <div class="form-row">

          <div class="form-group col-md-4">
              <label for="inputAddress2">Nota</label>
              <textarea class="form-control" rows="8" name="note" placeholder="Descrição do Usuário"><?= (!empty($form))?$form["note"]:''; ?></textarea>
          </div>

        </div>

        <div class="button">
          <button type="submit" class="btn btn-success">Salvar</button>
          <a href="<?=$base;?>/users" class="btn btn-info">Voltar</a>
        </div>

        
      </form>
    </div>

    <script src="<?=$base;?>/assets/js/users.js"></script>
  </div>  		
</div>
<!-- /.content-system -->

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