<?php
// get the logged user
$loggedUser = Pampa_Auth_Cms::getInstance()->getIdentity();
// the usergroup
$loggedUserGroup = Plugin_Cms_User::getUserGroup($loggedUser);
if($loggedUserGroup->super === "1"):
?>
<div class="control-group">
  <label class="control-label" for="user-usergroup_id">Usergroup</label>
  <div class="controls">
    <?=$this->formSelect("user[usergroup_id]", $this->user->usergroup_id, array('class' => 'input-xxlarge'), $this->usergroups); ?>
  </div>
</div>

<?php endif; ?>



<div class="control-group">
  <label class="control-label" for="user-name">Name</label>
  <div class="controls">
    <?= $this->inputText('user[name]', $this->escape($this->user->name), array('class' => 'input-xxlarge required')); ?>
  </div>
</div>

<div class="control-group">
  <label class="control-label" for="user-name">Email</label>
  <div class="controls">
    <?= $this->inputText('user[email]', $this->escape($this->user->email), array('class' => 'input-xxlarge required email')); ?>
  </div>
</div>

<div class="control-group">
  <label class="control-label" for="user-phone">Phone</label>
  <div class="controls">
    <?= $this->inputText('user[phone]', $this->escape($this->user->phone), array('class' => 'input-xxlarge')); ?>
  </div>
</div>

<div class="control-group">
  <label class="control-label" for="user-login">Login</label>
  <div class="controls">
    <?= $this->inputText('user[login]', $this->escape($this->user->login), array('class' => 'input-xxlarge required', ($this->loggedUser()->usergroup_id <= 2)? '': 'readonly'=>'readonly')); ?>
  </div>
</div>

<div class="control-group">
  <label class="control-label" for="user-name">Password</label>
  <div class="controls">
    <input class="input-xxlarge" minlength="4" type="password" name="user[password]" />
    <? if(!empty($this->user->id)): ?>
    <p class="help-block">leave it blank if you don't want to change your password</p>
    <? endif; ?>
  </div>
</div>

<?php if($this->loggedUser()->usergroup_id <= 2): ?>
<div class="control-group">
  <label class="control-label" for="user-online">Publicado</label>
  <div class="controls">
    <label class="checkbox">
      <input type="checkbox" id="online" name="user[online]" value="1"<?= (($this->user->online != '0')? ' checked="yes"': '') ?> />
    </label>
  </div>
</div>

<div class="control-group">
  <label class="control-label" for="user-obs">Obs</label>
  <div class="controls">
    <textarea name="user[obs]" id="user-obs" class="input-xxlarge" rows="4"><?=$this->escape($this->user->obs);?></textarea>
  </div>
</div>
<?php endif; ?>

<input type="hidden" name="user[id]" value="<?=$this->user->id;?>"/>