<div class="users-permissions-popup">
  <div class="header">
    <h3>Uprawnienia uzytkownika</h3>
    <div class="user">
      <?= htmlspecialchars( trim( $this -> target_user['name'] . ' ' . $this -> target_user['surname'] ) );?>
      (<?= htmlspecialchars( $this -> target_user['email'] );?>)
    </div>
  </div>

  <? if ( (int)$this -> target_user['id'] === 1 ):?>
    <div class="admin-note">Administrator ma pelny dostep i jego uprawnienia nie sa edytowalne.</div>
  <? else:?>
    <div class="groups">
      <? foreach ( $this -> permission_groups as $group_name => $group_modules ):?>
        <div class="group">
          <h4><?= htmlspecialchars( $group_name );?></h4>
          <div class="items">
            <? foreach ( $group_modules as $mod ):?>
              <label class="item">
                <input type="checkbox" class="g-checkbox permission-popup-checkbox" data-module="<?= htmlspecialchars( $mod );?>" <?= !empty( $this -> permissions[ $mod ] ) ? 'checked="checked"' : '';?>>
                <span><?= htmlspecialchars( $this -> module_labels[ $mod ] );?></span>
              </label>
            <? endforeach;?>
          </div>
        </div>
      <? endforeach;?>
    </div>
  <? endif;?>

  <div class="actions">
    <a href="#" class="btn btn-default js-users-permissions-cancel">Anuluj</a>
    <? if ( (int)$this -> target_user['id'] !== 1 ):?>
      <a href="#" class="btn btn-primary js-users-permissions-save" data-user-id="<?= (int)$this -> target_user['id'];?>">Zapisz</a>
    <? endif;?>
  </div>
</div>
